# HG changeset patch
# User Stanislau Hlebik <st...@fb.com>
# Date 1473954996 25200
#      Thu Sep 15 08:56:36 2016 -0700
# Node ID 3456cba8a4879e74f3b928df321ce7e7c695fb4c
# Parent  f3fb030f0e4601561ac94137c7481694407db7b7
bundle2: add `bookmarks` part handler

diff --git a/mercurial/bundle2.py b/mercurial/bundle2.py
--- a/mercurial/bundle2.py
+++ b/mercurial/bundle2.py
@@ -154,8 +154,12 @@
 import sys
 
 from .i18n import _
+from .node import (
+    bin,
+)
 from . import (
     changegroup,
+    encoding,
     error,
     obsolete,
     pushkey,
@@ -1614,3 +1618,20 @@
 
     cache.write()
     op.ui.debug('applied %i hgtags fnodes cache entries\n' % count)
+
+@parthandler('bookmarks')
+def handlebookmarks(op, inpart):
+    dec = encoding.tolocal
+    bookmarks = {}
+    for bookmarknode in inpart.read().splitlines():
+        book, node = bookmarknode.rsplit(' ', 1)
+        bookmarks[dec(book)] = node
+    if op.applybookmarks:
+        for bookmark, node in bookmarks.items():
+            if node:
+                op.repo._bookmarks[bookmark] = bin(node)
+            else:
+                del op.repo._bookmarks[bookmark]
+        op.repo._bookmarks.recordchange(op.gettransaction())
+    else:
+        op.records.add('bookmarks', bookmarks)
_______________________________________________
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel

Reply via email to