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

login
register
mail settings
Submitter Jordi Gutiérrez Hermoso
Date March 18, 2014, 1:48 a.m.
Message ID <da00652364a5702c181c.1395107287@Iris>
Download mbox | patch
Permalink /patch/3958/
State Accepted
Commit 03774a2b6991b451bde7095238fde9ce98380d28
Headers show

Comments

Jordi Gutiérrez Hermoso - March 18, 2014, 1:48 a.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 da00652364a5702c181c3e9e3691c47c051f690a
# 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.
Sean Farley - March 18, 2014, 2:02 a.m.
Jordi Gutiérrez Hermoso <jordigh@octave.org> writes:

> # HG changeset patch
> # User Jordi Gutiérrez Hermoso <jordigh@octave.org>
> # Date 1395082633 14400
> #      Mon Mar 17 14:57:13 2014 -0400
> # Node ID da00652364a5702c181c3e9e3691c47c051f690a
> # 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.

hg email --flag V2
Siddharth Agarwal - March 18, 2014, 2:22 a.m.
On 03/17/2014 06:48 PM, Jordi Gutiérrez Hermoso wrote:
> # HG changeset patch
> # User Jordi Gutiérrez Hermoso <jordigh@octave.org>
> # Date 1395082633 14400
> #      Mon Mar 17 14:57:13 2014 -0400
> # Node ID da00652364a5702c181c3e9e3691c47c051f690a
> # 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.
>
> 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.t b/tests/test-subrepo.t
> --- a/tests/test-subrepo.t
> +++ b/tests/test-subrepo.t
> @@ -1294,3 +1294,18 @@
>     15: secret
>   
>     $ cd ..
> +
> +
> +Test that comit --secret works on both repo and subrepo (issue4182)

"Test that commit --secret works"

Other than that, looks good to me.

> +
> +  $ cd main
> +  $ echo secret >> b
> +  $ echo secret >> s/b
> +  $ hg commit --secret --subrepo -m "secret"
> +  committing subrepository s
> +  $ hg phase -r .
> +  6: secret
> +  $ cd s
> +  $ hg phase -r .
> +  6: secret
> +  $ cd ../../
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@selenic.com
> https://urldefense.proofpoint.com/v1/url?u=http://selenic.com/mailman/listinfo/mercurial-devel&k=ZVNjlDMF0FElm4dQtryO4A%3D%3D%0A&r=%2FSg8Zq7yFXBOhOzuAORckw%3D%3D%0A&m=8pPniBQu2o31ogFWinjuw%2BeL1zErsrpU9n3N05a5uEk%3D%0A&s=c23675ddefdf671d6f19ff9b22afa5ac66a82fd2d83a1ac0fc77a2190f2e48ab
Matt Mackall - March 18, 2014, 7 p.m.
On Mon, 2014-03-17 at 19:22 -0700, Siddharth Agarwal wrote:

> > +Test that comit --secret works on both repo and subrepo (issue4182)
> 
> "Test that commit --secret works"
> 
> Other than that, looks good to me.

Thanks, guys. This looks like it belongs on stable, so queued for stable
with the above fixed.

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.t b/tests/test-subrepo.t
--- a/tests/test-subrepo.t
+++ b/tests/test-subrepo.t
@@ -1294,3 +1294,18 @@ 
   15: secret
 
   $ cd ..
+
+
+Test that comit --secret works on both repo and subrepo (issue4182)
+
+  $ cd main
+  $ echo secret >> b
+  $ echo secret >> s/b
+  $ hg commit --secret --subrepo -m "secret"
+  committing subrepository s
+  $ hg phase -r .
+  6: secret
+  $ cd s
+  $ hg phase -r .
+  6: secret
+  $ cd ../../