Patchwork D3664: graft: reuse the --edit value passed initially in `hg graft --continue` (BC)

login
register
mail settings
Submitter phabricator
Date May 25, 2018, 10:26 p.m.
Message ID <differential-rev-PHID-DREV-leq255xjfci2vffyivli-req@phab.mercurial-scm.org>
Download mbox | patch
Permalink /patch/31878/
State New
Headers show

Comments

phabricator - May 25, 2018, 10:26 p.m.
pulkit created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  This patch starts storing the value of --edit flag passed by the user initially
  when they runs `hg graft --edit`. We can now read the value from graftstate in
  case of `--continue` and respect the value which user passed earlier.
  
  The tests changes demonstrate the fix.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D3664

AFFECTED FILES
  mercurial/commands.py
  tests/test-graft.t

CHANGE DETAILS




To: pulkit, #hg-reviewers
Cc: mercurial-devel
Yuya Nishihara - June 5, 2018, 11:25 a.m.
Queued the first two, thanks.

>   This patch starts storing the value of --edit flag passed by the user initially
>   when they runs `hg graft --edit`. We can now read the value from graftstate in
>   case of `--continue` and respect the value which user passed earlier.

I'm -0.5 on this since --edit is an option to change the interactive behavior,
and I think we don't preserve such options across interrupted sessions.
phabricator - June 5, 2018, noon
yuja added a comment.


  Queued the first two, thanks.
  
  >   This patch starts storing the value of --edit flag passed by the user initially
  >   when they runs `hg graft --edit`. We can now read the value from graftstate in
  >   case of `--continue` and respect the value which user passed earlier.
  
  I'm -0.5 on this since --edit is an option to change the interactive behavior,
  and I think we don't preserve such options across interrupted sessions.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D3664

To: pulkit, #hg-reviewers
Cc: yuja, mercurial-devel

Patch

diff --git a/tests/test-graft.t b/tests/test-graft.t
--- a/tests/test-graft.t
+++ b/tests/test-graft.t
@@ -1585,7 +1585,25 @@ 
   continue: hg graft --continue
   $ HGEDITOR=cat hg graft --continue
   grafting 1:80e6d2c47cfe "added b"
+  added b
+  
+  
+  HG: Enter commit message.  Lines beginning with 'HG:' are removed.
+  HG: Leave message empty to abort commit.
+  HG: --
+  HG: user: test
+  HG: branch 'default'
+  HG: changed b
   grafting 2:8be98ac1a569 "added c"
+  added c
+  
+  
+  HG: Enter commit message.  Lines beginning with 'HG:' are removed.
+  HG: Leave message empty to abort commit.
+  HG: --
+  HG: user: test
+  HG: branch 'default'
+  HG: added c
 
   $ hg log -Gr '.^^::.'
   @  changeset:   13:7ee8d3496b19
diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -2215,9 +2215,6 @@ 
     if not opts.get('date') and opts.get('currentdate'):
         opts['date'] = "%d %d" % dateutil.makedate()
 
-    editor = cmdutil.getcommiteditor(editform='graft',
-                                     **pycompat.strkwargs(opts))
-
     cont = False
     graftstate = statemod.cmdstate(repo, 'graftstate')
     if opts.get('continue'):
@@ -2233,6 +2230,8 @@ 
                 opts['user'] = statedata['user']
             if statedata.get('log'):
                 opts['log'] = True
+            if statedata.get('edit'):
+                opts['edit'] = True
             nodes = statedata['nodes']
             revs = [repo[node].rev() for node in nodes]
         else:
@@ -2244,6 +2243,9 @@ 
         cmdutil.bailifchanged(repo)
         revs = scmutil.revrange(repo, revs)
 
+    editor = cmdutil.getcommiteditor(editform='graft',
+                                     **pycompat.strkwargs(opts))
+
     skipped = set()
     # check for merges
     for rev in repo.revs('%ld and merge()', revs):
@@ -2365,6 +2367,8 @@ 
                 # write out state for --continue
                 nodes = [repo[rev].hex() for rev in revs[pos:]]
                 statedata['nodes'] = nodes
+                if opts.get('edit'):
+                    statedata['edit'] = True
                 stateversion = 1
                 graftstate.save(stateversion, statedata)
                 hint=_("use 'hg resolve' and 'hg graft --continue'")