[meld] filediff: Fix push-change actions for missing three way chunks (#359)



commit 8c862a2c53a26e18fc4f0364755d6d580bbd142e
Author: Kai Willadsen <kai willadsen gmail com>
Date:   Thu Aug 15 08:36:26 2019 +1000

    filediff: Fix push-change actions for missing three way chunks (#359)
    
    Way back in 80bfe200 when we added support for pushing change deletions,
    removing the "is there anything to push" check had the side effect of
    incorrectly allowing the user to try to push a change between panes
    where no such change exists.
    
    This patch adds a three-way-comparison-specific check for whether we
    actually have a change chunk in the direction that we're trying to push.

 meld/filediff.py | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)
---
diff --git a/meld/filediff.py b/meld/filediff.py
index dadb7693..39f13b91 100644
--- a/meld/filediff.py
+++ b/meld/filediff.py
@@ -628,6 +628,8 @@ class FileDiff(Gtk.VBox, MeldDoc):
             push_left, push_right, pull_left, pull_right, delete, \
                 copy_left, copy_right = (True,) * 7
 
+            three_way = self.num_panes == 3
+
             # Push and Delete are active if the current pane has something to
             # act on, and the target pane exists and is editable. Pull is
             # sensitive if the source pane has something to get, and the
@@ -654,14 +656,14 @@ class FileDiff(Gtk.VBox, MeldDoc):
             elif pane == 1:
                 chunk0 = self.linediffer.get_chunk(chunk_id, 1, 0)
                 chunk2 = None
-                if self.num_panes == 3:
+                if three_way:
                     chunk2 = self.linediffer.get_chunk(chunk_id, 1, 2)
                 left_mid_exists = bool(chunk0 and chunk0[1] != chunk0[2])
                 left_exists = bool(chunk0 and chunk0[3] != chunk0[4])
                 right_mid_exists = bool(chunk2 and chunk2[1] != chunk2[2])
                 right_exists = bool(chunk2 and chunk2[3] != chunk2[4])
-                push_left = editable_left
-                push_right = editable_right
+                push_left = editable_left and bool(not three_way or chunk0)
+                push_right = editable_right and bool(not three_way or chunk2)
                 pull_left = editable and left_exists
                 pull_right = editable and right_exists
                 delete = editable and (left_mid_exists or right_mid_exists)


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]