Mercurial > public > mercurial-scm > hg
diff mercurial/bookmarks.py @ 20026:84905561ad41
bookmarks: rewrite pushing local bookmarks in "commands.push()" by "compare()"
This patch adds "pushtoremote()", which uses "compare()" to compare
bookmarks between the local and the remote repositories, to replace
pushing local bookmarks in "commands.push()".
author | FUJIWARA Katsunori <foozy@lares.dti.ne.jp> |
---|---|
date | Fri, 08 Nov 2013 12:45:52 +0900 |
parents | e8a11791abfc |
children | 4b06b2a445a1 |
line wrap: on
line diff
--- a/mercurial/bookmarks.py Fri Nov 08 12:45:52 2013 +0900 +++ b/mercurial/bookmarks.py Fri Nov 08 12:45:52 2013 +0900 @@ -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"))