[PATCH 17 of 17 RFC] clfilter: enforce hidden changeset globally XXX

pierre-yves.david at logilab.fr pierre-yves.david at logilab.fr
Mon Sep 3 07:58:41 CDT 2012


# HG changeset patch
# User Pierre-Yves David <pierre-yves.david at logilab.fr>
# Date 1346676976 -7200
# Node ID 555c8b590727b2733750a220fe4cfabbdd2a38c0
# Parent  73a4754751b127cbe20a50b81f664873a14f2afa
clfilter: enforce hidden changeset globally XXX

The dispatch code now enables filtering of "hidden" changesets globally. The
filter is installed before command and extension invocation. The `--hidden`
switch is now global and disables this filtering for any command.

Code in log dedicated to changeset exclusion is removed as this global filtering
has the same effect.

XXX I think there is more config to do arround the `--hidden` global switch

diff --git a/hgext/graphlog.py b/hgext/graphlog.py
--- a/hgext/graphlog.py
+++ b/hgext/graphlog.py
@@ -37,11 +37,10 @@ testedwith = 'internal'
      _('BRANCH')),
     ('b', 'branch', [],
      _('show changesets within the given named branch'), _('BRANCH')),
     ('P', 'prune', [],
      _('do not display revision or any of its ancestors'), _('REV')),
-    ('', 'hidden', False, _('show hidden changesets (DEPRECATED)')),
     ] + commands.logopts + commands.walkopts,
     _('[OPTION]... [FILE]'))
 def graphlog(ui, repo, *pats, **opts):
     """show revision history alongside an ASCII revision graph
 
diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
--- a/mercurial/cmdutil.py
+++ b/mercurial/cmdutil.py
@@ -1393,16 +1393,11 @@ def getgraphlogrevs(repo, pats, opts):
         return iter([]), None, None
     expr, filematcher = _makegraphlogrevset(repo, pats, opts, revs)
     if expr:
         matcher = revset.match(repo.ui, expr)
         revs = increasingrevs(repo, revs, matcher)
-    if not opts.get('hidden'):
-        # --hidden is still experimental and not worth a dedicated revset
-        # yet. Fortunately, filtering revision number is fast.
-        revs = (r for r in revs if r not in repo.hiddenrevs)
-    else:
-        revs = iter(revs)
+    revs = iter(revs)
     return revs, expr, filematcher
 
 def displaygraph(ui, dag, displayer, showparents, edgefn, getrenamed=None,
                  filematcher=None):
     seen, state = [], graphmod.asciistate()
diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -47,10 +47,11 @@ globalopts = [
     ('', 'traceback', None, _('always print a traceback on exception')),
     ('', 'time', None, _('time how long the command takes')),
     ('', 'profile', None, _('print command execution profile')),
     ('', 'version', None, _('output version information and exit')),
     ('h', 'help', None, _('display help and exit')),
+    ('', 'hidden', False, _('consider hidden changesets')),
 ]
 
 dryrunopts = [('n', 'dry-run', None,
                _('do not perform actions, just print output'))]
 
@@ -3980,11 +3981,10 @@ def locate(ui, repo, *pats, **opts):
      _('BRANCH')),
     ('b', 'branch', [],
      _('show changesets within the given named branch'), _('BRANCH')),
     ('P', 'prune', [],
      _('do not display revision or any of its ancestors'), _('REV')),
-    ('', 'hidden', False, _('show hidden changesets (DEPRECATED)')),
     ] + logopts + walkopts,
     _('[OPTION]... [FILE]'))
 def log(ui, repo, *pats, **opts):
     """show revision history of entire repository or files
 
@@ -4096,12 +4096,10 @@ def log(ui, repo, *pats, **opts):
             return
         if opts.get('only_merges') and len(parents) != 2:
             return
         if opts.get('branch') and ctx.branch() not in opts['branch']:
             return
-        if not opts.get('hidden') and ctx.hidden():
-            return
         if df and not df(ctx.date()[0]):
             return
 
         lower = encoding.lower
         if opts.get('user'):
diff --git a/mercurial/dispatch.py b/mercurial/dispatch.py
--- a/mercurial/dispatch.py
+++ b/mercurial/dispatch.py
@@ -708,10 +708,14 @@ def _dispatch(req):
         else:
             try:
                 repo = hg.repository(ui, path=path)
                 if not repo.local():
                     raise util.Abort(_("repository '%s' is not local") % path)
+                if not options['hidden']:
+                    repo.revsfilter.set('hidden')
+                else:
+                    repo.revsfilter.set('None')
                 repo.ui.setconfig("bundle", "mainreporoot", repo.root)
             except error.RequirementError:
                 raise
             except error.RepoError:
                 if cmd not in commands.optionalrepo.split():
