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

bookmarks: add support for push --bookmark to export bookmarks

parent cb21fb1b
No related branches found
No related tags found
No related merge requests found
......@@ -409,6 +409,42 @@
return result
def push(oldpush, ui, repo, dest=None, **opts):
dopush = True
if opts.get('bookmark'):
dopush = False
for b in opts['bookmark']:
if b in repo._bookmarks:
dopush = True
opts.setdefault('rev', []).append(b)
result = 0
if dopush:
result = oldpush(ui, repo, dest, **opts)
if opts.get('bookmark'):
# this is an unpleasant hack as push will do this internally
dest = ui.expandpath(dest or 'default-push', dest or 'default')
dest, branches = hg.parseurl(dest, opts.get('branch'))
other = hg.repository(hg.remoteui(repo, opts), dest)
rb = other.listkeys('bookmarks')
for b in opts['bookmark']:
# explicit push overrides remote bookmark if any
if b in repo._bookmarks:
ui.status(_("exporting bookmark %s\n") % b)
new = repo[b].hex()
else:
ui.status(_("deleting remote bookmark %s\n") % b)
new = '' # delete
old = rb.get(b, '')
r = other.pushkey('bookmarks', b, old, new)
if not r:
ui.warn(_('updating bookmark %s failed!\n') % b)
if not result:
result = 2
return result
def uisetup(ui):
extensions.wrapfunction(repair, "strip", strip)
if ui.configbool('bookmarks', 'track.current'):
......@@ -417,6 +453,9 @@
entry = extensions.wrapcommand(commands.table, 'pull', pull)
entry[1].append(('B', 'bookmark', [],
_("bookmark to import")))
entry = extensions.wrapcommand(commands.table, 'push', push)
entry[1].append(('B', 'bookmark', [],
_("bookmark to export")))
pushkey.register('bookmarks', pushbookmark, listbookmarks)
......
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