Comments
Patch
@@ -364,6 +364,36 @@
writer(msg)
localmarks.write()
+def pushtoremote(ui, repo, remote, targets):
+ (addsrc, adddst, advsrc, advdst, diverge, differ, invalid
+ ) = compare(repo, repo._bookmarks, remote.listkeys('bookmarks'),
+ srchex=hex, targets=targets)
+ if invalid:
+ b, scid, dcid = invalid[0]
+ ui.warn(_('bookmark %s does not exist on the local '
+ 'or remote repository!\n') % b)
+ return 2
+
+ def push(b, old, new):
+ r = remote.pushkey('bookmarks', b, old, new)
+ if not r:
+ ui.warn(_('updating bookmark %s failed!\n') % b)
+ return 1
+ return 0
+ failed = 0
+ for b, scid, dcid in sorted(addsrc + advsrc + advdst + diverge + differ):
+ ui.status(_("exporting bookmark %s\n") % b)
+ if dcid is None:
+ dcid = ''
+ failed += push(b, dcid, scid)
+ for b, scid, dcid in adddst:
+ # treat as "deleted locally"
+ ui.status(_("deleting remote bookmark %s\n") % b)
+ failed += push(b, dcid, '')
+
+ if failed:
+ return 1
+
def diff(ui, dst, src):
ui.status(_("searching for changed bookmarks\n"))
@@ -4701,25 +4701,11 @@
result = not result
if opts.get('bookmark'):
- 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()
- elif b in rb:
- ui.status(_("deleting remote bookmark %s\n") % b)
- new = '' # delete
- else:
- ui.warn(_('bookmark %s does not exist on the local '
- 'or remote repository!\n') % b)
- return 2
- 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
+ bresult = bookmarks.pushtoremote(ui, repo, other, opts['bookmark'])
+ if bresult == 2:
+ return 2
+ if not result and bresult:
+ result = 2
return result