--- a/hgext/bookmarks.py Thu Jun 17 15:51:27 2010 +0200
+++ b/hgext/bookmarks.py Thu Jun 17 14:26:23 2010 -0500
@@ -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,10 +383,41 @@
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)
+
+ 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):