|
1 # -*- coding: utf-8 -*- |
|
2 |
|
3 # Copyright (c) 2011 - 2022 Detlev Offenbach <detlev@die-offenbachs.de> |
|
4 # |
|
5 |
|
6 """ |
|
7 Module implementing the rebase 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 Rebase(HgExtension): |
|
17 """ |
|
18 Class implementing the rebase extension interface. |
|
19 """ |
|
20 def __init__(self, vcs): |
|
21 """ |
|
22 Constructor |
|
23 |
|
24 @param vcs reference to the Mercurial vcs object |
|
25 """ |
|
26 super().__init__(vcs) |
|
27 |
|
28 def hgRebase(self): |
|
29 """ |
|
30 Public method to rebase changesets to a different branch. |
|
31 |
|
32 @return flag indicating that the project should be reread (boolean) |
|
33 """ |
|
34 res = False |
|
35 from .HgRebaseDialog import HgRebaseDialog |
|
36 dlg = HgRebaseDialog(self.vcs.hgGetTagsList(), |
|
37 self.vcs.hgGetBranchesList(), |
|
38 self.vcs.hgGetBookmarksList(), |
|
39 self.vcs.version) |
|
40 if dlg.exec() == QDialog.DialogCode.Accepted: |
|
41 (indicator, sourceRev, destRev, collapse, keep, keepBranches, |
|
42 detach, dryRunOnly, dryRunConfirm) = dlg.getData() |
|
43 |
|
44 args = self.vcs.initCommand("rebase") |
|
45 if indicator == "S": |
|
46 args.append("--source") |
|
47 args.append(sourceRev) |
|
48 elif indicator == "B": |
|
49 args.append("--base") |
|
50 args.append(sourceRev) |
|
51 if destRev: |
|
52 args.append("--dest") |
|
53 args.append(destRev) |
|
54 if collapse: |
|
55 args.append("--collapse") |
|
56 if keep: |
|
57 args.append("--keep") |
|
58 if keepBranches: |
|
59 args.append("--keepbranches") |
|
60 if detach: |
|
61 args.append("--detach") |
|
62 if dryRunOnly: |
|
63 args.append("--dry-run") |
|
64 elif dryRunConfirm: |
|
65 args.append("--confirm") |
|
66 args.append("--verbose") |
|
67 |
|
68 dia = HgDialog(self.tr('Rebase Changesets'), self.vcs) |
|
69 res = dia.startProcess(args) |
|
70 if res: |
|
71 dia.exec() |
|
72 res = dia.hasAddOrDelete() |
|
73 self.vcs.checkVCSStatus() |
|
74 return res |
|
75 |
|
76 def hgRebaseContinue(self): |
|
77 """ |
|
78 Public method to continue rebasing changesets from another branch. |
|
79 |
|
80 @return flag indicating that the project should be reread (boolean) |
|
81 """ |
|
82 args = self.vcs.initCommand("rebase") |
|
83 args.append("--continue") |
|
84 args.append("--verbose") |
|
85 |
|
86 dia = HgDialog(self.tr('Rebase Changesets (Continue)'), self.vcs) |
|
87 res = dia.startProcess(args) |
|
88 if res: |
|
89 dia.exec() |
|
90 res = dia.hasAddOrDelete() |
|
91 self.vcs.checkVCSStatus() |
|
92 return res |
|
93 |
|
94 def hgRebaseAbort(self): |
|
95 """ |
|
96 Public method to abort rebasing changesets from another branch. |
|
97 |
|
98 @return flag indicating that the project should be reread (boolean) |
|
99 """ |
|
100 args = self.vcs.initCommand("rebase") |
|
101 args.append("--abort") |
|
102 args.append("--verbose") |
|
103 |
|
104 dia = HgDialog(self.tr('Rebase Changesets (Abort)'), self.vcs) |
|
105 res = dia.startProcess(args) |
|
106 if res: |
|
107 dia.exec() |
|
108 res = dia.hasAddOrDelete() |
|
109 self.vcs.checkVCSStatus() |
|
110 return res |