--- a/mercurial/commands.py Sun Nov 13 00:29:26 2011 +0000
+++ b/mercurial/commands.py Sat Nov 12 13:15:40 2011 +0100
@@ -2590,7 +2590,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']
--- a/tests/test-graft.t Sun Nov 13 00:29:26 2011 +0000
+++ b/tests/test-graft.t Sat Nov 12 13:15:40 2011 +0100
@@ -225,3 +225,33 @@
|/
o test@rev: 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
+
+