Commit d6f8fbda authored by Matt Harbison's avatar Matt Harbison
Browse files

uncommit: add options to update to the current user or current date

These are also from the evolve extension's version of uncommit.

I tried adding validation that both forms of user or date can't be specified at
the same time, but that fails because these show up in `opts` with a None value
whether or not the option was given on the command line.  Presumably that means
the conditional in `resolvecommitoptions` could be simplified.  But this is how
both evolve and MQ handle it.

Differential Revision:
parent ff1ff2aae132
......@@ -112,7 +112,8 @@ def _commitfiltered(repo, ctx, match, keepcommit, message=None, user=None,
[('', 'keep', None, _('allow an empty commit after uncommiting')),
('', 'allow-dirty-working-copy', False,
_('allow uncommit with outstanding changes'))
] + commands.walkopts + commands.commitopts + commands.commitopts2,
] + commands.walkopts + commands.commitopts + commands.commitopts2
+ commands.commitopts3,
_('[OPTION]... [FILE]...'),
def uncommit(ui, repo, *pats, **opts):
......@@ -128,6 +129,8 @@ def uncommit(ui, repo, *pats, **opts):
opts = pycompat.byteskwargs(opts)
cmdutil.resolvecommitoptions(ui, opts)
with repo.wlock(), repo.lock():
m, a, r, d = repo.status()[:4]
......@@ -100,6 +100,13 @@ commitopts2 = [
_('record the specified user as committer'), _('USER')),
commitopts3 = [
(b'D', b'current-date', None,
_(b'record the current date as commit date')),
(b'U', b'current-user', None,
_(b'record the current user as committer')),
formatteropts = [
('T', 'template', '',
_('display with template'), _('TEMPLATE')),
......@@ -175,6 +182,15 @@ debugrevlogopts = [
# editor text
_linebelow = "^HG: ------------------------ >8 ------------------------$"
def resolvecommitoptions(ui, opts):
"""modify commit options dict to handle related options
# N.B. this is extremely similar to setupheaderopts() in
if not opts.get(b'date') and opts.get(b'current_date'):
opts[b'date'] = b'%d %d' % dateutil.makedate()
if not opts.get(b'user') and opts.get(b'current_user'):
opts[b'user'] = ui.username()
def ishunk(x):
hunkclasses = (crecordmod.uihunk, patch.recordhunk)
return isinstance(x, hunkclasses)
......@@ -118,6 +118,7 @@ remoteopts = cmdutil.remoteopts
walkopts = cmdutil.walkopts
commitopts = cmdutil.commitopts
commitopts2 = cmdutil.commitopts2
commitopts3 = cmdutil.commitopts3
formatteropts = cmdutil.formatteropts
templateopts = cmdutil.templateopts
logopts = cmdutil.logopts
......@@ -42,6 +42,8 @@ Help for uncommit
-l --logfile FILE read commit message from file
-d --date DATE record the specified date as commit date
-u --user USER record the specified user as committer
-D --current-date record the current date as commit date
-U --current-user record the current user as committer
(some details hidden, use --verbose to show complete help)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment