Patchwork D6830: exchange: avoid unnecessary conversion of bookmark nodes to hex (API)

login
register
mail settings
Submitter phabricator
Date Sept. 9, 2019, 12:42 a.m.
Message ID <differential-rev-PHID-DREV-guwkxbtrjpzgjxiwg6y7-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/41578/
State Superseded
Headers show

Comments

phabricator - Sept. 9, 2019, 12:42 a.m.
valentin.gatienbaron created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D6830

AFFECTED FILES
  mercurial/exchange.py

CHANGE DETAILS




To: valentin.gatienbaron, #hg-reviewers
Cc: mercurial-devel

Patch

diff --git a/mercurial/exchange.py b/mercurial/exchange.py
--- a/mercurial/exchange.py
+++ b/mercurial/exchange.py
@@ -441,7 +441,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 +716,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 +866,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 +1039,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 +1070,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 +1326,8 @@ 
             r = e.callcommand('pushkey', {
                 'namespace': 'bookmarks',
                 'key': b,
-                'old': old,
-                'new': new,
+                'old': hex(old),
+                'new': hex(new),
             }).result()
 
         if r: