|
1 # -*- coding: utf-8 -*- |
|
2 |
|
3 # Copyright (c) 2016 - 2021 Detlev Offenbach <detlev@die-offenbachs.de> |
|
4 # |
|
5 |
|
6 """ |
|
7 Module implementing the strip extension interface. |
|
8 """ |
|
9 |
|
10 from PyQt5.QtWidgets import QDialog |
|
11 |
|
12 from ..HgExtension import HgExtension |
|
13 from ..HgDialog import HgDialog |
|
14 |
|
15 |
|
16 class Strip(HgExtension): |
|
17 """ |
|
18 Class implementing the strip extension interface. |
|
19 """ |
|
20 def __init__(self, vcs): |
|
21 """ |
|
22 Constructor |
|
23 |
|
24 @param vcs reference to the Mercurial vcs object |
|
25 @type Hg |
|
26 """ |
|
27 super().__init__(vcs) |
|
28 |
|
29 def hgStrip(self, rev=""): |
|
30 """ |
|
31 Public method to strip revisions from a repository. |
|
32 |
|
33 @param rev revision to strip from |
|
34 @type str |
|
35 @return flag indicating that the project should be reread |
|
36 @rtype bool |
|
37 """ |
|
38 from .HgStripDialog import HgStripDialog |
|
39 res = False |
|
40 dlg = HgStripDialog(self.vcs.hgGetTagsList(), |
|
41 self.vcs.hgGetBranchesList(), |
|
42 self.vcs.hgGetBookmarksList(), |
|
43 rev) |
|
44 if dlg.exec() == QDialog.DialogCode.Accepted: |
|
45 rev, bookmark, force, noBackup, keep = dlg.getData() |
|
46 |
|
47 args = self.vcs.initCommand("strip") |
|
48 if bookmark: |
|
49 args.append("--bookmark") |
|
50 args.append(bookmark) |
|
51 if force: |
|
52 args.append("--force") |
|
53 if noBackup: |
|
54 args.append("--no-backup") |
|
55 if keep: |
|
56 args.append("--keep") |
|
57 args.append("-v") |
|
58 args.append(rev) |
|
59 |
|
60 dia = HgDialog( |
|
61 self.tr("Stripping changesets from repository"), |
|
62 self.vcs) |
|
63 res = dia.startProcess(args) |
|
64 if res: |
|
65 dia.exec() |
|
66 res = dia.hasAddOrDelete() |
|
67 self.vcs.checkVCSStatus() |
|
68 return res |