amend: prune replacement commit without sucessors stable
authorPierre-Yves David <pierre-yves.david@ens-lyon.org>
Fri, 08 Feb 2013 21:43:00 +0000
branchstable
changeset 699 dba3ed9f2c4f
parent 698 b21437d19ea2
child 700 ebcfd72e7609
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.
hgext/evolve.py
tests/test-amend.t
tests/test-evolve.t
tests/test-stabilize-order.t
tests/test-stabilize-result.t
--- 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'))
--- a/tests/test-amend.t	Fri Feb 08 21:27:48 2013 +0000
+++ b/tests/test-amend.t	Fri Feb 08 21:43:00 2013 +0000
@@ -24,8 +24,8 @@
   (branches are permanent and global, did you want a bookmark?)
   $ hg amend
   $ hg debugobsolete
-  bd19cbe78fbfbd87eb33420c63986fe5f3154f2c a34b93d251e49c93d5685ebacad785c73a7e8605 0 {'date': '* *', 'user': 'test'} (glob)
   07f4944404050f47db2e5c5071e0e84e7a27bba9 a34b93d251e49c93d5685ebacad785c73a7e8605 0 {'date': '* *', 'user': 'test'} (glob)
+  bd19cbe78fbfbd87eb33420c63986fe5f3154f2c 0 {'date': '* *', 'user': 'test'} (glob)
   $ hg branch
   foo
   $ hg branches
@@ -69,8 +69,8 @@
   $ hg pdiff
   $ hg ci -m reseta
   $ hg debugobsolete
-  bd19cbe78fbfbd87eb33420c63986fe5f3154f2c a34b93d251e49c93d5685ebacad785c73a7e8605 0 {'date': '* *', 'user': 'test'} (glob)
   07f4944404050f47db2e5c5071e0e84e7a27bba9 a34b93d251e49c93d5685ebacad785c73a7e8605 0 {'date': '* *', 'user': 'test'} (glob)
+  bd19cbe78fbfbd87eb33420c63986fe5f3154f2c 0 {'date': '* *', 'user': 'test'} (glob)
   $ hg phase 2
   2: draft
   $ glog
--- a/tests/test-evolve.t	Fri Feb 08 21:27:48 2013 +0000
+++ b/tests/test-evolve.t	Fri Feb 08 21:43:00 2013 +0000
@@ -265,10 +265,10 @@
   @  0:e55e0562ee93@default(public) base
   
   $ hg debugobsolete
-  524e478d4811d405c8771e4c441de4483bdf8b33 f8111a076f0975cbecb336e2bd3411be22b673fb 0 {'date': '* *', 'user': 'test'} (glob)
   7b36850622b2fd159fa30a4fb2a1edd2043b4a14 f8111a076f0975cbecb336e2bd3411be22b673fb 0 {'date': '* *', 'user': 'test'} (glob)
-  e416e48b27428695d00c2a2cc4a0b9619482e63f 23409eba69a0986e90cd42252852c1e6da97af5b 0 {'date': '* *', 'user': 'test'} (glob)
+  524e478d4811d405c8771e4c441de4483bdf8b33 0 {'date': '* *', 'user': 'test'} (glob)
   568a468b60fc99a42d5d4ddbe181caff1eef308d 23409eba69a0986e90cd42252852c1e6da97af5b 0 {'date': '* *', 'user': 'test'} (glob)
+  e416e48b27428695d00c2a2cc4a0b9619482e63f 0 {'date': '* *', 'user': 'test'} (glob)
   $ hg evolve
   move:[4] another feature
   atop:[6] a nifty feature
--- a/tests/test-stabilize-order.t	Fri Feb 08 21:27:48 2013 +0000
+++ b/tests/test-stabilize-order.t	Fri Feb 08 21:43:00 2013 +0000
@@ -102,8 +102,8 @@
   --- successors.old* (glob)
   +++ successors.new* (glob)
   @@ -3,3 +3,4 @@
-   3a4a591493f80708e46f2bf6d3b4debfad8ff91e f5ff10856e5ab3c8dc420b9c11460e6832a3b78c 0 {'date': '* *', 'user': 'test'} (glob)
    93418d2c0979643ad446f621195e78720edb05b4 f5ff10856e5ab3c8dc420b9c11460e6832a3b78c 0 {'date': '* *', 'user': 'test'} (glob)
+   3a4a591493f80708e46f2bf6d3b4debfad8ff91e 0 {'date': '* *', 'user': 'test'} (glob)
    ab8cbb6d87ff3ab5526735a051cba6b63f3d6775 6bf44048e43f830accbf7d2bd7bc252ad7a3b99c 0 {'date': '* *', 'user': 'test'} (glob)
   +7a7552255fb5f8bd745e46fba6f0ca633a4dd716 5e819fbb0d278117c0a83b7f6f6486689732cfb2 0 {'date': '* *', 'user': 'test'} (glob)
   [1]
--- a/tests/test-stabilize-result.t	Fri Feb 08 21:27:48 2013 +0000
+++ b/tests/test-stabilize-result.t	Fri Feb 08 21:43:00 2013 +0000
@@ -45,8 +45,8 @@
   o  0:07f494440405@default(draft) bk:[] adda
   
   $ hg debugobsolete
-  41ad4fe8c79565a06c89f032ef0937b3cbd68a04 1447e1c4828d2347df8f858aa041305fa4cf7db1 0 {'date': '* *', 'user': 'test'} (glob)
   102a90ea7b4a3361e4082ed620918c261189a36a 1447e1c4828d2347df8f858aa041305fa4cf7db1 0 {'date': '* *', 'user': 'test'} (glob)
+  41ad4fe8c79565a06c89f032ef0937b3cbd68a04 0 {'date': '* *', 'user': 'test'} (glob)
   cce2c55b896511e0b6e04173c9450ba822ebc740 0 {'date': '* *', 'user': 'test'} (glob)
 
 Test evolve with conflict