Patchwork [1,of,3] repoview: split _gethiddenblockers

login
register
mail settings
Submitter David Soria Parra
Date Aug. 7, 2014, 6:08 p.m.
Message ID <4ac33b2438c3d50d5f1f.1407434925@dev544.prn1.facebook.com>
Download mbox | patch
Permalink /patch/5314/
State Superseded
Commit 16ef2c485f0355b972ccd92bfee27e4e192394dc
Headers show

Comments

David Soria Parra - Aug. 7, 2014, 6:08 p.m.
# HG changeset patch
# User David Soria Parra <davidsp@fb.com>
# Date 1407356764 25200
#      Wed Aug 06 13:26:04 2014 -0700
# Node ID 4ac33b2438c3d50d5f1f21423f0a51ed32d12994
# Parent  4354b1e35f533f72d5b6ccc76e8bc742f8cb5257
repoview: split _gethiddenblockers

Split up _gethiddenblockers into two categories: (1) blockers that solely rely
on the contents of obstore and are visible children of hidden changsets. (2)
"dynamic" blockers, appearing by having wd parents, bookmarks or tags pointing
to hidden changesets.

We assume that (1) doesn't change often and can be easily cached with a good
invalidation strategy. (2) change often, but barely produce blockers, so we
can recompute them if necessary.
Pierre-Yves David - Aug. 8, 2014, 3:41 a.m.
On 08/07/2014 11:08 AM, David Soria Parra wrote:
> # HG changeset patch
> # User David Soria Parra <davidsp@fb.com>
> # Date 1407356764 25200
> #      Wed Aug 06 13:26:04 2014 -0700
> # Node ID 4ac33b2438c3d50d5f1f21423f0a51ed32d12994
> # Parent  4354b1e35f533f72d5b6ccc76e8bc742f8cb5257
> repoview: split _gethiddenblockers
>
> Split up _gethiddenblockers into two categories: (1) blockers that solely rely
> on the contents of obstore and are visible children of hidden changsets. (2)
> "dynamic" blockers, appearing by having wd parents, bookmarks or tags pointing
> to hidden changesets.
>
> We assume that (1) doesn't change often and can be easily cached with a good
> invalidation strategy. (2) change often, but barely produce blockers, so we
> can recompute them if necessary.

I really love the idea. However, you have to call the extracted function 
too. So that the code keep gathering both after this patches.

This -would- be a good place to introduce the two pass filtering to 
minimize next patch churn.

Patch

diff --git a/mercurial/repoview.py b/mercurial/repoview.py
--- a/mercurial/repoview.py
+++ b/mercurial/repoview.py
@@ -20,8 +20,10 @@ 
     return obsolete.getrevs(repo, 'obsolete')
 
 def _gethiddenblockers(repo):
-    """Get revisions that will block hidden changesets from being filtered
+    """Get revisions that will block hidden changesets from being filtered and
+    can be cached.
 
+    Additional non-cached hidden blockers are computed in _getdynamicblockers.
     This is a standalone function to help extensions to wrap it."""
     assert not repo.changelog.filteredrevs
     hideable = hideablerevs(repo)
@@ -34,16 +36,26 @@ 
         tofilter = repo.revs(
             '(%ld) and children(%ld)', list(revs), list(hideable))
         blockers = [r for r in tofilter if r not in hideable]
-        for par in repo[None].parents():
-            blockers.append(par.rev())
-        for bm in repo._bookmarks.values():
-            blockers.append(cl.rev(bm))
-        tags = {}
-        tagsmod.readlocaltags(repo.ui, repo, tags, {})
-        if tags:
-            blockers.extend(cl.rev(t[0]) for t in tags.values())
+        return blockers
+
     return blockers
 
+def _getdynamicblockers(repo):
+    """Get revisions that will block hidden changesets and are likely to change,
+    but unlikely to create hidden blockers. They won't be cached, so be careful
+    with adding additional computation."""
+
+    cl = repo.changelog
+    blockers = []
+    blockers.extend([par.rev() for par in repo[None].parents()])
+    blockers.extend([cl.rev(bm) for bm in repo._bookmarks.values()])
+
+    tags = {}
+    tagsmod.readlocaltags(repo.ui, repo, tags, {})
+    if tags:
+        blockers.extend([cl.rev(t[0]) for t in tags.values()])
+    return frozenset(blockers)
+
 def computehidden(repo):
     """compute the set of hidden revision to filter