[PATCH] fix #2201 (resolve window: add "diff to common ancestor" buttons)

Showing 1-7 of 7 messages
[PATCH] fix #2201 (resolve window: add "diff to common ancestor" buttons) ike 10/21/12 12:43 PM
Hi,

Warning: this is my first python and qt code.

Regards,
Ike

# HG changeset patch
# User i...@compufit.be
# Date 1350848383 -7200
# Node ID 6b9935b9da8aa74e0a0203e4fcc1c616fab3b67e
# Parent  40f1d75ee003736a1fc52fd828a8abfb6f191cb3
fixes #2201

resolve window: add "diff to common ancestor" buttons

diff --git a/tortoisehg/hgqt/resolve.py b/tortoisehg/hgqt/resolve.py
--- a/tortoisehg/hgqt/resolve.py
+++ b/tortoisehg/hgqt/resolve.py
@@ -111,13 +111,21 @@
         res = QPushButton(_('Mark as Resolved'))
         res.setToolTip(_('Mark this file as resolved'))
         res.clicked.connect(self.markresolved)
+        diffLocToAnc = QPushButton(_('Diff Local to Ancestor'))
+        diffLocToAnc.setToolTip(_('Visual diff between local file and common ancestor'))
+        diffLocToAnc.clicked.connect(self.diffLocToAnc)
+        diffOthToAnc = QPushButton(_('Diff Other to Ancestor'))
+        diffOthToAnc.setToolTip(_('Visual diff between other file and common ancestor'))
+        diffOthToAnc.clicked.connect(self.diffOthToAnc)
         vbox.addWidget(auto)
         vbox.addWidget(manual)
         vbox.addWidget(local)
         vbox.addWidget(other)
         vbox.addWidget(res)
+        vbox.addWidget(diffLocToAnc)
+        vbox.addWidget(diffOthToAnc)
         vbox.addStretch(1)
-        self.ubuttons = (auto, manual, local, other, res)
+        self.ubuttons = (auto, manual, local, other, res, diffLocToAnc, diffOthToAnc)
 
         self.utreecmenu = QMenu(self)
         cmauto = self.utreecmenu.addAction(_('Mercurial Resolve'))
@@ -130,7 +138,11 @@
         cmother.triggered.connect(lambda: self.merge('internal:other'))
         cmres = self.utreecmenu.addAction(_('Mark as Resolved'))
         cmres.triggered.connect(self.markresolved)
-        self.umenuitems = (cmauto, cmmanual, cmlocal, cmother, cmres)
+        cmdiffLocToAnc = self.utreecmenu.addAction(_('Diff Local to Ancestor'))
+        cmdiffLocToAnc.triggered.connect(self.diffLocToAnc)
+        cmdiffOthToAnc = self.utreecmenu.addAction(_('Diff Other to Ancestor'))
+        cmdiffOthToAnc.triggered.connect(self.diffOthToAnc)
+        self.umenuitems = (cmauto, cmmanual, cmlocal, cmother, cmres, cmdiffLocToAnc, cmdiffOthToAnc)
 
         res = qtlib.LabeledSeparator(_('Resolved conflicts'))
         self.layout().addWidget(res)
@@ -269,7 +281,7 @@
             qtlib.editfiles(self.repo, abspaths, parent=self)
 
     def getVdiffFiles(self, tree):
-        paths = self.getSelectedPaths(self.rtree)
+        paths = self.getSelectedPaths(tree)
         if not paths:
             return []
         files, sub = [], False
@@ -314,6 +326,26 @@
             if dlg:
                 dlg.exec_()
 
+    def diffLocToAnc(self):
+        paths = self.getVdiffFiles(self.utree)
+        if paths:
+            opts = {}
+            opts['rev'] = ['ancestor(p1(),p2())..p1()']
+            opts['tool'] = self.tcombo.readValue()
+            dlg = visdiff.visualdiff(self.repo.ui, self.repo, paths, opts)
+            if dlg:
+                dlg.exec_()
+
+    def diffOthToAnc(self):
+        paths = self.getVdiffFiles(self.utree)
+        if paths:
+            opts = {}
+            opts['rev'] = ['ancestor(p1(),p2())..p2()']
+            opts['tool'] = self.tcombo.readValue()
+            dlg = visdiff.visualdiff(self.repo.ui, self.repo, paths, opts)
+            if dlg:
+                dlg.exec_()
+
     def configChanged(self):
         'repository has detected a change to config files'
         self.tcombo.reset()

