Mercurial > hg
diff hgext/uncommit.py @ 42902:ff1ff2aae132
uncommit: add support to modify the commit message and date
Currently, the evolve extension's version of this command supports it.
Differential Revision: https://phab.mercurial-scm.org/D6827
author | Matt Harbison <matt_harbison@yahoo.com> |
---|---|
date | Sat, 07 Sep 2019 13:44:29 -0400 |
parents | 566daffc607d |
children | 66048f6b5d0d |
line wrap: on
line diff
--- a/hgext/uncommit.py Fri Jun 14 17:50:04 2019 +0100 +++ b/hgext/uncommit.py Sat Sep 07 13:44:29 2019 -0400 @@ -55,7 +55,8 @@ # leave the attribute unspecified. testedwith = 'ships-with-hg-core' -def _commitfiltered(repo, ctx, match, keepcommit): +def _commitfiltered(repo, ctx, match, keepcommit, message=None, user=None, + date=None): """Recommit ctx with changed files not in match. Return the new node identifier, or None if nothing changed. """ @@ -90,13 +91,20 @@ if not files: repo.ui.status(_("note: keeping empty commit\n")) + if message is None: + message = ctx.description() + if not user: + user = ctx.user() + if not date: + date = ctx.date() + new = context.memctx(repo, parents=[base.node(), node.nullid], - text=ctx.description(), + text=message, files=files, filectxfn=filectxfn, - user=ctx.user(), - date=ctx.date(), + user=user, + date=date, extra=ctx.extra()) return repo.commitctx(new) @@ -104,7 +112,7 @@ [('', 'keep', None, _('allow an empty commit after uncommiting')), ('', 'allow-dirty-working-copy', False, _('allow uncommit with outstanding changes')) - ] + commands.walkopts, + ] + commands.walkopts + commands.commitopts + commands.commitopts2, _('[OPTION]... [FILE]...'), helpcategory=command.CATEGORY_CHANGE_MANAGEMENT) def uncommit(ui, repo, *pats, **opts): @@ -162,13 +170,19 @@ % scmutil.getuipathfn(repo)(f), hint=hint) with repo.transaction('uncommit'): + if not (opts[b'message'] or opts[b'logfile']): + opts[b'message'] = old.description() + message = cmdutil.logmessage(ui, pycompat.byteskwargs(opts)) + keepcommit = pats if not keepcommit: if opts.get('keep') is not None: keepcommit = opts.get('keep') else: keepcommit = ui.configbool('experimental', 'uncommit.keep') - newid = _commitfiltered(repo, old, match, keepcommit) + newid = _commitfiltered(repo, old, match, keepcommit, + message=message, user=opts.get(b'user'), + date=opts.get(b'date')) if newid is None: ui.status(_("nothing to uncommit\n")) return 1