eric6/Plugins/VcsPlugins/vcsMercurial/StripExtension/strip.py

changeset 7970
c4ee8a81584c
parent 7923
91e843545d9a
child 8043
0acf98cd089a
child 8143
2c730d5fd177
equal deleted inserted replaced
7969:62eff8b34a8d 7970:c4ee8a81584c
4 # 4 #
5 5
6 """ 6 """
7 Module implementing the strip extension interface. 7 Module implementing the strip extension interface.
8 """ 8 """
9
10 import os
11 9
12 from PyQt5.QtWidgets import QDialog 10 from PyQt5.QtWidgets import QDialog
13 11
14 from ..HgExtension import HgExtension 12 from ..HgExtension import HgExtension
15 from ..HgDialog import HgDialog 13 from ..HgDialog import HgDialog
26 @param vcs reference to the Mercurial vcs object 24 @param vcs reference to the Mercurial vcs object
27 @type Hg 25 @type Hg
28 """ 26 """
29 super(Strip, self).__init__(vcs) 27 super(Strip, self).__init__(vcs)
30 28
31 def hgStrip(self, name, rev=""): 29 def hgStrip(self, rev=""):
32 """ 30 """
33 Public method to strip revisions from a repository. 31 Public method to strip revisions from a repository.
34 32
35 @param name file/directory name
36 @type str
37 @param rev revision to strip from 33 @param rev revision to strip from
38 @type str 34 @type str
39 @return flag indicating that the project should be reread 35 @return flag indicating that the project should be reread
40 @rtype bool 36 @rtype bool
41 """ 37 """
42 # find the root of the repo
43 repodir = self.vcs.splitPath(name)[0]
44 while not os.path.isdir(os.path.join(repodir, self.vcs.adminDir)):
45 repodir = os.path.dirname(repodir)
46 if os.path.splitdrive(repodir)[1] == os.sep:
47 return False
48
49 from .HgStripDialog import HgStripDialog 38 from .HgStripDialog import HgStripDialog
50 res = False 39 res = False
51 dlg = HgStripDialog(self.vcs.hgGetTagsList(repodir), 40 dlg = HgStripDialog(self.vcs.hgGetTagsList(),
52 self.vcs.hgGetBranchesList(repodir), 41 self.vcs.hgGetBranchesList(),
53 self.vcs.hgGetBookmarksList(repodir), 42 self.vcs.hgGetBookmarksList(),
54 rev) 43 rev)
55 if dlg.exec() == QDialog.Accepted: 44 if dlg.exec() == QDialog.Accepted:
56 rev, bookmark, force, noBackup, keep = dlg.getData() 45 rev, bookmark, force, noBackup, keep = dlg.getData()
57 46
58 args = self.vcs.initCommand("strip") 47 args = self.vcs.initCommand("strip")
69 args.append(rev) 58 args.append(rev)
70 59
71 dia = HgDialog( 60 dia = HgDialog(
72 self.tr("Stripping changesets from repository"), 61 self.tr("Stripping changesets from repository"),
73 self.vcs) 62 self.vcs)
74 res = dia.startProcess(args, repodir) 63 res = dia.startProcess(args)
75 if res: 64 if res:
76 dia.exec() 65 dia.exec()
77 res = dia.hasAddOrDelete() 66 res = dia.hasAddOrDelete()
78 self.vcs.checkVCSStatus() 67 self.vcs.checkVCSStatus()
79 return res 68 return res

eric ide

mercurial