[PATCH 4 of 4 V2] repoview: cache hidden changesets

David Soria Parra davidsp at fb.com
Wed Aug 13 16:44:01 CDT 2014


# HG changeset patch
# User David Soria Parra <davidsp at fb.com>
# Date 1407861554 25200
#      Tue Aug 12 09:39:14 2014 -0700
# Node ID f738123b59e43e7de5145298012f0b7aca778c06
# Parent  b42aa11b82553e53ec29e145be46facc5fe09394
repoview: cache hidden changesets

Use the introduced caching infrastructure to cache hidden
changesets. We crosscheck if the content of the cache unless
experimental.verifyhiddencache is set to False. This will be removed
in the future. Without crosschecking the caches speed ups hg status and
other commands:

without caching:
$ time hg status
hg status  0.72s user 0.20s system 100% cpu 0.917 total

with caching
$ time hg status
hg status  0.49s user 0.15s system 100% cpu 0.645 total

diff --git a/mercurial/repoview.py b/mercurial/repoview.py
--- a/mercurial/repoview.py
+++ b/mercurial/repoview.py
@@ -127,12 +127,24 @@
 
     During most operation hidden should be filtered."""
     assert not repo.changelog.filteredrevs
+
     hidden = frozenset()
     hideable = hideablerevs(repo)
     if hideable:
         cl = repo.changelog
-        blocked = cl.ancestors(_getstaticblockers(repo), inclusive=True)
-        hidden = frozenset(r for r in hideable if r not in blocked)
+        hidden = tryreadcache(repo, hideable)
+        if hidden is None:
+            blocked = cl.ancestors(_getstaticblockers(repo), inclusive=True)
+            hidden = frozenset(r for r in hideable if r not in blocked)
+            trywritehiddencache(repo, hideable, hidden)
+        elif repo.ui.configbool('experimental', 'verifyhiddencache', True):
+            blocked = cl.ancestors(_getstaticblockers(repo), inclusive=True)
+            computed = frozenset(r for r in hideable if r not in blocked)
+            if computed != hidden:
+                trywritehiddencache(repo, hideable, computed)
+                repo.ui.warn(_('Cache inconsistency detected. Please ' +
+                    'open an issue on http://bz.selenic.com.\n'))
+                hidden = computed
 
         # check if we have wd parents, bookmarks or tags pointing to hidden
         # changesets and remove those.


More information about the Mercurial-devel mailing list