Show More
@@ -364,6 +364,36 b' def updatefromremote(ui, repo, remotemar' | |||||
364 | writer(msg) |
|
364 | writer(msg) | |
365 | localmarks.write() |
|
365 | localmarks.write() | |
366 |
|
366 | |||
|
367 | def pushtoremote(ui, repo, remote, targets): | |||
|
368 | (addsrc, adddst, advsrc, advdst, diverge, differ, invalid | |||
|
369 | ) = compare(repo, repo._bookmarks, remote.listkeys('bookmarks'), | |||
|
370 | srchex=hex, targets=targets) | |||
|
371 | if invalid: | |||
|
372 | b, scid, dcid = invalid[0] | |||
|
373 | ui.warn(_('bookmark %s does not exist on the local ' | |||
|
374 | 'or remote repository!\n') % b) | |||
|
375 | return 2 | |||
|
376 | ||||
|
377 | def push(b, old, new): | |||
|
378 | r = remote.pushkey('bookmarks', b, old, new) | |||
|
379 | if not r: | |||
|
380 | ui.warn(_('updating bookmark %s failed!\n') % b) | |||
|
381 | return 1 | |||
|
382 | return 0 | |||
|
383 | failed = 0 | |||
|
384 | for b, scid, dcid in sorted(addsrc + advsrc + advdst + diverge + differ): | |||
|
385 | ui.status(_("exporting bookmark %s\n") % b) | |||
|
386 | if dcid is None: | |||
|
387 | dcid = '' | |||
|
388 | failed += push(b, dcid, scid) | |||
|
389 | for b, scid, dcid in adddst: | |||
|
390 | # treat as "deleted locally" | |||
|
391 | ui.status(_("deleting remote bookmark %s\n") % b) | |||
|
392 | failed += push(b, dcid, '') | |||
|
393 | ||||
|
394 | if failed: | |||
|
395 | return 1 | |||
|
396 | ||||
367 | def diff(ui, dst, src): |
|
397 | def diff(ui, dst, src): | |
368 | ui.status(_("searching for changed bookmarks\n")) |
|
398 | ui.status(_("searching for changed bookmarks\n")) | |
369 |
|
399 |
@@ -4711,25 +4711,11 b' def push(ui, repo, dest=None, **opts):' | |||||
4711 | result = not result |
|
4711 | result = not result | |
4712 |
|
4712 | |||
4713 | if opts.get('bookmark'): |
|
4713 | if opts.get('bookmark'): | |
4714 | rb = other.listkeys('bookmarks') |
|
4714 | bresult = bookmarks.pushtoremote(ui, repo, other, opts['bookmark']) | |
4715 | for b in opts['bookmark']: |
|
4715 | if bresult == 2: | |
4716 | # explicit push overrides remote bookmark if any |
|
4716 | return 2 | |
4717 | if b in repo._bookmarks: |
|
4717 | if not result and bresult: | |
4718 | ui.status(_("exporting bookmark %s\n") % b) |
|
4718 | result = 2 | |
4719 | new = repo[b].hex() |
|
|||
4720 | elif b in rb: |
|
|||
4721 | ui.status(_("deleting remote bookmark %s\n") % b) |
|
|||
4722 | new = '' # delete |
|
|||
4723 | else: |
|
|||
4724 | ui.warn(_('bookmark %s does not exist on the local ' |
|
|||
4725 | 'or remote repository!\n') % b) |
|
|||
4726 | return 2 |
|
|||
4727 | old = rb.get(b, '') |
|
|||
4728 | r = other.pushkey('bookmarks', b, old, new) |
|
|||
4729 | if not r: |
|
|||
4730 | ui.warn(_('updating bookmark %s failed!\n') % b) |
|
|||
4731 | if not result: |
|
|||
4732 | result = 2 |
|
|||
4733 |
|
4719 | |||
4734 | return result |
|
4720 | return result | |
4735 |
|
4721 |
General Comments 0
You need to be logged in to leave comments.
Login now