##// END OF EJS Templates
test-grep: add tests for --follow with/without --diff and/or paths...
Yuya Nishihara -
r46434:20dd2a25 default
parent child Browse files
Show More
This diff has been collapsed as it changes many lines, (516 lines changed) Show them Hide them
@@ -813,3 +813,519 b' test -rMULTIREV'
813 um:1:unmod
813 um:1:unmod
814 $ cd ..
814 $ cd ..
815
815
816 --follow with/without --diff and/or paths
817 -----------------------------------------
818
819 For each test case, we compare the history traversal of "hg log",
820 "hg grep --diff", and "hg grep" (--all-files).
821
822 "hg grep --diff" should traverse the log in the same way as "hg log".
823 "hg grep" (--all-files) is slightly different in that it includes
824 unmodified changes.
825
826 $ hg init follow
827 $ cd follow
828
829 $ cat <<'EOF' >> .hg/hgrc
830 > [ui]
831 > logtemplate = '{rev}: {join(files % "{status} {path}", ", ")}\n'
832 > EOF
833
834 $ for f in add0 add0-mod1 add0-rm1 add0-mod2 add0-rm2 add0-mod3 add0-mod4 add0-rm4; do
835 > echo data0 >> $f
836 > done
837 $ hg ci -qAm0
838
839 $ hg cp add0 add0-cp1
840 $ hg cp add0 add0-cp1-mod1
841 $ hg cp add0 add0-cp1-mod1-rm3
842 $ hg rm add0-rm1
843 $ for f in *mod1*; do
844 > echo data1 >> $f
845 > done
846 $ hg ci -qAm1
847
848 $ hg update -q 0
849 $ hg cp add0 add0-cp2
850 $ hg cp add0 add0-cp2-mod2
851 $ hg rm add0-rm2
852 $ for f in *mod2*; do
853 > echo data2 >> $f
854 > done
855 $ hg ci -qAm2
856
857 $ hg update -q 1
858 $ hg cp add0-cp1 add0-cp1-cp3
859 $ hg cp add0-cp1-mod1 add0-cp1-mod1-cp3-mod3
860 $ hg rm add0-cp1-mod1-rm3
861 $ for f in *mod3*; do
862 > echo data3 >> $f
863 > done
864 $ hg ci -qAm3
865
866 $ hg cp add0 add0-cp4
867 $ hg cp add0 add0-cp4-mod4
868 $ hg rm add0-rm4
869 $ for f in *mod4*; do
870 > echo data4 >> $f
871 > done
872
873 $ hg log -Gr':wdir()'
874 o 2147483647: A add0-cp4, A add0-cp4-mod4, M add0-mod4, R add0-rm4
875 |
876 @ 3: A add0-cp1-cp3, A add0-cp1-mod1-cp3-mod3, R add0-cp1-mod1-rm3, M add0-mod3
877 |
878 | o 2: A add0-cp2, A add0-cp2-mod2, M add0-mod2, R add0-rm2
879 | |
880 o | 1: A add0-cp1, A add0-cp1-mod1, A add0-cp1-mod1-rm3, M add0-mod1, R add0-rm1
881 |/
882 o 0: A add0, A add0-mod1, A add0-mod2, A add0-mod3, A add0-mod4, A add0-rm1, A add0-rm2, A add0-rm4
883
884
885 follow revision history from wdir parent:
886
887 $ hg log -f
888 3: A add0-cp1-cp3, A add0-cp1-mod1-cp3-mod3, R add0-cp1-mod1-rm3, M add0-mod3
889 1: A add0-cp1, A add0-cp1-mod1, A add0-cp1-mod1-rm3, M add0-mod1, R add0-rm1
890 0: A add0, A add0-mod1, A add0-mod2, A add0-mod3, A add0-mod4, A add0-rm1, A add0-rm2, A add0-rm4
891
892 $ hg grep --diff -f data
893 add0-cp1-mod1-cp3-mod3:3:+:data3
894 add0-mod3:3:+:data3
895 add0-cp1-mod1:1:+:data1
896 add0-cp1-mod1-rm3:1:+:data1
897 add0-mod1:1:+:data1
898 add0:0:+:data0
899 add0-mod1:0:+:data0
900 add0-mod2:0:+:data0
901 add0-mod3:0:+:data0
902 add0-mod4:0:+:data0
903 add0-rm1:0:+:data0
904 add0-rm2:0:+:data0
905 add0-rm4:0:+:data0
906
907 BROKEN: should not fall back to plain grep
908 $ hg grep -f data
909 add0:data0
910 add0-cp1:data0
911 add0-cp1-cp3:data0
912 add0-cp1-mod1:data0
913 add0-cp1-mod1:data1
914 add0-cp1-mod1-cp3-mod3:data0
915 add0-cp1-mod1-cp3-mod3:data1
916 add0-cp1-mod1-cp3-mod3:data3
917 add0-cp4:data0
918 add0-cp4-mod4:data0
919 add0-cp4-mod4:data4
920 add0-mod1:data0
921 add0-mod1:data1
922 add0-mod2:data0
923 add0-mod3:data0
924 add0-mod3:data3
925 add0-mod4:data0
926 add0-mod4:data4
927 add0-rm2:data0
928
929 follow revision history from specified revision:
930
931 $ hg log -fr2
932 2: A add0-cp2, A add0-cp2-mod2, M add0-mod2, R add0-rm2
933 0: A add0, A add0-mod1, A add0-mod2, A add0-mod3, A add0-mod4, A add0-rm1, A add0-rm2, A add0-rm4
934
935 BROKEN: should follow history
936 $ hg grep --diff -fr2 data
937 add0-cp2-mod2:2:+:data2
938 add0-mod2:2:+:data2
939
940 BROKEN: should follow history
941 $ hg grep -fr2 data
942 add0:2:data0
943 add0-cp2:2:data0
944 add0-cp2-mod2:2:data0
945 add0-cp2-mod2:2:data2
946 add0-mod1:2:data0
947 add0-mod2:2:data0
948 add0-mod2:2:data2
949 add0-mod3:2:data0
950 add0-mod4:2:data0
951 add0-rm1:2:data0
952 add0-rm4:2:data0
953
954 follow revision history from wdir:
955
956 $ hg log -fr'wdir()'
957 2147483647: A add0-cp4, A add0-cp4-mod4, M add0-mod4, R add0-rm4
958 3: A add0-cp1-cp3, A add0-cp1-mod1-cp3-mod3, R add0-cp1-mod1-rm3, M add0-mod3
959 1: A add0-cp1, A add0-cp1-mod1, A add0-cp1-mod1-rm3, M add0-mod1, R add0-rm1
960 0: A add0, A add0-mod1, A add0-mod2, A add0-mod3, A add0-mod4, A add0-rm1, A add0-rm2, A add0-rm4
961
962 BROKEN: should follow history
963 BROKEN: should not abort because of removed file
964 $ hg grep --diff -fr'wdir()' data
965 add0-cp4-mod4:2147483647:+:data4
966 add0-mod4:2147483647:+:data4
967 add0-rm4:2147483647:-:abort: add0-rm4@None: not found in manifest!
968 [255]
969
970 BROKEN: should follow history
971 $ hg grep -fr'wdir()' data
972 add0:2147483647:data0
973 add0-cp1:2147483647:data0
974 add0-cp1-cp3:2147483647:data0
975 add0-cp1-mod1:2147483647:data0
976 add0-cp1-mod1:2147483647:data1
977 add0-cp1-mod1-cp3-mod3:2147483647:data0
978 add0-cp1-mod1-cp3-mod3:2147483647:data1
979 add0-cp1-mod1-cp3-mod3:2147483647:data3
980 add0-cp4:2147483647:data0
981 add0-cp4-mod4:2147483647:data0
982 add0-cp4-mod4:2147483647:data4
983 add0-mod1:2147483647:data0
984 add0-mod1:2147483647:data1
985 add0-mod2:2147483647:data0
986 add0-mod3:2147483647:data0
987 add0-mod3:2147483647:data3
988 add0-mod4:2147483647:data0
989 add0-mod4:2147483647:data4
990 add0-rm2:2147483647:data0
991
992 follow revision history from multiple revisions:
993
994 $ hg log -fr'1+2'
995 2: A add0-cp2, A add0-cp2-mod2, M add0-mod2, R add0-rm2
996 1: A add0-cp1, A add0-cp1-mod1, A add0-cp1-mod1-rm3, M add0-mod1, R add0-rm1
997 0: A add0, A add0-mod1, A add0-mod2, A add0-mod3, A add0-mod4, A add0-rm1, A add0-rm2, A add0-rm4
998
999 BROKEN: should follow history
1000 BROKEN: should include the revision 2
1001 $ hg grep --diff -fr'1+2' data
1002 add0-cp1-mod1:1:+:data1
1003 add0-cp1-mod1-rm3:1:+:data1
1004 add0-mod1:1:+:data1
1005
1006 BROKEN: should follow history
1007 BROKEN: should include the revision 2
1008 $ hg grep -fr'1+2' data
1009 add0:1:data0
1010 add0-cp1:1:data0
1011 add0-cp1-mod1:1:data0
1012 add0-cp1-mod1:1:data1
1013 add0-cp1-mod1-rm3:1:data0
1014 add0-cp1-mod1-rm3:1:data1
1015 add0-mod1:1:data0
1016 add0-mod1:1:data1
1017 add0-mod2:1:data0
1018 add0-mod3:1:data0
1019 add0-mod4:1:data0
1020 add0-rm2:1:data0
1021 add0-rm4:1:data0
1022
1023 follow file history from wdir parent, unmodified in wdir:
1024
1025 $ hg log -f add0-mod3
1026 3: A add0-cp1-cp3, A add0-cp1-mod1-cp3-mod3, R add0-cp1-mod1-rm3, M add0-mod3
1027 0: A add0, A add0-mod1, A add0-mod2, A add0-mod3, A add0-mod4, A add0-rm1, A add0-rm2, A add0-rm4
1028
1029 $ hg grep --diff -f data add0-mod3
1030 add0-mod3:3:+:data3
1031 add0-mod3:0:+:data0
1032
1033 BROKEN: should not fall back to plain grep
1034 $ hg grep -f data add0-mod3
1035 add0-mod3:data0
1036 add0-mod3:data3
1037
1038 follow file history from wdir parent, modified in wdir:
1039
1040 $ hg log -f add0-mod4
1041 0: A add0, A add0-mod1, A add0-mod2, A add0-mod3, A add0-mod4, A add0-rm1, A add0-rm2, A add0-rm4
1042
1043 $ hg grep --diff -f data add0-mod4
1044 add0-mod4:0:+:data0
1045
1046 BROKEN: should not fall back to plain grep
1047 $ hg grep -f data add0-mod4
1048 add0-mod4:data0
1049 add0-mod4:data4
1050
1051 follow file history from wdir parent, copied but unmodified:
1052
1053 $ hg log -f add0-cp1-cp3
1054 3: A add0-cp1-cp3, A add0-cp1-mod1-cp3-mod3, R add0-cp1-mod1-rm3, M add0-mod3
1055 1: A add0-cp1, A add0-cp1-mod1, A add0-cp1-mod1-rm3, M add0-mod1, R add0-rm1
1056 0: A add0, A add0-mod1, A add0-mod2, A add0-mod3, A add0-mod4, A add0-rm1, A add0-rm2, A add0-rm4
1057
1058 $ hg grep --diff -f data add0-cp1-cp3
1059 add0:0:+:data0
1060
1061 BROKEN: should not fall back to plain grep
1062 $ hg grep -f data add0-cp1-cp3
1063 add0-cp1-cp3:data0
1064
1065 follow file history from wdir parent, copied and modified:
1066
1067 $ hg log -f add0-cp1-mod1-cp3-mod3
1068 3: A add0-cp1-cp3, A add0-cp1-mod1-cp3-mod3, R add0-cp1-mod1-rm3, M add0-mod3
1069 1: A add0-cp1, A add0-cp1-mod1, A add0-cp1-mod1-rm3, M add0-mod1, R add0-rm1
1070 0: A add0, A add0-mod1, A add0-mod2, A add0-mod3, A add0-mod4, A add0-rm1, A add0-rm2, A add0-rm4
1071
1072 $ hg grep --diff -f data add0-cp1-mod1-cp3-mod3
1073 add0-cp1-mod1-cp3-mod3:3:+:data3
1074 add0-cp1-mod1:1:+:data1
1075 add0:0:+:data0
1076
1077 BROKEN: should not fall back to plain grep
1078 $ hg grep -f data add0-cp1-mod1-cp3-mod3
1079 add0-cp1-mod1-cp3-mod3:data0
1080 add0-cp1-mod1-cp3-mod3:data1
1081 add0-cp1-mod1-cp3-mod3:data3
1082
1083 follow file history from wdir parent, copied in wdir:
1084
1085 $ hg log -f add0-cp4
1086 abort: cannot follow nonexistent file: "add0-cp4"
1087 [255]
1088
1089 $ hg grep --diff -f data add0-cp4
1090 abort: cannot follow file not in parent revision: "add0-cp4"
1091 [255]
1092
1093 BROKEN: should not fall back to plain grep
1094 $ hg grep -f data add0-cp4
1095 add0-cp4:data0
1096
1097 follow file history from wdir parent, removed:
1098
1099 $ hg log -f add0-cp1-mod1-rm3
1100 abort: cannot follow file not in parent revision: "add0-cp1-mod1-rm3"
1101 [255]
1102
1103 $ hg grep --diff -f data add0-cp1-mod1-rm3
1104 abort: cannot follow file not in parent revision: "add0-cp1-mod1-rm3"
1105 [255]
1106
1107 BROKEN: should not fall back to plain grep
1108 $ hg grep -f data add0-cp1-mod1-rm3
1109 [1]
1110
1111 follow file history from wdir parent (explicit), removed:
1112
1113 $ hg log -fr. add0-cp1-mod1-rm3
1114 abort: cannot follow file not in any of the specified revisions: "add0-cp1-mod1-rm3"
1115 [255]
1116
1117 $ hg grep --diff -fr. data add0-cp1-mod1-rm3
1118 abort: cannot follow file not in parent revision: "add0-cp1-mod1-rm3"
1119 [255]
1120
1121 BROKEN: should abort
1122 $ hg grep -fr. data add0-cp1-mod1-rm3
1123 [1]
1124
1125 follow file history from wdir parent, removed in wdir:
1126
1127 $ hg log -f add0-rm4
1128 abort: cannot follow file not in parent revision: "add0-rm4"
1129 [255]
1130
1131 BROKEN: may be okay, but different behavior from "hg log"
1132 $ hg grep --diff -f data add0-rm4
1133 add0-rm4:0:+:data0
1134
1135 BROKEN: should not fall back to plain grep
1136 $ hg grep -f data add0-rm4
1137 [1]
1138
1139 follow file history from wdir parent (explicit), removed in wdir:
1140
1141 $ hg log -fr. add0-rm4
1142 0: A add0, A add0-mod1, A add0-mod2, A add0-mod3, A add0-mod4, A add0-rm1, A add0-rm2, A add0-rm4
1143
1144 BROKEN: should follow history
1145 $ hg grep --diff -fr. data add0-rm4
1146 [1]
1147
1148 BROKEN: should follow history
1149 $ hg grep -fr. data add0-rm4
1150 add0-rm4:3:data0
1151
1152 follow file history from wdir parent, multiple files:
1153
1154 $ hg log -f add0-mod3 add0-cp1-mod1
1155 3: A add0-cp1-cp3, A add0-cp1-mod1-cp3-mod3, R add0-cp1-mod1-rm3, M add0-mod3
1156 1: A add0-cp1, A add0-cp1-mod1, A add0-cp1-mod1-rm3, M add0-mod1, R add0-rm1
1157 0: A add0, A add0-mod1, A add0-mod2, A add0-mod3, A add0-mod4, A add0-rm1, A add0-rm2, A add0-rm4
1158
1159 $ hg grep --diff -f data add0-mod3 add0-cp1-mod1
1160 add0-mod3:3:+:data3
1161 add0-cp1-mod1:1:+:data1
1162 add0:0:+:data0
1163 add0-mod3:0:+:data0
1164
1165 BROKEN: should not fall back to plain grep
1166 $ hg grep -f data add0-mod3 add0-cp1-mod1
1167 add0-cp1-mod1:data0
1168 add0-cp1-mod1:data1
1169 add0-mod3:data0
1170 add0-mod3:data3
1171
1172 follow file history from specified revision, modified:
1173
1174 $ hg log -fr2 add0-mod2
1175 2: A add0-cp2, A add0-cp2-mod2, M add0-mod2, R add0-rm2
1176 0: A add0, A add0-mod1, A add0-mod2, A add0-mod3, A add0-mod4, A add0-rm1, A add0-rm2, A add0-rm4
1177
1178 BROKEN: should follow history from the specified revision
1179 $ hg grep --diff -fr2 data add0-mod2
1180 [1]
1181
1182 BROKEN: should follow history
1183 $ hg grep -fr2 data add0-mod2
1184 add0-mod2:2:data0
1185 add0-mod2:2:data2
1186
1187 follow file history from specified revision, copied but unmodified:
1188
1189 $ hg log -fr2 add0-cp2
1190 2: A add0-cp2, A add0-cp2-mod2, M add0-mod2, R add0-rm2
1191 0: A add0, A add0-mod1, A add0-mod2, A add0-mod3, A add0-mod4, A add0-rm1, A add0-rm2, A add0-rm4
1192
1193 BROKEN: should follow history from the specified revision
1194 $ hg grep --diff -fr2 data add0-cp2
1195 abort: cannot follow file not in parent revision: "add0-cp2"
1196 [255]
1197
1198 BROKEN: should follow history across renames
1199 $ hg grep -fr2 data add0-cp2
1200 add0-cp2:2:data0
1201
1202 follow file history from specified revision, copied and modified:
1203
1204 $ hg log -fr2 add0-cp2-mod2
1205 2: A add0-cp2, A add0-cp2-mod2, M add0-mod2, R add0-rm2
1206 0: A add0, A add0-mod1, A add0-mod2, A add0-mod3, A add0-mod4, A add0-rm1, A add0-rm2, A add0-rm4
1207
1208 BROKEN: should follow history from the specified revision
1209 $ hg grep --diff -fr2 data add0-cp2-mod2
1210 abort: cannot follow file not in parent revision: "add0-cp2-mod2"
1211 [255]
1212
1213 BROKEN: should follow history across renames
1214 $ hg grep -fr2 data add0-cp2-mod2
1215 add0-cp2-mod2:2:data0
1216 add0-cp2-mod2:2:data2
1217
1218 follow file history from specified revision, removed:
1219
1220 $ hg log -fr2 add0-rm2
1221 abort: cannot follow file not in any of the specified revisions: "add0-rm2"
1222 [255]
1223
1224 BROKEN: should abort
1225 $ hg grep --diff -fr2 data add0-rm2
1226 [1]
1227
1228 BROKEN: should abort
1229 $ hg grep -fr2 data add0-rm2
1230 [1]
1231
1232 follow file history from specified revision, multiple files:
1233
1234 $ hg log -fr2 add0-cp2 add0-mod2
1235 2: A add0-cp2, A add0-cp2-mod2, M add0-mod2, R add0-rm2
1236 0: A add0, A add0-mod1, A add0-mod2, A add0-mod3, A add0-mod4, A add0-rm1, A add0-rm2, A add0-rm4
1237
1238 BROKEN: should follow history from the specified revision
1239 $ hg grep --diff -fr2 data add0-cp2 add0-mod2
1240 abort: cannot follow file not in parent revision: "add0-cp2"
1241 [255]
1242
1243 BROKEN: should follow history
1244 $ hg grep -fr2 data add0-cp2 add0-mod2
1245 add0-cp2:2:data0
1246 add0-mod2:2:data0
1247 add0-mod2:2:data2
1248
1249 follow file history from wdir, unmodified:
1250
1251 $ hg log -fr'wdir()' add0-mod3
1252 2147483647: A add0-cp4, A add0-cp4-mod4, M add0-mod4, R add0-rm4
1253 3: A add0-cp1-cp3, A add0-cp1-mod1-cp3-mod3, R add0-cp1-mod1-rm3, M add0-mod3
1254 0: A add0, A add0-mod1, A add0-mod2, A add0-mod3, A add0-mod4, A add0-rm1, A add0-rm2, A add0-rm4
1255
1256 BROKEN: should follow history
1257 $ hg grep --diff -fr'wdir()' data add0-mod3
1258 [1]
1259
1260 BROKEN: should follow history
1261 $ hg grep -fr'wdir()' data add0-mod3
1262 add0-mod3:2147483647:data0
1263 add0-mod3:2147483647:data3
1264
1265 follow file history from wdir, modified:
1266
1267 $ hg log -fr'wdir()' add0-mod4
1268 2147483647: A add0-cp4, A add0-cp4-mod4, M add0-mod4, R add0-rm4
1269 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
1271 BROKEN: should follow history and show the changes in wdir
1272 $ hg grep --diff -fr'wdir()' data add0-mod4
1273 [1]
1274
1275 BROKEN: should follow history
1276 $ hg grep -fr'wdir()' data add0-mod4
1277 add0-mod4:2147483647:data0
1278 add0-mod4:2147483647:data4
1279
1280 follow file history from wdir, copied but unmodified:
1281
1282 $ hg log -fr'wdir()' add0-cp4
1283 2147483647: A add0-cp4, A add0-cp4-mod4, M add0-mod4, R add0-rm4
1284 0: A add0, A add0-mod1, A add0-mod2, A add0-mod3, A add0-mod4, A add0-rm1, A add0-rm2, A add0-rm4
1285
1286 BROKEN: should follow history
1287 $ hg grep --diff -fr'wdir()' data add0-cp4
1288 abort: cannot follow file not in parent revision: "add0-cp4"
1289 [255]
1290
1291 BROKEN: should follow history across renames
1292 $ hg grep -fr'wdir()' data add0-cp4
1293 add0-cp4:2147483647:data0
1294
1295 follow file history from wdir, copied and modified:
1296
1297 $ hg log -fr'wdir()' add0-cp4-mod4
1298 2147483647: A add0-cp4, A add0-cp4-mod4, M add0-mod4, R add0-rm4
1299 0: A add0, A add0-mod1, A add0-mod2, A add0-mod3, A add0-mod4, A add0-rm1, A add0-rm2, A add0-rm4
1300
1301 BROKEN: should follow history
1302 $ hg grep --diff -fr'wdir()' data add0-cp4-mod4
1303 abort: cannot follow file not in parent revision: "add0-cp4-mod4"
1304 [255]
1305
1306 BROKEN: should follow history across renames
1307 $ hg grep -fr'wdir()' data add0-cp4-mod4
1308 add0-cp4-mod4:2147483647:data0
1309 add0-cp4-mod4:2147483647:data4
1310
1311 follow file history from wdir, multiple files:
1312
1313 $ hg log -fr'wdir()' add0-cp4 add0-mod4 add0-mod3
1314 2147483647: A add0-cp4, A add0-cp4-mod4, M add0-mod4, R add0-rm4
1315 3: A add0-cp1-cp3, A add0-cp1-mod1-cp3-mod3, R add0-cp1-mod1-rm3, M add0-mod3
1316 0: A add0, A add0-mod1, A add0-mod2, A add0-mod3, A add0-mod4, A add0-rm1, A add0-rm2, A add0-rm4
1317
1318 BROKEN: should follow history
1319 $ hg grep --diff -fr'wdir()' data add0-cp4 add0-mod4 add0-mod3
1320 abort: cannot follow file not in parent revision: "add0-cp4"
1321 [255]
1322
1323 BROKEN: should follow history
1324 $ hg grep -fr'wdir()' data add0-cp4 add0-mod4 add0-mod3
1325 add0-cp4:2147483647:data0
1326 add0-mod3:2147483647:data0
1327 add0-mod3:2147483647:data3
1328 add0-mod4:2147483647:data0
1329 add0-mod4:2147483647:data4
1330
1331 $ cd ..
General Comments 0
You need to be logged in to leave comments. Login now