diff mercurial/cmd_impls/graft.py @ 52330:8572e80f978c

graft: assign computed configuration value to statedata instead of opts The goal is for the graft logic to not deal with the command line option, so lets to reinjecting value in these config option.
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Wed, 20 Nov 2024 02:10:43 +0100
parents 5ab77b93567c
children 11fb7f737456
line wrap: on
line diff
--- a/mercurial/cmd_impls/graft.py	Tue Nov 19 15:54:20 2024 +0100
+++ b/mercurial/cmd_impls/graft.py	Wed Nov 20 02:10:43 2024 +0100
@@ -96,12 +96,6 @@
         # read in unfinished revisions
         if graftstate.exists():
             statedata = cmdutil.readgraftstate(repo, graftstate)
-            if statedata.get(b'date'):
-                opts['date'] = statedata[b'date']
-            if statedata.get(b'user'):
-                opts['user'] = statedata[b'user']
-            if statedata.get(b'log'):
-                opts['log'] = True
             if statedata.get(b'no_commit'):
                 opts['no_commit'] = statedata.get(b'no_commit')
             if statedata.get(b'base'):
@@ -117,6 +111,17 @@
         cmdutil.bailifchanged(repo)
         revs = logcmdutil.revrange(repo, revs)
 
+    for o in (
+        b'date',
+        b'user',
+        b'log',
+    ):
+        v = opts.get(o.decode('ascii'))
+        # if statedata is already set, it comes from --continue and test says
+        # we should honor them above the options (which seems weird).
+        if v and o not in statedata:
+            statedata[o] = v
+
     skipped = set()
     basectx = None
     if opts.get('base'):
@@ -251,18 +256,11 @@
             extra[b'intermediate-source'] = ctx.hex()
         else:
             extra[b'source'] = ctx.hex()
-        user = ctx.user()
-        if opts.get('user'):
-            user = opts['user']
-            statedata[b'user'] = user
-        date = ctx.date()
-        if opts.get('date'):
-            date = opts['date']
-            statedata[b'date'] = date
+        user = statedata.get(b'user', ctx.user())
+        date = statedata.get(b'date', ctx.date())
         message = ctx.description()
-        if opts.get('log'):
+        if statedata.get(b'log'):
             message += b'\n(grafted from %s)' % ctx.hex()
-            statedata[b'log'] = True
 
         # we don't merge the first commit when continuing
         if not cont: