##// END OF EJS Templates
bookmarks: add support for push --bookmark to export bookmarks
Matt Mackall -
r11379:e1a145ee default
parent child Browse files
Show More
@@ -409,6 +409,42 b' def pull(oldpull, ui, repo, source="defa'
409
409
410 return result
410 return result
411
411
412 def push(oldpush, ui, repo, dest=None, **opts):
413 dopush = True
414 if opts.get('bookmark'):
415 dopush = False
416 for b in opts['bookmark']:
417 if b in repo._bookmarks:
418 dopush = True
419 opts.setdefault('rev', []).append(b)
420
421 result = 0
422 if dopush:
423 result = oldpush(ui, repo, dest, **opts)
424
425 if opts.get('bookmark'):
426 # this is an unpleasant hack as push will do this internally
427 dest = ui.expandpath(dest or 'default-push', dest or 'default')
428 dest, branches = hg.parseurl(dest, opts.get('branch'))
429 other = hg.repository(hg.remoteui(repo, opts), dest)
430 rb = other.listkeys('bookmarks')
431 for b in opts['bookmark']:
432 # explicit push overrides remote bookmark if any
433 if b in repo._bookmarks:
434 ui.status(_("exporting bookmark %s\n") % b)
435 new = repo[b].hex()
436 else:
437 ui.status(_("deleting remote bookmark %s\n") % b)
438 new = '' # delete
439 old = rb.get(b, '')
440 r = other.pushkey('bookmarks', b, old, new)
441 if not r:
442 ui.warn(_('updating bookmark %s failed!\n') % b)
443 if not result:
444 result = 2
445
446 return result
447
412 def uisetup(ui):
448 def uisetup(ui):
413 extensions.wrapfunction(repair, "strip", strip)
449 extensions.wrapfunction(repair, "strip", strip)
414 if ui.configbool('bookmarks', 'track.current'):
450 if ui.configbool('bookmarks', 'track.current'):
@@ -417,6 +453,9 b' def uisetup(ui):'
417 entry = extensions.wrapcommand(commands.table, 'pull', pull)
453 entry = extensions.wrapcommand(commands.table, 'pull', pull)
418 entry[1].append(('B', 'bookmark', [],
454 entry[1].append(('B', 'bookmark', [],
419 _("bookmark to import")))
455 _("bookmark to import")))
456 entry = extensions.wrapcommand(commands.table, 'push', push)
457 entry[1].append(('B', 'bookmark', [],
458 _("bookmark to export")))
420
459
421 pushkey.register('bookmarks', pushbookmark, listbookmarks)
460 pushkey.register('bookmarks', pushbookmark, listbookmarks)
422
461
General Comments 0
You need to be logged in to leave comments. Login now