# HG changeset patch # User Pierre-Yves David # Date 2024-12-02 01:41:57 # Node ID de16800904f96d116e355b960669f5529a7a1ec6 # Parent cef86c1d5dfd6c4868ed27424c29733a1806aa4c graft: extract meta information computation in a function This will be useful to reuse it in an in-memory version of graft. diff --git a/mercurial/cmd_impls/graft.py b/mercurial/cmd_impls/graft.py --- a/mercurial/cmd_impls/graft.py +++ b/mercurial/cmd_impls/graft.py @@ -231,6 +231,22 @@ def _build_progress(ui, repo, ctx): 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 @@ def _graft_revisions( 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: