Patchwork D11685: rewrite: fix issue6599

login
register
mail settings
Submitter phabricator
Date Oct. 18, 2021, 3:12 p.m.
Message ID <differential-rev-PHID-DREV-qsuz6sftgalwrbs3ir64-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/50009/
State Superseded
Headers show

Comments

phabricator - Oct. 18, 2021, 3:12 p.m.
Alphare created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  Explanation inside.

REPOSITORY
  rHG Mercurial

BRANCH
  stable

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

AFFECTED FILES
  mercurial/revlogutils/rewrite.py

CHANGE DETAILS




To: Alphare, #hg-reviewers
Cc: mercurial-patches, mercurial-devel

Patch

diff --git a/mercurial/revlogutils/rewrite.py b/mercurial/revlogutils/rewrite.py
--- a/mercurial/revlogutils/rewrite.py
+++ b/mercurial/revlogutils/rewrite.py
@@ -589,7 +589,9 @@ 
     except error.CensoredNodeError:
         # We don't care about censored nodes as they never carry metadata
         return False
-    has_meta = raw_text.startswith(b'\x01\n')
+
+    # raw text can be a `memoryview`, which doesn't implement `startswith`
+    has_meta = len(raw_text) >= 2 and bytes(raw_text[:2]) == b'\x01\n'
     if metadata_cache is not None:
         metadata_cache[filerev] = has_meta
     if has_meta: