##// END OF EJS Templates
patch: improve heuristics to not take the word "diff" as header (issue1879)...
Yuya Nishihara -
r34965:7ebf850d default
parent child Browse files
Show More
@@ -203,7 +203,7 b' def extract(ui, fileobj):'
203 203
204 204 # attempt to detect the start of a patch
205 205 # (this heuristic is borrowed from quilt)
206 diffre = re.compile(br'^(?:Index:[ \t]|diff[ \t]|RCS file: |'
206 diffre = re.compile(br'^(?:Index:[ \t]|diff[ \t]-|RCS file: |'
207 207 br'retrieving revision [0-9]+(\.[0-9]+)*$|'
208 208 br'---[ \t].*?^\+\+\+[ \t]|'
209 209 br'\*\*\*[ \t].*?^---[ \t])',
@@ -1346,6 +1346,93 b' import a unified diff with no lines of c'
1346 1346
1347 1347 $ cd ..
1348 1348
1349 commit message that looks like a diff header (issue1879)
1350
1351 $ hg init headerlikemsg
1352 $ cd headerlikemsg
1353 $ touch empty
1354 $ echo nonempty >> nonempty
1355 $ hg ci -qAl - <<EOF
1356 > blah blah
1357 > diff blah
1358 > blah blah
1359 > EOF
1360 $ hg --config diff.git=1 log -pv
1361 changeset: 0:c6ef204ef767
1362 tag: tip
1363 user: test
1364 date: Thu Jan 01 00:00:00 1970 +0000
1365 files: empty nonempty
1366 description:
1367 blah blah
1368 diff blah
1369 blah blah
1370
1371
1372 diff --git a/empty b/empty
1373 new file mode 100644
1374 diff --git a/nonempty b/nonempty
1375 new file mode 100644
1376 --- /dev/null
1377 +++ b/nonempty
1378 @@ -0,0 +1,1 @@
1379 +nonempty
1380
1381
1382 (without --git, empty file is lost, but commit message should be preserved)
1383
1384 $ hg init plain
1385 $ hg export 0 | hg -R plain import -
1386 applying patch from stdin
1387 $ hg --config diff.git=1 -R plain log -pv
1388 changeset: 0:60a2d231e71f
1389 tag: tip
1390 user: test
1391 date: Thu Jan 01 00:00:00 1970 +0000
1392 files: nonempty
1393 description:
1394 blah blah
1395 diff blah
1396 blah blah
1397
1398
1399 diff --git a/nonempty b/nonempty
1400 new file mode 100644
1401 --- /dev/null
1402 +++ b/nonempty
1403 @@ -0,0 +1,1 @@
1404 +nonempty
1405
1406
1407 (with --git, patch contents should be fully preserved)
1408
1409 $ hg init git
1410 $ hg --config diff.git=1 export 0 | hg -R git import -
1411 applying patch from stdin
1412 $ hg --config diff.git=1 -R git log -pv
1413 changeset: 0:c6ef204ef767
1414 tag: tip
1415 user: test
1416 date: Thu Jan 01 00:00:00 1970 +0000
1417 files: empty nonempty
1418 description:
1419 blah blah
1420 diff blah
1421 blah blah
1422
1423
1424 diff --git a/empty b/empty
1425 new file mode 100644
1426 diff --git a/nonempty b/nonempty
1427 new file mode 100644
1428 --- /dev/null
1429 +++ b/nonempty
1430 @@ -0,0 +1,1 @@
1431 +nonempty
1432
1433
1434 $ cd ..
1435
1349 1436 no segfault while importing a unified diff which start line is zero but chunk
1350 1437 size is non-zero
1351 1438
General Comments 0
You need to be logged in to leave comments. Login now