diff mercurial/cmdutil.py @ 17475:63e45aee46d4

amend: add obsolete support If the obsolete feature is enabled, `hg commit --amend` marks a changeset as obsolete instead of stripping it.
author Pierre-Yves David <pierre-yves.david@logilab.fr>
date Tue, 11 Sep 2012 00:12:07 +0200
parents 9732473aa24b
children 8575f4a2126e
line wrap: on
line diff
--- a/mercurial/cmdutil.py	Fri Aug 24 21:16:23 2012 +0200
+++ b/mercurial/cmdutil.py	Tue Sep 11 00:12:07 2012 +0200
@@ -10,7 +10,7 @@
 import os, sys, errno, re, tempfile
 import util, scmutil, templater, patch, error, templatekw, revlog, copies
 import match as matchmod
-import subrepo, context, repair, bookmarks, graphmod, revset, phases
+import subrepo, context, repair, bookmarks, graphmod, revset, phases, obsolete
 import lock as lockmod
 
 def parsealiases(cmd):
@@ -1697,12 +1697,20 @@
                         repo._bookmarks[bm] = newid
                     bookmarks.write(repo)
             #commit the whole amend process
+            if obsolete._enabled and newid != old.node():
+                # mark the new changeset as successor of the rewritten one
+                new = repo[newid]
+                obs = [(old, (new,))]
+                if node:
+                    obs.append((ctx, (new,)))
+
+                obsolete.createmarkers(repo, obs)
             tr.close()
         finally:
             tr.release()
-        # Strip the intermediate commit (if there was one) and the amended
-        # commit
-        if newid != old.node():
+        if (not obsolete._enabled) and newid != old.node():
+            # Strip the intermediate commit (if there was one) and the amended
+            # commit
             if node:
                 ui.note(_('stripping intermediate changeset %s\n') % ctx)
             ui.note(_('stripping amended changeset %s\n') % old)