evolve: add -i flag to amend command
The -i flag was missing because it is not a global flag of the commit command.
We can't make it a global flag yet as it is used in many places where it would
not be appropriate so we just add it for this occurrence.
Also, we only want to add it when commit supports it (otherwise it wouldn't
work with older versions of mercurial)
--- a/README Wed Apr 29 10:20:04 2015 -0700
+++ b/README Thu Apr 23 17:45:46 2015 -0700
@@ -54,6 +54,7 @@
5.1.5 --
- minor documentation cleanup
+- support -i option for `hg amend` if commit supports it (3.4)
5.1.4 -- 2015-04-23
--- a/hgext/evolve.py Wed Apr 29 10:20:04 2015 -0700
+++ b/hgext/evolve.py Thu Apr 23 17:45:46 2015 -0700
@@ -86,7 +86,12 @@
else:
raise ImportError('evolve needs version %s or above' % min(testedwith.split()))
-
+aliases, entry = cmdutil.findcmd('commit', commands.table)
+hasinteractivemode = util.any(['interactive' in e for e in entry[1]])
+if hasinteractivemode:
+ interactiveopt = [['i', 'interactive', None, _('use interactive mode')]]
+else:
+ interactiveopt = []
# This extension contains the following code
#
# - Extension Helper code
@@ -1830,7 +1835,7 @@
('', 'close-branch', None,
_('mark a branch as closed, hiding it from the branch list')),
('s', 'secret', None, _('use the secret phase for committing')),
- ] + walkopts + commitopts + commitopts2 + commitopts3,
+ ] + walkopts + commitopts + commitopts2 + commitopts3 + interactiveopt,
_('[OPTION]... [FILE]...'))
def amend(ui, repo, *pats, **opts):
"""combine a changeset with updates and replace it with a new one
--- a/tests/test-amend.t Wed Apr 29 10:20:04 2015 -0700
+++ b/tests/test-amend.t Thu Apr 23 17:45:46 2015 -0700
@@ -115,3 +115,46 @@
branch: foo
commit: 1 unknown (clean)
update: (current)
+
+Check the help
+ $ hg amend -h
+ hg amend [OPTION]... [FILE]...
+
+ aliases: refresh
+
+ combine a changeset with updates and replace it with a new one
+
+ Commits a new changeset incorporating both the changes to the given files
+ and all the changes from the current parent changeset into the repository.
+
+ See "hg commit" for details about committing changes.
+
+ If you don't specify -m, the parent's message will be reused.
+
+ Behind the scenes, Mercurial first commits the update as a regular child
+ of the current parent. Then it creates a new commit on the parent's
+ parents with the updated contents. Then it changes the working copy parent
+ to this new combined changeset. Finally, the old changeset and its update
+ are hidden from "hg log" (unless you use --hidden with log).
+
+ Returns 0 on success, 1 if nothing changed.
+
+ options ([+] can be repeated):
+
+ -A --addremove mark new/missing files as added/removed before
+ committing
+ -e --edit invoke editor on commit messages
+ --close-branch mark a branch as closed, hiding it from the branch
+ list
+ -s --secret use the secret phase for committing
+ -I --include PATTERN [+] include names matching the given patterns
+ -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
+ -D --current-date record the current date as commit date
+ -U --current-user record the current user as committer
+ -i --interactive use interactive mode
+
+ (some details hidden, use --verbose to show complete help)