# HG changeset patch # User Anton Shestakov # Date 1602420602 -28800 # Node ID ba8bc1b0acd2c85cff7d75f021d95c701621d2f9 # Parent 0cb1718ed95c0e835a842c11de06eb43ee522bd0 rewind: actually track folds using fold-* metadata in obsmarkers Switching "(%d changesets obsoleted)" to using successorsmap because it's the source of items in relationships (and the latter variable now can have less items than before this patch). diff -r 0cb1718ed95c -r ba8bc1b0acd2 CHANGELOG --- a/CHANGELOG Fri Sep 25 21:47:30 2020 -0700 +++ b/CHANGELOG Sun Oct 11 20:50:02 2020 +0800 @@ -8,6 +8,7 @@ * metaedit: update bookmark location when applicable * evolve: fix various issues with --continue when solving content-divergence * rewind: add a --dry-run flag + * rewind: properly record rewind of splits as folds * evolve: while resolving conflicts, the evolved node will no longer be a dirstate parent (won't show up in `hg parents` and not as `@` in `hg log -G`, but it will show up as `%` with hg >= 5.4) diff -r 0cb1718ed95c -r ba8bc1b0acd2 hgext3rd/evolve/rewind.py --- a/hgext3rd/evolve/rewind.py Fri Sep 25 21:47:30 2020 -0700 +++ b/hgext3rd/evolve/rewind.py Sun Oct 11 20:50:02 2020 +0800 @@ -10,6 +10,7 @@ obsolete, obsutil, scmutil, + util, ) from mercurial.utils import dateutil @@ -128,6 +129,17 @@ relationships.append(rel) if wctxp.node() == source: update_target = newdest[-1] + # Use this condition as a proxy since the commit we care about + # (b99903534e06) didn't change any signatures. + if util.safehasattr(scmutil, 'nullrev'): + # hg <= 4.7 (b99903534e06) + destmap = util.sortdict() + for src, dest in relationships: + destmap.setdefault(dest, []).append(src) + relationships = [ + (tuple(src), dest) + for dest, src in destmap.items() + ] obsolete.createmarkers(unfi, relationships, operation=b'rewind') if update_target is not None: if opts.get('keep'): @@ -171,8 +183,8 @@ compat.update(repo[update_target]) ui.status(_(b'rewound to %d changesets\n') % len(targets)) - if relationships: - ui.status(_(b'(%d changesets obsoleted)\n') % len(relationships)) + if successorsmap: + ui.status(_(b'(%d changesets obsoleted)\n') % len(successorsmap)) if update_target is not None and not opts.get('keep'): ui.status(_(b'working directory is now at %s\n') % repo[b'.']) diff -r 0cb1718ed95c -r ba8bc1b0acd2 tests/test-rewind.t --- a/tests/test-rewind.t Fri Sep 25 21:47:30 2020 -0700 +++ b/tests/test-rewind.t Sun Oct 11 20:50:02 2020 +0800 @@ -596,18 +596,18 @@ $ 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 4535d0af405c1bf35f37b35f26ec6f9acfa6fe0b 0 (Thu Jan 01 00:00:02 1970 +0000) {'ef1': '14', 'fold-id': 'eeda726b', 'fold-idx': '1', 'fold-size': '2', 'operation': 'rewind', 'user': 'test'} + a0316c4c54179357e71d068fb8884678ebc7c351 4535d0af405c1bf35f37b35f26ec6f9acfa6fe0b 0 (Thu Jan 01 00:00:02 1970 +0000) {'ef1': '10', 'fold-id': 'eeda726b', 'fold-idx': '2', 'fold-size': '2', 'operation': 'rewind', 'user': 'test'} $ hg obslog --no-origin @ 4535d0af405c (6) c_CD0 |\ | \ | |\ | x | 9576e80d6851 (5) c_CD0 - |/ / rewritten(meta, parent, content) as 4535d0af405c using rewind by test (Thu Jan 01 00:00:02 1970 +0000) + |/ / folded(meta, parent, content) as 4535d0af405c using rewind by test (Thu Jan 01 00:00:02 1970 +0000) | | | x a0316c4c5417 (4) c_CD0 - |/ rewritten(meta, content) as 4535d0af405c using rewind by test (Thu Jan 01 00:00:02 1970 +0000) + |/ folded(meta, content) as 4535d0af405c using rewind by test (Thu Jan 01 00:00:02 1970 +0000) | x 49fb7d900906 (3) c_CD0 meta-changed(meta) as 4535d0af405c using rewind by test (Thu Jan 01 00:00:02 1970 +0000) @@ -616,8 +616,7 @@ $ hg obslog @ 4535d0af405c (6) c_CD0 |\ meta-changed(meta) from 49fb7d900906 using rewind by test (Thu Jan 01 00:00:02 1970 +0000) - | | rewritten(meta, parent, content) from 9576e80d6851 using rewind by test (Thu Jan 01 00:00:02 1970 +0000) - | | rewritten(meta, content) from a0316c4c5417 using rewind by test (Thu Jan 01 00:00:02 1970 +0000) + | | folded(meta, parent, content) from 9576e80d6851, a0316c4c5417 using rewind by test (Thu Jan 01 00:00:02 1970 +0000) | | | \ | |\ @@ -687,8 +686,8 @@ $ 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 4535d0af405c1bf35f37b35f26ec6f9acfa6fe0b 0 (Thu Jan 01 00:00:02 1970 +0000) {'ef1': '14', 'fold-id': 'eeda726b', 'fold-idx': '1', 'fold-size': '2', 'operation': 'rewind', 'user': 'test'} + a0316c4c54179357e71d068fb8884678ebc7c351 4535d0af405c1bf35f37b35f26ec6f9acfa6fe0b 0 (Thu Jan 01 00:00:02 1970 +0000) {'ef1': '10', 'fold-id': 'eeda726b', 'fold-idx': '2', 'fold-size': '2', 'operation': 'rewind', 'user': 'test'} a0316c4c54179357e71d068fb8884678ebc7c351 e76375de0bfc9c59bdd91067c901f3eed7d6c8fe 4 (Thu Jan 01 00:00:03 1970 +0000) {'ef1': '2', 'operation': 'rewind', 'user': 'test'} 9576e80d6851ce79cd535e2dc5fa01b444d89a39 95d72d892df7fec59107e10914c5729bdf03665f 4 (Thu Jan 01 00:00:03 1970 +0000) {'ef1': '6', 'operation': 'rewind', 'user': 'test'} 4535d0af405c1bf35f37b35f26ec6f9acfa6fe0b e76375de0bfc9c59bdd91067c901f3eed7d6c8fe 95d72d892df7fec59107e10914c5729bdf03665f 0 (Thu Jan 01 00:00:03 1970 +0000) {'ef1': '14', 'operation': 'rewind', 'user': 'test'} @@ -701,11 +700,11 @@ |\| | split(meta, parent, content) as 95d72d892df7, e76375de0bfc 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) + |/ / folded(meta, parent, content) as 4535d0af405c using rewind by test (Thu Jan 01 00:00:02 1970 +0000) | | rewritten(meta, parent) as 95d72d892df7 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) + |/ folded(meta, content) as 4535d0af405c using rewind by test (Thu Jan 01 00:00:02 1970 +0000) | meta-changed(meta) as e76375de0bfc using rewind by test (Thu Jan 01 00:00:03 1970 +0000) | x 49fb7d900906 (3) c_CD0