Patchwork D8367: manifest: remove a 20-byte-hash assumption from pure manifest parsing

login
register
mail settings
Submitter phabricator
Date April 2, 2020, 8:32 p.m.
Message ID <differential-rev-PHID-DREV-urwifvxa5ksf6taef6d3-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/46001/
State Superseded
Headers show

Comments

phabricator - April 2, 2020, 8:32 p.m.
durin42 created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  This is almost certainly slower, but it shouldn't be by much. We need
  to do this for the eventual hash transition, no matter what that looks like.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  mercurial/manifest.py

CHANGE DETAILS




To: durin42, #hg-reviewers
Cc: mercurial-devel
phabricator - April 14, 2020, 6:55 p.m.
pulkit added a comment.
pulkit accepted this revision.


  Queuing the series, thanks to @Alphare for reviewing.

REPOSITORY
  rHG Mercurial

BRANCH
  default

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D8367/new/

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

To: durin42, #hg-reviewers, pulkit, Alphare
Cc: mercurial-devel

Patch

diff --git a/mercurial/manifest.py b/mercurial/manifest.py
--- a/mercurial/manifest.py
+++ b/mercurial/manifest.py
@@ -386,7 +386,11 @@ 
         self.extradata = []
 
     def _pack(self, d):
-        return d[0] + b'\x00' + hex(d[1][:20]) + d[2] + b'\n'
+        n = d[1]
+        if len(n) == 21 or len(n) == 33:
+            n = n[:-1]
+        assert len(n) == 20 or len(n) == 32
+        return d[0] + b'\x00' + hex(n) + d[2] + b'\n'
 
     def text(self):
         self._compact()