Plugins/VcsPlugins/vcsMercurial/hg.py

changeset 1655
d2b583fdde1c
parent 1608
b6390d242303
child 1767
bfc7ba3b3663
diff -r 08264848be08 -r d2b583fdde1c Plugins/VcsPlugins/vcsMercurial/hg.py
--- a/Plugins/VcsPlugins/vcsMercurial/hg.py	Wed Feb 22 19:14:07 2012 +0100
+++ b/Plugins/VcsPlugins/vcsMercurial/hg.py	Wed Feb 22 19:22:42 2012 +0100
@@ -51,6 +51,7 @@
 from .HgImportDialog import HgImportDialog
 from .HgExportDialog import HgExportDialog
 from .HgPhaseDialog import HgPhaseDialog
+from .HgGraftDialog import HgGraftDialog
 
 from .BookmarksExtension.bookmarks import Bookmarks
 from .QueuesExtension.queues import Queues
@@ -2525,6 +2526,78 @@
         
         return res
     
+    def hgGraft(self, path):
+        """
+        Public method to copy changesets from another branch.
+        
+        @param path directory name of the project (string)
+        @return flag indicating that the project should be reread (boolean)
+        """
+        # find the root of the repo
+        repodir = self.splitPath(path)[0]
+        while not os.path.isdir(os.path.join(repodir, self.adminDir)):
+            repodir = os.path.dirname(repodir)
+            if os.path.splitdrive(repodir)[1] == os.sep:
+                return False
+        
+        res = False
+        dlg = HgGraftDialog()
+        if dlg.exec_() == QDialog.Accepted:
+            revs, (userData, currentUser, userName), \
+            (dateData, currentDate, dateStr) = dlg.getData()
+            
+            args = []
+            args.append("graft")
+            args.append("--verbose")
+            if userData:
+                if currentUser:
+                    args.append("--currentuser")
+                else:
+                    args.append("--user")
+                    args.append(userName)
+            if dateData:
+                if currentDate:
+                    args.append("--currentdate")
+                else:
+                    args.append("--date")
+                    args.append(dateStr)
+            args.extend(revs)
+            
+            dia = HgDialog(self.trUtf8('Copy Changesets'), self)
+            res = dia.startProcess(args, repodir)
+            if res:
+                dia.exec_()
+                res = dia.hasAddOrDelete()
+                self.checkVCSStatus()
+        return res
+    
+    def hgGraftContinue(self, path):
+        """
+        Public method to continue copying changesets from another branch.
+        
+        @param path directory name of the project (string)
+        @return flag indicating that the project should be reread (boolean)
+        """
+        # find the root of the repo
+        repodir = self.splitPath(path)[0]
+        while not os.path.isdir(os.path.join(repodir, self.adminDir)):
+            repodir = os.path.dirname(repodir)
+            if os.path.splitdrive(repodir)[1] == os.sep:
+                return
+        
+        args = []
+        args.append("graft")
+        args.append("--continue")
+        args.append("--verbose")
+        
+        dia = HgDialog(self.trUtf8('Copy Changesets (Continue)'), self)
+        res = dia.startProcess(args, repodir)
+        if res:
+            dia.exec_()
+            res = dia.hasAddOrDelete()
+            self.vcs.checkVCSStatus()
+        return res
+    
     ############################################################################
     ## Methods to handle extensions are below.
     ############################################################################

eric ide

mercurial