diff hgext/evolve.py @ 699:dba3ed9f2c4f stable

amend: prune replacement commit without sucessors This align with the core behavior of `commit --amend`. All user of rewrite are not responsible for creating their own marker.
author Pierre-Yves David <pierre-yves.david@ens-lyon.org>
date Fri, 08 Feb 2013 21:43:00 +0000
parents 121e2d265e85
children f752089479ce
line wrap: on
line diff
--- a/hgext/evolve.py	Fri Feb 08 21:27:48 2013 +0000
+++ b/hgext/evolve.py	Fri Feb 08 21:43:00 2013 +0000
@@ -753,17 +753,7 @@
         newid = repo.commitctx(new)
         new = repo[newid]
         created = len(repo) != revcount
-        if created:
-            updatebookmarks(newid)
-            # add evolution metadata
-            markers = [(u, (new,)) for u in updates]
-            markers.append((old, (new,)))
-            createmarkers(repo, markers)
-        else:
-            # newid is an existing revision. It could make sense to
-            # replace revisions with existing ones but probably not by
-            # default.
-            pass
+        updatebookmarks(newid)
     finally:
         wlock.release()
 
@@ -1387,6 +1377,11 @@
                     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])
@@ -1395,8 +1390,6 @@
                     # rewrite() recreated an existing revision, discard
                     # the intermediate revision if any. No need to update
                     # phases or parents.
-                    if tempid is not None:
-                        createmarkers(repo, [(repo[tempid], ())])
                     # XXX: need another message in collapse case.
                     tr.close()
                     raise error.Abort(_('no updates found'))