# HG changeset patch # User Pierre-Yves David # Date 1408154622 25200 # Node ID ed222ebd61be69d621d05946ba3d112d42a8afd6 # Parent 3dc3cf8d0e73e70c4b25cd21de7ab22823f114c0 push: add bookmarks to the unified bundle2 push We use the `pushkey` part to exchange bookmark updates within the unified bundle2 push. Note that this only applies on update (moving a bookmark known on both sides) since bookmark export (creation of a new bookmark on remote) is apparently done outside of the _push function. diff -r 3dc3cf8d0e73 -r ed222ebd61be mercurial/exchange.py --- a/mercurial/exchange.py Fri Aug 15 19:03:33 2014 -0700 +++ b/mercurial/exchange.py Fri Aug 15 19:03:42 2014 -0700 @@ -422,6 +422,40 @@ pushop.ui.warn(msg) return handlereply +@b2partsgenerator('bookmarks') +def _pushb2bookmarks(pushop, bundler): + """handle phase push through bundle2""" + if 'bookmarks' in pushop.stepsdone: + return + b2caps = bundle2.bundle2caps(pushop.remote) + if 'b2x:pushkey' not in b2caps: + return + pushop.stepsdone.add('bookmarks') + part2book = [] + enc = pushkey.encode + for book, old, new in pushop.outbookmarks: + part = bundler.newpart('b2x:pushkey') + part.addparam('namespace', enc('bookmarks')) + part.addparam('key', enc(book)) + part.addparam('old', enc(old)) + part.addparam('new', enc(new)) + part2book.append((part.id, book)) + def handlereply(op): + for partid, book in part2book: + partrep = op.records.getreplies(partid) + results = partrep['pushkey'] + assert len(results) <= 1 + if not results: + pushop.ui.warn(_('server ignored bookmark %s update\n') % book) + else: + ret = int(results[0]['return']) + if ret: + pushop.ui.status(_("updating bookmark %s\n") % book) + else: + pushop.ui.warn(_('updating bookmark %s failed!\n') % book) + return handlereply + + def _pushbundle2(pushop): """push data to the remote using bundle2