[PATCH 2 of 3] graft: preserve original source in subsequent grafts
Mads Kiilerich
mads at kiilerich.com
Sat Nov 12 07:38:11 CST 2011
Stefano Tortarolo wrote, On 11/12/2011 02:05 PM:
> # HG changeset patch
> # User Stefano Tortarolo<stefano.tortarolo at gmail.com>
> # Date 1321100140 -3600
> # Node ID b7644d5507d26bc84c8d171d4a6a13883021b2d3
> # Parent 211d35717f64f723be889a6016c529d244f702ef
> graft: preserve original source in subsequent grafts
>
> diff --git a/mercurial/commands.py b/mercurial/commands.py
> --- a/mercurial/commands.py
> +++ b/mercurial/commands.py
> @@ -2613,7 +2613,10 @@
> cont = False
>
> # commit
> - extra = {'source': ctx.hex()}
> + source = ctx.extra().get('source')
> + if not source:
> + source = ctx.hex()
> + extra = {'source': source}
> user = ctx.user()
> if opts.get('user'):
> user = opts['user']
(For reference, Matt said
> A closely related question is what 'source' to set for a graft of a
> graft. We should probably copy the original source.
)
It is hard to tell which of the previous identities that is most
important, so wouldn't it be better to preserve all of them?
Changing 'source' to a list would be slightly incompatible with 2.0, but
that might be acceptable considering the impact.
I can imagine that liquid/phases could benefit from similar
functionality, but I don't know if it should be handled differently. The
generic 'source' key indicates that its use isn't limited to grafting.
(For a short term solution: It would be convenient if the node id in
patchbombed patches was handled in a similar way by mq and import, so
that qpush of a patch that has been accepted upstream would be detected
automatically.)
/Mads
> diff --git a/tests/test-graft.t b/tests/test-graft.t
> --- a/tests/test-graft.t
> +++ b/tests/test-graft.t
> @@ -225,3 +225,33 @@
> |/
> o test at 0: 0
>
> +Graft again onto another branch should preserve the original source
> + $ hg up -q 0
> + $ echo 'g'>g
> + $ hg add g
> + $ hg ci -m 7
> + created new head
> + $ hg graft 7
> + grafting revision 7
> +
> + $ hg log -r 7 --template '{rev}:{node}\n'
> + 7:d2e44c99fd3f31c176ea4efb9eca9f6306c81756
> + $ hg log -r 2 --template '{rev}:{node}\n'
> + 2:5c095ad7e90f871700f02dd1fa5012cb4498a2d4
> +
> + $ hg log --debug -r tip
> + changeset: 13:39bb1d13572759bd1e6fc874fed1b12ece047a18
> + tag: tip
> + parent: 12:b592ea63bb0c19a6c5c44685ee29a2284f9f1b8f
> + parent: -1:0000000000000000000000000000000000000000
> + manifest: 13:0780e055d8f4cd12eadd5a2719481648f336f7a9
> + user: foo
> + date: Thu Jan 01 00:00:00 1970 +0000
> + files+: b
> + files-: a
> + extra: branch=default
> + extra: source=5c095ad7e90f871700f02dd1fa5012cb4498a2d4
> + description:
> + 2
> +
> +
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel at selenic.com
> http://selenic.com/mailman/listinfo/mercurial-devel
More information about the Mercurial-devel
mailing list