Pierre-Yves David avatar Pierre-Yves David committed dba3ed9

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.

Comments (0)

Files changed (5)

         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()
 
                     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])
                     # 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'))

tests/test-amend.t

   (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
   $ 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

tests/test-evolve.t

   @  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

tests/test-stabilize-order.t

   --- 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]

tests/test-stabilize-result.t

   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
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.