32 QObject.__init__(self, vcs) |
33 QObject.__init__(self, vcs) |
33 |
34 |
34 self.vcs = vcs |
35 self.vcs = vcs |
35 |
36 |
36 self.bookmarksListDlg = None |
37 self.bookmarksListDlg = None |
|
38 self.bookmarksInOutDlg = None |
37 self.bookmarksList = [] |
39 self.bookmarksList = [] |
38 |
40 |
39 def shutdown(self): |
41 def shutdown(self): |
40 """ |
42 """ |
41 Public method used to shutdown the bookmarks interface. |
43 Public method used to shutdown the bookmarks interface. |
42 """ |
44 """ |
43 if self.bookmarksListDlg is not None: |
45 if self.bookmarksListDlg is not None: |
44 self.bookmarksListDlg.close() |
46 self.bookmarksListDlg.close() |
|
47 if self.bookmarksInOutDlg is not None: |
|
48 self.bookmarksInOutDlg.close() |
45 |
49 |
46 def hgListBookmarks(self, path): |
50 def hgListBookmarks(self, path): |
47 """ |
51 """ |
48 Public method used to list the available bookmarks. |
52 Public method used to list the available bookmarks. |
49 |
53 |
215 |
211 |
216 dia = HgDialog(self.trUtf8('Move Mercurial Bookmark')) |
212 dia = HgDialog(self.trUtf8('Move Mercurial Bookmark')) |
217 res = dia.startProcess(args, repodir) |
213 res = dia.startProcess(args, repodir) |
218 if res: |
214 if res: |
219 dia.exec_() |
215 dia.exec_() |
|
216 |
|
217 def hgBookmarkIncoming(self, name): |
|
218 """ |
|
219 Public method to show a list of incoming bookmarks. |
|
220 |
|
221 @param name file/directory name (string) |
|
222 """ |
|
223 self.bookmarksInOutDlg = HgBookmarksInOutDialog( |
|
224 self.vcs, HgBookmarksInOutDialog.INCOMING) |
|
225 self.bookmarksInOutDlg.show() |
|
226 self.bookmarksInOutDlg.start(name) |
|
227 |
|
228 def hgBookmarkOutgoing(self, name): |
|
229 """ |
|
230 Public method to show a list of outgoing bookmarks. |
|
231 |
|
232 @param name file/directory name (string) |
|
233 """ |
|
234 self.bookmarksInOutDlg = HgBookmarksInOutDialog( |
|
235 self.vcs, HgBookmarksInOutDialog.OUTGOING) |
|
236 self.bookmarksInOutDlg.show() |
|
237 self.bookmarksInOutDlg.start(name) |
|
238 |
|
239 def __getInOutBookmarks(self, repodir, incoming): |
|
240 """ |
|
241 Public method to get the list of incoming or outgoing bookmarks. |
|
242 |
|
243 @param repodir directory name of the repository (string) |
|
244 @param incoming flag indicating to get incoming bookmarks (boolean) |
|
245 @return list of bookmarks (list of string) |
|
246 """ |
|
247 bookmarksList = [] |
|
248 |
|
249 ioEncoding = Preferences.getSystem("IOEncoding") |
|
250 process = QProcess() |
|
251 args = [] |
|
252 if incoming: |
|
253 args.append('incoming') |
|
254 else: |
|
255 args.append('outgoing') |
|
256 args.append('--bookmarks') |
|
257 process.setWorkingDirectory(repodir) |
|
258 process.start('hg', args) |
|
259 procStarted = process.waitForStarted() |
|
260 if procStarted: |
|
261 finished = process.waitForFinished(30000) |
|
262 if finished and process.exitCode() == 0: |
|
263 output = \ |
|
264 str(process.readAllStandardOutput(), ioEncoding, 'replace') |
|
265 for line in output.splitlines(): |
|
266 if line.startswith(" "): |
|
267 l = line.strip().split() |
|
268 del l[-1] |
|
269 name = " ".join(l) |
|
270 bookmarksList.append(name) |
|
271 |
|
272 return bookmarksList |
|
273 |
|
274 def hgBookmarkPull(self, name): |
|
275 """ |
|
276 Public method to pull a bookmark from a remote repository. |
|
277 |
|
278 @param name file/directory name (string) |
|
279 """ |
|
280 # find the root of the repo |
|
281 repodir = self.vcs.splitPath(name)[0] |
|
282 while not os.path.isdir(os.path.join(repodir, self.vcs.adminDir)): |
|
283 repodir = os.path.dirname(repodir) |
|
284 if repodir == os.sep: |
|
285 return |
|
286 |
|
287 bookmarks = self.__getInOutBookmarks(repodir, True) |
|
288 |
|
289 bookmark, ok = QInputDialog.getItem( |
|
290 None, |
|
291 self.trUtf8("Pull Bookmark"), |
|
292 self.trUtf8("Select the bookmark to be pulled:"), |
|
293 [""] + sorted(bookmarks), |
|
294 0, True) |
|
295 if ok and bookmark: |
|
296 args = [] |
|
297 args.append('pull') |
|
298 args.append('--bookmark') |
|
299 args.append(bookmark) |
|
300 |
|
301 dia = HgDialog(self.trUtf8('Pulling bookmark from a remote Mercurial repository')) |
|
302 res = dia.startProcess(args, repodir) |
|
303 if res: |
|
304 dia.exec_() |
|
305 |
|
306 def hgBookmarkPush(self, name): |
|
307 """ |
|
308 Public method to push a bookmark to a remote repository. |
|
309 |
|
310 @param name file/directory name (string) |
|
311 """ |
|
312 # find the root of the repo |
|
313 repodir = self.vcs.splitPath(name)[0] |
|
314 while not os.path.isdir(os.path.join(repodir, self.vcs.adminDir)): |
|
315 repodir = os.path.dirname(repodir) |
|
316 if repodir == os.sep: |
|
317 return |
|
318 |
|
319 bookmarks = self.__getInOutBookmarks(repodir, False) |
|
320 |
|
321 bookmark, ok = QInputDialog.getItem( |
|
322 None, |
|
323 self.trUtf8("Push Bookmark"), |
|
324 self.trUtf8("Select the bookmark to be push:"), |
|
325 [""] + sorted(bookmarks), |
|
326 0, True) |
|
327 if ok and bookmark: |
|
328 args = [] |
|
329 args.append('push') |
|
330 args.append('--bookmark') |
|
331 args.append(bookmark) |
|
332 |
|
333 dia = HgDialog(self.trUtf8('Pushing bookmark to a remote Mercurial repository')) |
|
334 res = dia.startProcess(args, repodir) |
|
335 if res: |
|
336 dia.exec_() |