Re: [PATCH] fix #2201 (resolve window: add "diff to common ancestor" buttons) ike 10/22/12 12:13 PM
Hi,

Just wanted to mention that this uses code that is also in the patch 2200.
Because the 2 new buttons that this patch (in this post) adds, are also in the contextmenu that get implemented in patch 2200

In any case, there is still the patch with both fixes in (see here)

Best regards,
Ike
Re: [PATCH] fix #2201 (resolve window: add "diff to common ancestor" buttons) ike 10/31/12 4:17 PM
Hi,

Since my commit message wasn't according the guidelines, I created a new commit.
This does assume that another patch has been applied see issue2200

Best regards,

Ike

# HG changeset patch
# User i...@gmail.com
# Date 1351725219 -3600
# Node ID a929b948c0d6c78f28fe67da022c75d61132c613
# Parent  1d3c549cda6e20a347a2f6b7c7776ce650e6ede8
resolve: add "diff to common ancestor" buttons in resolve window (fixes #2201)

In the resolve window 2 buttons have been added for unresolved files
"Diff Local to Ancestor": shows the diff between local and the common ancestor
"Diff Other to Ancestor": shows the diff between other and the common ancestor


diff --git a/tortoisehg/hgqt/resolve.py b/tortoisehg/hgqt/resolve.py
--- a/tortoisehg/hgqt/resolve.py
+++ b/tortoisehg/hgqt/resolve.py
@@ -103,13 +103,21 @@

         res = QPushButton(_('Mark as Resolved'))
         res.setToolTip(_('Mark this file as resolved'))
         res.clicked.connect(self.markresolved)
+        diffLocToAnc = QPushButton(_('Diff Local to Ancestor'))
+        diffLocToAnc.setToolTip(_('Visual diff between local file and common ancestor'))
+        diffLocToAnc.clicked.connect(self.diffLocToAnc)
+        diffOthToAnc = QPushButton(_('Diff Other to Ancestor'))
+        diffOthToAnc.setToolTip(_('Visual diff between other file and common ancestor'))
+        diffOthToAnc.clicked.connect(self.diffOthToAnc)
         vbox.addWidget(auto)
         vbox.addWidget(manual)
         vbox.addWidget(local)
         vbox.addWidget(other)
         vbox.addWidget(res)
+        vbox.addWidget(diffLocToAnc)
+        vbox.addWidget(diffOthToAnc)
         vbox.addStretch(1)
-        self.ubuttons = (auto, manual, local, other, res)
+        self.ubuttons = (auto, manual, local, other, res, diffLocToAnc, diffOthToAnc)
 
         self.utree.setContextMenuPolicy(Qt.CustomContextMenu)
         self.utreecmenu = QMenu(self)
@@ -123,7 +131,11 @@

         cmother.triggered.connect(lambda: self.merge('internal:other'))
         cmres = self.utreecmenu.addAction(_('Mark as Resolved'))
         cmres.triggered.connect(self.markresolved)
-        self.umenuitems = (cmauto, cmmanual, cmlocal, cmother, cmres)
+        cmdiffLocToAnc = self.utreecmenu.addAction(_('Diff Local to Ancestor'))
+        cmdiffLocToAnc.triggered.connect(self.diffLocToAnc)
+        cmdiffOthToAnc = self.utreecmenu.addAction(_('Diff Other to Ancestor'))
+        cmdiffOthToAnc.triggered.connect(self.diffOthToAnc)
+        self.umenuitems = (cmauto, cmmanual, cmlocal, cmother, cmres, cmdiffLocToAnc, cmdiffOthToAnc)
         self.utree.customContextMenuRequested.connect(self.utreeMenuRequested)

 
         res = qtlib.LabeledSeparator(_('Resolved conflicts'))
@@ -265,7 +277,7 @@

             qtlib.editfiles(self.repo, abspaths, parent=self)
 
     def getVdiffFiles(self, tree):
-        paths = self.getSelectedPaths(self.rtree)
+        paths = self.getSelectedPaths(tree)
         if not paths:
             return []
         files, sub = [], False
@@ -310,6 +322,26 @@
Re: [thg-dev] Re: [PATCH] fix #2201 (resolve window: add "diff to common ancestor" buttons) Yuya Nishihara 11/3/12 10:24 PM
How about providing diff actions only on context menu, i.e. no buttons?
All buttons for "Unresolved conflicts" are methods to resolve conflicts,
but "Diff X to Ancestor" isn't.

Regards,
Re: [thg-dev] Re: [PATCH] fix #2201 (resolve window: add "diff to common ancestor" buttons) Angel Ezquerra 11/4/12 1:41 AM

+1

Angel

Re: [thg-dev] Re: [PATCH] fix #2201 (resolve window: add "diff to common ancestor" buttons) ike 11/4/12 11:16 AM
# HG changeset patch
# User i...@gmail.com
# Date 1352056451 -3600
# Node ID c6b606608f1f2e308e28f9f839dd7c3c445d0cd9
# Parent  1f7dfd2a0e6d52e67bfec0d27e6a67159431c180
resolve: add "diff to common ancestor" cmenu actions in resolve window (fixes #2201)

In the resolve window 2 contextmenu actions have been added for unresolved files

"Diff Local to Ancestor": shows the diff between local and the common ancestor
"Diff Other to Ancestor": shows the diff between other and the common ancestor

diff --git a/tortoisehg/hgqt/resolve.py b/tortoisehg/hgqt/resolve.py
--- a/tortoisehg/hgqt/resolve.py
+++ b/tortoisehg/hgqt/resolve.py
@@ -123,7 +123,11 @@

         cmother.triggered.connect(lambda: self.merge('internal:other'))
         cmres = self.utreecmenu.addAction(_('Mark as Resolved'))
         cmres.triggered.connect(self.markresolved)
-        self.umenuitems = (cmauto, cmmanual, cmlocal, cmother, cmres)
+        cmdiffLocToAnc = self.utreecmenu.addAction(_('Diff Local to Ancestor'))
+        cmdiffLocToAnc.triggered.connect(self.diffLocToAnc)
+        cmdiffOthToAnc = self.utreecmenu.addAction(_('Diff Other to Ancestor'))
+        cmdiffOthToAnc.triggered.connect(self.diffOthToAnc)

+        self.umenuitems = (cmauto, cmmanual, cmlocal, cmother, cmres, cmdiffLocToAnc, cmdiffOthToAnc)
         self.utree.customContextMenuRequested.connect(self.utreeMenuRequested)
 
         res = qtlib.LabeledSeparator(_('Resolved conflicts'))
@@ -265,7 +269,7 @@

             qtlib.editfiles(self.repo, abspaths, parent=self)
 
     def getVdiffFiles(self, tree):
-        paths = self.getSelectedPaths(self.rtree)
+        paths = self.getSelectedPaths(tree)
         if not paths:
             return []
         files, sub = [], False
@@ -310,6 +314,26 @@
Re: [thg-dev] Re: [PATCH] fix #2201 (resolve window: add "diff to common ancestor" buttons) Yuya Nishihara 11/5/12 7:43 AM
On Sun, 4 Nov 2012 11:16:33 -0800 (PST), ike wrote:
> # HG changeset patch
> # User i...@gmail.com
> # Date 1352056451 -3600
> # Node ID c6b606608f1f2e308e28f9f839dd7c3c445d0cd9
> # Parent  1f7dfd2a0e6d52e67bfec0d27e6a67159431c180
> resolve: add "diff to common ancestor" cmenu actions in resolve window
> (fixes #2201)
>
> In the resolve window 2 contextmenu actions have been added for unresolved
> files
> "Diff Local to Ancestor": shows the diff between local and the common
> ancestor
> "Diff Other to Ancestor": shows the diff between other and the common
> ancestor

Thanks, this looks good to me.
Maybe we've already in code freeze, I'm going to queue this patch for 2.6.1.

Regards,