|
1 # -*- coding: utf-8 -*- |
|
2 |
|
3 # Copyright (c) 2019 - 2022 Detlev Offenbach <detlev@die-offenbachs.de> |
|
4 # |
|
5 |
|
6 """ |
|
7 Module implementing the closehead extension interface. |
|
8 """ |
|
9 |
|
10 from PyQt6.QtWidgets import QDialog |
|
11 |
|
12 from ..HgExtension import HgExtension |
|
13 from ..HgDialog import HgDialog |
|
14 |
|
15 |
|
16 class Closehead(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 hgCloseheads(self, revisions=None): |
|
30 """ |
|
31 Public method to close arbitrary heads. |
|
32 |
|
33 @param revisions revisions of branch heads to be closed |
|
34 @type str |
|
35 """ |
|
36 message = "" |
|
37 if not revisions: |
|
38 from .HgCloseHeadSelectionDialog import HgCloseHeadSelectionDialog |
|
39 dlg = HgCloseHeadSelectionDialog(self.vcs) |
|
40 if dlg.exec() == QDialog.DialogCode.Accepted: |
|
41 revisions, message = dlg.getData() |
|
42 |
|
43 if not revisions: |
|
44 # still no revisions given; abort... |
|
45 return |
|
46 |
|
47 args = self.vcs.initCommand("close-head") |
|
48 if not message: |
|
49 if len(revisions) == 1: |
|
50 message = self.tr("Revision <{0}> closed.").format( |
|
51 revisions[0]) |
|
52 else: |
|
53 message = self.tr("Revisions <{0}> closed.").format( |
|
54 ", ".join(revisions)) |
|
55 args += ["--message", message] |
|
56 for revision in revisions: |
|
57 args += ["--rev", revision] |
|
58 |
|
59 dia = HgDialog(self.tr("Closing Heads"), self.vcs) |
|
60 res = dia.startProcess(args) |
|
61 if res: |
|
62 dia.exec() |