Skip to content
Snippets Groups Projects
Commit cb21fb1b authored by Matt Mackall's avatar Matt Mackall
Browse files

bookmarks: add support for pull --bookmark to import remote bookmarks

parent 9916263d
No related merge requests found
......@@ -30,7 +30,7 @@
from mercurial.i18n import _
from mercurial.node import nullid, nullrev, hex, short
from mercurial import util, commands, repair, extensions, pushkey
from mercurial import util, commands, repair, extensions, pushkey, hg
import os
def write(repo):
......@@ -383,7 +383,33 @@
finally:
w.release()
def pull(oldpull, ui, repo, source="default", **opts):
# translate bookmark args to rev args for actual pull
if opts.get('bookmark'):
# this is an unpleasant hack as pull will do this internally
source, branches = hg.parseurl(ui.expandpath(source),
opts.get('branch'))
other = hg.repository(hg.remoteui(repo, opts), source)
rb = other.listkeys('bookmarks')
for b in opts['bookmark']:
if b not in rb:
raise util.Abort(_('remote bookmark %s not found!') % b)
opts.setdefault('rev', []).append(b)
result = oldpull(ui, repo, source, **opts)
# update specified bookmarks
if opts.get('bookmark'):
for b in opts['bookmark']:
# explicit pull overrides local bookmark if any
ui.status(_("importing bookmark %s\n") % b)
repo._bookmarks[b] = repo[rb[b]].node()
write(repo)
return result
def uisetup(ui):
extensions.wrapfunction(repair, "strip", strip)
if ui.configbool('bookmarks', 'track.current'):
extensions.wrapcommand(commands.table, 'update', updatecurbookmark)
......@@ -386,7 +412,12 @@
def uisetup(ui):
extensions.wrapfunction(repair, "strip", strip)
if ui.configbool('bookmarks', 'track.current'):
extensions.wrapcommand(commands.table, 'update', updatecurbookmark)
entry = extensions.wrapcommand(commands.table, 'pull', pull)
entry[1].append(('B', 'bookmark', [],
_("bookmark to import")))
pushkey.register('bookmarks', pushbookmark, listbookmarks)
def updatecurbookmark(orig, ui, repo, *args, **opts):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment