Patchwork [1,of,4,V2-SeriesB] clfilter: enforce hidden changeset globally

login
register
mail settings
Submitter Pierre-Yves David
Date Jan. 8, 2013, 8:10 p.m.
Message ID <d4e10f74e85ecf9fb2c0.1357675842@yamac.lan>
Download mbox | patch
Permalink /patch/500/
State Accepted
Commit 5bb610f87d1d89b7da8a3683945b4cadf2a6dc7e
Headers show

Comments

Pierre-Yves David - Jan. 8, 2013, 8:10 p.m.
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david@logilab.fr>
# Date 1357673857 -3600
# Node ID d4e10f74e85ecf9fb2c04fa2f9065b83a1439eaa
# Parent  a32255dee8599db1e1fdcca1a4d09f0ed25b6d60
clfilter: enforce hidden changeset globally

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.

Patch

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
@@ -1404,12 +1404,10 @@  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
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'))]
 
@@ -4087,11 +4088,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
 
@@ -4203,12 +4203,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 = repo.filtered('hidden')
+                else:
+                    repo = repo.unfiltered()
                 repo.ui.setconfig("bundle", "mainreporoot", repo.root)
             except error.RequirementError:
                 raise
             except error.RepoError:
                 if cmd not in commands.optionalrepo.split():
diff --git a/tests/test-commit-amend.t b/tests/test-commit-amend.t
--- a/tests/test-commit-amend.t
+++ b/tests/test-commit-amend.t
@@ -490,13 +490,13 @@  ride of)
 
 Test that amend does not make it easy to create obsoletescence cycle
 ---------------------------------------------------------------------
 
 
-  $ hg id -r 14
+  $ hg id -r 14 --hidden
   b650e6ee8614 (a)
-  $ hg revert -ar 14
+  $ hg revert -ar 14 --hidden
   reverting a
   $ hg commit --amend
   $ hg id
   b99e5df575f7 (a) tip
 
diff --git a/tests/test-debugcomplete.t b/tests/test-debugcomplete.t
--- a/tests/test-debugcomplete.t
+++ b/tests/test-debugcomplete.t
@@ -121,10 +121,11 @@  Show the global options
   --debug
   --debugger
   --encoding
   --encodingmode
   --help
+  --hidden
   --noninteractive
   --profile
   --quiet
   --repository
   --time
@@ -151,10 +152,11 @@  Show the options for the "serve" command
   --debugger
   --encoding
   --encodingmode
   --errorlog
   --help
+  --hidden
   --ipv6
   --name
   --noninteractive
   --pid-file
   --port
@@ -198,11 +200,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
   pull: update, force, rev, bookmark, branch, ssh, remotecmd, insecure
   push: force, rev, bookmark, branch, new-branch, ssh, remotecmd, insecure
   remove: after, force, include, exclude
   serve: accesslog, daemon, daemon-pipefds, errorlog, port, address, prefix, name, web-conf, webdir-conf, pid-file, stdio, cmdserver, templates, style, ipv6, certificate
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
@@ -246,10 +246,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
 
@@ -332,10 +333,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-keyword.t b/tests/test-keyword.t
--- a/tests/test-keyword.t
+++ b/tests/test-keyword.t
@@ -574,10 +574,11 @@  Copy and show added kwfiles
   c
 
 Commit and show expansion in original and copy
 
   $ hg --debug commit -ma2c -d '1 0' -u 'User Name <user@example.com>'
+  invalid branchheads cache (unserved): tip differs
   c
    c: copy a:0045e12f6c5791aac80ca6cbfd97709a88307292
   overwriting c expanding keywords
   committed changeset 2:25736cf2f5cbe41f6be4e6784ef6ecf9f3bbcc7d
   $ cat a c
@@ -757,11 +758,10 @@  Commit with multi-line message and custo
 | cache is not updated on disk. The on disk version therefor stay invalid for
 | some time. This explains why the "unserved" branchheads cache is detect
 | invalid here.
 
   $ hg --debug commit -l log -d '2 0' -u 'User Name <user@example.com>'
-  invalid branchheads cache: tip differs
   invalid branchheads cache (unserved): tip differs
   a
   invalid branchheads cache: tip differs
   invalid branchheads cache (unserved): tip differs
   overwriting a expanding keywords