diff --git a/mercurial/repofilter.py b/mercurial/repofilter.py
--- a/mercurial/repofilter.py
+++ b/mercurial/repofilter.py
@@ -10,11 +10,16 @@ import weakref
 
 def computeunserved(repo):
     assert not repo.changelog.filteredrevs
     return set(repo.revs('hidden() + secret()'))
 
-computefiltered = {'unserved': computeunserved}
+def computehidden(repo):
+    assert not repo.changelog.filteredrevs
+    return set(repo.revs('hidden()'))
+
+computefiltered = {'unserved': computeunserved,
+                   'hidden':   computehidden}
 
 
 class revsfilter(object):
 
     def __init__(self, repo):
diff --git a/tests/test-debugcomplete.t b/tests/test-debugcomplete.t
--- a/tests/test-debugcomplete.t
+++ b/tests/test-debugcomplete.t
@@ -120,10 +120,11 @@ Show the global options
   --debug
   --debugger
   --encoding
   --encodingmode
   --help
+  --hidden
   --noninteractive
   --profile
   --quiet
   --repository
   --time
@@ -150,10 +151,11 @@ Show the options for the "serve" command
   --debugger
   --encoding
   --encodingmode
   --errorlog
   --help
+  --hidden
   --ipv6
   --name
   --noninteractive
   --pid-file
   --port
@@ -197,11 +199,11 @@ Show all commands + options
   commit: addremove, close-branch, amend, include, exclude, message, logfile, date, user, subrepos
   diff: rev, change, text, git, nodates, show-function, reverse, ignore-all-space, ignore-space-change, ignore-blank-lines, unified, stat, include, exclude, subrepos
   export: output, switch-parent, rev, text, git, nodates
   forget: include, exclude
   init: ssh, remotecmd, insecure
-  log: follow, follow-first, date, copies, keyword, rev, removed, only-merges, user, only-branch, branch, prune, hidden, patch, git, limit, no-merges, stat, graph, style, template, include, exclude
+  log: follow, follow-first, date, copies, keyword, rev, removed, only-merges, user, only-branch, branch, prune, patch, git, limit, no-merges, stat, graph, style, template, include, exclude
   merge: force, rev, preview, tool
   phase: public, draft, secret, force, rev
   pull: update, force, rev, bookmark, branch, ssh, remotecmd, insecure
   push: force, rev, bookmark, branch, new-branch, ssh, remotecmd, insecure
   remove: after, force, include, exclude
diff --git a/tests/test-extension.t b/tests/test-extension.t
--- a/tests/test-extension.t
+++ b/tests/test-extension.t
@@ -198,10 +198,11 @@ hide outer repo
       --traceback         always print a traceback on exception
       --time              time how long the command takes
       --profile           print command execution profile
       --version           output version information and exit
    -h --help              display help and exit
+      --hidden            consider hidden changesets
   
   [+] marked option can be specified multiple times
 
   $ hg --debug help debugextension
   debugextension extension - only debugcommands
@@ -228,10 +229,11 @@ hide outer repo
       --traceback         always print a traceback on exception
       --time              time how long the command takes
       --profile           print command execution profile
       --version           output version information and exit
    -h --help              display help and exit
+      --hidden            consider hidden changesets
   
   [+] marked option can be specified multiple times
   $ echo 'debugextension = !' >> $HGRCPATH
 
 Extension module help vs command help:
diff --git a/tests/test-help.t b/tests/test-help.t
--- a/tests/test-help.t
+++ b/tests/test-help.t
@@ -249,10 +249,11 @@ Test short command list with verbose opt
       --traceback         always print a traceback on exception
       --time              time how long the command takes
       --profile           print command execution profile
       --version           output version information and exit
    -h --help              display help and exit
+      --hidden            consider hidden changesets
   
   [+] marked option can be specified multiple times
   
   use "hg help" for the full list of commands
 
@@ -335,10 +336,11 @@ Verbose help for add
       --traceback         always print a traceback on exception
       --time              time how long the command takes
       --profile           print command execution profile
       --version           output version information and exit
    -h --help              display help and exit
+      --hidden            consider hidden changesets
   
   [+] marked option can be specified multiple times
 
 Test help option with version option
 
diff --git a/tests/test-obsolete.t b/tests/test-obsolete.t
--- a/tests/test-obsolete.t
+++ b/tests/test-obsolete.t
@@ -121,11 +121,11 @@ Check that graphlog detect that a change
      summary:     add a
   
 
 Check that public changeset are not accounted as obsolete:
 
-  $ hg phase --public 2
+  $ hg --hidden phase --public 2
   $ hg --config 'extensions.graphlog=' glog
   @  changeset:   5:5601fb93a350
   |  tag:         tip
   |  parent:      1:7c3bad9141dc
   |  user:        test


More information about the Mercurial-devel mailing list