19 |
19 |
20 class Histedit(HgExtension): |
20 class Histedit(HgExtension): |
21 """ |
21 """ |
22 Class implementing the histedit extension interface. |
22 Class implementing the histedit extension interface. |
23 """ |
23 """ |
|
24 |
24 def __init__(self, vcs): |
25 def __init__(self, vcs): |
25 """ |
26 """ |
26 Constructor |
27 Constructor |
27 |
28 |
28 @param vcs reference to the Mercurial vcs object |
29 @param vcs reference to the Mercurial vcs object |
29 @type Hg |
30 @type Hg |
30 """ |
31 """ |
31 super().__init__(vcs) |
32 super().__init__(vcs) |
32 |
33 |
33 def hgHisteditStart(self, rev=""): |
34 def hgHisteditStart(self, rev=""): |
34 """ |
35 """ |
35 Public method to start a histedit session. |
36 Public method to start a histedit session. |
36 |
37 |
37 @param rev revision to start histedit at |
38 @param rev revision to start histedit at |
38 @type str |
39 @type str |
39 @return flag indicating that the project should be reread |
40 @return flag indicating that the project should be reread |
40 @rtype bool |
41 @rtype bool |
41 """ |
42 """ |
42 from .HgHisteditConfigDialog import HgHisteditConfigDialog |
43 from .HgHisteditConfigDialog import HgHisteditConfigDialog |
|
44 |
43 res = False |
45 res = False |
44 dlg = HgHisteditConfigDialog(self.vcs.hgGetTagsList(), |
46 dlg = HgHisteditConfigDialog( |
45 self.vcs.hgGetBranchesList(), |
47 self.vcs.hgGetTagsList(), |
46 self.vcs.hgGetBookmarksList(), |
48 self.vcs.hgGetBranchesList(), |
47 rev) |
49 self.vcs.hgGetBookmarksList(), |
|
50 rev, |
|
51 ) |
48 if dlg.exec() == QDialog.DialogCode.Accepted: |
52 if dlg.exec() == QDialog.DialogCode.Accepted: |
49 rev, force, keep = dlg.getData() |
53 rev, force, keep = dlg.getData() |
50 |
54 |
51 editor = os.path.join( |
55 editor = os.path.join(os.path.dirname(__file__), "HgHisteditEditor.py") |
52 os.path.dirname(__file__), "HgHisteditEditor.py") |
56 |
53 |
|
54 args = self.vcs.initCommand("histedit") |
57 args = self.vcs.initCommand("histedit") |
55 args.append("-v") |
58 args.append("-v") |
56 args.extend([ |
59 args.extend( |
57 "--config", |
60 ["--config", f"ui.editor={Globals.getPythonExecutable()} {editor}"] |
58 f"ui.editor={Globals.getPythonExecutable()} {editor}" |
61 ) |
59 ]) |
|
60 if keep: |
62 if keep: |
61 args.append("--keep") |
63 args.append("--keep") |
62 if rev: |
64 if rev: |
63 if rev == "--outgoing": |
65 if rev == "--outgoing": |
64 if force: |
66 if force: |
65 args.append("--force") |
67 args.append("--force") |
66 else: |
68 else: |
67 args.append("--rev") |
69 args.append("--rev") |
68 args.append(rev) |
70 args.append(rev) |
69 |
71 |
70 env = { |
72 env = { |
71 "HGEDITOR": "{0} {1}".format( |
73 "HGEDITOR": "{0} {1}".format(Globals.getPythonExecutable(), editor), |
72 Globals.getPythonExecutable(), editor), |
74 "EDITOR": "{0} {1}".format(Globals.getPythonExecutable(), editor), |
73 "EDITOR": "{0} {1}".format( |
|
74 Globals.getPythonExecutable(), editor), |
|
75 } |
75 } |
76 |
76 |
77 dia = HgDialog( |
77 dia = HgDialog( |
78 self.tr("Starting histedit session"), |
78 self.tr("Starting histedit session"), self.vcs, useClient=False |
79 self.vcs, |
79 ) |
80 useClient=False) |
|
81 res = dia.startProcess(args, environment=env) |
80 res = dia.startProcess(args, environment=env) |
82 if res: |
81 if res: |
83 dia.exec() |
82 dia.exec() |
84 res = dia.hasAddOrDelete() |
83 res = dia.hasAddOrDelete() |
85 self.vcs.checkVCSStatus() |
84 self.vcs.checkVCSStatus() |
86 return res |
85 return res |
87 |
86 |
88 def hgHisteditContinue(self): |
87 def hgHisteditContinue(self): |
89 """ |
88 """ |
90 Public method to continue an interrupted histedit session. |
89 Public method to continue an interrupted histedit session. |
91 |
90 |
92 @return flag indicating that the project should be reread |
91 @return flag indicating that the project should be reread |
93 @rtype bool |
92 @rtype bool |
94 """ |
93 """ |
95 args = self.vcs.initCommand("histedit") |
94 args = self.vcs.initCommand("histedit") |
96 args.append("--continue") |
95 args.append("--continue") |
97 args.append("-v") |
96 args.append("-v") |
98 |
97 |
99 editor = os.path.join( |
98 editor = os.path.join(os.path.dirname(__file__), "HgHisteditEditor.py") |
100 os.path.dirname(__file__), "HgHisteditEditor.py") |
99 env = {"HGEDITOR": "{0} {1}".format(Globals.getPythonExecutable(), editor)} |
101 env = {"HGEDITOR": "{0} {1}".format( |
100 |
102 Globals.getPythonExecutable(), editor)} |
101 dia = HgDialog(self.tr("Continue histedit session"), self.vcs, useClient=False) |
103 |
|
104 dia = HgDialog( |
|
105 self.tr("Continue histedit session"), |
|
106 self.vcs, |
|
107 useClient=False) |
|
108 res = dia.startProcess(args, environment=env) |
102 res = dia.startProcess(args, environment=env) |
109 if res: |
103 if res: |
110 dia.exec() |
104 dia.exec() |
111 res = dia.hasAddOrDelete() |
105 res = dia.hasAddOrDelete() |
112 self.vcs.checkVCSStatus() |
106 self.vcs.checkVCSStatus() |
113 return res |
107 return res |
114 |
108 |
115 def hgHisteditAbort(self, name): |
109 def hgHisteditAbort(self, name): |
116 """ |
110 """ |
117 Public method to abort an interrupted histedit session. |
111 Public method to abort an interrupted histedit session. |
118 |
112 |
119 @param name file/directory name |
113 @param name file/directory name |
120 @type str |
114 @type str |
121 @return flag indicating that the project should be reread |
115 @return flag indicating that the project should be reread |
122 @rtype bool |
116 @rtype bool |
123 """ |
117 """ |
124 args = self.vcs.initCommand("histedit") |
118 args = self.vcs.initCommand("histedit") |
125 args.append("--abort") |
119 args.append("--abort") |
126 args.append("-v") |
120 args.append("-v") |
127 |
121 |
128 editor = os.path.join( |
122 editor = os.path.join(os.path.dirname(__file__), "HgHisteditEditor.py") |
129 os.path.dirname(__file__), "HgHisteditEditor.py") |
123 env = {"HGEDITOR": "{0} {1}".format(Globals.getPythonExecutable(), editor)} |
130 env = {"HGEDITOR": "{0} {1}".format( |
124 |
131 Globals.getPythonExecutable(), editor)} |
125 dia = HgDialog(self.tr("Abort histedit session"), self.vcs, useClient=False) |
132 |
|
133 dia = HgDialog( |
|
134 self.tr("Abort histedit session"), |
|
135 self.vcs, |
|
136 useClient=False) |
|
137 res = dia.startProcess(args, environment=env) |
126 res = dia.startProcess(args, environment=env) |
138 if res: |
127 if res: |
139 dia.exec() |
128 dia.exec() |
140 res = dia.hasAddOrDelete() |
129 res = dia.hasAddOrDelete() |
141 self.vcs.checkVCSStatus() |
130 self.vcs.checkVCSStatus() |
142 return res |
131 return res |
143 |
132 |
144 def hgHisteditEditPlan(self): |
133 def hgHisteditEditPlan(self): |
145 """ |
134 """ |
146 Public method to edit the remaining actions list of an interrupted |
135 Public method to edit the remaining actions list of an interrupted |
147 histedit session. |
136 histedit session. |
148 |
137 |
149 @return flag indicating that the project should be reread |
138 @return flag indicating that the project should be reread |
150 @rtype bool |
139 @rtype bool |
151 """ |
140 """ |
152 args = self.vcs.initCommand("histedit") |
141 args = self.vcs.initCommand("histedit") |
153 args.append("--edit-plan") |
142 args.append("--edit-plan") |
154 args.append("-v") |
143 args.append("-v") |
155 |
144 |
156 editor = os.path.join( |
145 editor = os.path.join(os.path.dirname(__file__), "HgHisteditEditor.py") |
157 os.path.dirname(__file__), "HgHisteditEditor.py") |
146 env = {"HGEDITOR": "{0} {1}".format(Globals.getPythonExecutable(), editor)} |
158 env = {"HGEDITOR": "{0} {1}".format( |
147 |
159 Globals.getPythonExecutable(), editor)} |
148 dia = HgDialog(self.tr("Edit Plan"), self.vcs, useClient=False) |
160 |
|
161 dia = HgDialog( |
|
162 self.tr("Edit Plan"), |
|
163 self.vcs, |
|
164 useClient=False) |
|
165 res = dia.startProcess(args, environment=env) |
149 res = dia.startProcess(args, environment=env) |
166 if res: |
150 if res: |
167 dia.exec() |
151 dia.exec() |
168 res = dia.hasAddOrDelete() |
152 res = dia.hasAddOrDelete() |
169 self.vcs.checkVCSStatus() |
153 self.vcs.checkVCSStatus() |