Patchwork [V3] commit: propagate --secret option to subrepos (issue4182)

login
register
mail settings
Submitter Jordi Gutiérrez Hermoso
Date March 18, 2014, 8:47 p.m.
Message ID <edb6d35f2ccd060e4993.1395175655@Iris>
Download mbox | patch
Permalink /patch/3970/
State Accepted
Headers show

Comments

Jordi Gutiérrez Hermoso - March 18, 2014, 8:47 p.m.
# HG changeset patch
# User Jordi Gutiérrez Hermoso <jordigh@octave.org>
# Date 1395082633 14400
#      Mon Mar 17 14:57:13 2014 -0400
# Node ID edb6d35f2ccd060e4993e826a3f0ef3618ae7bbe
# Parent  b93791e0de25ac0090d66fa04f956414b572a739
commit: propagate --secret option to subrepos (issue4182)

Before this patch, `hg commit --secret` was not getting propagated
correctly, and subrepos were not getting the commit in the secret
phase. The problem is that subrepos get their ui from the base repo's
baseui object and ignore the ui object passed on to them. This sets
and restores both ui objects with the appropriate option.

Patch

diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -1436,11 +1436,14 @@ 
             try:
                 if opts.get('secret'):
                     ui.setconfig('phases', 'new-commit', 'secret')
+                    # Propagate to subrepos
+                    repo.baseui.setconfig('phases', 'new-commit', 'secret')
 
                 return repo.commit(message, opts.get('user'), opts.get('date'),
                                    match, editor=e, extra=extra)
             finally:
                 ui.setconfig('phases', 'new-commit', oldcommitphase)
+                repo.baseui.setconfig('phases', 'new-commit', oldcommitphase)
 
 
         node = cmdutil.commit(ui, repo, commitfunc, pats, opts)
diff --git a/tests/test-subrepo-recursion.t b/tests/test-subrepo-recursion.t
--- a/tests/test-subrepo-recursion.t
+++ b/tests/test-subrepo-recursion.t
@@ -185,6 +185,12 @@ 
   $ hg commit --subrepos -m 2-3-2
   committing subrepository foo
   committing subrepository foo/bar (glob)
+  $ hg phase -r .
+  2: draft
+  $ hg -R foo phase -r .
+  3: draft
+  $ hg -R foo/bar phase -r .
+  2: draft
 
 Test explicit path commands within subrepos: add/forget
   $ echo z1 > foo/bar/z2.txt
diff --git a/tests/test-subrepo.t b/tests/test-subrepo.t
--- a/tests/test-subrepo.t
+++ b/tests/test-subrepo.t
@@ -1294,3 +1294,16 @@ 
   15: secret
 
   $ cd ..
+
+Test that comit --secret works (issue4182)
+
+  $ cd main
+  $ echo secret >> b
+  $ echo secret >> s/b
+  $ hg commit --secret --subrepo -m "secret"
+  committing subrepository s
+  $ hg phase -r .
+  6: secret
+  $ hg -R s phase -r .
+  6: secret
+  $ cd ..