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

changeset 6942
2602857055c5
parent 6645
ad476851d7e0
child 7229
53054eb5b15a
equal deleted inserted replaced
6941:f99d60d6b59b 6942:2602857055c5
1 # -*- coding: utf-8 -*-
2
3 # Copyright (c) 2016 - 2019 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 class Strip(HgExtension):
21 """
22 Class implementing the strip extension interface.
23 """
24 def __init__(self, vcs):
25 """
26 Constructor
27
28 @param vcs reference to the Mercurial vcs object
29 @type Hg
30 """
31 super(Strip, self).__init__(vcs)
32
33 def hgStrip(self, name, rev=""):
34 """
35 Public method to strip revisions from a repository.
36
37 @param name file/directory name
38 @type str
39 @keyparam rev revision to strip from
40 @type str
41 @return flag indicating that the project should be reread
42 @rtype bool
43 """
44 # find the root of the repo
45 repodir = self.vcs.splitPath(name)[0]
46 while not os.path.isdir(os.path.join(repodir, self.vcs.adminDir)):
47 repodir = os.path.dirname(repodir)
48 if os.path.splitdrive(repodir)[1] == os.sep:
49 return False
50
51 from .HgStripDialog import HgStripDialog
52 res = False
53 dlg = HgStripDialog(self.vcs.hgGetTagsList(repodir),
54 self.vcs.hgGetBranchesList(repodir),
55 self.vcs.hgGetBookmarksList(repodir),
56 rev)
57 if dlg.exec_() == QDialog.Accepted:
58 rev, bookmark, force, noBackup, keep = dlg.getData()
59
60 args = self.vcs.initCommand("strip")
61 if bookmark:
62 args.append("--bookmark")
63 args.append(bookmark)
64 if force:
65 args.append("--force")
66 if noBackup:
67 args.append("--no-backup")
68 if keep:
69 args.append("--keep")
70 args.append("-v")
71 args.append(rev)
72
73 dia = HgDialog(
74 self.tr("Stripping changesets from repository"),
75 self.vcs)
76 res = dia.startProcess(args, repodir)
77 if res:
78 dia.exec_()
79 res = dia.hasAddOrDelete()
80 self.vcs.checkVCSStatus()
81 return res

eric ide

mercurial