@@ -804,11 +804,10 @@  remove with status checks
 
   $ hg debugrebuildstate
   $ hg remove a
   $ hg --debug commit -m rma
   invalid branchheads cache: tip differs
-  invalid branchheads cache: tip differs
   committed changeset 3:d14c712653769de926994cf7fbb06c8fbd68f012
   $ hg status
   ? c
 
 Rollback, revert, and check expansion
@@ -915,11 +914,10 @@  kwexpand x/a should abort
   $ hg --verbose kwexpand x/a
   abort: outstanding uncommitted changes
   [255]
   $ cd x
   $ hg --debug commit -m xa -d '3 0' -u 'User Name <user@example.com>'
-  invalid branchheads cache: tip differs
   x/a
    x/a: copy a:779c764182ce5d43e2b1eb66ce06d7b47bfe342e
   invalid branchheads cache: tip differs
   overwriting x/a expanding keywords
   committed changeset 3:b4560182a3f9a358179fd2d835c15e9da379c1e4
diff --git a/tests/test-log.t b/tests/test-log.t
--- a/tests/test-log.t
+++ b/tests/test-log.t
@@ -1162,11 +1162,11 @@  enable obsolete to test hidden feature
   1:a765632148dc55d38c35c4f247c618701886cb2f
   0:9f758d63dcde62d547ebfb08e1e7ee96535f2b05
 
 test that parent prevent a changeset to be hidden
 
-  $ hg up 1 -q
+  $ hg up 1 -q --hidden
   $ hg log --template='{rev}:{node}\n'
   1:a765632148dc55d38c35c4f247c618701886cb2f
   0:9f758d63dcde62d547ebfb08e1e7ee96535f2b05
 
 test that second parent prevent a changeset to be hidden too
diff --git a/tests/test-newbranch.t b/tests/test-newbranch.t
--- a/tests/test-newbranch.t
+++ b/tests/test-newbranch.t
@@ -134,11 +134,10 @@  Test for invalid branch cache:
   summary:     modify a branch
   
   $ cp .hg/bc-invalid $branchcache
 
   $ hg --debug log -r foo
-  invalid branchheads cache: tip differs
   changeset:   4:adf1a74a7f7b4cd193d12992f5d0d6a004ed21d6
   branch:      foo
   tag:         tip
   phase:       draft
   parent:      1:6c0e42da283a56b5edc5b4fadb491365ec7f5fa8
diff --git a/tests/test-obsolete-divergent.t b/tests/test-obsolete-divergent.t
--- a/tests/test-obsolete-divergent.t
+++ b/tests/test-obsolete-divergent.t
@@ -25,11 +25,11 @@  Enable obsolete
   >    echo "$1" > "$1"
   >    hg add "$1"
   >    hg ci -m "$1"
   > }
   $ getid() {
-  >    hg id --debug -ir "desc('$1')"
+  >    hg id --debug --hidden -ir "desc('$1')"
   > }
 
 setup repo
 
   $ hg init reference
@@ -70,11 +70,11 @@  A_1 have two direct and divergent succes
   |/
   | x  1:007dc284c1f8 A_0
   |/
   @  0:d20a80d4def3 base
   
-  $ hg debugsuccessorssets 'all()'
+  $ hg debugsuccessorssets --hidden 'all()'
   d20a80d4def3
       d20a80d4def3
   007dc284c1f8
       392fd25390da
       82623d38b9ba
@@ -117,11 +117,11 @@  indirect divergence with known changeset
   |/
   | x  1:007dc284c1f8 A_0
   |/
   o  0:d20a80d4def3 base
   
-  $ hg debugsuccessorssets 'all()'
+  $ hg debugsuccessorssets --hidden 'all()'
   d20a80d4def3
       d20a80d4def3
   007dc284c1f8
       01f36c5a8fda
       82623d38b9ba
@@ -152,11 +152,11 @@  indirect divergence with known changeset
   |/
   | x  1:007dc284c1f8 A_0
   |/
   @  0:d20a80d4def3 base
   
