Patchwork D8684: manifest: use the same logic for handling flags in _parse as elsewhere

login
register
mail settings
Submitter phabricator
Date July 6, 2020, 12:50 p.m.
Message ID <differential-rev-PHID-DREV-siydrjsnufpk5wr6ig5m-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/46637/
State Superseded
Headers show

Comments

phabricator - July 6, 2020, 12:50 p.m.
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




To: joerg.sonnenberger, #hg-reviewers
Cc: mercurial-patches, mercurial-devel

Patch

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