repoview: invalidate 'visible' filtered revisions when bookmarks change
authorLaurent Charignon <lcharignon@fb.com>
Sat, 13 Jun 2015 00:51:43 -0700
changeset 25569 2612e6dab189
parent 25568 c1ff82daed62
child 25570 7cc1d33f0ba6
repoview: invalidate 'visible' filtered revisions when bookmarks change Context: the result of computehidden, used to compute the 'visible' revisions is cached. Its output can change when: 1) new obsolete commits are created 2) new bookmarks are created or deleted 3) new tags are created or deleted 4) the parents of the working copy change We currently correctly invalidate the cache only in the case 1). This patch fixes the second case (bookmarks) by invalidating the cache once a bookmark is added or removed.
mercurial/bookmarks.py
tests/test-obsolete.t
--- a/mercurial/bookmarks.py	Fri Jun 12 22:09:41 2015 -0400
+++ b/mercurial/bookmarks.py	Sat Jun 13 00:51:43 2015 -0700
@@ -80,6 +80,7 @@
         '''
         repo = self._repo
         self._writerepo(repo)
+        repo.invalidatevolatilesets()
 
     def _writerepo(self, repo):
         """Factored out for extensibility"""
--- a/tests/test-obsolete.t	Fri Jun 12 22:09:41 2015 -0400
+++ b/tests/test-obsolete.t	Sat Jun 13 00:51:43 2015 -0700
@@ -927,3 +927,42 @@
   $ echo aa > a
   $ hg amendtransient
   [1, 3]
+
+Test cache consistency for the visible filter
+1) We want to make sure that the cached filtered revs are invalidated when
+bookmarks change
+  $ cd ..
+  $ cat >$TESTTMP/test_extension.py  << EOF
+  > 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
+  > def extsetup(ui):
+  >   extensions.wrapfunction(bookmarks.bmstore, 'write', _bookmarkchanged)
+  > EOF
+
+  $ hg init repo-cache-inconsistency
+  $ cd repo-issue-nativerevs-pending-changes
+  $ mkcommit a
+  a already tracked!
+  $ mkcommit b
+  $ hg id
+  13bedc178fce tip
+  $ echo "hello" > b
+  $ hg commit --amend -m "message"
+  $ hg book bookb -r 13bedc178fce --hidden
+  $ hg log -r 13bedc178fce
+  5:13bedc178fce (draft) [ bookb] add b
+  $ hg book -d bookb
+  $ hg log -r 13bedc178fce
+  abort: hidden revision '13bedc178fce'!
+  (use --hidden to access hidden revisions)
+  [255]
+
+
+