[Request] [+ ] D8684: manifest: use the same logic for handling flags in _parse as elsewhere

joerg.sonnenberger (Joerg Sonnenberger) phabricator at mercurial-scm.org
Mon Jul 6 12:50:14 UTC 2020


joerg.sonnenberger created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  mercurial/manifest.py

CHANGE DETAILS

diff --git a/mercurial/manifest.py b/mercurial/manifest.py
--- a/mercurial/manifest.py
+++ b/mercurial/manifest.py
@@ -58,14 +58,16 @@
         prev = l
         f, n = l.split(b'\0')
         nl = len(n)
-        if 64 < nl:
-            # modern hash, full width
-            yield f, bin(n[:64]), n[64:]
-        elif 40 < nl < 45:
-            # legacy hash, always sha1
-            yield f, bin(n[:40]), n[40:]
+        flags = n[-1:]
+        if flags in _manifestflags:
+            n = n[:-1]
+            nl -= 1
         else:
-            yield f, bin(n), b''
+            flags = b''
+        if nl not in (40, 64):
+            raise ValueError(b'Invalid manifest line')
+
+        yield f, bin(n), flags
 
 
 def _text(it):



To: joerg.sonnenberger, #hg-reviewers
Cc: mercurial-patches, mercurial-devel
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mercurial-scm.org/pipermail/mercurial-patches/attachments/20200706/0122ff40/attachment-0001.html>


More information about the Mercurial-patches mailing list