changeset 38154:decdb587ea12

graft: reuse --user and --date values in `hg graft --continue` (BC) Reading the user and date information from graftstate during `hg graft --continue` will help us in preserving the user and date arguments passed when `hg graft` was called. This patch reads that information and reuses that while running `hg graft --continue`. So after this patch, --user and --date values are preserved even if conflicts occur and user don't need to pass them again. The test changes demonstrate the fix. This is a backward incompatible change but I think of this more as a bug fix. Also thinking about removing the line from `hg help graft` which says --continue does not reapply other flags but need to check what are the other flags which needs to be preserved. Differential Revision: https://phab.mercurial-scm.org/D3659
author Pulkit Goyal <7895pulkit@gmail.com>
date Fri, 25 May 2018 17:21:01 +0530
parents 108ebd8eff5c
children 5736570718fe
files mercurial/commands.py tests/test-graft.t
diffstat 2 files changed, 14 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/commands.py	Sat May 26 01:52:42 2018 +0530
+++ b/mercurial/commands.py	Fri May 25 17:21:01 2018 +0530
@@ -2226,7 +2226,12 @@
             raise error.Abort(_("can't specify --continue and revisions"))
         # read in unfinished revisions
         if graftstate.exists():
-            nodes = _readgraftstate(repo, graftstate)['nodes']
+            statedata = _readgraftstate(repo, graftstate)
+            if statedata.get('date'):
+                opts['date'] = statedata['date']
+            if statedata.get('user'):
+                opts['user'] = statedata['user']
+            nodes = statedata['nodes']
             revs = [repo[node].rev() for node in nodes]
         else:
             cmdutil.wrongtooltocontinue(repo, _('graft'))
--- a/tests/test-graft.t	Sat May 26 01:52:42 2018 +0530
+++ b/tests/test-graft.t	Fri May 25 17:21:01 2018 +0530
@@ -1468,17 +1468,16 @@
   grafting 1:80e6d2c47cfe "added b"
   grafting 2:8be98ac1a569 "added c"
 
-XXX: the user of 6 and 7 should be batman
   $ hg log -Gr 3::
-  @  changeset:   7:89f377552d81
+  @  changeset:   7:11a36ffaacf2
   |  tag:         tip
-  |  user:        test
+  |  user:        batman
   |  date:        Thu Jan 01 00:00:00 1970 +0000
   |  summary:     added c
   |
-  o  changeset:   6:393512ff89b9
+  o  changeset:   6:76803afc6511
   |  parent:      3:9e887f7a939c
-  |  user:        test
+  |  user:        batman
   |  date:        Thu Jan 01 00:00:00 1970 +0000
   |  summary:     added b
   |
@@ -1518,18 +1517,17 @@
   grafting 1:80e6d2c47cfe "added b"
   grafting 2:8be98ac1a569 "added c"
 
-XXX: 8 and 9 show have the date we passed
   $ hg log -Gr '.^^::.'
-  @  changeset:   9:7ee8d3496b19
+  @  changeset:   9:1896b76e007a
   |  tag:         tip
   |  user:        test
-  |  date:        Thu Jan 01 00:00:00 1970 +0000
+  |  date:        Fri Feb 13 21:18:00 2009 -0002
   |  summary:     added c
   |
-  o  changeset:   8:802f1eae3af3
+  o  changeset:   8:ce2b4f1632af
   |  parent:      3:9e887f7a939c
   |  user:        test
-  |  date:        Thu Jan 01 00:00:00 1970 +0000
+  |  date:        Fri Feb 13 21:18:00 2009 -0002
   |  summary:     added b
   |
   o  changeset:   3:9e887f7a939c