comparison mercurial/cmd_impls/graft.py @ 52504:de16800904f9

graft: extract meta information computation in a function This will be useful to reuse it in an in-memory version of graft.
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Mon, 02 Dec 2024 02:41:57 +0100
parents cef86c1d5dfd
children 68dc6cecca32
comparison
equal deleted inserted replaced
52503:cef86c1d5dfd 52504:de16800904f9
229 if names: 229 if names:
230 rev_sum += b' (%s)' % b' '.join(names) 230 rev_sum += b' (%s)' % b' '.join(names)
231 return _(b'grafting %s\n') % rev_sum 231 return _(b'grafting %s\n') % rev_sum
232 232
233 233
234 def _build_meta(ui, repo, ctx, statedata):
235 source = ctx.extra().get(b'source')
236 extra = {}
237 if source:
238 extra[b'source'] = source
239 extra[b'intermediate-source'] = ctx.hex()
240 else:
241 extra[b'source'] = ctx.hex()
242 user = statedata.get(b'user', ctx.user())
243 date = statedata.get(b'date', ctx.date())
244 message = ctx.description()
245 if statedata.get(b'log'):
246 message += b'\n(grafted from %s)' % ctx.hex()
247 return (user, date, message, extra)
248
249
234 def _graft_revisions( 250 def _graft_revisions(
235 ui, 251 ui,
236 repo, 252 repo,
237 graftstate, 253 graftstate,
238 statedata, 254 statedata,
246 for pos, ctx in enumerate(repo.set(b"%ld", revs)): 262 for pos, ctx in enumerate(repo.set(b"%ld", revs)):
247 ui.status(_build_progress(ui, repo, ctx)) 263 ui.status(_build_progress(ui, repo, ctx))
248 if dry_run: 264 if dry_run:
249 continue 265 continue
250 266
251 source = ctx.extra().get(b'source') 267 (user, date, message, extra) = _build_meta(ui, repo, ctx, statedata)
252 extra = {}
253 if source:
254 extra[b'source'] = source
255 extra[b'intermediate-source'] = ctx.hex()
256 else:
257 extra[b'source'] = ctx.hex()
258 user = statedata.get(b'user', ctx.user())
259 date = statedata.get(b'date', ctx.date())
260 message = ctx.description()
261 if statedata.get(b'log'):
262 message += b'\n(grafted from %s)' % ctx.hex()
263 268
264 # we don't merge the first commit when continuing 269 # we don't merge the first commit when continuing
265 if not cont: 270 if not cont:
266 # perform the graft merge with p1(rev) as 'ancestor' 271 # perform the graft merge with p1(rev) as 'ancestor'
267 overrides = {(b'ui', b'forcemerge'): tool} 272 overrides = {(b'ui', b'forcemerge'): tool}