##// END OF EJS Templates
grep: fix --follow with no --diff nor --rev to not fall back to plain grep...
Yuya Nishihara -
r46050:07c424a1 default
parent child Browse files
Show More
@@ -3357,7 +3357,11 b' def grep(ui, repo, pattern, *pats, **opt'
3357 raise error.Abort(_(b'--diff and --all-files are mutually exclusive'))
3357 raise error.Abort(_(b'--diff and --all-files are mutually exclusive'))
3358 if opts.get(b'all_files') is None and not diff:
3358 if opts.get(b'all_files') is None and not diff:
3359 opts[b'all_files'] = True
3359 opts[b'all_files'] = True
3360 plaingrep = opts.get(b'all_files') and not opts.get(b'rev')
3360 plaingrep = (
3361 opts.get(b'all_files')
3362 and not opts.get(b'rev')
3363 and not opts.get(b'follow')
3364 )
3361 all_files = opts.get(b'all_files')
3365 all_files = opts.get(b'all_files')
3362 if plaingrep:
3366 if plaingrep:
3363 opts[b'rev'] = [b'wdir()']
3367 opts[b'rev'] = [b'wdir()']
@@ -904,27 +904,44 b' follow revision history from wdir parent'
904 add0-rm2:0:+:data0
904 add0-rm2:0:+:data0
905 add0-rm4:0:+:data0
905 add0-rm4:0:+:data0
906
906
907 BROKEN: should not fall back to plain grep
908 $ hg grep -f data
907 $ hg grep -f data
909 add0:data0
908 add0:3:data0
910 add0-cp1:data0
909 add0-cp1:3:data0
911 add0-cp1-cp3:data0
910 add0-cp1-cp3:3:data0
912 add0-cp1-mod1:data0
911 add0-cp1-mod1:3:data0
913 add0-cp1-mod1:data1
912 add0-cp1-mod1:3:data1
914 add0-cp1-mod1-cp3-mod3:data0
913 add0-cp1-mod1-cp3-mod3:3:data0
915 add0-cp1-mod1-cp3-mod3:data1
914 add0-cp1-mod1-cp3-mod3:3:data1
916 add0-cp1-mod1-cp3-mod3:data3
915 add0-cp1-mod1-cp3-mod3:3:data3
917 add0-cp4:data0
916 add0-mod1:3:data0
918 add0-cp4-mod4:data0
917 add0-mod1:3:data1
919 add0-cp4-mod4:data4
918 add0-mod2:3:data0
920 add0-mod1:data0
919 add0-mod3:3:data0
921 add0-mod1:data1
920 add0-mod3:3:data3
922 add0-mod2:data0
921 add0-mod4:3:data0
923 add0-mod3:data0
922 add0-rm2:3:data0
924 add0-mod3:data3
923 add0-rm4:3:data0
925 add0-mod4:data0
924 add0:1:data0
926 add0-mod4:data4
925 add0-cp1:1:data0
927 add0-rm2:data0
926 add0-cp1-mod1:1:data0
927 add0-cp1-mod1:1:data1
928 add0-cp1-mod1-rm3:1:data0
929 add0-cp1-mod1-rm3:1:data1
930 add0-mod1:1:data0
931 add0-mod1:1:data1
932 add0-mod2:1:data0
933 add0-mod3:1:data0
934 add0-mod4:1:data0
935 add0-rm2:1:data0
936 add0-rm4:1:data0
937 add0:0:data0
938 add0-mod1:0:data0
939 add0-mod2:0:data0
940 add0-mod3:0:data0
941 add0-mod4:0:data0
942 add0-rm1:0:data0
943 add0-rm2:0:data0
944 add0-rm4:0:data0
928
945
929 follow revision history from specified revision:
946 follow revision history from specified revision:
930
947
@@ -1030,10 +1047,13 b' follow file history from wdir parent, un'
1030 add0-mod3:3:+:data3
1047 add0-mod3:3:+:data3
1031 add0-mod3:0:+:data0
1048 add0-mod3:0:+:data0
1032
1049
1033 BROKEN: should not fall back to plain grep
1050 BROKEN: should not include the revision 2
1034 $ hg grep -f data add0-mod3
1051 $ hg grep -f data add0-mod3
1035 add0-mod3:data0
1052 add0-mod3:3:data0
1036 add0-mod3:data3
1053 add0-mod3:3:data3
1054 add0-mod3:2:data0
1055 add0-mod3:1:data0
1056 add0-mod3:0:data0
1037
1057
1038 follow file history from wdir parent, modified in wdir:
1058 follow file history from wdir parent, modified in wdir:
1039
1059
@@ -1043,10 +1063,12 b' follow file history from wdir parent, mo'
1043 $ hg grep --diff -f data add0-mod4
1063 $ hg grep --diff -f data add0-mod4
1044 add0-mod4:0:+:data0
1064 add0-mod4:0:+:data0
1045
1065
1046 BROKEN: should not fall back to plain grep
1066 BROKEN: should not include the revision 2
1047 $ hg grep -f data add0-mod4
1067 $ hg grep -f data add0-mod4
1048 add0-mod4:data0
1068 add0-mod4:3:data0
1049 add0-mod4:data4
1069 add0-mod4:2:data0
1070 add0-mod4:1:data0
1071 add0-mod4:0:data0
1050
1072
1051 follow file history from wdir parent, copied but unmodified:
1073 follow file history from wdir parent, copied but unmodified:
1052
1074
@@ -1058,9 +1080,9 b' follow file history from wdir parent, co'
1058 $ hg grep --diff -f data add0-cp1-cp3
1080 $ hg grep --diff -f data add0-cp1-cp3
1059 add0:0:+:data0
1081 add0:0:+:data0
1060
1082
1061 BROKEN: should not fall back to plain grep
1083 BROKEN: should follow history across renames
1062 $ hg grep -f data add0-cp1-cp3
1084 $ hg grep -f data add0-cp1-cp3
1063 add0-cp1-cp3:data0
1085 add0-cp1-cp3:3:data0
1064
1086
1065 follow file history from wdir parent, copied and modified:
1087 follow file history from wdir parent, copied and modified:
1066
1088
@@ -1074,11 +1096,11 b' follow file history from wdir parent, co'
1074 add0-cp1-mod1:1:+:data1
1096 add0-cp1-mod1:1:+:data1
1075 add0:0:+:data0
1097 add0:0:+:data0
1076
1098
1077 BROKEN: should not fall back to plain grep
1099 BROKEN: should follow history across renames
1078 $ hg grep -f data add0-cp1-mod1-cp3-mod3
1100 $ hg grep -f data add0-cp1-mod1-cp3-mod3
1079 add0-cp1-mod1-cp3-mod3:data0
1101 add0-cp1-mod1-cp3-mod3:3:data0
1080 add0-cp1-mod1-cp3-mod3:data1
1102 add0-cp1-mod1-cp3-mod3:3:data1
1081 add0-cp1-mod1-cp3-mod3:data3
1103 add0-cp1-mod1-cp3-mod3:3:data3
1082
1104
1083 follow file history from wdir parent, copied in wdir:
1105 follow file history from wdir parent, copied in wdir:
1084
1106
@@ -1090,9 +1112,9 b' follow file history from wdir parent, co'
1090 abort: cannot follow file not in parent revision: "add0-cp4"
1112 abort: cannot follow file not in parent revision: "add0-cp4"
1091 [255]
1113 [255]
1092
1114
1093 BROKEN: should not fall back to plain grep
1115 BROKEN: maybe better to abort
1094 $ hg grep -f data add0-cp4
1116 $ hg grep -f data add0-cp4
1095 add0-cp4:data0
1117 [1]
1096
1118
1097 follow file history from wdir parent, removed:
1119 follow file history from wdir parent, removed:
1098
1120
@@ -1104,9 +1126,10 b' follow file history from wdir parent, re'
1104 abort: cannot follow file not in parent revision: "add0-cp1-mod1-rm3"
1126 abort: cannot follow file not in parent revision: "add0-cp1-mod1-rm3"
1105 [255]
1127 [255]
1106
1128
1107 BROKEN: should not fall back to plain grep
1129 BROKEN: maybe better to abort
1108 $ hg grep -f data add0-cp1-mod1-rm3
1130 $ hg grep -f data add0-cp1-mod1-rm3
1109 [1]
1131 add0-cp1-mod1-rm3:1:data0
1132 add0-cp1-mod1-rm3:1:data1
1110
1133
1111 follow file history from wdir parent (explicit), removed:
1134 follow file history from wdir parent (explicit), removed:
1112
1135
@@ -1132,9 +1155,12 b' follow file history from wdir parent, re'
1132 $ hg grep --diff -f data add0-rm4
1155 $ hg grep --diff -f data add0-rm4
1133 add0-rm4:0:+:data0
1156 add0-rm4:0:+:data0
1134
1157
1135 BROKEN: should not fall back to plain grep
1158 BROKEN: should not include the revision 2, and maybe better to abort
1136 $ hg grep -f data add0-rm4
1159 $ hg grep -f data add0-rm4
1137 [1]
1160 add0-rm4:3:data0
1161 add0-rm4:2:data0
1162 add0-rm4:1:data0
1163 add0-rm4:0:data0
1138
1164
1139 follow file history from wdir parent (explicit), removed in wdir:
1165 follow file history from wdir parent (explicit), removed in wdir:
1140
1166
@@ -1162,12 +1188,18 b' follow file history from wdir parent, mu'
1162 add0:0:+:data0
1188 add0:0:+:data0
1163 add0-mod3:0:+:data0
1189 add0-mod3:0:+:data0
1164
1190
1165 BROKEN: should not fall back to plain grep
1191 BROKEN: should not include the revision 2
1192 BROKEN: should follow history across renames
1166 $ hg grep -f data add0-mod3 add0-cp1-mod1
1193 $ hg grep -f data add0-mod3 add0-cp1-mod1
1167 add0-cp1-mod1:data0
1194 add0-cp1-mod1:3:data0
1168 add0-cp1-mod1:data1
1195 add0-cp1-mod1:3:data1
1169 add0-mod3:data0
1196 add0-mod3:3:data0
1170 add0-mod3:data3
1197 add0-mod3:3:data3
1198 add0-mod3:2:data0
1199 add0-cp1-mod1:1:data0
1200 add0-cp1-mod1:1:data1
1201 add0-mod3:1:data0
1202 add0-mod3:0:data0
1171
1203
1172 follow file history from specified revision, modified:
1204 follow file history from specified revision, modified:
1173
1205
General Comments 0
You need to be logged in to leave comments. Login now