Patchwork [2,of,2] commit: commit should ignore secret heads for "new heads" warning (issue5017)

login
register
mail settings
Submitter Laurent Charignon
Date Dec. 23, 2015, 7:07 p.m.
Message ID <9954c27e3d395aad2896.1450897651@dev5073.prn1.facebook.com>
Download mbox | patch
Permalink /patch/12306/
State Changes Requested
Delegated to: Yuya Nishihara
Headers show

Comments

Laurent Charignon - Dec. 23, 2015, 7:07 p.m.
# HG changeset patch
# User Laurent Charignon <lcharignon@fb.com>
# Date 1450897516 28800
#      Wed Dec 23 11:05:16 2015 -0800
# Node ID 9954c27e3d395aad2896e88023fcfbce049eb617
# Parent  1721c112f0194a078103b3b673de236b5cd5cd52
commit: commit should ignore secret heads for "new heads" warning (issue5017)

The warning exists to keep people from having multi-headed push trouble but
since secret commits are not pushed we don't need to display this warning.
Gilles Moris - Dec. 24, 2015, 4:56 p.m.
Le 23/12/2015 20:07, Laurent Charignon a écrit :
> # HG changeset patch
> # User Laurent Charignon<lcharignon@fb.com>
> # Date 1450897516 28800
> #      Wed Dec 23 11:05:16 2015 -0800
> # Node ID 9954c27e3d395aad2896e88023fcfbce049eb617
> # Parent  1721c112f0194a078103b3b673de236b5cd5cd52
> commit: commit should ignore secret heads for "new heads" warning (issue5017)
>
> The warning exists to keep people from having multi-headed push trouble but
> since secret commits are not pushed we don't need to display this warning.
>
> diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
> --- a/mercurial/cmdutil.py
> +++ b/mercurial/cmdutil.py
> @@ -2807,7 +2807,8 @@
>       parents = ctx.parents()
>   
>       if (not opts.get('amend') and bheads and node not in bheads and not
> -        [x for x in parents if x.node() in bheads and x.branch() == branch]):
> +        [x for x in parents if x.node() in bheads and x.branch() == branch]
> +        and not ctx.secret()):
May be secret should be tested first to allow an early test exit.

Regards.
Gilles.
Yuya Nishihara - Dec. 26, 2015, 1:32 p.m.
On Wed, 23 Dec 2015 11:07:31 -0800, Laurent Charignon wrote:
> # HG changeset patch
> # User Laurent Charignon <lcharignon@fb.com>
> # Date 1450897516 28800
> #      Wed Dec 23 11:05:16 2015 -0800
> # Node ID 9954c27e3d395aad2896e88023fcfbce049eb617
> # Parent  1721c112f0194a078103b3b673de236b5cd5cd52
> commit: commit should ignore secret heads for "new heads" warning (issue5017)
> 
> The warning exists to keep people from having multi-headed push trouble but
> since secret commits are not pushed we don't need to display this warning.
> 
> diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
> --- a/mercurial/cmdutil.py
> +++ b/mercurial/cmdutil.py
> @@ -2807,7 +2807,8 @@
>      parents = ctx.parents()
>  
>      if (not opts.get('amend') and bheads and node not in bheads and not
> -        [x for x in parents if x.node() in bheads and x.branch() == branch]):
> +        [x for x in parents if x.node() in bheads and x.branch() == branch]
> +        and not ctx.secret()):

I think this change is also good, but is different from the issue5017. It says
"bheads" should ignore existing secret revisions.

  0(draft)---1(secret)
   \
    -------------------2(draft)
       new commit 2 shouldn't say "created new head" because 1 is secret
       therefore non-secret bheads are {0}.
Laurent Charignon - Dec. 27, 2015, 3:45 a.m.
On 12/26/15, 5:32 AM, "Yuya Nishihara" <youjah@gmail.com on behalf of
yuya@tcha.org> wrote:

>On Wed, 23 Dec 2015 11:07:31 -0800, Laurent Charignon wrote:
>> # HG changeset patch
>> # User Laurent Charignon <lcharignon@fb.com>
>> # Date 1450897516 28800
>> #      Wed Dec 23 11:05:16 2015 -0800
>> # Node ID 9954c27e3d395aad2896e88023fcfbce049eb617
>> # Parent  1721c112f0194a078103b3b673de236b5cd5cd52
>> commit: commit should ignore secret heads for "new heads" warning
>>(issue5017)
>> 
>> The warning exists to keep people from having multi-headed push trouble
>>but
>> since secret commits are not pushed we don't need to display this
>>warning.
>> 
>> diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
>> --- a/mercurial/cmdutil.py
>> +++ b/mercurial/cmdutil.py
>> @@ -2807,7 +2807,8 @@
>>      parents = ctx.parents()
>>  
>>      if (not opts.get('amend') and bheads and node not in bheads and not
>> -        [x for x in parents if x.node() in bheads and x.branch() ==
>>branch]):
>> +        [x for x in parents if x.node() in bheads and x.branch() ==
>>branch]
>> +        and not ctx.secret()):
>
>I think this change is also good, but is different from the issue5017. It
>says
>"bheads" should ignore existing secret revisions.

