changeset 985:6a37044ec0b3

amend: add -U/--current-user option (inspired by mq)
author Greg Ward <greg@gerg.ca>
date Sun, 22 Jun 2014 12:01:11 -0400
parents b286f77d680c
children c1f8ece4182d
files README hgext/evolve.py tests/test-amend.t
diffstat 3 files changed, 12 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/README	Sat Jun 21 18:31:21 2014 -0400
+++ b/README	Sun Jun 22 12:01:11 2014 -0400
@@ -50,6 +50,7 @@
 4.1.0 --
 
 - amend: add -D/--current-date option
+- amend: add -U/--current-user option
 
 4.0.0 -- 2014-06-03
 
--- a/hgext/evolve.py	Sat Jun 21 18:31:21 2014 -0400
+++ b/hgext/evolve.py	Sun Jun 22 12:01:11 2014 -0400
@@ -328,9 +328,11 @@
 commitopts3 = [
     ('D', 'current-date', None,
      _('record the current date as commit date')),
+    ('U', 'current-user', None,
+     _('record the current user as committer')),
 ]
 
-def _resolveoptions(opts):
+def _resolveoptions(ui, opts):
     """modify commit options dict to handle related options
 
     For now, all it does is figure out the commit date: respect -D unless
@@ -339,6 +341,8 @@
     # N.B. this is extremely similar to setupheaderopts() in mq.py
     if not opts.get('date') and opts.get('current_date'):
         opts['date'] = '%d %d' % util.makedate()
+    if not opts.get('user') and opts.get('current_user'):
+        opts['user'] = ui.username()
 
 @eh.wrapfunction(mercurial.obsolete, 'createmarkers')
 def _createmarkers(orig, repo, relations, *args, **kwargs):
@@ -1841,7 +1845,7 @@
     opts['amend'] = True
     if not (edit or opts['message']):
         opts['message'] = repo['.'].description()
-    _resolveoptions(opts)
+    _resolveoptions(ui, opts)
     _alias, commitcmd = cmdutil.findcmd('commit', commands.table)
     return commitcmd[0](ui, repo, *pats, **opts)
 
--- a/tests/test-amend.t	Sat Jun 21 18:31:21 2014 -0400
+++ b/tests/test-amend.t	Sun Jun 22 12:01:11 2014 -0400
@@ -92,3 +92,8 @@
   \d+ (re)
   \d+ 0 rev6 (re)
   \d+ (re)
+
+Specify current user as committer with -U
+  $ HGUSER=newbie hg amend -U
+  $ hg parents --template '{rev}  {author}\n'
+  7  newbie