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

login
register
mail settings
Submitter phabricator
Date April 14, 2020, 3:29 p.m.
Message ID <d474be6f85557c498455219cbde30e5f@localhost.localdomain>
Download mbox | patch
Permalink /patch/46078/
State Not Applicable
Headers show

Comments

phabricator - April 14, 2020, 3:29 p.m.
durin42 updated this revision to Diff 21050.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D8367?vs=20970&id=21050

BRANCH
  default

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

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

AFFECTED FILES
  mercurial/manifest.py

CHANGE DETAILS




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()