##// END OF EJS Templates
bookmarks: add support for pull --bookmark to import remote bookmarks
Matt Mackall -
r11378:cb21fb1b default
parent child Browse files
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, pushkey
33 from mercurial import util, commands, repair, extensions, pushkey, hg
34 import os
34 import os
35
35
36 def write(repo):
36 def write(repo):
@@ -383,10 +383,41 b' def pushbookmark(repo, key, old, new):'
383 finally:
383 finally:
384 w.release()
384 w.release()
385
385
386 def pull(oldpull, ui, repo, source="default", **opts):
387 # translate bookmark args to rev args for actual pull
388 if opts.get('bookmark'):
389 # this is an unpleasant hack as pull will do this internally
390 source, branches = hg.parseurl(ui.expandpath(source),
391 opts.get('branch'))
392 other = hg.repository(hg.remoteui(repo, opts), source)
393 rb = other.listkeys('bookmarks')
394
395 for b in opts['bookmark']:
396 if b not in rb:
397 raise util.Abort(_('remote bookmark %s not found!') % b)
398 opts.setdefault('rev', []).append(b)
399
400 result = oldpull(ui, repo, source, **opts)
401
402 # update specified bookmarks
403 if opts.get('bookmark'):
404 for b in opts['bookmark']:
405 # explicit pull overrides local bookmark if any
406 ui.status(_("importing bookmark %s\n") % b)
407 repo._bookmarks[b] = repo[rb[b]].node()
408 write(repo)
409
410 return result
411
386 def uisetup(ui):
412 def uisetup(ui):
387 extensions.wrapfunction(repair, "strip", strip)
413 extensions.wrapfunction(repair, "strip", strip)
388 if ui.configbool('bookmarks', 'track.current'):
414 if ui.configbool('bookmarks', 'track.current'):
389 extensions.wrapcommand(commands.table, 'update', updatecurbookmark)
415 extensions.wrapcommand(commands.table, 'update', updatecurbookmark)
416
417 entry = extensions.wrapcommand(commands.table, 'pull', pull)
418 entry[1].append(('B', 'bookmark', [],
419 _("bookmark to import")))
420
390 pushkey.register('bookmarks', pushbookmark, listbookmarks)
421 pushkey.register('bookmarks', pushbookmark, listbookmarks)
391
422
392 def updatecurbookmark(orig, ui, repo, *args, **opts):
423 def updatecurbookmark(orig, ui, repo, *args, **opts):
General Comments 0
You need to be logged in to leave comments. Login now