-  $ hg debugsuccessorssets 'all()'
+  $ hg debugsuccessorssets --hidden 'all()'
   d20a80d4def3
       d20a80d4def3
   007dc284c1f8
       392fd25390da
       82623d38b9ba
@@ -178,11 +178,11 @@  do not take unknown node in account if t
   invalid branchheads cache (unserved): tip differs
   $ hg debugobsolete `getid A_0` bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
   $ hg debugobsolete bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb cccccccccccccccccccccccccccccccccccccccc
   $ hg debugobsolete `getid A_1` dddddddddddddddddddddddddddddddddddddddd
 
-  $ hg debugsuccessorssets 'desc('A_0')'
+  $ hg debugsuccessorssets --hidden 'desc('A_0')'
   007dc284c1f8
       392fd25390da
 
   $ cd ..
 
@@ -206,11 +206,11 @@  divergence that converge again is not di
   |/
   | x  1:007dc284c1f8 A_0
   |/
   o  0:d20a80d4def3 base
   
-  $ hg debugsuccessorssets 'all()'
+  $ hg debugsuccessorssets --hidden 'all()'
   d20a80d4def3
       d20a80d4def3
   007dc284c1f8
       01f36c5a8fda
   82623d38b9ba
@@ -234,11 +234,11 @@  split is not divergences
   |/
   | x  1:007dc284c1f8 A_0
   |/
   @  0:d20a80d4def3 base
   
-  $ hg debugsuccessorssets 'all()'
+  $ hg debugsuccessorssets --hidden 'all()'
   d20a80d4def3
       d20a80d4def3
   007dc284c1f8
       82623d38b9ba 392fd25390da
   82623d38b9ba
@@ -275,11 +275,11 @@  Even when subsequente rewriting happen
   |/
   | x  1:007dc284c1f8 A_0
   |/
   o  0:d20a80d4def3 base
   
-  $ hg debugsuccessorssets 'all()'
+  $ hg debugsuccessorssets --hidden 'all()'
   d20a80d4def3
       d20a80d4def3
   007dc284c1f8
       01f36c5a8fda e442cfc57690
   82623d38b9ba
@@ -331,11 +331,11 @@  Check more complexe obsolescence graft (
   |/
   | x  1:007dc284c1f8 A_0
   |/
   @  0:d20a80d4def3 base
   
-  $ hg debugsuccessorssets 'all()'
+  $ hg debugsuccessorssets --hidden 'all()'
   d20a80d4def3
       d20a80d4def3
   007dc284c1f8
       01f36c5a8fda bed64f5d2f5a
       01f36c5a8fda 7ae126973a96 14608b260df8
@@ -398,11 +398,11 @@  fix the divergence
   |/
   | x  1:007dc284c1f8 A_0
   |/
   @  0:d20a80d4def3 base
   
-  $ hg debugsuccessorssets 'all()'
+  $ hg debugsuccessorssets --hidden 'all()'
   d20a80d4def3
       d20a80d4def3
   007dc284c1f8
       01f36c5a8fda a139f71be9da
   82623d38b9ba
@@ -438,10 +438,10 @@  successors-set. (report [A,B] not [A] + 
 
   $ newcase subset
   $ hg debugobsolete `getid A_0` `getid A_2`
   $ hg debugobsolete `getid A_0` `getid A_1` `getid A_2`
   invalid branchheads cache (unserved): tip differs
-  $ hg debugsuccessorssets 'desc('A_0')'
+  $ hg debugsuccessorssets --hidden 'desc('A_0')'
   007dc284c1f8
       82623d38b9ba 392fd25390da
 
   $ cd ..
diff --git a/tests/test-obsolete.t b/tests/test-obsolete.t
--- a/tests/test-obsolete.t
+++ b/tests/test-obsolete.t
@@ -9,11 +9,11 @@ 
   >    echo "$1" > "$1"
   >    hg add "$1"
   >    hg ci -m "add $1"
   > }
   $ getid() {
-  >    hg id --debug -ir "desc('$1')"
+  >    hg id --debug --hidden -ir "desc('$1')"
   > }
 
   $ cat > debugkeys.py <<EOF
   > def reposetup(ui, repo):
   >     class debugkeysrepo(repo.__class__):
@@ -128,11 +128,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