##// END OF EJS Templates
record: abort on malformed patches instead of crashing
Mads Kiilerich -
r18953:e4ae3975 default
parent child Browse files
Show More
@@ -531,7 +531,11 b' def dorecord(ui, repo, commitfunc, cmdsu'
531 fp.seek(0)
531 fp.seek(0)
532
532
533 # 1. filter patch, so we have intending-to apply subset of it
533 # 1. filter patch, so we have intending-to apply subset of it
534 chunks = filterpatch(ui, parsepatch(fp))
534 try:
535 chunks = filterpatch(ui, parsepatch(fp))
536 except patch.PatchError, err:
537 raise util.Abort(_('error parsing patch: %s') % err)
538
535 del fp
539 del fp
536
540
537 contenders = set()
541 contenders = set()
@@ -1176,6 +1176,53 b' Invalid patch'
1176 +That change will not be committed
1176 +That change will not be committed
1177 +That is the second line
1177 +That is the second line
1178 +That line has been added
1178 +That line has been added
1179
1180 Malformed patch - error handling
1181
1182 $ cat > editor.sh << '__EOF__'
1183 > sed -e '/^@/p' "$1" > tmp
1184 > mv tmp "$1"
1185 > __EOF__
1186 $ HGEDITOR="\"sh\" \"`pwd`/editor.sh\"" hg record <<EOF
1187 > y
1188 > e
1189 > EOF
1190 diff --git a/editedfile b/editedfile
1191 1 hunks, 3 lines changed
1192 examine changes to 'editedfile'? [Ynesfdaq?]
1193 @@ -1,3 +1,3 @@
1194 -This is the first line
1195 -This change will be committed
1196 -This is the third line
1197 +This change will not be committed
1198 +This is the second line
1199 +This line has been added
1200 record this change to 'editedfile'? [Ynesfdaq?]
1201 abort: error parsing patch: unhandled transition: range -> range
1202 [255]
1203
1204 $ cat > editor.sh << '__EOF__'
1205 > sed -e '/^@/iother' "$1" > tmp
1206 > mv tmp "$1"
1207 > __EOF__
1208 $ HGEDITOR="\"sh\" \"`pwd`/editor.sh\"" hg record <<EOF
1209 > y
1210 > e
1211 > EOF
1212 diff --git a/editedfile b/editedfile
1213 1 hunks, 3 lines changed
1214 examine changes to 'editedfile'? [Ynesfdaq?]
1215 @@ -1,3 +1,3 @@
1216 -This is the first line
1217 -This change will be committed
1218 -This is the third line
1219 +This change will not be committed
1220 +This is the second line
1221 +This line has been added
1222 record this change to 'editedfile'? [Ynesfdaq?]
1223 abort: error parsing patch: unknown patch content: 'other\n'
1224 [255]
1225
1179 $ hg up -C
1226 $ hg up -C
1180 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
1227 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
1181
1228
General Comments 0
You need to be logged in to leave comments. Login now