test-obsolete: update extension in test to actually work stable
authorAugie Fackler <augie@google.com>
Thu, 05 May 2016 15:41:37 +0200
branchstable
changeset 29065 dae4552390fc
parent 29064 9dc27a334fb1
child 29066 e6f490e32863
test-obsolete: update extension in test to actually work This hasn't been testing anything since partway through the 3.7 cycle due to unrelated refactoring. Sadly, the behavior it was trying to prevent reemerged in the codebase at that time. A fix is in the next patch, because proving that the fix was actually correct ended up being trickier than I expected.
tests/test-obsolete.t
--- a/tests/test-obsolete.t	Thu May 05 20:57:38 2016 +0900
+++ b/tests/test-obsolete.t	Thu May 05 15:41:37 2016 +0200
@@ -982,17 +982,21 @@
 bookmarks change
   $ cd ..
   $ cat >$TESTTMP/test_extension.py  << EOF
+  > import weakref
   > from mercurial import cmdutil, extensions, bookmarks, repoview
   > def _bookmarkchanged(orig, bkmstoreinst, *args, **kwargs):
-  >  repo = bkmstoreinst._repo
-  >  ret = orig(bkmstoreinst, *args, **kwargs)
-  >  hidden1 = repoview.computehidden(repo)
-  >  hidden = repoview.filterrevs(repo, 'visible')
-  >  if sorted(hidden1) != sorted(hidden):
-  >    print "cache inconsistency"
-  >  return ret
+  >  reporef = weakref.ref(bkmstoreinst._repo)
+  >  def trhook(tr):
+  >   repo = reporef()
+  >   hidden1 = repoview.computehidden(repo)
+  >   hidden = repoview.filterrevs(repo, 'visible')
+  >   if sorted(hidden1) != sorted(hidden):
+  >     print "cache inconsistency"
+  >  bkmstoreinst._repo.currenttransaction().addpostclose('test_extension', trhook)
+  >  orig(bkmstoreinst, *args, **kwargs)
   > def extsetup(ui):
-  >   extensions.wrapfunction(bookmarks.bmstore, 'write', _bookmarkchanged)
+  >   extensions.wrapfunction(bookmarks.bmstore, 'recordchange',
+  >                           _bookmarkchanged)
   > EOF
 
   $ hg init repo-cache-inconsistency
@@ -1005,14 +1009,20 @@
   $ echo "hello" > b
   $ hg commit --amend -m "message"
   $ hg book bookb -r 13bedc178fce --hidden
+  cache inconsistency
   $ hg log -r 13bedc178fce
   5:13bedc178fce (draft) [ bookb] add b
   $ hg book -d bookb
+  cache inconsistency
   $ hg log -r 13bedc178fce
   abort: hidden revision '13bedc178fce'!
   (use --hidden to access hidden revisions)
   [255]
 
+Empty out the test extension, as it isn't compatible with later parts
+of the test.
+  $ echo > $TESTTMP/test_extension.py
+
 Test ability to pull changeset with locally applying obsolescence markers
 (issue4945)