hgext/evolve.py
changeset 742 760d01a549a6
parent 741 892a6d708c8f
child 743 af74a5cdf96b
--- a/hgext/evolve.py	Tue Oct 15 16:20:17 2013 +0200
+++ b/hgext/evolve.py	Wed Oct 16 00:37:29 2013 +0200
@@ -1166,7 +1166,7 @@
         try:
             repo.dirstate.setparents(divergent.node(), node.nullid)
             oldlen = len(repo)
-            amend(ui, repo)
+            amend(ui, repo, message='', logfile='')
             if oldlen == len(repo):
                 new = divergent
                 # no changes
@@ -1379,6 +1379,9 @@
     [('A', 'addremove', None,
      _('mark new/missing files as added/removed before committing')),
     ('e', 'edit', False, _('invoke editor on commit messages')),
+    ('', '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,
     _('[OPTION]... [FILE]...'))
 def amend(ui, repo, *pats, **opts):
@@ -1399,79 +1402,13 @@
 
     Returns 0 on success, 1 if nothing changed.
     """
-
-    # determine updates to subsume
-    old = scmutil.revsingle(repo, '.')
-    metadata = _getmetadata(**opts)
-
-    lock = repo.lock()
-    try:
-        wlock = repo.wlock()
-        try:
-            if old.phase() == phases.public:
-                raise util.Abort(_("can not rewrite immutable changeset %s")
-                                 % old)
-            tr = repo.transaction('amend')
-            try:
-                oldphase = old.phase()
-                # commit current changes as update
-                # code copied from commands.commit to avoid noisy messages
-                ciopts = dict(opts)
-                ciopts.pop('message', None)
-                ciopts.pop('logfile', None)
-                ciopts['message'] = 'amends %s' % old.hex()
-                e = cmdutil.commiteditor
-                def commitfunc(ui, repo, message, match, opts):
-                    return repo.commit(message, opts.get('user'), opts.get('date'),
-                                       match, editor=e)
-                revcount = len(repo)
-                tempid = cmdutil.commit(ui, repo, commitfunc, pats, ciopts)
-                if len(repo) == revcount:
-                    # No revision created
-                    tempid = None
-
-                # find all changesets to be considered updates
-                head = repo['.']
-                updatenodes = set(repo.changelog.nodesbetween(
-                        roots=[old.node()], heads=[head.node()])[0])
-                updatenodes.remove(old.node())
-                okoptions = ['message', 'logfile', 'edit', 'user']
-                if not updatenodes:
-                    for o in okoptions:
-                        if opts.get(o):
-                            break
-                    else:
-                        raise error.Abort(_('no updates found'))
-                updates = [repo[n] for n in updatenodes]
-
-                # perform amend
-                if opts.get('edit'):
-                    opts['force_editor'] = True
-                newid, created = rewrite(repo, old, updates, head,
-                                         [old.p1().node(), old.p2().node()], opts)
-
-                if newid != old.node():
-                    createmarkers(repo, [(old, (repo[newid],))])
-                if tempid is not None:
-                    createmarkers(repo, [(repo[tempid], ())])
-                if created:
-                    # reroute the working copy parent to the new changeset
-                    phases.retractboundary(repo, oldphase, [newid])
-                    repo.dirstate.setparents(newid, node.nullid)
-                else:
-                    # rewrite() recreated an existing revision, discard
-                    # the intermediate revision if any. No need to update
-                    # phases or parents.
-                    # XXX: need another message in collapse case.
-                    tr.close()
-                    raise error.Abort(_('no updates found'))
-                tr.close()
-            finally:
-                tr.release()
-        finally:
-            wlock.release()
-    finally:
-        lock.release()
+    opts = opts.copy()
+    edit = opts.pop('edit', False)
+    opts['amend'] = True
+    if not (edit or opts['message']):
+        opts['message'] = repo['.'].description()
+    _alias, commitcmd = cmdutil.findcmd('commit', commands.table)
+    return commitcmd[0](ui, repo, *pats, **opts)
 
 def _commitfiltered(repo, ctx, match):
     """Recommit ctx with changed files not in match. Return the new
@@ -1793,7 +1730,7 @@
     except KeyError:
         raise error.Abort(_('evolution extension requires rebase extension.'))
 
-    for cmd in ['amend', 'kill', 'uncommit', 'touch', 'fold']:
+    for cmd in ['kill', 'uncommit', 'touch', 'fold']:
         entry = extensions.wrapcommand(cmdtable, cmd,
                                        warnobserrors)