changeset 3866:de42d00d6ee2

rewind: use rewinded parent when creating multiple changesets Use use the rewinded parent instead of creating orphans based on identical, but obsolete, changesets.
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Sun, 17 Jun 2018 02:03:03 +0200
parents b945f2dae587
children 339b05c3e929
files hgext3rd/evolve/rewind.py tests/test-rewind.t
diffstat 2 files changed, 18 insertions(+), 28 deletions(-) [+]
line wrap: on
line diff
--- a/hgext3rd/evolve/rewind.py	Sun Jun 17 00:22:31 2018 +0200
+++ b/hgext3rd/evolve/rewind.py	Sun Jun 17 02:03:03 2018 +0200
@@ -73,9 +73,9 @@
 
         # Check that we can rewind these changesets
         with repo.transaction('rewind'):
-            for rev in rewinded:
+            for rev in sorted(rewinded):
                 ctx = unfi[rev]
-                rewindmap[ctx.node()] = _revive_revision(unfi, rev)
+                rewindmap[ctx.node()] = _revive_revision(unfi, rev, rewindmap)
 
             relationships = []
             cl = unfi.changelog
@@ -97,7 +97,7 @@
     if update_target is not None:
         ui.status(_('working directory is now at %s\n') % repo['.'])
 
-def _revive_revision(unfi, rev):
+def _revive_revision(unfi, rev, rewindmap):
     """rewind a single revision rev.
     """
     ctx = unfi[rev]
@@ -113,7 +113,9 @@
     extra['__rewind-hash__'] = hashlib.sha256(noise).hexdigest()
 
     p1 = ctx.p1().node()
+    p1 = rewindmap.get(p1, p1)
     p2 = ctx.p2().node()
+    p2 = rewindmap.get(p2, p2)
 
     extradict = {'extra': extra}
 
--- a/tests/test-rewind.t	Sun Jun 17 00:22:31 2018 +0200
+++ b/tests/test-rewind.t	Sun Jun 17 02:03:03 2018 +0200
@@ -577,35 +577,32 @@
 
   $ echo 'default-date = 3 0' >> $HGRCPATH
 
