Mercurial > hg
changeset 18444:55aff0c2b73c
rebase: do not invent successor to skipped changeset
When rebase results in an empty a changeset it is "skipped" and no related
changeset is created at all. When we added obsolescence support to rebase (in
fc2a6114f0a0) it seemed a good idea to use its parent successor as the
successors for such dropped changesets. (see old version of the altered test).
This option was chosen because it seems a good way to hint about were the
dropped changeset "intended" to be. Such hint would have been used by automatic
evolution mechanism to rebase potential unstable children.
However, field testing of this version are not conclusive. It very often leads
to the creation of (totally unfounded) evolution divergence. This changeset
changes this behavior and mark skipped changesets as pruned (obsolete without
successors). This prevents the issue and seems semantically better probably a
win for obsolescence reading tool.
See example bellow for details:
User Babar has five changesets of interest:
- O, its current base of development.
- U, the new upstream
- A and C, some development changesets
- B another development changeset independent from A
O - A - B - C
\
U
Babar decides that B is more critical than the A and C and rebase it first
$ hg rebase --rev B --dest U
B is now obsolete (in lower case bellow). Rebase result, B', is its
successors.(note, C is unstable)
O - A - b - C
\
U - B'
Babar is now done with B', and want to rebase the rest of its history:
$ hg rebase --source A --dest B'
hg rebase process A, B and C. B is skipped as all its changes are already contained
in B'.
O - U - B' - A' - C'
Babar have the expected result graph wise, obsolescence marker are as follow:
B -> B' (from first rebase)
A -> A' (from second rebase)
C -> C' (from second rebase)
B -> ?? (from second rebase)
Before this changeset, the last marker is `B -> A'`. This cause two issues:
- This is semantically wrong. B have nothing to do with A'
- B has now two successors sets: (B',) and (A',). We detect a divergent
rewriting. The B' and A' are reported as "divergent" to Babar, confusion
ensues. In addition such divergent situation (divergent changeset are children
to each other) is tricky to solve.
With this changeset the last marker is `B -> ΓΈ`:
- This is semantically better.
- B has a single successors set (B',)
This scenario is added to the tests suite.
author | Pierre-Yves David <pierre-yves.david@ens-lyon.org> |
---|---|
date | Fri, 18 Jan 2013 14:15:32 +0100 |
parents | 64848f7fb764 |
children | 4d92e2d75cff |
files | hgext/rebase.py tests/test-rebase-obsolete.t |
diffstat | 2 files changed, 68 insertions(+), 8 deletions(-) [+] |
line wrap: on
line diff
--- a/hgext/rebase.py Thu Jan 17 17:51:30 2013 +0100 +++ b/hgext/rebase.py Fri Jan 18 14:15:32 2013 +0100 @@ -312,7 +312,7 @@ collapsedas = None if collapsef: collapsedas = newrev - clearrebased(ui, repo, state, collapsedas) + clearrebased(ui, repo, state, skipped, collapsedas) if currentbookmarks: updatebookmarks(repo, nstate, currentbookmarks, **opts) @@ -660,7 +660,7 @@ state[r] = nullmerge return repo['.'].rev(), dest.rev(), state -def clearrebased(ui, repo, state, collapsedas=None): +def clearrebased(ui, repo, state, skipped, collapsedas=None): """dispose of rebased revision at the end of the rebase If `collapsedas` is not None, the rebase was a collapse whose result if the @@ -669,9 +669,13 @@ markers = [] for rev, newrev in sorted(state.items()): if newrev >= 0: - if collapsedas is not None: - newrev = collapsedas - markers.append((repo[rev], (repo[newrev],))) + if rev in skipped: + succs = () + elif collapsedas is not None: + succs = (repo[collapsedas],) + else: + succs = (repo[newrev],) + markers.append((repo[rev], succs)) if markers: obsolete.createmarkers(repo, markers) else:
--- a/tests/test-rebase-obsolete.t Thu Jan 17 17:51:30 2013 +0100 +++ b/tests/test-rebase-obsolete.t Fri Jan 18 14:15:32 2013 +0100 @@ -166,10 +166,65 @@ o 0:cd010b8cd998 A $ hg debugobsolete - 42ccdea3bb16d28e1848c95fe2e44c000f3f21b1 08483444fef91d6224f6655ee586a65d263ad34c 0 {'date': '*', 'user': 'test'} (glob) + 42ccdea3bb16d28e1848c95fe2e44c000f3f21b1 0 {'date': '*', 'user': 'test'} (glob) + 5fddd98957c8a54a4d436dfe1da9d87f21a1b97b 5ae4c968c6aca831df823664e706c9d4aa34473d 0 {'date': '*', 'user': 'test'} (glob) + 32af7686d403cf45b5d95f2d70cebea587ac806a 0 {'date': '*', 'user': 'test'} (glob) + + +More complex case were part of the rebase set were already rebased + + $ hg rebase --rev 'desc(D)' --dest 'desc(H)' + $ hg debugobsolete + 42ccdea3bb16d28e1848c95fe2e44c000f3f21b1 0 {'date': '*', 'user': 'test'} (glob) 5fddd98957c8a54a4d436dfe1da9d87f21a1b97b 5ae4c968c6aca831df823664e706c9d4aa34473d 0 {'date': '*', 'user': 'test'} (glob) - 32af7686d403cf45b5d95f2d70cebea587ac806a 5ae4c968c6aca831df823664e706c9d4aa34473d 0 {'date': '*', 'user': 'test'} (glob) - + 32af7686d403cf45b5d95f2d70cebea587ac806a 0 {'date': '*', 'user': 'test'} (glob) + 08483444fef91d6224f6655ee586a65d263ad34c cbc07f26687521cecfc9a141bf5ecfc0fd2b8531 0 {'date': '* *', 'user': 'test'} (glob) + $ hg log -G + @ 11:cbc07f266875 D + | + | o 10:5ae4c968c6ac C + | | + | x 9:08483444fef9 D + | | + | o 8:8877864f1edb B + | | + o | 7:02de42196ebe H + | | + | o 6:eea13746799a G + |/| + o | 5:24b6387c8c8c F + | | + | o 4:9520eea781bc E + |/ + o 0:cd010b8cd998 A + + $ hg rebase --source 'desc(B)' --dest 'tip' + $ hg debugobsolete + 42ccdea3bb16d28e1848c95fe2e44c000f3f21b1 0 {'date': '* *', 'user': 'test'} (glob) + 5fddd98957c8a54a4d436dfe1da9d87f21a1b97b 5ae4c968c6aca831df823664e706c9d4aa34473d 0 {'date': '* *', 'user': 'test'} (glob) + 32af7686d403cf45b5d95f2d70cebea587ac806a 0 {'date': '* *', 'user': 'test'} (glob) + 08483444fef91d6224f6655ee586a65d263ad34c cbc07f26687521cecfc9a141bf5ecfc0fd2b8531 0 {'date': '* *', 'user': 'test'} (glob) + 8877864f1edb05d0e07dc4ba77b67a80a7b86672 b1861c79d66ec3aa1b607ac3c9fb819e38b12238 0 {'date': '* *', 'user': 'test'} (glob) + 08483444fef91d6224f6655ee586a65d263ad34c 0 {'date': '* *', 'user': 'test'} (glob) + 5ae4c968c6aca831df823664e706c9d4aa34473d dd4be135457a404ce5541de427ae1d98a28f4acd 0 {'date': '* *', 'user': 'test'} (glob) + $ hg log --rev 'divergent()' + $ hg log -G + @ 13:dd4be135457a C + | + o 12:b1861c79d66e B + | + o 11:cbc07f266875 D + | + o 7:02de42196ebe H + | + | o 6:eea13746799a G + |/| + o | 5:24b6387c8c8c F + | | + | o 4:9520eea781bc E + |/ + o 0:cd010b8cd998 A + $ cd .. @@ -329,3 +384,4 @@ |/ o 0:cd010b8cd998 A + $ cd ..