Mercurial > public > mercurial-scm > hg-stable
diff mercurial/cmd_impls/graft.py @ 52531: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 |
line wrap: on
line diff
--- a/mercurial/cmd_impls/graft.py Mon Dec 02 11:36:57 2024 +0100 +++ b/mercurial/cmd_impls/graft.py Mon Dec 02 02:41:57 2024 +0100 @@ -231,6 +231,22 @@ return _(b'grafting %s\n') % rev_sum +def _build_meta(ui, repo, ctx, statedata): + source = ctx.extra().get(b'source') + extra = {} + if source: + extra[b'source'] = source + extra[b'intermediate-source'] = ctx.hex() + else: + extra[b'source'] = ctx.hex() + user = statedata.get(b'user', ctx.user()) + date = statedata.get(b'date', ctx.date()) + message = ctx.description() + if statedata.get(b'log'): + message += b'\n(grafted from %s)' % ctx.hex() + return (user, date, message, extra) + + def _graft_revisions( ui, repo, @@ -248,18 +264,7 @@ if dry_run: continue - source = ctx.extra().get(b'source') - extra = {} - if source: - extra[b'source'] = source - extra[b'intermediate-source'] = ctx.hex() - else: - extra[b'source'] = ctx.hex() - user = statedata.get(b'user', ctx.user()) - date = statedata.get(b'date', ctx.date()) - message = ctx.description() - if statedata.get(b'log'): - message += b'\n(grafted from %s)' % ctx.hex() + (user, date, message, extra) = _build_meta(ui, repo, ctx, statedata) # we don't merge the first commit when continuing if not cont: