Patchwork [v2] dispatch: take --hidden from individual commands into account

login
register
mail settings
Submitter Julien Cristau
Date Jan. 27, 2014, 10:11 a.m.
Message ID <52fd2aac6f7e2af59503.1390817487@crater2.logilab.fr>
Download mbox | patch
Permalink /patch/3411/
State Accepted
Commit 69a0d22b96775e44a31d11436d7f93f51cb98031
Headers show

Comments

Julien Cristau - Jan. 27, 2014, 10:11 a.m.
# HG changeset patch
# User Julien Cristau <julien.cristau@logilab.fr>
# Date 1390816640 -3600
#      Mon Jan 27 10:57:20 2014 +0100
# Branch stable
# Node ID 52fd2aac6f7e2af595033c069df22f665352f360
# Parent  427d672c0e4e07642d2400a28946cefde11e04ff
dispatch: take --hidden from individual commands into account

The command server would otherwise ignore that option, since the repo
object is only created once.
Pierre-Yves David - Jan. 29, 2014, 1:54 a.m.
On 01/27/2014 02:11 AM, Julien Cristau wrote:
> # HG changeset patch
> # User Julien Cristau <julien.cristau@logilab.fr>
> # Date 1390816640 -3600
> #      Mon Jan 27 10:57:20 2014 +0100
> # Branch stable
> # Node ID 52fd2aac6f7e2af595033c069df22f665352f360
> # Parent  427d672c0e4e07642d2400a28946cefde11e04ff
> dispatch: take --hidden from individual commands into account
>
> The command server would otherwise ignore that option, since the repo
> object is only created once.

Looks good to me.

Nothing happen between the old position and the new position (but error 
handling code for failing to create the repo)
Matt Mackall - Jan. 30, 2014, 8:35 p.m.
On Mon, 2014-01-27 at 11:11 +0100, Julien Cristau wrote:
> # HG changeset patch
> # User Julien Cristau <julien.cristau@logilab.fr>
> # Date 1390816640 -3600
> #      Mon Jan 27 10:57:20 2014 +0100
> # Branch stable
> # Node ID 52fd2aac6f7e2af595033c069df22f665352f360
> # Parent  427d672c0e4e07642d2400a28946cefde11e04ff
> dispatch: take --hidden from individual commands into account

Queued for stable, thanks.

Patch

diff --git a/mercurial/dispatch.py b/mercurial/dispatch.py
--- a/mercurial/dispatch.py
+++ b/mercurial/dispatch.py
@@ -772,12 +772,10 @@  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 options['hidden']:
-                    repo = repo.unfiltered()
                 repo.ui.setconfig("bundle", "mainreporoot", repo.root)
             except error.RequirementError:
                 raise
             except error.RepoError:
                 if cmd not in commands.optionalrepo.split():
@@ -793,10 +791,12 @@  def _dispatch(req):
                                                 " (.hg not found)")
                                               % os.getcwd())
                     raise
         if repo:
             ui = repo.ui
+            if options['hidden']:
+                repo = repo.unfiltered()
         args.insert(0, repo)
     elif rpath:
         ui.warn(_("warning: --repository ignored\n"))
 
     msg = ' '.join(' ' in a and repr(a) or a for a in fullargs)
diff --git a/tests/test-commandserver.py b/tests/test-commandserver.py
--- a/tests/test-commandserver.py
+++ b/tests/test-commandserver.py
@@ -260,10 +260,19 @@  def phasecacheafterstrip(server):
     os.system('hg -q --config extensions.mq= strip 1')
 
     # shouldn't raise "7966c8e3734d: no node!"
     runcommand(server, ['branches'])
 
+def obsolete(server):
+    readchannel(server)
+
+    runcommand(server, ['up', 'null'])
+    runcommand(server, ['phase', '-df', 'tip'])
+    os.system('hg debugobsolete `hg log -r tip --template {node}`')
+    runcommand(server, ['log', '--hidden'])
+    runcommand(server, ['log'])
+
 if __name__ == '__main__':
     os.system('hg init')
 
     check(hellomessage)
     check(unknowncommand)
@@ -283,5 +292,12 @@  if __name__ == '__main__':
     check(setphase)
     check(rollback)
     check(branch)
     check(hgignore)
     check(phasecacheafterstrip)
+    obs = open('obs.py', 'w')
+    obs.write('import mercurial.obsolete\nmercurial.obsolete._enabled = True\n')
+    obs.close()
+    hgrc = open('.hg/hgrc', 'a')
+    hgrc.write('[extensions]\nobs=obs.py\n')
+    hgrc.close()
+    check(obsolete)
diff --git a/tests/test-commandserver.py.out b/tests/test-commandserver.py.out
--- a/tests/test-commandserver.py.out
+++ b/tests/test-commandserver.py.out
@@ -189,5 +189,36 @@  o  0:eff892de26ec
  runcommand phase -p .
  runcommand phase .
 5: public
  runcommand branches
 default                        1:731265503d86
+
+testing obsolete:
+
+ runcommand up null
+0 files updated, 0 files merged, 1 files removed, 0 files unresolved
+ runcommand phase -df tip
+ runcommand log --hidden
+changeset:   1:731265503d86
+tag:         tip
+user:        test
+date:        Thu Jan 01 00:00:00 1970 +0000
+summary:     .
+
+changeset:   0:eff892de26ec
+bookmark:    bm1
+bookmark:    bm2
+bookmark:    bm3
+user:        test
+date:        Thu Jan 01 00:00:00 1970 +0000
+summary:     1
+
+ runcommand log
+changeset:   0:eff892de26ec
+bookmark:    bm1
+bookmark:    bm2
+bookmark:    bm3
+tag:         tip
+user:        test
+date:        Thu Jan 01 00:00:00 1970 +0000
+summary:     1
+