eric6/Plugins/VcsPlugins/vcsMercurial/ShelveExtension/shelve.py

branch
maintenance
changeset 8043
0acf98cd089a
parent 7924
8a96736d465e
parent 8036
74b6a7be4f83
child 8176
31965986ecd1
--- a/eric6/Plugins/VcsPlugins/vcsMercurial/ShelveExtension/shelve.py	Sun Jan 17 13:53:08 2021 +0100
+++ b/eric6/Plugins/VcsPlugins/vcsMercurial/ShelveExtension/shelve.py	Mon Feb 01 10:38:16 2021 +0100
@@ -7,8 +7,6 @@
 Module implementing the shelve extension interface.
 """
 
-import os
-
 from PyQt5.QtWidgets import QDialog
 
 from E5Gui import E5MessageBox
@@ -40,11 +38,10 @@
         if self.__shelveBrowserDialog is not None:
             self.__shelveBrowserDialog.close()
     
-    def __hgGetShelveNamesList(self, repodir):
+    def __hgGetShelveNamesList(self):
         """
         Private method to get the list of shelved changes.
         
-        @param repodir directory name of the repository (string)
         @return list of shelved changes (list of string)
         """
         args = self.vcs.initCommand("shelve")
@@ -68,18 +65,6 @@
             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(self.vcs.version)
@@ -94,7 +79,7 @@
                 args.append("--message")
                 args.append(message)
             if addRemove:
-                args.append("--addRemove")
+                args.append("--addremove")
             if dateTime.isValid():
                 args.append("--date")
                 args.append(dateTime.toString("yyyy-MM-dd hh:mm:ss"))
@@ -108,44 +93,34 @@
                 args.append(name)
             
             dia = HgDialog(self.tr('Shelve current changes'), self.vcs)
-            res = dia.startProcess(args, repodir)
+            res = dia.startProcess(args)
             if res:
                 dia.exec()
                 res = dia.hasAddOrDelete()
                 self.vcs.checkVCSStatus()
         return res
     
-    def hgShelveBrowser(self, projectDir):
+    def hgShelveBrowser(self):
         """
         Public method to show the shelve browser dialog.
-        
-        @param projectDir name of the project directory (string)
         """
         if self.__shelveBrowserDialog is None:
             from .HgShelveBrowserDialog import HgShelveBrowserDialog
             self.__shelveBrowserDialog = HgShelveBrowserDialog(
                 self.vcs)
         self.__shelveBrowserDialog.show()
-        self.__shelveBrowserDialog.start(projectDir)
+        self.__shelveBrowserDialog.start()
     
-    def hgUnshelve(self, name, shelveName=""):
+    def hgUnshelve(self, shelveName=""):
         """
         Public method to restore shelved changes to the project directory.
         
-        @param name name of the project directory (string)
-        @keyparam shelveName name of the shelve to restore (string)
+        @param shelveName name of the shelve to restore (string)
         @return flag indicating that the project should be reread (boolean)
         """
-        # find the root of the repo
-        repodir = name
-        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 .HgUnshelveDataDialog import HgUnshelveDataDialog
-        dlg = HgUnshelveDataDialog(self.__hgGetShelveNamesList(repodir),
+        dlg = HgUnshelveDataDialog(self.__hgGetShelveNamesList(),
                                    shelveName=shelveName)
         if dlg.exec() == QDialog.Accepted:
             shelveName, keep = dlg.getData()
@@ -158,84 +133,60 @@
                 args.append(shelveName)
             
             dia = HgDialog(self.tr('Restore shelved changes'), self.vcs)
-            res = dia.startProcess(args, repodir)
+            res = dia.startProcess(args)
             if res:
                 dia.exec()
                 res = dia.hasAddOrDelete()
                 self.vcs.checkVCSStatus()
         return res
     
-    def hgUnshelveAbort(self, name):
+    def hgUnshelveAbort(self):
         """
         Public method to abort the ongoing restore operation.
         
-        @param name name of the project directory (string)
         @return flag indicating that the project should be reread (boolean)
         """
-        # find the root of the repo
-        repodir = name
-        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
-        
         args = self.vcs.initCommand("unshelve")
         args.append("--abort")
         
         dia = HgDialog(self.tr('Abort restore operation'), self.vcs)
-        res = dia.startProcess(args, repodir)
+        res = dia.startProcess(args)
         if res:
             dia.exec()
             res = dia.hasAddOrDelete()
             self.vcs.checkVCSStatus()
         return res
     
-    def hgUnshelveContinue(self, name):
+    def hgUnshelveContinue(self):
         """
         Public method to continue the ongoing restore operation.
         
-        @param name name of the project directory (string)
         @return flag indicating that the project should be reread (boolean)
         """
-        # find the root of the repo
-        repodir = name
-        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
-        
         args = self.vcs.initCommand("unshelve")
         if self.__unshelveKeep:
             args.append("--keep")
         args.append("--continue")
         
         dia = HgDialog(self.tr('Continue restore operation'), self.vcs)
-        res = dia.startProcess(args, repodir)
+        res = dia.startProcess(args)
         if res:
             dia.exec()
             res = dia.hasAddOrDelete()
             self.vcs.checkVCSStatus()
         return res
     
-    def hgDeleteShelves(self, name, shelveNames=None):
+    def hgDeleteShelves(self, shelveNames=None):
         """
         Public method to delete named shelves.
         
-        @param name name of the project directory (string)
         @param shelveNames name of shelves to delete (list of string)
         """
-        # find the root of the repo
-        repodir = name
-        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
-        
         if not shelveNames:
             from .HgShelvesSelectionDialog import HgShelvesSelectionDialog
             dlg = HgShelvesSelectionDialog(
                 self.tr("Select the shelves to be deleted:"),
-                self.__hgGetShelveNamesList(repodir))
+                self.__hgGetShelveNamesList())
             if dlg.exec() == QDialog.Accepted:
                 shelveNames = dlg.getSelectedShelves()
             else:
@@ -255,23 +206,14 @@
             args.extend(shelveNames)
             
             dia = HgDialog(self.tr('Delete shelves'), self.vcs)
-            res = dia.startProcess(args, repodir)
+            res = dia.startProcess(args)
             if res:
                 dia.exec()
     
-    def hgCleanupShelves(self, name):
+    def hgCleanupShelves(self):
         """
         Public method to delete all shelves.
-        
-        @param name name of the project directory (string)
         """
-        # find the root of the repo
-        repodir = name
-        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
-        
         res = E5MessageBox.yesNo(
             None,
             self.tr("Delete all shelves"),
@@ -281,6 +223,6 @@
             args.append("--cleanup")
             
             dia = HgDialog(self.tr('Delete all shelves'), self.vcs)
-            res = dia.startProcess(args, repodir)
+            res = dia.startProcess(args)
             if res:
                 dia.exec()

eric ide

mercurial