hidden: remove _consistencyblockers()
authorMartin von Zweigbergk <martinvonz@google.com>
Sat, 27 May 2017 22:55:19 -0700
changeset 37803 c777dac2b27ccda26134d8efeef7eef37bb80595
parent 37802 306bba74c56eb9f71a794a8e3d1cbb047515d187
child 37804 2af0b9a02bf99a52e8f6ec8fd2dce1268bcce24a
push id525
push usergszorc@mozilla.com
push dateFri, 09 Jun 2017 06:37:32 +0000
bugs4616, 0, 8235, 10000, 4727, 8371
hidden: remove _consistencyblockers() Roughly speaking, we currently do this to reveal hidden ancestors of visible revisions: 1. Iterate over all visible non-public revisions and see if they have hidden parents 2. For each revision found in step (1) walk the chain of hidden commits and reveal it We can simplify that by skipping step (1) and doing step (2) from all visible non-public revisions instead. This doesn't seem to have much impact on "perfvolatilesets". Before: ! obsolete ! wall 0.004616 comb 0.000000 user 0.000000 sys 0.000000 (best of 570) ! visible ! wall 0.008235 comb 0.010000 user 0.010000 sys 0.000000 (best of 326) After: ! obsolete ! wall 0.004727 comb 0.010000 user 0.010000 sys 0.000000 (best of 543) ! visible ! wall 0.008371 comb 0.000000 user 0.000000 sys 0.000000 (best of 324)
mercurial/repoview.py
--- a/mercurial/repoview.py
+++ b/mercurial/repoview.py
@@ -39,29 +39,16 @@ def pinnedrevs(repo):
 
     tags = {}
     tagsmod.readlocaltags(repo.ui, repo, tags, {})
     if tags:
         rev, nodemap = cl.rev, cl.nodemap
         pinned.update(rev(t[0]) for t in tags.values() if t[0] in nodemap)
     return pinned
 
-def _consistencyblocker(pfunc, hideable, revs):
-    """return non-hideable changeset blocking hideable one
-
-    For consistency, we cannot actually hide a changeset if one of it children
-    are visible, this function find such children.
-    """
-    blockers = set()
-    for r in revs:
-        for p in pfunc(r):
-            if p != nullrev and p in hideable:
-                blockers.add(r)
-                break
-    return blockers
 
 def _revealancestors(pfunc, hidden, revs):
     """reveals contiguous chains of hidden ancestors of 'revs' by removing them
     from 'hidden'
 
     - pfunc(r): a funtion returning parent of 'r',
     - hidden: the (preliminary) hidden revisions, to be updated
     - revs: iterable of revnum,
@@ -84,26 +71,22 @@ def computehidden(repo):
     assert not repo.changelog.filteredrevs
 
     hidden = hideablerevs(repo)
     if hidden:
         pfunc = repo.changelog.parentrevs
         mutablephases = (phases.draft, phases.secret)
         mutable = repo._phasecache.getrevset(repo, mutablephases)
 
-        visible = mutable - hidden
-        blockers = _consistencyblocker(pfunc, hidden, visible)
-
-        # check if we have wd parents, bookmarks or tags pointing to hidden
-        # changesets and remove those.
-        blockers |= (hidden & pinnedrevs(repo))
-        if blockers:
+        visible = set(mutable - hidden)
+        visible |= (hidden & pinnedrevs(repo))
+        if visible:
             # don't modify possibly cached result of hideablerevs()
             hidden = hidden.copy()
-            _revealancestors(pfunc, hidden, blockers)
+            _revealancestors(pfunc, hidden, visible)
     return frozenset(hidden)
 
 def computeunserved(repo):
     """compute the set of revision that should be filtered when used a server
 
     Secret and hidden changeset should not pretend to be here."""
     assert not repo.changelog.filteredrevs
     # fast path in simple case to avoid impact of non optimised code