-note: the orphan creation is unfortunate, and should be fixed later.
-
 Actual Rewind
 `````````````
 
   $ hg rewind --to '9576e80d6851+a0316c4c5417' --hidden
-  1 new orphan changesets
   rewinded to 2 changesets
   (1 changesets obsoleted)
-  working directory is now at d3bb9de71a17
+  working directory is now at 85be7b94f69e
   $ hg debugobsolete
   49fb7d900906b0a3d329e90da4dcb0a7582d3b6e a0316c4c54179357e71d068fb8884678ebc7c351 9576e80d6851ce79cd535e2dc5fa01b444d89a39 0 (Thu Jan 01 00:00:02 1970 +0000) {'ef1': '12', 'operation': 'split', 'user': 'test'}
   49fb7d900906b0a3d329e90da4dcb0a7582d3b6e 4535d0af405c1bf35f37b35f26ec6f9acfa6fe0b 4 (Thu Jan 01 00:00:02 1970 +0000) {'ef1': '2', 'operation': 'rewind', 'user': 'test'}
   9576e80d6851ce79cd535e2dc5fa01b444d89a39 4535d0af405c1bf35f37b35f26ec6f9acfa6fe0b 0 (Thu Jan 01 00:00:02 1970 +0000) {'ef1': '14', 'operation': 'rewind', 'user': 'test'}
   a0316c4c54179357e71d068fb8884678ebc7c351 4535d0af405c1bf35f37b35f26ec6f9acfa6fe0b 0 (Thu Jan 01 00:00:02 1970 +0000) {'ef1': '10', 'operation': 'rewind', 'user': 'test'}
-  9576e80d6851ce79cd535e2dc5fa01b444d89a39 d3bb9de71a17a85301bce02abc13114d2bc11615 4 (Thu Jan 01 00:00:03 1970 +0000) {'ef1': '34', 'operation': 'rewind', 'user': 'test'}
   a0316c4c54179357e71d068fb8884678ebc7c351 73a1ac2e570de1f33bbea7d8260b00d5af1d30a7 4 (Thu Jan 01 00:00:03 1970 +0000) {'ef1': '34', 'operation': 'rewind', 'user': 'test'}
-  4535d0af405c1bf35f37b35f26ec6f9acfa6fe0b 73a1ac2e570de1f33bbea7d8260b00d5af1d30a7 d3bb9de71a17a85301bce02abc13114d2bc11615 0 (Thu Jan 01 00:00:03 1970 +0000) {'ef1': '46', 'operation': 'rewind', 'user': 'test'}
+  9576e80d6851ce79cd535e2dc5fa01b444d89a39 85be7b94f69e936d6f0fc52118211da82fe4e838 4 (Thu Jan 01 00:00:03 1970 +0000) {'ef1': '38', 'operation': 'rewind', 'user': 'test'}
+  4535d0af405c1bf35f37b35f26ec6f9acfa6fe0b 73a1ac2e570de1f33bbea7d8260b00d5af1d30a7 85be7b94f69e936d6f0fc52118211da82fe4e838 0 (Thu Jan 01 00:00:03 1970 +0000) {'ef1': '46', 'operation': 'rewind', 'user': 'test'}
   $ hg obslog -r -2:
-  o    73a1ac2e570d (8) c_CD0
+  o    73a1ac2e570d (7) c_CD0
   |\
-  +---@  d3bb9de71a17 (7) c_CD0
+  +---@  85be7b94f69e (8) c_CD0
   | | |
   x---+  4535d0af405c (6) c_CD0
-  |\| |    rewritten(meta, date, parent, content) as 73a1ac2e570d, d3bb9de71a17 using rewind by test (Thu Jan 01 00:00:03 1970 +0000)
+  |\| |    rewritten(meta, date, parent, content) as 73a1ac2e570d, 85be7b94f69e using rewind by test (Thu Jan 01 00:00:03 1970 +0000)
   | | |
   +---x  9576e80d6851 (5) c_CD0
   | |      rewritten(meta, parent, content) as 4535d0af405c using rewind by test (Thu Jan 01 00:00:02 1970 +0000)
-  | |      rewritten(meta, date) as d3bb9de71a17 using rewind by test (Thu Jan 01 00:00:03 1970 +0000)
+  | |      rewritten(meta, date, parent) as 85be7b94f69e using rewind by test (Thu Jan 01 00:00:03 1970 +0000)
   | |
   | x  a0316c4c5417 (4) c_CD0
   |/     rewritten(meta, content) as 4535d0af405c using rewind by test (Thu Jan 01 00:00:02 1970 +0000)
@@ -616,26 +613,17 @@
        rewritten(parent, content) as 9576e80d6851, a0316c4c5417 using split by test (Thu Jan 01 00:00:02 1970 +0000)
   
   $ hg log -G
-  o  changeset:   8:73a1ac2e570d
+  @  changeset:   8:85be7b94f69e
   |  tag:         tip
-  |  parent:      2:7e594302a05d
   |  user:        test
   |  date:        Thu Jan 01 00:00:03 1970 +0000
   |  summary:     c_CD0
   |
-  | @  changeset:   7:d3bb9de71a17
-  | |  parent:      4:a0316c4c5417
-  | |  user:        test
-  | |  date:        Thu Jan 01 00:00:03 1970 +0000
-  | |  instability: orphan
-  | |  summary:     c_CD0
-  | |
-  | x  changeset:   4:a0316c4c5417
-  |/   parent:      2:7e594302a05d
-  |    user:        test
-  |    date:        Thu Jan 01 00:00:02 1970 +0000
-  |    obsolete:    split using rewind as 8:73a1ac2e570d, 7:d3bb9de71a17
-  |    summary:     c_CD0
+  o  changeset:   7:73a1ac2e570d
+  |  parent:      2:7e594302a05d
+  |  user:        test
+  |  date:        Thu Jan 01 00:00:03 1970 +0000
+  |  summary:     c_CD0
   |
   o  changeset:   2:7e594302a05d
   |  user:        test