Patchwork [Bug,5235] New: Stale phasecache after strip causes IndexError when inspecting phases

login
register
mail settings
Submitter mercurial-bugs@selenic.com
Date May 11, 2016, 12:53 p.m.
Message ID <bug-5235-285@https.bz.mercurial-scm.org/>
Download mbox | patch
Permalink /patch/15014/
State Not Applicable
Headers show

Comments

mercurial-bugs@selenic.com - May 11, 2016, 12:53 p.m.
https://bz.mercurial-scm.org/show_bug.cgi?id=5235

            Bug ID: 5235
           Summary: Stale phasecache after strip causes IndexError when
                    inspecting phases
           Product: Mercurial
           Version: default branch
          Hardware: PC
                OS: Mac OS
            Status: UNCONFIRMED
          Severity: feature
          Priority: wish
         Component: strip
          Assignee: bugzilla@selenic.com
          Reporter: lcharignon@fb.com
                CC: mercurial-devel@selenic.com

This test reproduces the issue the issue by creating an extension that wraps
transaction close. When the transaction to update bookmarks in strip is closed,
querying the "not public()" revset hitting the phasecache causes a crash.

 (They should be gracefully handled and reported)

Patch

diff --git a/tests/test-strip.t b/tests/test-strip.t
--- a/tests/test-strip.t
+++ b/tests/test-strip.t
@@ -838,6 +838,41 @@ 
   date:        Thu Jan 01 00:00:00 1970 +0000
   summary:     mergeCD

+Check that the phase cache is properly invalidated after a strip with
bookmark.
+
+  $ cat > ../crashstrip2.py << EOF
+  > from mercurial import extensions, localrepo
+  > def transactioncallback(orig, repo, desc, *args, **kwargs):
+  >     def test(transaction):
+  >         # observe cache inconsistency
+  >         try:
+  >             [repo.changelog.node(r) for r in repo.revs("not public()")]
+  >         except IndexError:
+  >             repo.ui.status("Index error!\n")
+  >     transaction = orig(repo, desc, *args, **kwargs)
+  >     # warm up the phase cache
+  >     list(repo.revs("not public()"))
+  >     if desc != 'strip':
+  >          transaction.addpostclose("phase invalidation test", test)
+  >     return transaction
+  > def extsetup(ui):
+  >     extensions.wrapfunction(localrepo.localrepository, "transaction",
+  >                             transactioncallback)
+  > EOF
+  $ hg up -C 2
+  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  $ echo k > k
+  $ hg add k
+  $ hg commit -m commitK
+  $ echo l > l
+  $ hg add l
+  $ hg commit -m commitL
+  $ hg book -r tip blah
+  $ hg strip ".^" --config extensions.crash=$TESTTMP/crashstrip2.py
+  0 files updated, 0 files merged, 2 files removed, 0 files unresolved
+  saved backup bundle to
$TESTTMP/issue4736/.hg/strip-backup/8f0b4384875c-4fa10deb-backup.hg (glob)
+  Index error!

 Error during post-close callback of the strip transaction