comparison mercurial/cmd_impls/graft.py @ 52530:cef86c1d5dfd

graft: extract creation of progress report line 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 11:36:57 +0100
parents 9042ffea4edd
children de16800904f9
comparison
equal deleted inserted replaced
52529:3abf9bc10fcc 52530:cef86c1d5dfd
217 dry_run = bool(opts.get("dry_run")) 217 dry_run = bool(opts.get("dry_run"))
218 tool = opts.get('tool', b'') 218 tool = opts.get('tool', b'')
219 return "GRAFT", graftstate, (statedata, revs, editor, cont, dry_run, tool) 219 return "GRAFT", graftstate, (statedata, revs, editor, cont, dry_run, tool)
220 220
221 221
222 def _build_progress(ui, repo, ctx):
223 rev_sum = b'%d:%s "%s"' % (
224 ctx.rev(),
225 ctx,
226 ctx.description().split(b'\n', 1)[0],
227 )
228 names = repo.nodetags(ctx.node()) + repo.nodebookmarks(ctx.node())
229 if names:
230 rev_sum += b' (%s)' % b' '.join(names)
231 return _(b'grafting %s\n') % rev_sum
232
233
222 def _graft_revisions( 234 def _graft_revisions(
223 ui, 235 ui,
224 repo, 236 repo,
225 graftstate, 237 graftstate,
226 statedata, 238 statedata,
230 dry_run=False, 242 dry_run=False,
231 tool=b'', 243 tool=b'',
232 ): 244 ):
233 """actually graft some revisions""" 245 """actually graft some revisions"""
234 for pos, ctx in enumerate(repo.set(b"%ld", revs)): 246 for pos, ctx in enumerate(repo.set(b"%ld", revs)):
235 desc = b'%d:%s "%s"' % ( 247 ui.status(_build_progress(ui, repo, ctx))
236 ctx.rev(),
237 ctx,
238 ctx.description().split(b'\n', 1)[0],
239 )
240 names = repo.nodetags(ctx.node()) + repo.nodebookmarks(ctx.node())
241 if names:
242 desc += b' (%s)' % b' '.join(names)
243 ui.status(_(b'grafting %s\n') % desc)
244 if dry_run: 248 if dry_run:
245 continue 249 continue
246 250
247 source = ctx.extra().get(b'source') 251 source = ctx.extra().get(b'source')
248 extra = {} 252 extra = {}