evolution: add a --new argument for kill
authorPierre-Yves David <pierre-yves.david@logilab.fr>
Wed, 11 Jan 2012 17:01:06 +0100
changeset 130 b70fadbccc2a
parent 129 3ad25876ee68
child 131 3124889cad55
evolution: add a --new argument for kill
hgext/evolution.py
--- a/hgext/evolution.py	Tue Jan 10 19:52:44 2012 +0100
+++ b/hgext/evolution.py	Wed Jan 11 17:01:06 2012 +0100
@@ -222,9 +222,11 @@
 
 
 @command('^kill',
-    [],
+    [
+    ('n', 'new', [], _("New changeset that justify this one to be killed"))
+    ],
     '<revs>')
-def kill(ui, repo, *revs):
+def kill(ui, repo, *revs, **opts):
     """mark a changeset as obsolete
 
     This update the parent directory to a not-killed parent if the current
@@ -236,9 +238,16 @@
     """
     wlock = repo.wlock()
     try:
+        new = opts['new']
         targetnodes = set(noderange(repo, revs))
+        if not new:
+            new = [node.nullid]
         for n in targetnodes:
-            repo.addobsolete(node.nullid, n)
+            if not repo[n].mutable():
+                ui.warn(_("Can't kill immutable changeset %s") % repo[n])
+            else:
+                for ne in new:
+                    repo.addobsolete(ne, n)
         # update to an unkilled parent
         wdp = repo['.']
         newnode = wdp