Mercurial > hg-stable
comparison tests/test-rebase-obsolete.t @ 33807:0975506120fb
rebase: rewrite core algorithm (issue5578) (issue5630)
"defineparents" is the core algorithm of rebase. The old code has too many
tech debts (like outdated comments, confusing assertions, etc) and is very
error-prone to be improved. This patch rewrites "defineparents" to make the
code easier to reason about, and solve a bunch of issues, including:
- Assertion error: no base found (demonstrated by D212, issue5578)
- Asymmetric result (demonstrated by D211, "F with one parent")
- Wrong new parent (demonstrated by D262, "C':A'A'")
- "revlog index out of range" (demonstrated by D262, issue5630)
- "nothing to merge" (demonstrated by D262)
As a side effect, merge base decision has been made more solid - rebase now
prints out explicitly what could go wrong when it cannot find a unique
suitable merge base.
.. fix:: Issue 5578, Issue 5630
Core rebase algorithm has been rewritten to be more robust.
Differential Revision: https://phab.mercurial-scm.org/D21
author | Jun Wu <quark@fb.com> |
---|---|
date | Thu, 10 Aug 2017 21:30:31 -0700 |
parents | f078d7358e90 |
children | 19f495fef0a3 |
comparison
equal
deleted
inserted
replaced
33806:f7d6978a4da9 | 33807:0975506120fb |
---|---|
486 > B D G | 486 > B D G |
487 > \|/ | 487 > \|/ |
488 > A | 488 > A |
489 > EOF | 489 > EOF |
490 | 490 |
491 BROKEN: This raises an exception | 491 $ hg rebase -d G -r 'B + D + F' |
492 $ hg rebase -d G -r 'B + D + F' 2>&1 | grep '^AssertionError' | 492 rebasing 1:112478962961 "B" (B) |
493 AssertionError: no base found to rebase on (defineparents called wrong) | 493 rebasing 2:b18e25de2cf5 "D" (D) |
494 not rebasing ignored 4:26805aba1e60 "C" (C) | |
495 not rebasing ignored 5:4b61ff5c62e2 "E" (E) | |
496 rebasing 6:f15c3adaf214 "F" (F tip) | |
497 abort: cannot use revision 6 as base, result would have 3 parents | |
498 [255] | |
494 | 499 |
495 $ cd .. | 500 $ cd .. |
496 | 501 |
497 test on rebase dropping a merge | 502 test on rebase dropping a merge |
498 | 503 |
960 > E D B # replace: E -> B | 965 > E D B # replace: E -> B |
961 > \|/ | 966 > \|/ |
962 > A | 967 > A |
963 > EOF | 968 > EOF |
964 | 969 |
965 BROKEN: Raises an exception | 970 $ hg rebase -d B -s E |
966 $ hg rebase -d B -s E 2>&1 | grep AssertionError: | 971 note: not rebasing 3:7fb047a69f22 "E" (E), already in destination as 1:112478962961 "B" |
967 AssertionError: no base found to rebase on (defineparents called wrong) | 972 rebasing 4:66f1a38021c9 "F" (F tip) |
968 $ hg log -G | 973 $ hg log -G |
969 o 4:66f1a38021c9 F | 974 o 5:aae1787dacee F |
970 |\ | 975 |\ |
971 | x 3:7fb047a69f22 E | 976 | | x 4:66f1a38021c9 F |
972 | | | 977 | |/| |
973 o | 2:b18e25de2cf5 D | 978 | | x 3:7fb047a69f22 E |
974 |/ | 979 | | | |
975 | o 1:112478962961 B | 980 | o | 2:b18e25de2cf5 D |
981 | |/ | |
982 o / 1:112478962961 B | |
976 |/ | 983 |/ |
977 o 0:426bada5c675 A | 984 o 0:426bada5c675 A |
978 | 985 |
979 $ cd .. | 986 $ cd .. |
980 | 987 |
992 > EOF | 999 > EOF |
993 | 1000 |
994 $ hg rebase -d C -s D | 1001 $ hg rebase -d C -s D |
995 note: not rebasing 2:b18e25de2cf5 "D" (D), already in destination as 1:112478962961 "B" | 1002 note: not rebasing 2:b18e25de2cf5 "D" (D), already in destination as 1:112478962961 "B" |
996 rebasing 5:66f1a38021c9 "F" (F tip) | 1003 rebasing 5:66f1a38021c9 "F" (F tip) |
997 BROKEN: not rebased on top of requested destination (C) | 1004 |
998 $ hg log -G | 1005 $ hg log -G |
999 o 6:50e9d60b99c6 F | 1006 o 6:0913febf6439 F |
1000 |\ | 1007 |\ |
1001 | | x 5:66f1a38021c9 F | 1008 +---x 5:66f1a38021c9 F |
1002 | |/| | 1009 | | | |
1003 +-----o 4:26805aba1e60 C | 1010 | o | 4:26805aba1e60 C |
1004 | | | | 1011 | | | |
1005 | o | 3:7fb047a69f22 E | 1012 o | | 3:7fb047a69f22 E |
1006 | | | | 1013 | | | |
1007 | | x 2:b18e25de2cf5 D | 1014 +---x 2:b18e25de2cf5 D |
1008 | |/ | 1015 | | |
1009 o | 1:112478962961 B | 1016 | o 1:112478962961 B |
1010 |/ | 1017 |/ |
1011 o 0:426bada5c675 A | 1018 o 0:426bada5c675 A |
1012 | 1019 |
1013 $ cd .. | 1020 $ cd .. |
1014 | 1021 |
1023 > E D B # replace: E -> B | 1030 > E D B # replace: E -> B |
1024 > \|/ | 1031 > \|/ |
1025 > A | 1032 > A |
1026 > EOF | 1033 > EOF |
1027 | 1034 |
1028 BROKEN: Raises an exception | 1035 $ hg rebase -d C -s E |
1029 $ hg rebase -d C -s E 2>&1 | grep AssertionError: | 1036 note: not rebasing 3:7fb047a69f22 "E" (E), already in destination as 1:112478962961 "B" |
1030 AssertionError: no base found to rebase on (defineparents called wrong) | 1037 rebasing 5:66f1a38021c9 "F" (F tip) |
1031 $ hg log -G | 1038 $ hg log -G |
1032 o 5:66f1a38021c9 F | 1039 o 6:c6ab0cc6d220 F |
1033 |\ | 1040 |\ |
1034 | | o 4:26805aba1e60 C | 1041 +---x 5:66f1a38021c9 F |
1035 | | | | 1042 | | | |
1036 | x | 3:7fb047a69f22 E | 1043 | o | 4:26805aba1e60 C |
1037 | | | | 1044 | | | |
1038 o | | 2:b18e25de2cf5 D | 1045 | | x 3:7fb047a69f22 E |
1039 |/ / | 1046 | | | |
1040 | o 1:112478962961 B | 1047 o---+ 2:b18e25de2cf5 D |
1048 / / | |
1049 o / 1:112478962961 B | |
1041 |/ | 1050 |/ |
1042 o 0:426bada5c675 A | 1051 o 0:426bada5c675 A |
1043 | 1052 |
1044 $ cd .. | 1053 $ cd .. |
1045 | 1054 |
1058 | 1067 |
1059 $ hg rebase -d C -b F | 1068 $ hg rebase -d C -b F |
1060 rebasing 2:b18e25de2cf5 "D" (D) | 1069 rebasing 2:b18e25de2cf5 "D" (D) |
1061 note: not rebasing 3:7fb047a69f22 "E" (E), already in destination as 1:112478962961 "B" | 1070 note: not rebasing 3:7fb047a69f22 "E" (E), already in destination as 1:112478962961 "B" |
1062 rebasing 5:66f1a38021c9 "F" (F tip) | 1071 rebasing 5:66f1a38021c9 "F" (F tip) |
1072 warning: rebasing 5:66f1a38021c9 may include unwanted changes from 3:7fb047a69f22 | |
1063 $ hg log -G | 1073 $ hg log -G |
1064 o 7:9ed45af61fa0 F | 1074 o 7:9ed45af61fa0 F |
1065 | | 1075 | |
1066 o 6:8f47515dda15 D | 1076 o 6:8f47515dda15 D |
1067 | | 1077 | |
1094 | 1104 |
1095 $ hg rebase -d C -b F | 1105 $ hg rebase -d C -b F |
1096 note: not rebasing 2:b18e25de2cf5 "D" (D), already in destination as 1:112478962961 "B" | 1106 note: not rebasing 2:b18e25de2cf5 "D" (D), already in destination as 1:112478962961 "B" |
1097 rebasing 3:7fb047a69f22 "E" (E) | 1107 rebasing 3:7fb047a69f22 "E" (E) |
1098 rebasing 5:66f1a38021c9 "F" (F tip) | 1108 rebasing 5:66f1a38021c9 "F" (F tip) |
1099 BROKEN: This should have resulted in a rebased F with one parent, just like in | 1109 warning: rebasing 5:66f1a38021c9 may include unwanted changes from 2:b18e25de2cf5 |
1100 the test case above | 1110 |
1101 $ hg log -G | 1111 $ hg log -G |
1102 o 7:c1e6f26e339d F | 1112 o 7:502540f44880 F |
1103 |\ | 1113 | |
1104 | o 6:533690786a86 E | 1114 o 6:533690786a86 E |
1105 |/ | 1115 | |
1106 | x 5:66f1a38021c9 F | 1116 | x 5:66f1a38021c9 F |
1107 | |\ | 1117 | |\ |
1108 o | | 4:26805aba1e60 C | 1118 o | | 4:26805aba1e60 C |
1109 | | | | 1119 | | | |
1110 | | x 3:7fb047a69f22 E | 1120 | | x 3:7fb047a69f22 E |