changeset 2728:3c371aa16cb9

uncommit: add support for --user and --date This is also long overdue
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Tue, 11 Jul 2017 11:59:18 +0200
parents f7d44441dfd3
children 69fe16428b0f
files hgext3rd/evolve/evocommands.py tests/test-tutorial.t tests/test-uncommit.t
diffstat 3 files changed, 18 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/hgext3rd/evolve/evocommands.py	Tue Jul 11 11:58:07 2017 +0200
+++ b/hgext3rd/evolve/evocommands.py	Tue Jul 11 11:59:18 2017 +0200
@@ -116,7 +116,8 @@
         touched.update(files)
     return touched
 
-def _commitfiltered(repo, ctx, match, target=None, message=None):
+def _commitfiltered(repo, ctx, match, target=None, message=None, user=None,
+                    date=None):
     """Recommit ctx with changed files not in match. Return the new
     node identifier, or None if nothing changed.
     """
@@ -158,13 +159,17 @@
 
     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=message,
                          files=files,
                          filectxfn=filectxfn,
-                         user=ctx.user(),
-                         date=ctx.date(),
+                         user=user,
+                         date=date,
                          extra=ctx.extra())
     # commitctx always create a new revision, no need to check
     newid = repo.commitctx(new)
@@ -218,7 +223,7 @@
     '^uncommit',
     [('a', 'all', None, _('uncommit all changes when no arguments given')),
      ('r', 'rev', '', _('revert commit content to REV instead')),
-     ] + commands.walkopts + commitopts,
+     ] + commands.walkopts + commitopts + commitopts2,
     _('[OPTION]... [NAME]'))
 def uncommit(ui, repo, *pats, **opts):
     """move changes from parent revision to working directory
@@ -278,7 +283,8 @@
                 opts['message'] = old.description()
             message = cmdutil.logmessage(ui, opts)
             newid = _commitfiltered(repo, old, match, target=rev,
-                                    message=message)
+                                    message=message, user=opts.get('user'),
+                                    date=opts.get('date'))
         if newid is None:
             raise error.Abort(_('nothing to uncommit'),
                               hint=_("use --all to uncommit all files"))
--- a/tests/test-tutorial.t	Tue Jul 11 11:58:07 2017 +0200
+++ b/tests/test-tutorial.t	Tue Jul 11 11:59:18 2017 +0200
@@ -463,6 +463,8 @@
    -X --exclude PATTERN [+] exclude names matching the given patterns
    -m --message TEXT        use text as commit message
    -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
   
   (some details hidden, use --verbose to show complete help)
 
--- a/tests/test-uncommit.t	Tue Jul 11 11:58:07 2017 +0200
+++ b/tests/test-uncommit.t	Tue Jul 11 11:59:18 2017 +0200
@@ -363,7 +363,7 @@
   b
   b
 
-Test message update
+Test date, message and user update
 
   $ hg log -r .
   changeset:   12:912ed871207c
@@ -374,13 +374,13 @@
   date:        Thu Jan 01 00:00:00 1970 +0000
   summary:     touncommit
   
-  $ hg uncommit -m 'to-uncommit' d
+  $ hg uncommit -m 'to-uncommit' d --user test2 --date '1337 0'
   $ hg log -r .
-  changeset:   13:dfe358c8c130
+  changeset:   13:f1efd9ec508c
   branch:      bar
   tag:         tip
   parent:      7:4f1c269eab68
-  user:        test
-  date:        Thu Jan 01 00:00:00 1970 +0000
+  user:        test2
+  date:        Thu Jan 01 00:22:17 1970 +0000
   summary:     to-uncommit