Open weshouman opened 1 year ago
I found the following snippets in your repository. I will now analyze these snippets and come up with a plan.
meld/dirdiff.py
✅ Commit 3447ab7
Modify meld/dirdiff.py with contents:
• Add a new method `select_left_file_to_compare` in the `DirDiff` class. This method should store the selected file or directory path in a class variable.
• Add a new method `select_right_file_to_compare` in the `DirDiff` class. This method should store the selected file or directory path in a class variable.
• Modify the `on_button_press_event` method in the `DirDiff` class to add two new options in the context menu: "Select left file/dir to compare" and "Compare to 'filename'". The first option should call the `select_left_file_to_compare` method and the second option should call the `select_right_file_to_compare` method.
• Modify the `compare_selected_files` method in the `DirDiff` class to compare the files or directories stored in the class variables when the "Compare to 'filename'" option is selected.
Here are my self-reviews of my changes at sweep/compare-files-with-different-names
.
Here is the 1st review
Thanks for your contribution. There are a few changes that need to be made: 1. In `meld/dirdiff.py`, the `select_left_file_to_compare` and `select_right_file_to_compare` methods are connected to the "activate" signal of the menu items, but these methods expect a `pane` argument which is not provided by the "activate" signal. This will cause a TypeError when the menu items are activated. You need to modify these methods to not require the `pane` argument. 2. The `compare_selected_files` method is trying to get an iterator from the file paths stored in `self.left_file_to_compare` and `self.right_file_to_compare` using the `get_iter` method of the model. However, the `get_iter` method expects a TreePath or a string that represents a TreePath, not a file path. This will cause a ValueError. You need to find a way to convert the file paths to TreePaths. 3. The "Compare to 'filename'" menu item is always added to the context menu, even when no file or directory has been selected for comparison. This could confuse the user as clicking this menu item without selecting a file or directory for comparison will do nothing. You should add a condition to only add this menu item when a file or directory has been selected for comparison. 4. The `left_file_to_compare` and `right_file_to_compare` variables are not initialized in the `DirDiff` class. If the `action_diff` method is called before these variables are set, it will cause an AttributeError. You should initialize these variables in the `__init__` method of the `DirDiff` class. Please make these changes and submit a new pull request.
I finished incorporating these changes.
💡 To recreate the pull request edit the issue title or description. To tweak the pull request, leave a comment on the pull request. Join Our Discord
Brief
While comparing 2 directories we would like to have the option to compare 2 file names that may have different names.
Expected behavior
Right click on a file on the left and select "Select left file/dir to compare" then right click on the right file (or dir) and select "Compare to 'filename'". Note we should be able to do that also starting from the right file
Checklist
- [X] ``meld/dirdiff.py`` ✅ Commit3447ab7