Show More
@@ -30,7 +30,7 b' branching.' | |||||
30 |
|
30 | |||
31 | from mercurial.i18n import _ |
|
31 | from mercurial.i18n import _ | |
32 | from mercurial.node import nullid, nullrev, hex, short |
|
32 | from mercurial.node import nullid, nullrev, hex, short | |
33 | from mercurial import util, commands, repair, extensions |
|
33 | from mercurial import util, commands, repair, extensions, pushkey | |
34 | import os |
|
34 | import os | |
35 |
|
35 | |||
36 | def write(repo): |
|
36 | def write(repo): | |
@@ -312,10 +312,34 b' def reposetup(ui, repo):' | |||||
312 |
|
312 | |||
313 | repo.__class__ = bookmark_repo |
|
313 | repo.__class__ = bookmark_repo | |
314 |
|
314 | |||
|
315 | def listbookmarks(repo): | |||
|
316 | d = {} | |||
|
317 | for k, v in repo._bookmarks.iteritems(): | |||
|
318 | d[k] = hex(v) | |||
|
319 | return d | |||
|
320 | ||||
|
321 | def pushbookmark(repo, key, old, new): | |||
|
322 | w = repo.wlock() | |||
|
323 | try: | |||
|
324 | marks = repo._bookmarks | |||
|
325 | if hex(marks.get(key, '')) != old: | |||
|
326 | return False | |||
|
327 | if new == '': | |||
|
328 | del marks[key] | |||
|
329 | else: | |||
|
330 | if new not in repo: | |||
|
331 | return False | |||
|
332 | marks[key] = repo[new].node() | |||
|
333 | write(repo) | |||
|
334 | return True | |||
|
335 | finally: | |||
|
336 | w.release() | |||
|
337 | ||||
315 | def uisetup(ui): |
|
338 | def uisetup(ui): | |
316 | extensions.wrapfunction(repair, "strip", strip) |
|
339 | extensions.wrapfunction(repair, "strip", strip) | |
317 | if ui.configbool('bookmarks', 'track.current'): |
|
340 | if ui.configbool('bookmarks', 'track.current'): | |
318 | extensions.wrapcommand(commands.table, 'update', updatecurbookmark) |
|
341 | extensions.wrapcommand(commands.table, 'update', updatecurbookmark) | |
|
342 | pushkey.register('bookmarks', pushbookmark, listbookmarks) | |||
319 |
|
343 | |||
320 | def updatecurbookmark(orig, ui, repo, *args, **opts): |
|
344 | def updatecurbookmark(orig, ui, repo, *args, **opts): | |
321 | '''Set the current bookmark |
|
345 | '''Set the current bookmark |
General Comments 0
You need to be logged in to leave comments.
Login now