Patchwork [2,of,7,Series-A] log: use "hidden" filtering instead of manual check at display time

login
register
mail settings
Submitter Pierre-Yves David
Date Jan. 7, 2013, 6:30 p.m.
Message ID <6d3722e0bb15da9f6966.1357583434@crater2.logilab.fr>
Download mbox | patch
Permalink /patch/491/
State Accepted
Commit b3b1b8e127e5122cf1104a2f0e7b6c6447839b5f
Headers show

Comments

Pierre-Yves David - Jan. 7, 2013, 6:30 p.m.
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david at logilab.fr>
# Date 1357583076 -3600
# Node ID 6d3722e0bb15da9f69666732bd53fdca07e7e184
# Parent  8487569146e69cad68ec11e8d8a6f677424fb26f
log: use "hidden" filtering instead of manual check at display time

When log is not given the --hidden option, hidden revision are not shown. We
move the implementation from manual checking at display time to changelog
filtering.

This is the first official usage of the hidden filtering.
Kevin Bullock - Jan. 8, 2013, 1:56 a.m.
On 7 Jan 2013, at 12:30 PM, pierre-yves.david at logilab.fr wrote:

> # HG changeset patch
> # User Pierre-Yves David <pierre-yves.david at logilab.fr>
> # Date 1357583076 -3600
> # Node ID 6d3722e0bb15da9f69666732bd53fdca07e7e184
> # Parent  8487569146e69cad68ec11e8d8a6f677424fb26f
> log: use "hidden" filtering instead of manual check at display time

Pushed 1 & 2 to crew as b3b1b8e127e5, thanks. Rest of the series LGTM except for my comments on 3.

pacem in terris / ??? / ?????? / ????????? / ??
Kevin R. Bullock

Patch

diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
--- a/mercurial/cmdutil.py
+++ b/mercurial/cmdutil.py
@@ -1404,10 +1404,12 @@  def getgraphlogrevs(repo, pats, opts):
     limit = loglimit(opts)
     # Default --rev value depends on --follow but --follow behaviour
     # depends on revisions resolved from --rev...
     follow = opts.get('follow') or opts.get('follow_first')
     possiblyunsorted = False # whether revs might need sorting
+    if not opts.get('hidden'):
+        repo = repo.filtered('hidden')
     if opts.get('rev'):
         revs = scmutil.revrange(repo, opts['rev'])
         # Don't sort here because _makegraphlogrevset might depend on the
         # order of revs
         possiblyunsorted = True
@@ -1430,28 +1432,11 @@  def getgraphlogrevs(repo, pats, opts):
         # Revset matches can reorder revisions. "A or B" typically returns
         # returns the revision matching A then the revision matching B. Sort
         # again to fix that.
         revs = matcher(repo, revs)
         revs.sort(reverse=True)
-    if not opts.get('hidden'):
-        # --hidden is still experimental and not worth a dedicated revset
-        # yet. Fortunately, filtering revision number is fast.
-        hiddenrevs = repo.hiddenrevs
-        nrevs = []
-        taken = 0
-        if limit is not None:
-            for i in xrange(len(revs)):
-                if taken >= limit:
-                    break
-                r = revs[i]
-                if r not in hiddenrevs:
-                    nrevs.append(r)
-                    taken += 1
-            revs = nrevs
-        else:
-            revs = [r for r in revs if r not in hiddenrevs]
-    elif limit is not None:
+    if limit is not None:
         revs = revs[:limit]
 
     return revs, expr, filematcher
 
 def displaygraph(ui, dag, displayer, showparents, edgefn, getrenamed=None,