14 |
14 |
15 from E5Gui import E5MessageBox |
15 from E5Gui import E5MessageBox |
16 |
16 |
17 from ..HgExtension import HgExtension |
17 from ..HgExtension import HgExtension |
18 from ..HgDialog import HgDialog |
18 from ..HgDialog import HgDialog |
19 |
|
20 import Preferences |
|
21 |
19 |
22 |
20 |
23 class Shelve(HgExtension): |
21 class Shelve(HgExtension): |
24 """ |
22 """ |
25 Class implementing the shelve extension interface. |
23 Class implementing the shelve extension interface. |
48 Private method to get the list of shelved changes. |
46 Private method to get the list of shelved changes. |
49 |
47 |
50 @param repodir directory name of the repository (string) |
48 @param repodir directory name of the repository (string) |
51 @return list of shelved changes (list of string) |
49 @return list of shelved changes (list of string) |
52 """ |
50 """ |
53 args = [] |
51 args = self.vcs.initCommand("shelve") |
54 args.append('shelve') |
|
55 args.append('--list') |
52 args.append('--list') |
56 args.append('--quiet') |
53 args.append('--quiet') |
57 |
54 |
58 client = self.vcs.getClient() |
55 client = self.vcs.getClient() |
59 output = "" |
56 output = "" |
60 if client: |
57 if client: |
61 output = client.runcommand(args)[0] |
58 output = client.runcommand(args)[0] |
62 else: |
59 else: |
63 ioEncoding = Preferences.getSystem("IOEncoding") |
|
64 process = QProcess() |
60 process = QProcess() |
65 process.setWorkingDirectory(repodir) |
61 process.setWorkingDirectory(repodir) |
66 process.start('hg', args) |
62 process.start('hg', args) |
67 procStarted = process.waitForStarted(5000) |
63 procStarted = process.waitForStarted(5000) |
68 if procStarted: |
64 if procStarted: |
69 finished = process.waitForFinished(30000) |
65 finished = process.waitForFinished(30000) |
70 if finished and process.exitCode() == 0: |
66 if finished and process.exitCode() == 0: |
71 output = str( |
67 output = str(process.readAllStandardOutput(), |
72 process.readAllStandardOutput(), ioEncoding, |
68 self.vcs.getEncoding(), 'replace') |
73 'replace') |
|
74 |
69 |
75 shelveNamesList = [] |
70 shelveNamesList = [] |
76 for line in output.splitlines(): |
71 for line in output.splitlines(): |
77 shelveNamesList.append(line.strip()) |
72 shelveNamesList.append(line.strip()) |
78 |
73 |
102 from .HgShelveDataDialog import HgShelveDataDialog |
97 from .HgShelveDataDialog import HgShelveDataDialog |
103 dlg = HgShelveDataDialog() |
98 dlg = HgShelveDataDialog() |
104 if dlg.exec_() == QDialog.Accepted: |
99 if dlg.exec_() == QDialog.Accepted: |
105 shelveName, dateTime, message, addRemove = dlg.getData() |
100 shelveName, dateTime, message, addRemove = dlg.getData() |
106 |
101 |
107 args = [] |
102 args = self.vcs.initCommand("shelve") |
108 args.append("shelve") |
|
109 if shelveName: |
103 if shelveName: |
110 args.append("--name") |
104 args.append("--name") |
111 args.append(shelveName) |
105 args.append(shelveName) |
112 if message: |
106 if message: |
113 args.append("--message") |
107 args.append("--message") |
166 shelveName=shelveName) |
160 shelveName=shelveName) |
167 if dlg.exec_() == QDialog.Accepted: |
161 if dlg.exec_() == QDialog.Accepted: |
168 shelveName, keep = dlg.getData() |
162 shelveName, keep = dlg.getData() |
169 self.__unshelveKeep = keep # store for potential continue |
163 self.__unshelveKeep = keep # store for potential continue |
170 |
164 |
171 args = [] |
165 args = self.vcs.initCommand("unshelve") |
172 args.append("unshelve") |
|
173 if keep: |
166 if keep: |
174 args.append("--keep") |
167 args.append("--keep") |
175 if shelveName: |
168 if shelveName: |
176 args.append(shelveName) |
169 args.append(shelveName) |
177 |
170 |
195 while not os.path.isdir(os.path.join(repodir, self.vcs.adminDir)): |
188 while not os.path.isdir(os.path.join(repodir, self.vcs.adminDir)): |
196 repodir = os.path.dirname(repodir) |
189 repodir = os.path.dirname(repodir) |
197 if os.path.splitdrive(repodir)[1] == os.sep: |
190 if os.path.splitdrive(repodir)[1] == os.sep: |
198 return False |
191 return False |
199 |
192 |
200 args = [] |
193 args = self.vcs.initCommand("unshelve") |
201 args.append("unshelve") |
|
202 args.append("--abort") |
194 args.append("--abort") |
203 |
195 |
204 dia = HgDialog(self.tr('Abort restore operation'), self.vcs) |
196 dia = HgDialog(self.tr('Abort restore operation'), self.vcs) |
205 res = dia.startProcess(args, repodir) |
197 res = dia.startProcess(args, repodir) |
206 if res: |
198 if res: |
221 while not os.path.isdir(os.path.join(repodir, self.vcs.adminDir)): |
213 while not os.path.isdir(os.path.join(repodir, self.vcs.adminDir)): |
222 repodir = os.path.dirname(repodir) |
214 repodir = os.path.dirname(repodir) |
223 if os.path.splitdrive(repodir)[1] == os.sep: |
215 if os.path.splitdrive(repodir)[1] == os.sep: |
224 return False |
216 return False |
225 |
217 |
226 args = [] |
218 args = self.vcs.initCommand("unshelve") |
227 args.append("unshelve") |
|
228 if self.__unshelveKeep: |
219 if self.__unshelveKeep: |
229 args.append("--keep") |
220 args.append("--keep") |
230 args.append("--continue") |
221 args.append("--continue") |
231 |
222 |
232 dia = HgDialog(self.tr('Continue restore operation'), self.vcs) |
223 dia = HgDialog(self.tr('Continue restore operation'), self.vcs) |
267 None, |
258 None, |
268 self.tr("Delete shelves"), |
259 self.tr("Delete shelves"), |
269 self.tr("Do you really want to delete these shelves?"), |
260 self.tr("Do you really want to delete these shelves?"), |
270 shelveNames) |
261 shelveNames) |
271 if dlg.exec_() == QDialog.Accepted: |
262 if dlg.exec_() == QDialog.Accepted: |
272 args = [] |
263 args = self.vcs.initCommand("shelve") |
273 args.append("shelve") |
|
274 args.append("--delete") |
264 args.append("--delete") |
275 args.extend(shelveNames) |
265 args.extend(shelveNames) |
276 |
266 |
277 dia = HgDialog(self.tr('Delete shelves'), self.vcs) |
267 dia = HgDialog(self.tr('Delete shelves'), self.vcs) |
278 res = dia.startProcess(args, repodir) |
268 res = dia.startProcess(args, repodir) |
295 res = E5MessageBox.yesNo( |
285 res = E5MessageBox.yesNo( |
296 None, |
286 None, |
297 self.tr("Delete all shelves"), |
287 self.tr("Delete all shelves"), |
298 self.tr("""Do you really want to delete all shelved changes?""")) |
288 self.tr("""Do you really want to delete all shelved changes?""")) |
299 if res: |
289 if res: |
300 args = [] |
290 args = self.vcs.initCommand("shelve") |
301 args.append("shelve") |
|
302 args.append("--cleanup") |
291 args.append("--cleanup") |
303 |
292 |
304 dia = HgDialog(self.tr('Delete all shelves'), self.vcs) |
293 dia = HgDialog(self.tr('Delete all shelves'), self.vcs) |
305 res = dia.startProcess(args, repodir) |
294 res = dia.startProcess(args, repodir) |
306 if res: |
295 if res: |