Plugins/VcsPlugins/vcsMercurial/StripExtension/strip.py

changeset 5268
748e4c50523b
child 5270
7758f0c7d9f6
equal deleted inserted replaced
5266:c2abca3b5e7b 5268:748e4c50523b
1 # -*- coding: utf-8 -*-
2
3 # Copyright (c) 2016 Detlev Offenbach <detlev@die-offenbachs.de>
4 #
5
6 """
7 Module implementing the strip extension interface.
8 """
9
10 from __future__ import unicode_literals
11
12 import os
13
14 from PyQt5.QtWidgets import QDialog
15
16 from ..HgExtension import HgExtension
17 from ..HgDialog import HgDialog
18
19
20 # TODO: add strip support to the log browser
21 class Strip(HgExtension):
22 """
23 Class implementing the strip extension interface.
24 """
25 def __init__(self, vcs):
26 """
27 Constructor
28
29 @param vcs reference to the Mercurial vcs object
30 """
31 super(Strip, self).__init__(vcs)
32
33 def hgStrip(self, name):
34 """
35 Public method to strip revisions from a repository.
36
37 @param name file/directory name (string)
38 @return flag indicating that the project should be reread (boolean)
39 """
40 # find the root of the repo
41 repodir = self.vcs.splitPath(name)[0]
42 while not os.path.isdir(os.path.join(repodir, self.vcs.adminDir)):
43 repodir = os.path.dirname(repodir)
44 if os.path.splitdrive(repodir)[1] == os.sep:
45 return False
46
47 from .HgStripDialog import HgStripDialog
48 res = False
49 dlg = HgStripDialog(self.vcs.hgGetTagsList(repodir),
50 self.vcs.hgGetBranchesList(repodir),
51 self.vcs.hgGetBookmarksList(repodir))
52 if dlg.exec_() == QDialog.Accepted:
53 rev, bookmark, force, noBackup, keep = dlg.getData()
54
55 args = self.vcs.initCommand("strip")
56 if bookmark:
57 args.append("--bookmark")
58 args.append(bookmark)
59 if force:
60 args.append("--force")
61 if noBackup:
62 args.append("--no-backup")
63 if keep:
64 args.append("--keep")
65 args.append("-v")
66 args.append(rev)
67
68 dia = HgDialog(
69 self.tr("Stripping changesets from repository"),
70 self.vcs)
71 res = dia.startProcess(args, repodir)
72 if res:
73 dia.exec_()
74 res = dia.hasAddOrDelete()
75 self.vcs.checkVCSStatus()
76 return res

eric ide

mercurial