[PATCH] Fix "created new head" being shown incorrectly
Gilles Moris
gilles.moris at free.fr
Sat Jun 5 07:07:16 CDT 2010
On Saturday 05 June 2010 04:27:11 am Rafael Fernández López wrote:
> Hello again,
>
> Here is an updated version that makes pass subrepo test. This test was
> suffering exactly what this patch fixes.
>
>
> # HG changeset patch
> # User Rafael Fernández López <ereslibre at ereslibre.es>
> # Date 1275703057 -7200
> # Node ID f065a48476d7a51956726d778540da54929fd2c8
> # Parent e581f3acc3385da5d5ddf547882f274d9f7e5b6d
> commit: fix regression on "creating new head" message being shown when
> is not actually the case
>
> Revision 5b48d819d5f9 introduced this problem, and introduced changes
> basically performs
> the check "if all your parents are not in branch heads, then show the
> message".
>
> Heavily guided by tonfa. Thank you.
>
> Also adapt tests to pass. Here subrepo was expecting an extra "created new
> head"
>
> diff --git a/mercurial/commands.py b/mercurial/commands.py
> --- a/mercurial/commands.py
> +++ b/mercurial/commands.py
> @@ -766,9 +766,11 @@
> ctx = repo[node]
> parents = ctx.parents()
>
> - if bheads and [x for x in parents
> - if x.node() not in bheads and x.branch() == branch]:
> - ui.status(_('created new head\n'))
> + if bheads:
> + nothead = [x for x in parents
> + if x.node() not in bheads and x.branch() == branch]
> + if len(parents) == len(nothead):
> + ui.status(_('created new head\n'))
>
> if not opts.get('close_branch'):
> for r in parents:
> diff --git a/tests/test-subrepo.out b/tests/test-subrepo.out
> --- a/tests/test-subrepo.out
> +++ b/tests/test-subrepo.out
> @@ -90,7 +90,6 @@
> source t
> revision 6747d179aa9a688023c4b0cad32e4c92bb7f34ad
> committing subrepository t
> -created new head
> searching for copies back to rev 2
> resolving manifests
> overwrite None partial False
It seems that we have hard time converging for the 'new head' message.
I have some difficulties understanding the impact of your patch and what it
means exactly.
I would try to translate it in plain text as:
"new head is created if none of the parents are in branch heads"
If one of the parent is in branch head, then this means we are just continuing
a head. If the two parents are in head, we are reducing the number of branch
heads.
This would translate to:
diff -r 6ac0d9eaa93c mercurial/commands.py
--- a/mercurial/commands.py Wed May 19 17:40:28 2010 +0200
+++ b/mercurial/commands.py Sat Jun 05 14:04:10 2010 +0200
@@ -766,8 +766,8 @@
ctx = repo[node]
parents = ctx.parents()
- if bheads and [x for x in parents
- if x.node() not in bheads and x.branch() == branch]:
+ if bheads and not [x for x in parents
+ if x.node() in bheads and x.branch() == branch]:
ui.status(_('created new head\n'))
if not opts.get('close_branch'):
But several tests are impacted as well, and I will have to verify that my
alternative is valid and semantically equivalent to your patch.
Regards.
Gilles.
More information about the Mercurial-devel
mailing list