[PATCH 1 of 4] test-obsolete: update extension in test to actually work

Augie Fackler raf at durin42.com
Thu May 5 02:56:04 UTC 2016


# HG changeset patch
# User Augie Fackler <augie at google.com>
# Date 1462414190 14400
#      Wed May 04 22:09:50 2016 -0400
# Node ID ef75c94c7e670127b18bcfeda68f13e3247d8a07
# Parent  906a1c8a75fd8a18e43e8545eedcbe5222f84647
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.

diff --git a/tests/test-obsolete.t b/tests/test-obsolete.t
--- a/tests/test-obsolete.t
+++ b/tests/test-obsolete.t
@@ -984,15 +984,18 @@ bookmarks change
   $ cat >$TESTTMP/test_extension.py  << EOF
   > from mercurial import cmdutil, extensions, bookmarks, repoview
   > def _bookmarkchanged(orig, bkmstoreinst, *args, **kwargs):
+  >  global repo
   >  repo = bkmstoreinst._repo
-  >  ret = orig(bkmstoreinst, *args, **kwargs)
+  >  repo.currenttransaction().addpostclose('test_extension', trhook)
+  >  orig(bkmstoreinst, *args, **kwargs)
+  > def trhook(tr):
   >  hidden1 = repoview.computehidden(repo)
   >  hidden = repoview.filterrevs(repo, 'visible')
   >  if sorted(hidden1) != sorted(hidden):
   >    print "cache inconsistency"
-  >  return ret
   > def extsetup(ui):
-  >   extensions.wrapfunction(bookmarks.bmstore, 'write', _bookmarkchanged)
+  >   extensions.wrapfunction(bookmarks.bmstore, 'recordchange',
+  >                           _bookmarkchanged)
   > EOF
 
   $ hg init repo-cache-inconsistency
@@ -1005,14 +1008,20 @@ bookmarks change
   $ 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)
 


More information about the Mercurial-devel mailing list