Mercurial > hg
comparison tests/test-branches.t @ 46254:c4b792fa109e
branchmap: avoid ancestor computations in absence of non-continous branches
The branchhead computation is one of the more heavy operations for
bigger repositories as it has to scan all changesets and potentially
involves the expensive computation of the ancestor sets. Redo the
computation to handle the common cases directly and use tighter
conditions for when the ancestor scan is necessary. Most importantly,
avoid it completely if the non-continous branches are processed in one
update as seen in the initial computation after a clone.
For the Mercurial repository, it gives a small 2-3% performance boost.
For the NetBSD test repository, it cuts the time in half.
Differential Revision: https://phab.mercurial-scm.org/D9631
author | Joerg Sonnenberger <joerg@bec.de> |
---|---|
date | Fri, 18 Dec 2020 14:45:28 +0100 |
parents | f96fa4de5055 |
children | 6ed7ee9f44db |
comparison
equal
deleted
inserted
replaced
46253:1cebad969d88 | 46254:c4b792fa109e |
---|---|
986 (use --force-close-branch to close branch from a non-head changeset) | 986 (use --force-close-branch to close branch from a non-head changeset) |
987 [10] | 987 [10] |
988 | 988 |
989 $ hg ci -m "branch closed" --force-close-branch | 989 $ hg ci -m "branch closed" --force-close-branch |
990 created new head | 990 created new head |
991 $ cd .. | |
992 | |
993 Test various special cases for the branchmap | |
994 -------------------------------------------- | |
995 | |
996 Basic fork of the same branch | |
997 | |
998 $ hg init branchmap-testing1 | |
999 $ cd branchmap-testing1 | |
1000 $ hg debugbuild '@A . :base . :p1 *base /p1' | |
1001 $ hg log -G | |
1002 o changeset: 3:71ca9a6d524e | |
1003 |\ branch: A | |
1004 | | tag: tip | |
1005 | | parent: 2:a3b807b3ff0b | |
1006 | | parent: 1:99ba08759bc7 | |
1007 | | user: debugbuilddag | |
1008 | | date: Thu Jan 01 00:00:03 1970 +0000 | |
1009 | | summary: r3 | |
1010 | | | |
1011 | o changeset: 2:a3b807b3ff0b | |
1012 | | branch: A | |
1013 | | parent: 0:2ab8003a1750 | |
1014 | | user: debugbuilddag | |
1015 | | date: Thu Jan 01 00:00:02 1970 +0000 | |
1016 | | summary: r2 | |
1017 | | | |
1018 o | changeset: 1:99ba08759bc7 | |
1019 |/ branch: A | |
1020 | tag: p1 | |
1021 | user: debugbuilddag | |
1022 | date: Thu Jan 01 00:00:01 1970 +0000 | |
1023 | summary: r1 | |
1024 | | |
1025 o changeset: 0:2ab8003a1750 | |
1026 branch: A | |
1027 tag: base | |
1028 user: debugbuilddag | |
1029 date: Thu Jan 01 00:00:00 1970 +0000 | |
1030 summary: r0 | |
1031 | |
1032 $ hg branches | |
1033 A 3:71ca9a6d524e | |
1034 $ hg clone -r 1 -r 2 . ../branchmap-testing1-clone | |
1035 adding changesets | |
1036 adding manifests | |
1037 adding file changes | |
1038 added 3 changesets with 0 changes to 0 files (+1 heads) | |
1039 new changesets 2ab8003a1750:a3b807b3ff0b | |
1040 updating to branch A | |
1041 0 files updated, 0 files merged, 0 files removed, 0 files unresolved | |
1042 $ cd ../branchmap-testing1-clone | |
1043 $ hg pull ../branchmap-testing1 | |
1044 pulling from ../branchmap-testing1 | |
1045 searching for changes | |
1046 adding changesets | |
1047 adding manifests | |
1048 adding file changes | |
1049 added 1 changesets with 0 changes to 0 files (-1 heads) | |
1050 new changesets 71ca9a6d524e | |
1051 (run 'hg update' to get a working copy) | |
1052 $ hg branches | |
1053 A 3:71ca9a6d524e | |
1054 $ cd .. | |
1055 | |
1056 Switching to a different branch and back | |
1057 | |
1058 $ hg init branchmap-testing2 | |
1059 $ cd branchmap-testing2 | |
1060 $ hg debugbuild '@A . @B . @A .' | |
1061 $ hg log -G | |
1062 o changeset: 2:9699e9f260b5 | |
1063 | branch: A | |
1064 | tag: tip | |
1065 | user: debugbuilddag | |
1066 | date: Thu Jan 01 00:00:02 1970 +0000 | |
1067 | summary: r2 | |
1068 | | |
1069 o changeset: 1:0bc7d348d965 | |
1070 | branch: B | |
1071 | user: debugbuilddag | |
1072 | date: Thu Jan 01 00:00:01 1970 +0000 | |
1073 | summary: r1 | |
1074 | | |
1075 o changeset: 0:2ab8003a1750 | |
1076 branch: A | |
1077 user: debugbuilddag | |
1078 date: Thu Jan 01 00:00:00 1970 +0000 | |
1079 summary: r0 | |
1080 | |
1081 $ hg branches | |
1082 A 2:9699e9f260b5 | |
1083 B 1:0bc7d348d965 (inactive) | |
1084 $ hg clone -r 1 . ../branchmap-testing2-clone | |
1085 adding changesets | |
1086 adding manifests | |
1087 adding file changes | |
1088 added 2 changesets with 0 changes to 0 files | |
1089 new changesets 2ab8003a1750:0bc7d348d965 | |
1090 updating to branch B | |
1091 0 files updated, 0 files merged, 0 files removed, 0 files unresolved | |
1092 $ cd ../branchmap-testing2-clone | |
1093 $ hg pull ../branchmap-testing2 | |
1094 pulling from ../branchmap-testing2 | |
1095 searching for changes | |
1096 adding changesets | |
1097 adding manifests | |
1098 adding file changes | |
1099 added 1 changesets with 0 changes to 0 files | |
1100 new changesets 9699e9f260b5 | |
1101 (run 'hg update' to get a working copy) | |
1102 $ hg branches | |
1103 A 2:9699e9f260b5 | |
1104 B 1:0bc7d348d965 (inactive) | |
1105 $ cd .. | |
1106 | |
1107 A fork on a branch switching to a different branch and back | |
1108 is still collecting the fork. | |
1109 | |
1110 $ hg init branchmap-testing3 | |
1111 $ cd branchmap-testing3 | |
1112 $ hg debugbuild '@A . :base . :p1 *base @B . @A /p1' | |
1113 $ hg log -G | |
1114 o changeset: 4:3614a1711d23 | |
1115 |\ branch: A | |
1116 | | tag: tip | |
1117 | | parent: 3:e9c8abcf65aa | |
1118 | | parent: 1:99ba08759bc7 | |
1119 | | user: debugbuilddag | |
1120 | | date: Thu Jan 01 00:00:04 1970 +0000 | |
1121 | | summary: r4 | |
1122 | | | |
1123 | o changeset: 3:e9c8abcf65aa | |
1124 | | branch: B | |
1125 | | user: debugbuilddag | |
1126 | | date: Thu Jan 01 00:00:03 1970 +0000 | |
1127 | | summary: r3 | |
1128 | | | |
1129 | o changeset: 2:a3b807b3ff0b | |
1130 | | branch: A | |
1131 | | parent: 0:2ab8003a1750 | |
1132 | | user: debugbuilddag | |
1133 | | date: Thu Jan 01 00:00:02 1970 +0000 | |
1134 | | summary: r2 | |
1135 | | | |
1136 o | changeset: 1:99ba08759bc7 | |
1137 |/ branch: A | |
1138 | tag: p1 | |
1139 | user: debugbuilddag | |
1140 | date: Thu Jan 01 00:00:01 1970 +0000 | |
1141 | summary: r1 | |
1142 | | |
1143 o changeset: 0:2ab8003a1750 | |
1144 branch: A | |
1145 tag: base | |
1146 user: debugbuilddag | |
1147 date: Thu Jan 01 00:00:00 1970 +0000 | |
1148 summary: r0 | |
1149 | |
1150 $ hg branches | |
1151 A 4:3614a1711d23 | |
1152 B 3:e9c8abcf65aa (inactive) | |
1153 $ hg clone -r 1 -r 3 . ../branchmap-testing3-clone | |
1154 adding changesets | |
1155 adding manifests | |
1156 adding file changes | |
1157 added 4 changesets with 0 changes to 0 files (+1 heads) | |
1158 new changesets 2ab8003a1750:e9c8abcf65aa | |
1159 updating to branch A | |
1160 0 files updated, 0 files merged, 0 files removed, 0 files unresolved | |
1161 $ cd ../branchmap-testing3-clone | |
1162 $ hg pull ../branchmap-testing3 | |
1163 pulling from ../branchmap-testing3 | |
1164 searching for changes | |
1165 adding changesets | |
1166 adding manifests | |
1167 adding file changes | |
1168 added 1 changesets with 0 changes to 0 files (-1 heads) | |
1169 new changesets 3614a1711d23 | |
1170 (run 'hg update' to get a working copy) | |
1171 $ hg branches | |
1172 A 4:3614a1711d23 | |
1173 B 3:e9c8abcf65aa (inactive) | |
1174 $ cd .. | |
1175 | |
1176 Intermediary parents are on different branches. | |
1177 | |
1178 $ hg init branchmap-testing4 | |
1179 $ cd branchmap-testing4 | |
1180 $ hg debugbuild '@A . @B :base . @A :p1 *base @C . @A /p1' | |
1181 $ hg log -G | |
1182 o changeset: 4:4bf67499b70a | |
1183 |\ branch: A | |
1184 | | tag: tip | |
1185 | | parent: 3:4a546028fa8f | |
1186 | | parent: 1:0bc7d348d965 | |
1187 | | user: debugbuilddag | |
1188 | | date: Thu Jan 01 00:00:04 1970 +0000 | |
1189 | | summary: r4 | |
1190 | | | |
1191 | o changeset: 3:4a546028fa8f | |
1192 | | branch: C | |
1193 | | user: debugbuilddag | |
1194 | | date: Thu Jan 01 00:00:03 1970 +0000 | |
1195 | | summary: r3 | |
1196 | | | |
1197 | o changeset: 2:a3b807b3ff0b | |
1198 | | branch: A | |
1199 | | parent: 0:2ab8003a1750 | |
1200 | | user: debugbuilddag | |
1201 | | date: Thu Jan 01 00:00:02 1970 +0000 | |
1202 | | summary: r2 | |
1203 | | | |
1204 o | changeset: 1:0bc7d348d965 | |
1205 |/ branch: B | |
1206 | tag: p1 | |
1207 | user: debugbuilddag | |
1208 | date: Thu Jan 01 00:00:01 1970 +0000 | |
1209 | summary: r1 | |
1210 | | |
1211 o changeset: 0:2ab8003a1750 | |
1212 branch: A | |
1213 tag: base | |
1214 user: debugbuilddag | |
1215 date: Thu Jan 01 00:00:00 1970 +0000 | |
1216 summary: r0 | |
1217 | |
1218 $ hg branches | |
1219 A 4:4bf67499b70a | |
1220 C 3:4a546028fa8f (inactive) | |
1221 B 1:0bc7d348d965 (inactive) | |
1222 $ hg clone -r 1 -r 3 . ../branchmap-testing4-clone | |
1223 adding changesets | |
1224 adding manifests | |
1225 adding file changes | |
1226 added 4 changesets with 0 changes to 0 files (+1 heads) | |
1227 new changesets 2ab8003a1750:4a546028fa8f | |
1228 updating to branch B | |
1229 0 files updated, 0 files merged, 0 files removed, 0 files unresolved | |
1230 $ cd ../branchmap-testing4-clone | |
1231 $ hg pull ../branchmap-testing4 | |
1232 pulling from ../branchmap-testing4 | |
1233 searching for changes | |
1234 adding changesets | |
1235 adding manifests | |
1236 adding file changes | |
1237 added 1 changesets with 0 changes to 0 files (-1 heads) | |
1238 new changesets 4bf67499b70a | |
1239 (run 'hg update' to get a working copy) | |
1240 $ hg branches | |
1241 A 4:4bf67499b70a | |
1242 C 3:4a546028fa8f (inactive) | |
1243 B 1:0bc7d348d965 (inactive) | |
1244 $ cd .. |