changeset 29065:dae4552390fc stable

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.
author Augie Fackler <augie@google.com>
date Thu, 05 May 2016 15:41:37 +0200
parents 9dc27a334fb1
children e6f490e32863
files tests/test-obsolete.t
diffstat 1 files changed, 18 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- 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)