Yes, you are right this isn't exactly the same thing, good catch!
I will add a patch to this series and fix the commit messages.

Thanks,

Laurent

>
>  0(draft)---1(secret)
>   \
>    -------------------2(draft)
>       new commit 2 shouldn't say "created new head" because 1 is secret
>       therefore non-secret bheads are {0}.
Laurent Charignon - Dec. 27, 2015, 4:41 a.m.
> On Dec 24, 2015, at 8:56 AM, Gilles Moris <gilles.moris@free.fr> wrote:

> 

> 

> 

> Le 23/12/2015 20:07, Laurent Charignon a écrit :

>> # HG changeset patch

>> # User Laurent Charignon<lcharignon@fb.com>

>> # Date 1450897516 28800

>> #      Wed Dec 23 11:05:16 2015 -0800

>> # Node ID 9954c27e3d395aad2896e88023fcfbce049eb617

>> # Parent  1721c112f0194a078103b3b673de236b5cd5cd52

>> commit: commit should ignore secret heads for "new heads" warning (issue5017)

>> 

>> The warning exists to keep people from having multi-headed push trouble but

>> since secret commits are not pushed we don't need to display this warning.

>> 

>> diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py

>> --- a/mercurial/cmdutil.py

>> +++ b/mercurial/cmdutil.py

>> @@ -2807,7 +2807,8 @@

>>      parents = ctx.parents()

>>        if (not opts.get('amend') and bheads and node not in bheads and not

>> -        [x for x in parents if x.node() in bheads and x.branch() == branch]):

>> +        [x for x in parents if x.node() in bheads and x.branch() == branch]

>> +        and not ctx.secret()):

> May be secret should be tested first to allow an early test exit.


I expected ctx.secret() to be less likely than the other conditions, isn't it the case?

Regards,

Laurent

> 

> Regards.

> Gilles.

Patch

diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
--- a/mercurial/cmdutil.py
+++ b/mercurial/cmdutil.py
@@ -2807,7 +2807,8 @@ 
     parents = ctx.parents()
 
     if (not opts.get('amend') and bheads and node not in bheads and not
-        [x for x in parents if x.node() in bheads and x.branch() == branch]):
+        [x for x in parents if x.node() in bheads and x.branch() == branch]
+        and not ctx.secret()):
         repo.ui.status(_('created new head\n'))
         # The message is not printed for initial roots. For the other
         # changesets, it is printed in the following situations:
diff --git a/tests/test-histedit-obsolete.t b/tests/test-histedit-obsolete.t
--- a/tests/test-histedit-obsolete.t
+++ b/tests/test-histedit-obsolete.t
@@ -429,7 +429,6 @@ 
   $ echo wat >> wat
   $ hg add wat
   $ hg ci -m 'add wat'
-  created new head
   $ hg merge 769e8ee8708e
   2 files updated, 0 files merged, 0 files removed, 0 files unresolved
   (branch merge, don't forget to commit)
diff --git a/tests/test-phases.t b/tests/test-phases.t
--- a/tests/test-phases.t
+++ b/tests/test-phases.t
@@ -590,3 +590,28 @@ 
   crosschecking files in changesets and manifests
   checking files
   7 files, 8 changesets, 7 total revisions
+
+Check that commiting secret changes does not show the "created new head" 
+warning (issue5017)
+
+  $ hg log -G --template "{rev} {phase} {desc}\n"
+  @    7 public merge B' and E
+  |\
+  | o  6 public B'
+  | |
+  o |  4 public E
+  | |
+  o |  3 public D
+  | |
+  o |  2 public C
+  |/
+  o  1 public B
+  |
+  o  0 public A
+  
+
+  $ hg update 6
+  0 files updated, 0 files merged, 3 files removed, 0 files unresolved
+  $ touch foo
+  $ hg add foo
+  $ hg commit -s -m "secret commit"
diff --git a/tests/test-subrepo.t b/tests/test-subrepo.t
--- a/tests/test-subrepo.t
+++ b/tests/test-subrepo.t
@@ -1583,7 +1583,6 @@ 
   warning: changes are committed in secret phase from subrepository ss
   committing subrepository t
   warning: changes are committed in secret phase from subrepository s
-  created new head
   $ hg -R s/ss phase tip
   5: secret
   $ hg -R s phase tip