changeset 42924:e0bf41b83cef

exchange: avoid unnecessary conversion of bookmark nodes to hex (API) Differential Revision: https://phab.mercurial-scm.org/D6830
author Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
date Sun, 08 Sep 2019 20:10:32 -0400
parents a7abc6081bc5
children 9fd7710d9ae2
files mercurial/exchange.py
diffstat 1 files changed, 5 insertions(+), 19 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/exchange.py	Mon Sep 09 14:26:43 2019 -0400
+++ b/mercurial/exchange.py	Sun Sep 08 20:10:32 2019 -0400
@@ -12,7 +12,6 @@
 
 from .i18n import _
 from .node import (
-    bin,
     hex,
     nullid,
     nullrev,
@@ -441,7 +440,7 @@
         self.fallbackoutdatedphases = None
         # outgoing obsmarkers
         self.outobsmarkers = set()
-        # outgoing bookmarks
+        # outgoing bookmarks, list of (bm, oldnode | '', newnode | '')
         self.outbookmarks = []
         # transaction manager
         self.trmanager = None
@@ -716,17 +715,6 @@
 
     remotebookmark = bookmod.unhexlifybookmarks(remotebookmark)
     comp = bookmod.comparebookmarks(repo, repo._bookmarks, remotebookmark)
-
-    def safehex(x):
-        if x is None:
-            return x
-        return hex(x)
-
-    def hexifycompbookmarks(bookmarks):
-        return [(b, safehex(scid), safehex(dcid))
-                for (b, scid, dcid) in bookmarks]
-
-    comp = [hexifycompbookmarks(marks) for marks in comp]
     return _processcompared(pushop, ancestors, explicit, remotebookmark, comp)
 
 def _processcompared(pushop, pushed, explicit, remotebms, comp):
@@ -877,7 +865,6 @@
         return
     data = []
     for book, old, new in pushop.outbookmarks:
-        old = bin(old)
         data.append((book, old))
     checkdata = bookmod.binaryencode(data)
     bundler.newpart('check:bookmarks', data=checkdata)
@@ -1051,7 +1038,6 @@
     data = []
     for book, old, new in pushop.outbookmarks:
         _abortonsecretctx(pushop, new, book)
-        new = bin(new)
         data.append((book, new))
         allactions.append((book, _bmaction(old, new)))
     checkdata = bookmod.binaryencode(data)
@@ -1083,8 +1069,8 @@
         part = bundler.newpart('pushkey')
         part.addparam('namespace', enc('bookmarks'))
         part.addparam('key', enc(book))
-        part.addparam('old', enc(old))
-        part.addparam('new', enc(new))
+        part.addparam('old', enc(hex(old)))
+        part.addparam('new', enc(hex(new)))
         action = 'update'
         if not old:
             action = 'export'
@@ -1339,8 +1325,8 @@
             r = e.callcommand('pushkey', {
                 'namespace': 'bookmarks',
                 'key': b,
-                'old': old,
-                'new': new,
+                'old': hex(old),
+                'new': hex(new),
             }).result()
 
         if r: