Mercurial > public > mercurial-scm > hg-stable
diff 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 |
line wrap: on
line diff
--- a/mercurial/cmd_impls/graft.py Wed Dec 11 18:04:21 2024 -0500 +++ b/mercurial/cmd_impls/graft.py Mon Dec 02 11:36:57 2024 +0100 @@ -219,6 +219,18 @@ return "GRAFT", graftstate, (statedata, revs, editor, cont, dry_run, tool) +def _build_progress(ui, repo, ctx): + rev_sum = b'%d:%s "%s"' % ( + ctx.rev(), + ctx, + ctx.description().split(b'\n', 1)[0], + ) + names = repo.nodetags(ctx.node()) + repo.nodebookmarks(ctx.node()) + if names: + rev_sum += b' (%s)' % b' '.join(names) + return _(b'grafting %s\n') % rev_sum + + def _graft_revisions( ui, repo, @@ -232,15 +244,7 @@ ): """actually graft some revisions""" for pos, ctx in enumerate(repo.set(b"%ld", revs)): - desc = b'%d:%s "%s"' % ( - ctx.rev(), - ctx, - ctx.description().split(b'\n', 1)[0], - ) - names = repo.nodetags(ctx.node()) + repo.nodebookmarks(ctx.node()) - if names: - desc += b' (%s)' % b' '.join(names) - ui.status(_(b'grafting %s\n') % desc) + ui.status(_build_progress(ui, repo, ctx)) if dry_run: continue