D11232: rewriteutil: fix crash when a rewritten message references f{6, 64}

durin42 (Augie Fackler) phabricator at mercurial-scm.org
Thu Jul 29 20:40:02 UTC 2021


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

REVISION SUMMARY
  Without this, the rewriteutil logic thinks it's found a reference to the wdir
  pseudo-revision, and then tries to look it up and rewrite it. Stop it from
  doing that.
  
  Amusingly, I had trouble working with this changeset when I didn't
  describe the defect above using a regular expression, because it would
  trigger the bug in my installed version of hg.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  mercurial/rewriteutil.py
  tests/test-rebase-inmemory.t

CHANGE DETAILS

diff --git a/tests/test-rebase-inmemory.t b/tests/test-rebase-inmemory.t
--- a/tests/test-rebase-inmemory.t
+++ b/tests/test-rebase-inmemory.t
@@ -971,9 +971,9 @@
   $ hg ci -m 'this will change hash'
   created new head
   $ echo changed >> update_hash_refs
-  $ hg ci -m "this starts as the child of `hg log -r . -T'{node|short}'` but not 506e2454484b"
+  $ hg ci -m "this starts as the child of `hg log -r . -T'{node|short}'` but not 506e2454484b. Also, ffffffffffffffff"
   $ hg tglog
-  @  5: becd28036887 'this starts as the child of 98789aa60148 but not 506e2454484b'
+  @  5: a8b42cbbde83 'this starts as the child of 98789aa60148 but not 506e2454484b. Also, ffffffffffffffff'
   |
   o  4: 98789aa60148 'this will change hash'
   |
@@ -987,10 +987,10 @@
   
   $ hg rebase -r '.^::' -d 3
   rebasing 4:98789aa60148 "this will change hash"
-  rebasing 5:becd28036887 tip "this starts as the child of 98789aa60148 but not 506e2454484b"
-  saved backup bundle to $TESTTMP/keep_merge/.hg/strip-backup/98789aa60148-72ec40bd-rebase.hg
+  rebasing 5:a8b42cbbde83 tip "this starts as the child of 98789aa60148 but not 506e2454484b. Also, ffffffffffffffff"
+  saved backup bundle to $TESTTMP/keep_merge/.hg/strip-backup/98789aa60148-da3f4c2c-rebase.hg
   $ hg tglog
-  @  5: a445b8426f4b 'this starts as the child of c16c25696fe7 but not 506e2454484b'
+  @  5: 0fd2912e6cc1 'this starts as the child of c16c25696fe7 but not 506e2454484b. Also, ffffffffffffffff'
   |
   o  4: c16c25696fe7 'this will change hash'
   |
diff --git a/mercurial/rewriteutil.py b/mercurial/rewriteutil.py
--- a/mercurial/rewriteutil.py
+++ b/mercurial/rewriteutil.py
@@ -207,7 +207,12 @@
     hashes = re.findall(NODE_RE, commitmsg)
     unfi = repo.unfiltered()
     for h in hashes:
-        fullnode = scmutil.resolvehexnodeidprefix(unfi, h)
+        try:
+            fullnode = scmutil.resolvehexnodeidprefix(unfi, h)
+        except error.WdirUnsupported:
+            # Someone has an fffff... in a commit message we're
+            # rewriting. Don't try rewriting that.
+            continue
         if fullnode is None:
             continue
         ctx = unfi[fullnode]



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


More information about the Mercurial-devel mailing list