changeset 44701:ecbba7b2e444

manifest: remove a 20-byte-hash assumption from pure manifest parsing 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. Differential Revision: https://phab.mercurial-scm.org/D8367
author Augie Fackler <augie@google.com>
date Tue, 07 Jan 2020 11:25:13 -0500
parents 7834da4b00fa
children 0b0e72b5d551
files mercurial/manifest.py
diffstat 1 files changed, 5 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/manifest.py	Mon Apr 13 12:18:29 2020 -0400
+++ b/mercurial/manifest.py	Tue Jan 07 11:25:13 2020 -0500
@@ -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()