Mercurial > hg
comparison tests/test-grep.t @ 45480:8ceb5b4b2728
grep: make -frREV follow history from the specified revision (BC)
This is close to what "log -frREV" will do, and is backported from
8b4b9ee6001a, "log: make -fr show complete history from the given revs"
except for the "del opts['follow']" bit.
I'm planning to rewrite cmdutil.walkchangerevs() to share the core logic
with logcmdutil, and this is the first step towards that. There are still
many broken tests, but the fundamental behavior should be fixed by this
patch.
.. bc::
`hg grep -fr REV` now follows history from the specified `REV`, works in
the same way as `hg log -fr REV`. The previous behavior was to limit
the search space to `REV` while following the history.
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Thu, 10 Sep 2020 14:23:12 +0900 |
parents | 07c424a13811 |
children | 0356b41fe01d |
comparison
equal
deleted
inserted
replaced
45479:3dc848d5ec77 | 45480:8ceb5b4b2728 |
---|---|
947 | 947 |
948 $ hg log -fr2 | 948 $ hg log -fr2 |
949 2: A add0-cp2, A add0-cp2-mod2, M add0-mod2, R add0-rm2 | 949 2: A add0-cp2, A add0-cp2-mod2, M add0-mod2, R add0-rm2 |
950 0: A add0, A add0-mod1, A add0-mod2, A add0-mod3, A add0-mod4, A add0-rm1, A add0-rm2, A add0-rm4 | 950 0: A add0, A add0-mod1, A add0-mod2, A add0-mod3, A add0-mod4, A add0-rm1, A add0-rm2, A add0-rm4 |
951 | 951 |
952 BROKEN: should follow history | |
953 $ hg grep --diff -fr2 data | 952 $ hg grep --diff -fr2 data |
954 add0-cp2-mod2:2:+:data2 | 953 add0-cp2-mod2:2:+:data2 |
955 add0-mod2:2:+:data2 | 954 add0-mod2:2:+:data2 |
956 | 955 add0:0:+:data0 |
957 BROKEN: should follow history | 956 add0-mod1:0:+:data0 |
957 add0-mod2:0:+:data0 | |
958 add0-mod3:0:+:data0 | |
959 add0-mod4:0:+:data0 | |
960 add0-rm1:0:+:data0 | |
961 add0-rm2:0:+:data0 | |
962 add0-rm4:0:+:data0 | |
963 | |
958 $ hg grep -fr2 data | 964 $ hg grep -fr2 data |
959 add0:2:data0 | 965 add0:2:data0 |
960 add0-cp2:2:data0 | 966 add0-cp2:2:data0 |
961 add0-cp2-mod2:2:data0 | 967 add0-cp2-mod2:2:data0 |
962 add0-cp2-mod2:2:data2 | 968 add0-cp2-mod2:2:data2 |
965 add0-mod2:2:data2 | 971 add0-mod2:2:data2 |
966 add0-mod3:2:data0 | 972 add0-mod3:2:data0 |
967 add0-mod4:2:data0 | 973 add0-mod4:2:data0 |
968 add0-rm1:2:data0 | 974 add0-rm1:2:data0 |
969 add0-rm4:2:data0 | 975 add0-rm4:2:data0 |
976 add0:0:data0 | |
977 add0-mod1:0:data0 | |
978 add0-mod2:0:data0 | |
979 add0-mod3:0:data0 | |
980 add0-mod4:0:data0 | |
981 add0-rm1:0:data0 | |
982 add0-rm2:0:data0 | |
983 add0-rm4:0:data0 | |
970 | 984 |
971 follow revision history from wdir: | 985 follow revision history from wdir: |
972 | 986 |
973 $ hg log -fr'wdir()' | 987 $ hg log -fr'wdir()' |
974 2147483647: A add0-cp4, A add0-cp4-mod4, M add0-mod4, R add0-rm4 | 988 2147483647: A add0-cp4, A add0-cp4-mod4, M add0-mod4, R add0-rm4 |
982 add0-cp4-mod4:2147483647:+:data4 | 996 add0-cp4-mod4:2147483647:+:data4 |
983 add0-mod4:2147483647:+:data4 | 997 add0-mod4:2147483647:+:data4 |
984 add0-rm4:2147483647:-:abort: add0-rm4@None: not found in manifest! | 998 add0-rm4:2147483647:-:abort: add0-rm4@None: not found in manifest! |
985 [255] | 999 [255] |
986 | 1000 |
987 BROKEN: should follow history | |
988 $ hg grep -fr'wdir()' data | 1001 $ hg grep -fr'wdir()' data |
989 add0:2147483647:data0 | 1002 add0:2147483647:data0 |
990 add0-cp1:2147483647:data0 | 1003 add0-cp1:2147483647:data0 |
991 add0-cp1-cp3:2147483647:data0 | 1004 add0-cp1-cp3:2147483647:data0 |
992 add0-cp1-mod1:2147483647:data0 | 1005 add0-cp1-mod1:2147483647:data0 |
1003 add0-mod3:2147483647:data0 | 1016 add0-mod3:2147483647:data0 |
1004 add0-mod3:2147483647:data3 | 1017 add0-mod3:2147483647:data3 |
1005 add0-mod4:2147483647:data0 | 1018 add0-mod4:2147483647:data0 |
1006 add0-mod4:2147483647:data4 | 1019 add0-mod4:2147483647:data4 |
1007 add0-rm2:2147483647:data0 | 1020 add0-rm2:2147483647:data0 |
1008 | 1021 add0:3:data0 |
1009 follow revision history from multiple revisions: | 1022 add0-cp1:3:data0 |
1010 | 1023 add0-cp1-cp3:3:data0 |
1011 $ hg log -fr'1+2' | 1024 add0-cp1-mod1:3:data0 |
1012 2: A add0-cp2, A add0-cp2-mod2, M add0-mod2, R add0-rm2 | 1025 add0-cp1-mod1:3:data1 |
1013 1: A add0-cp1, A add0-cp1-mod1, A add0-cp1-mod1-rm3, M add0-mod1, R add0-rm1 | 1026 add0-cp1-mod1-cp3-mod3:3:data0 |
1014 0: A add0, A add0-mod1, A add0-mod2, A add0-mod3, A add0-mod4, A add0-rm1, A add0-rm2, A add0-rm4 | 1027 add0-cp1-mod1-cp3-mod3:3:data1 |
1015 | 1028 add0-cp1-mod1-cp3-mod3:3:data3 |
1016 BROKEN: should follow history | 1029 add0-mod1:3:data0 |
1017 BROKEN: should include the revision 2 | 1030 add0-mod1:3:data1 |
1018 $ hg grep --diff -fr'1+2' data | 1031 add0-mod2:3:data0 |
1019 add0-cp1-mod1:1:+:data1 | 1032 add0-mod3:3:data0 |
1020 add0-cp1-mod1-rm3:1:+:data1 | 1033 add0-mod3:3:data3 |
1021 add0-mod1:1:+:data1 | 1034 add0-mod4:3:data0 |
1022 | 1035 add0-rm2:3:data0 |
1023 BROKEN: should follow history | 1036 add0-rm4:3:data0 |
1024 BROKEN: should include the revision 2 | |
1025 $ hg grep -fr'1+2' data | |
1026 add0:1:data0 | 1037 add0:1:data0 |
1027 add0-cp1:1:data0 | 1038 add0-cp1:1:data0 |
1028 add0-cp1-mod1:1:data0 | 1039 add0-cp1-mod1:1:data0 |
1029 add0-cp1-mod1:1:data1 | 1040 add0-cp1-mod1:1:data1 |
1030 add0-cp1-mod1-rm3:1:data0 | 1041 add0-cp1-mod1-rm3:1:data0 |
1034 add0-mod2:1:data0 | 1045 add0-mod2:1:data0 |
1035 add0-mod3:1:data0 | 1046 add0-mod3:1:data0 |
1036 add0-mod4:1:data0 | 1047 add0-mod4:1:data0 |
1037 add0-rm2:1:data0 | 1048 add0-rm2:1:data0 |
1038 add0-rm4:1:data0 | 1049 add0-rm4:1:data0 |
1050 add0:0:data0 | |
1051 add0-mod1:0:data0 | |
1052 add0-mod2:0:data0 | |
1053 add0-mod3:0:data0 | |
1054 add0-mod4:0:data0 | |
1055 add0-rm1:0:data0 | |
1056 add0-rm2:0:data0 | |
1057 add0-rm4:0:data0 | |
1058 | |
1059 follow revision history from multiple revisions: | |
1060 | |
1061 $ hg log -fr'1+2' | |
1062 2: A add0-cp2, A add0-cp2-mod2, M add0-mod2, R add0-rm2 | |
1063 1: A add0-cp1, A add0-cp1-mod1, A add0-cp1-mod1-rm3, M add0-mod1, R add0-rm1 | |
1064 0: A add0, A add0-mod1, A add0-mod2, A add0-mod3, A add0-mod4, A add0-rm1, A add0-rm2, A add0-rm4 | |
1065 | |
1066 BROKEN: should include the revision 1 | |
1067 $ hg grep --diff -fr'1+2' data | |
1068 add0-cp2-mod2:2:+:data2 | |
1069 add0-mod2:2:+:data2 | |
1070 add0:0:+:data0 | |
1071 add0-mod1:0:+:data0 | |
1072 add0-mod2:0:+:data0 | |
1073 add0-mod3:0:+:data0 | |
1074 add0-mod4:0:+:data0 | |
1075 add0-rm1:0:+:data0 | |
1076 add0-rm2:0:+:data0 | |
1077 add0-rm4:0:+:data0 | |
1078 | |
1079 BROKEN: should include the revision 1 | |
1080 $ hg grep -fr'1+2' data | |
1081 add0:2:data0 | |
1082 add0-cp2:2:data0 | |
1083 add0-cp2-mod2:2:data0 | |
1084 add0-cp2-mod2:2:data2 | |
1085 add0-mod1:2:data0 | |
1086 add0-mod2:2:data0 | |
1087 add0-mod2:2:data2 | |
1088 add0-mod3:2:data0 | |
1089 add0-mod4:2:data0 | |
1090 add0-rm1:2:data0 | |
1091 add0-rm4:2:data0 | |
1092 add0:0:data0 | |
1093 add0-mod1:0:data0 | |
1094 add0-mod2:0:data0 | |
1095 add0-mod3:0:data0 | |
1096 add0-mod4:0:data0 | |
1097 add0-rm1:0:data0 | |
1098 add0-rm2:0:data0 | |
1099 add0-rm4:0:data0 | |
1039 | 1100 |
1040 follow file history from wdir parent, unmodified in wdir: | 1101 follow file history from wdir parent, unmodified in wdir: |
1041 | 1102 |
1042 $ hg log -f add0-mod3 | 1103 $ hg log -f add0-mod3 |
1043 3: A add0-cp1-cp3, A add0-cp1-mod1-cp3-mod3, R add0-cp1-mod1-rm3, M add0-mod3 | 1104 3: A add0-cp1-cp3, A add0-cp1-mod1-cp3-mod3, R add0-cp1-mod1-rm3, M add0-mod3 |
1141 abort: cannot follow file not in parent revision: "add0-cp1-mod1-rm3" | 1202 abort: cannot follow file not in parent revision: "add0-cp1-mod1-rm3" |
1142 [255] | 1203 [255] |
1143 | 1204 |
1144 BROKEN: should abort | 1205 BROKEN: should abort |
1145 $ hg grep -fr. data add0-cp1-mod1-rm3 | 1206 $ hg grep -fr. data add0-cp1-mod1-rm3 |
1146 [1] | 1207 add0-cp1-mod1-rm3:1:data0 |
1208 add0-cp1-mod1-rm3:1:data1 | |
1147 | 1209 |
1148 follow file history from wdir parent, removed in wdir: | 1210 follow file history from wdir parent, removed in wdir: |
1149 | 1211 |
1150 $ hg log -f add0-rm4 | 1212 $ hg log -f add0-rm4 |
1151 abort: cannot follow file not in parent revision: "add0-rm4" | 1213 abort: cannot follow file not in parent revision: "add0-rm4" |
1165 follow file history from wdir parent (explicit), removed in wdir: | 1227 follow file history from wdir parent (explicit), removed in wdir: |
1166 | 1228 |
1167 $ hg log -fr. add0-rm4 | 1229 $ hg log -fr. add0-rm4 |
1168 0: A add0, A add0-mod1, A add0-mod2, A add0-mod3, A add0-mod4, A add0-rm1, A add0-rm2, A add0-rm4 | 1230 0: A add0, A add0-mod1, A add0-mod2, A add0-mod3, A add0-mod4, A add0-rm1, A add0-rm2, A add0-rm4 |
1169 | 1231 |
1170 BROKEN: should follow history | |
1171 $ hg grep --diff -fr. data add0-rm4 | 1232 $ hg grep --diff -fr. data add0-rm4 |
1172 [1] | 1233 add0-rm4:0:+:data0 |
1173 | 1234 |
1174 BROKEN: should follow history | |
1175 $ hg grep -fr. data add0-rm4 | 1235 $ hg grep -fr. data add0-rm4 |
1176 add0-rm4:3:data0 | 1236 add0-rm4:3:data0 |
1237 add0-rm4:1:data0 | |
1238 add0-rm4:0:data0 | |
1177 | 1239 |
1178 follow file history from wdir parent, multiple files: | 1240 follow file history from wdir parent, multiple files: |
1179 | 1241 |
1180 $ hg log -f add0-mod3 add0-cp1-mod1 | 1242 $ hg log -f add0-mod3 add0-cp1-mod1 |
1181 3: A add0-cp1-cp3, A add0-cp1-mod1-cp3-mod3, R add0-cp1-mod1-rm3, M add0-mod3 | 1243 3: A add0-cp1-cp3, A add0-cp1-mod1-cp3-mod3, R add0-cp1-mod1-rm3, M add0-mod3 |
1205 | 1267 |
1206 $ hg log -fr2 add0-mod2 | 1268 $ hg log -fr2 add0-mod2 |
1207 2: A add0-cp2, A add0-cp2-mod2, M add0-mod2, R add0-rm2 | 1269 2: A add0-cp2, A add0-cp2-mod2, M add0-mod2, R add0-rm2 |
1208 0: A add0, A add0-mod1, A add0-mod2, A add0-mod3, A add0-mod4, A add0-rm1, A add0-rm2, A add0-rm4 | 1270 0: A add0, A add0-mod1, A add0-mod2, A add0-mod3, A add0-mod4, A add0-rm1, A add0-rm2, A add0-rm4 |
1209 | 1271 |
1210 BROKEN: should follow history from the specified revision | 1272 BROKEN: should include the revision 2 |
1211 $ hg grep --diff -fr2 data add0-mod2 | 1273 $ hg grep --diff -fr2 data add0-mod2 |
1212 [1] | 1274 add0-mod2:0:+:data0 |
1213 | 1275 |
1214 BROKEN: should follow history | |
1215 $ hg grep -fr2 data add0-mod2 | 1276 $ hg grep -fr2 data add0-mod2 |
1216 add0-mod2:2:data0 | 1277 add0-mod2:2:data0 |
1217 add0-mod2:2:data2 | 1278 add0-mod2:2:data2 |
1279 add0-mod2:0:data0 | |
1218 | 1280 |
1219 follow file history from specified revision, copied but unmodified: | 1281 follow file history from specified revision, copied but unmodified: |
1220 | 1282 |
1221 $ hg log -fr2 add0-cp2 | 1283 $ hg log -fr2 add0-cp2 |
1222 2: A add0-cp2, A add0-cp2-mod2, M add0-mod2, R add0-rm2 | 1284 2: A add0-cp2, A add0-cp2-mod2, M add0-mod2, R add0-rm2 |
1253 abort: cannot follow file not in any of the specified revisions: "add0-rm2" | 1315 abort: cannot follow file not in any of the specified revisions: "add0-rm2" |
1254 [255] | 1316 [255] |
1255 | 1317 |
1256 BROKEN: should abort | 1318 BROKEN: should abort |
1257 $ hg grep --diff -fr2 data add0-rm2 | 1319 $ hg grep --diff -fr2 data add0-rm2 |
1258 [1] | 1320 add0-rm2:0:+:data0 |
1259 | 1321 |
1260 BROKEN: should abort | 1322 BROKEN: should abort |
1261 $ hg grep -fr2 data add0-rm2 | 1323 $ hg grep -fr2 data add0-rm2 |
1262 [1] | 1324 add0-rm2:0:data0 |
1263 | 1325 |
1264 follow file history from specified revision, multiple files: | 1326 follow file history from specified revision, multiple files: |
1265 | 1327 |
1266 $ hg log -fr2 add0-cp2 add0-mod2 | 1328 $ hg log -fr2 add0-cp2 add0-mod2 |
1267 2: A add0-cp2, A add0-cp2-mod2, M add0-mod2, R add0-rm2 | 1329 2: A add0-cp2, A add0-cp2-mod2, M add0-mod2, R add0-rm2 |
1270 BROKEN: should follow history from the specified revision | 1332 BROKEN: should follow history from the specified revision |
1271 $ hg grep --diff -fr2 data add0-cp2 add0-mod2 | 1333 $ hg grep --diff -fr2 data add0-cp2 add0-mod2 |
1272 abort: cannot follow file not in parent revision: "add0-cp2" | 1334 abort: cannot follow file not in parent revision: "add0-cp2" |
1273 [255] | 1335 [255] |
1274 | 1336 |
1275 BROKEN: should follow history | 1337 BROKEN: should follow history across renames |
1276 $ hg grep -fr2 data add0-cp2 add0-mod2 | 1338 $ hg grep -fr2 data add0-cp2 add0-mod2 |
1277 add0-cp2:2:data0 | 1339 add0-cp2:2:data0 |
1278 add0-mod2:2:data0 | 1340 add0-mod2:2:data0 |
1279 add0-mod2:2:data2 | 1341 add0-mod2:2:data2 |
1342 add0-mod2:0:data0 | |
1280 | 1343 |
1281 follow file history from wdir, unmodified: | 1344 follow file history from wdir, unmodified: |
1282 | 1345 |
1283 $ hg log -fr'wdir()' add0-mod3 | 1346 $ hg log -fr'wdir()' add0-mod3 |
1284 2147483647: A add0-cp4, A add0-cp4-mod4, M add0-mod4, R add0-rm4 | 1347 2147483647: A add0-cp4, A add0-cp4-mod4, M add0-mod4, R add0-rm4 |
1285 3: A add0-cp1-cp3, A add0-cp1-mod1-cp3-mod3, R add0-cp1-mod1-rm3, M add0-mod3 | 1348 3: A add0-cp1-cp3, A add0-cp1-mod1-cp3-mod3, R add0-cp1-mod1-rm3, M add0-mod3 |
1286 0: A add0, A add0-mod1, A add0-mod2, A add0-mod3, A add0-mod4, A add0-rm1, A add0-rm2, A add0-rm4 | 1349 0: A add0, A add0-mod1, A add0-mod2, A add0-mod3, A add0-mod4, A add0-rm1, A add0-rm2, A add0-rm4 |
1287 | 1350 |
1288 BROKEN: should follow history | |
1289 $ hg grep --diff -fr'wdir()' data add0-mod3 | 1351 $ hg grep --diff -fr'wdir()' data add0-mod3 |
1290 [1] | 1352 add0-mod3:3:+:data3 |
1291 | 1353 add0-mod3:0:+:data0 |
1292 BROKEN: should follow history | 1354 |
1293 $ hg grep -fr'wdir()' data add0-mod3 | 1355 $ hg grep -fr'wdir()' data add0-mod3 |
1294 add0-mod3:2147483647:data0 | 1356 add0-mod3:2147483647:data0 |
1295 add0-mod3:2147483647:data3 | 1357 add0-mod3:2147483647:data3 |
1358 add0-mod3:3:data0 | |
1359 add0-mod3:3:data3 | |
1360 add0-mod3:1:data0 | |
1361 add0-mod3:0:data0 | |
1296 | 1362 |
1297 follow file history from wdir, modified: | 1363 follow file history from wdir, modified: |
1298 | 1364 |
1299 $ hg log -fr'wdir()' add0-mod4 | 1365 $ hg log -fr'wdir()' add0-mod4 |
1300 2147483647: A add0-cp4, A add0-cp4-mod4, M add0-mod4, R add0-rm4 | 1366 2147483647: A add0-cp4, A add0-cp4-mod4, M add0-mod4, R add0-rm4 |
1301 0: A add0, A add0-mod1, A add0-mod2, A add0-mod3, A add0-mod4, A add0-rm1, A add0-rm2, A add0-rm4 | 1367 0: A add0, A add0-mod1, A add0-mod2, A add0-mod3, A add0-mod4, A add0-rm1, A add0-rm2, A add0-rm4 |
1302 | 1368 |
1303 BROKEN: should follow history and show the changes in wdir | 1369 BROKEN: should include the changes in wdir |
1304 $ hg grep --diff -fr'wdir()' data add0-mod4 | 1370 $ hg grep --diff -fr'wdir()' data add0-mod4 |
1305 [1] | 1371 add0-mod4:0:+:data0 |
1306 | 1372 |
1307 BROKEN: should follow history | |
1308 $ hg grep -fr'wdir()' data add0-mod4 | 1373 $ hg grep -fr'wdir()' data add0-mod4 |
1309 add0-mod4:2147483647:data0 | 1374 add0-mod4:2147483647:data0 |
1310 add0-mod4:2147483647:data4 | 1375 add0-mod4:2147483647:data4 |
1376 add0-mod4:3:data0 | |
1377 add0-mod4:1:data0 | |
1378 add0-mod4:0:data0 | |
1311 | 1379 |
1312 follow file history from wdir, copied but unmodified: | 1380 follow file history from wdir, copied but unmodified: |
1313 | 1381 |
1314 $ hg log -fr'wdir()' add0-cp4 | 1382 $ hg log -fr'wdir()' add0-cp4 |
1315 2147483647: A add0-cp4, A add0-cp4-mod4, M add0-mod4, R add0-rm4 | 1383 2147483647: A add0-cp4, A add0-cp4-mod4, M add0-mod4, R add0-rm4 |
1350 BROKEN: should follow history | 1418 BROKEN: should follow history |
1351 $ hg grep --diff -fr'wdir()' data add0-cp4 add0-mod4 add0-mod3 | 1419 $ hg grep --diff -fr'wdir()' data add0-cp4 add0-mod4 add0-mod3 |
1352 abort: cannot follow file not in parent revision: "add0-cp4" | 1420 abort: cannot follow file not in parent revision: "add0-cp4" |
1353 [255] | 1421 [255] |
1354 | 1422 |
1355 BROKEN: should follow history | 1423 BROKEN: should follow history across renames |
1356 $ hg grep -fr'wdir()' data add0-cp4 add0-mod4 add0-mod3 | 1424 $ hg grep -fr'wdir()' data add0-cp4 add0-mod4 add0-mod3 |
1357 add0-cp4:2147483647:data0 | 1425 add0-cp4:2147483647:data0 |
1358 add0-mod3:2147483647:data0 | 1426 add0-mod3:2147483647:data0 |
1359 add0-mod3:2147483647:data3 | 1427 add0-mod3:2147483647:data3 |
1360 add0-mod4:2147483647:data0 | 1428 add0-mod4:2147483647:data0 |
1361 add0-mod4:2147483647:data4 | 1429 add0-mod4:2147483647:data4 |
1430 add0-mod3:3:data0 | |
1431 add0-mod3:3:data3 | |
1432 add0-mod4:3:data0 | |
1433 add0-mod3:1:data0 | |
1434 add0-mod4:1:data0 | |
1435 add0-mod3:0:data0 | |
1436 add0-mod4:0:data0 | |
1362 | 1437 |
1363 $ cd .. | 1438 $ cd .. |