[PATCH 5 of 7 V4] bundle2: add `pushbookmarks` part handler
Stanislau Hlebik
stash at fb.com
Sun Sep 4 18:46:57 EDT 2016
# HG changeset patch
# User Stanislau Hlebik <stash at fb.com>
# Date 1473012368 25200
# Sun Sep 04 11:06:08 2016 -0700
# Node ID 6d2fbc0ed52b54dfe525063da90973f426f2bcbe
# Parent db526b94eeb678879c2faceb40c64aebbe1054af
bundle2: add `pushbookmarks` part handler
diff --git a/mercurial/bundle2.py b/mercurial/bundle2.py
--- a/mercurial/bundle2.py
+++ b/mercurial/bundle2.py
@@ -155,6 +155,7 @@
from .i18n import _
from . import (
+ bookmarks,
changegroup,
encoding,
error,
@@ -1623,3 +1624,32 @@
book, node = bookmarknode.rsplit(' ', 1)
bookmarks[dec(book)] = dec(node)
op.records.add('bookmarks', bookmarks)
+
+ at parthandler('pushbookmarks')
+def handlepushbookmarks(op, inpart):
+ bookmarksresults = []
+ # Grab the transaction to ensure that we have the lock before performing the
+ # pushbookmark.
+ if op.ui.configbool('experimental', 'bundle2lazylocking'):
+ op.gettransaction()
+ for bookmarkinfo in inpart.read().splitlines():
+ dec = encoding.tolocal
+ book, old, new = bookmarkinfo.rsplit(' ', 2)
+ book = dec(book)
+ old = dec(old)
+ new = dec(new)
+ ret = bookmarks.pushbookmark(op.repo, book, old, new)
+ bookmarksresults.append('%s %i' % (book, ret))
+ if op.reply is not None:
+ rpart = op.reply.newpart(
+ 'reply:pushbookmarks', data='\n'.join(bookmarksresults))
+ rpart.addparam('in-reply-to', str(inpart.id), mandatory=False)
+
+ at parthandler('reply:pushbookmarks')
+def handlepushbookmarksreply(op, inpart):
+ partid = int(inpart.params['in-reply-to'])
+ for bookmarksresult in inpart.read().splitlines():
+ bookmark, ret = bookmarksresult.rsplit(' ', 1)
+ op.records.add('pushbookmarks',
+ {'bookmark': bookmark, 'return': ret},
+ partid)
More information about the Mercurial-devel
mailing list