Mercurial > public > mercurial-scm > hg
comparison 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 |
comparison
equal
deleted
inserted
replaced
52329:5ab77b93567c | 52330:8572e80f978c |
---|---|
94 if revs: | 94 if revs: |
95 raise error.InputError(_(b"can't specify --continue and revisions")) | 95 raise error.InputError(_(b"can't specify --continue and revisions")) |
96 # read in unfinished revisions | 96 # read in unfinished revisions |
97 if graftstate.exists(): | 97 if graftstate.exists(): |
98 statedata = cmdutil.readgraftstate(repo, graftstate) | 98 statedata = cmdutil.readgraftstate(repo, graftstate) |
99 if statedata.get(b'date'): | |
100 opts['date'] = statedata[b'date'] | |
101 if statedata.get(b'user'): | |
102 opts['user'] = statedata[b'user'] | |
103 if statedata.get(b'log'): | |
104 opts['log'] = True | |
105 if statedata.get(b'no_commit'): | 99 if statedata.get(b'no_commit'): |
106 opts['no_commit'] = statedata.get(b'no_commit') | 100 opts['no_commit'] = statedata.get(b'no_commit') |
107 if statedata.get(b'base'): | 101 if statedata.get(b'base'): |
108 opts['base'] = statedata.get(b'base') | 102 opts['base'] = statedata.get(b'base') |
109 nodes = statedata[b'nodes'] | 103 nodes = statedata[b'nodes'] |
114 raise error.InputError(_(b'no revisions specified')) | 108 raise error.InputError(_(b'no revisions specified')) |
115 else: | 109 else: |
116 cmdutil.checkunfinished(repo) | 110 cmdutil.checkunfinished(repo) |
117 cmdutil.bailifchanged(repo) | 111 cmdutil.bailifchanged(repo) |
118 revs = logcmdutil.revrange(repo, revs) | 112 revs = logcmdutil.revrange(repo, revs) |
113 | |
114 for o in ( | |
115 b'date', | |
116 b'user', | |
117 b'log', | |
118 ): | |
119 v = opts.get(o.decode('ascii')) | |
120 # if statedata is already set, it comes from --continue and test says | |
121 # we should honor them above the options (which seems weird). | |
122 if v and o not in statedata: | |
123 statedata[o] = v | |
119 | 124 |
120 skipped = set() | 125 skipped = set() |
121 basectx = None | 126 basectx = None |
122 if opts.get('base'): | 127 if opts.get('base'): |
123 basectx = logcmdutil.revsingle(repo, opts['base'], None) | 128 basectx = logcmdutil.revsingle(repo, opts['base'], None) |
249 if source: | 254 if source: |
250 extra[b'source'] = source | 255 extra[b'source'] = source |
251 extra[b'intermediate-source'] = ctx.hex() | 256 extra[b'intermediate-source'] = ctx.hex() |
252 else: | 257 else: |
253 extra[b'source'] = ctx.hex() | 258 extra[b'source'] = ctx.hex() |
254 user = ctx.user() | 259 user = statedata.get(b'user', ctx.user()) |
255 if opts.get('user'): | 260 date = statedata.get(b'date', ctx.date()) |
256 user = opts['user'] | |
257 statedata[b'user'] = user | |
258 date = ctx.date() | |
259 if opts.get('date'): | |
260 date = opts['date'] | |
261 statedata[b'date'] = date | |
262 message = ctx.description() | 261 message = ctx.description() |
263 if opts.get('log'): | 262 if statedata.get(b'log'): |
264 message += b'\n(grafted from %s)' % ctx.hex() | 263 message += b'\n(grafted from %s)' % ctx.hex() |
265 statedata[b'log'] = True | |
266 | 264 |
267 # we don't merge the first commit when continuing | 265 # we don't merge the first commit when continuing |
268 if not cont: | 266 if not cont: |
269 # perform the graft merge with p1(rev) as 'ancestor' | 267 # perform the graft merge with p1(rev) as 'ancestor' |
270 overrides = {(b'ui', b'forcemerge'): opts.get('tool', b'')} | 268 overrides = {(b'ui', b'forcemerge'): opts.get('tool', b'')} |