Patchwork D12551: tests: add test demonstrating issue with ambiguous has prefixes during rebase

login
register
mail settings
Submitter phabricator
Date April 13, 2022, 8:42 p.m.
Message ID <differential-rev-PHID-DREV-vy6tfttoymcptdg5or3c-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/50899/
State New
Headers show

Comments

phabricator - April 13, 2022, 8:42 p.m.
spectral created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REPOSITORY
  rHG Mercurial

BRANCH
  stable

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

AFFECTED FILES
  tests/test-rebase-inmemory.t

CHANGE DETAILS




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

Patch

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
@@ -1003,6 +1003,33 @@ 
   o  0: d20a80d4def3 'base'
   
 
+Add an explicit test for rewrite_hash_refs when the detected prefix is
+ambiguous. Here's the super low-tech way I found this collision, if the hashing
+scheme ever changes:
+# hg init
+# echo test0 > test
+# hg ci -qAm 'test0' -u 'test' -d '0 0'
+# i=1
+# while [[ $(chg log -r . -T'{shortest(node, 6)}' | wc -c) -eq 6 ]]; do
+#   chg co -r 0000000000
+#   echo "test$i" > test
+#   chg ci -qAm "test$i" -u test -d '0 0'
+#   (( ++i ))
+# done
+  $ hg co -q 0000000000
+  $ echo test5281 > test
+  $ hg ci -qAm 'test5281'
+  $ hg co -q 000000000
+  $ echo test9912 > test
+  $ hg ci -qAm 'test9912'
+  $ hg co -q 4
+  $ echo contents > some_file
+  $ hg ci -qAm 'The previous two (parentless) commits had a hash prefix of b04363. Check that rewrite_hash_refs will not fail because of that.'
+  $ hg rebase -r . -d 5
+  rebasing 8:5c4cdabf5769 tip "The previous two (parentless) commits had a hash prefix of b04363. Check that rewrite_hash_refs will not fail because of that."
+  abort: 00changelog@b04363: ambiguous identifier
+  [50]
+
   $ cd ..
 
 Test (virtual) working directory without changes, created by merge conflict