Plugins/VcsPlugins/vcsMercurial/HgLogBrowserDialog.py

branch
Py2 comp.
changeset 2545
2d385ccc14f9
parent 2525
8b507a9a2d40
child 2546
dd9f912d5bd9
diff -r 2757794dac10 -r 2d385ccc14f9 Plugins/VcsPlugins/vcsMercurial/HgLogBrowserDialog.py
--- a/Plugins/VcsPlugins/vcsMercurial/HgLogBrowserDialog.py	Mon Mar 25 15:46:44 2013 +0100
+++ b/Plugins/VcsPlugins/vcsMercurial/HgLogBrowserDialog.py	Mon Mar 25 18:15:32 2013 +0100
@@ -137,6 +137,12 @@
             self.logTree.setColumnHidden(self.PhaseColumn, True)
             self.phaseLine.hide()
             self.phaseButton.hide()
+        if self.vcs.version < (2, 0):
+            self.graftButton.setEnabled(False)
+            self.graftButton.hide()
+        if self.phaseButton.isHidden() and \
+           self.graftButton.isHidden():
+            self.phaseLine.hide()
     
     def __initData(self):
         """
@@ -160,6 +166,7 @@
         self.__branchColors = {}
         
         self.__projectRevision = -1
+        self.__projectBranch = ""
     
     def closeEvent(self, e):
         """
@@ -433,7 +440,7 @@
         
         args = []
         args.append("identify")
-        args.append("-n")
+        args.append("-nb")
         
         output = ""
         if self.__hgClient:
@@ -463,9 +470,12 @@
                 errMsg)
         
         if output:
-            self.__projectRevision = output.strip()
-            if self.__projectRevision.endswith("+"):
-                self.__projectRevision = self.__projectRevision[:-1]
+            outputList = output.strip().split()
+            if len(outputList) == 2:
+                self.__projectRevision = outputList[0].strip()
+                if self.__projectRevision.endswith("+"):
+                    self.__projectRevision = self.__projectRevision[:-1]
+                    self.__projectBranch = outputList[1].strip()
     
     def __getClosedBranches(self):
         """
@@ -1019,6 +1029,21 @@
         else:
             self.phaseButton.setEnabled(False)
     
+    def __updateGraftButton(self):
+        """
+        Private slot to update the status of the graft button.
+        """
+        if self.graftButton.isVisible():
+            # step 1: count selected entries not belonging to the current branch
+            otherBranches = 0
+            for itm in self.logTree.selectedItems():
+                branch = itm.text(self.BranchColumn)
+                if branch != self.__projectBranch:
+                    otherBranches += 1
+            
+            # step 2: set the status of the graft button
+            self.graftButton.setEnabled(otherBranches > 0)
+    
     def __updateGui(self, itm):
         """
         Private slot to update GUI elements except the diff and phase buttons.
@@ -1051,6 +1076,7 @@
         self.__updateGui(current)
         self.__updateDiffButtons()
         self.__updatePhaseButton()
+        self.__updateGraftButton()
     
     @pyqtSlot()
     def on_logTree_itemSelectionChanged(self):
@@ -1062,6 +1088,7 @@
         
         self.__updateDiffButtons()
         self.__updatePhaseButton()
+        self.__updateGraftButton()
     
     @pyqtSlot()
     def on_nextButton_clicked(self):
@@ -1312,3 +1339,27 @@
         if res:
             for itm in self.logTree.selectedItems():
                 itm.setText(self.PhaseColumn, newPhase)
+    
+    @pyqtSlot()
+    def on_graftButton_clicked(self):
+        """
+        Private slot to handle the Copy Changesets button.
+        """
+        revs = []
+        
+        for itm in self.logTree.selectedItems():
+            branch = itm.text(self.BranchColumn)
+            if branch != self.__projectBranch:
+                revs.append(itm.text(self.RevisionColumn).strip().split(":", 1)[0])
+        
+        if revs:
+            shouldReopen = self.vcs.hgGraft(self.repodir, revs)
+            if shouldReopen:
+                res = E5MessageBox.yesNo(None,
+                    self.trUtf8("Copy Changesets"),
+                    self.trUtf8("""The project should be reread. Do this now?"""),
+                    yesDefault=True)
+                if res:
+                    e5App().getObject("Project").reopenProject()
+            else:
+                self.on_refreshButton_clicked()

eric ide

mercurial