Plugins/VcsPlugins/vcsMercurial/ShelveExtension/shelve.py

changeset 3291
58e95eea9b6d
parent 3290
dbb53746813f
child 3292
2feabde31912
diff -r dbb53746813f -r 58e95eea9b6d Plugins/VcsPlugins/vcsMercurial/ShelveExtension/shelve.py
--- a/Plugins/VcsPlugins/vcsMercurial/ShelveExtension/shelve.py	Thu Feb 20 19:51:30 2014 +0100
+++ b/Plugins/VcsPlugins/vcsMercurial/ShelveExtension/shelve.py	Fri Feb 21 18:57:15 2014 +0100
@@ -7,8 +7,13 @@
 Module implementing the shelve extension interface.
 """
 
+import os
+
+from PyQt4.QtCore import QDateTime
+from PyQt4.QtGui import QDialog
+
 from ..HgExtension import HgExtension
-##from ..HgDialog import HgDialog
+from ..HgDialog import HgDialog
 
 
 class Shelve(HgExtension):
@@ -27,3 +32,57 @@
         """
         Public method used to shutdown the shelve interface.
         """
+    
+    def hgShelve(self, name):
+        """
+        Public method to shelve current changes of files or directories.
+        
+        @param name directory or file name (string) or list of directory
+            or file names (list of string)
+        @return flag indicating that the project should be reread (boolean)
+        """
+        if isinstance(name, list):
+            dname = self.vcs.splitPathList(name)[0]
+        else:
+            dname = self.vcs.splitPath(name)[0]
+        
+        # find the root of the repo
+        repodir = dname
+        while not os.path.isdir(os.path.join(repodir, self.vcs.adminDir)):
+            repodir = os.path.dirname(repodir)
+            if os.path.splitdrive(repodir)[1] == os.sep:
+                return False
+        
+        res = False
+        from .HgShelveDataDialog import HgShelveDataDialog
+        dlg = HgShelveDataDialog()
+        if dlg.exec_() == QDialog.Accepted:
+            shelveName, dateTime, message, addRemove = dlg.getData()
+            
+            args = []
+            args.append("shelve")
+            if shelveName:
+                args.append("--name")
+                args.append(shelveName)
+            if message:
+                args.append("--message")
+                args.append(message)
+            if addRemove:
+                args.append("--addRemove")
+            if dateTime != QDateTime.currentDateTime():
+                args.append("--date")
+                args.append(dateTime.toString("yyyy-MM-dd hh:mm:ss"))
+            args.append("-v")
+            
+            if isinstance(name, list):
+                self.vcs.addArguments(args, name)
+            else:
+                args.append(name)
+            
+            dia = HgDialog(self.tr('Shelve current changes'), self.vcs)
+            res = dia.startProcess(args, repodir)
+            if res:
+                dia.exec_()
+                res = dia.hasAddOrDelete()
+                self.vcs.checkVCSStatus()
+        return res

eric ide

mercurial