[PATCH] repoview: invalidate 'visible' filtered revisions when bookmarks change

Laurent Charignon lcharignon at fb.com
Mon Jun 15 17:11:05 UTC 2015


# HG changeset patch
# User Laurent Charignon <lcharignon at fb.com>
# Date 1434181903 25200
#      Sat Jun 13 00:51:43 2015 -0700
# Node ID bfec522ee24e3c2e1101ffa906a5e974c5a68250
# Parent  e8075329c5fbb651508777c15cb6bc9ae33b5dff
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.

diff --git a/mercurial/bookmarks.py b/mercurial/bookmarks.py
--- a/mercurial/bookmarks.py
+++ b/mercurial/bookmarks.py
@@ -80,6 +80,7 @@
         '''
         repo = self._repo
         self._writerepo(repo)
+        repo.invalidatevolatilesets()
 
     def _writerepo(self, repo):
         """Factored out for extensibility"""
diff --git a/tests/test-obsolete.t b/tests/test-obsolete.t
--- a/tests/test-obsolete.t
+++ b/tests/test-obsolete.t
@@ -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]
+
+
+


More information about the Mercurial-devel mailing list