Show More
@@ -973,7 +973,7 b' class hunk(object):' | |||
|
973 | 973 | # this removes context lines from the top and bottom of list 'l'. It |
|
974 | 974 | # checks the hunk to make sure only context lines are removed, and then |
|
975 | 975 | # returns a new shortened list of lines. |
|
976 |
fuzz = min(fuzz, len(old) |
|
|
976 | fuzz = min(fuzz, len(old)) | |
|
977 | 977 | if fuzz: |
|
978 | 978 | top = 0 |
|
979 | 979 | bot = 0 |
@@ -991,18 +991,8 b' class hunk(object):' | |||
|
991 | 991 | else: |
|
992 | 992 | break |
|
993 | 993 | |
|
994 | # top and bot now count context in the hunk | |
|
995 | # adjust them if either one is short | |
|
996 | context = max(top, bot, 3) | |
|
997 | if bot < context: | |
|
998 | bot = max(0, fuzz - (context - bot)) | |
|
999 | else: | |
|
1000 | bot = min(fuzz, bot) | |
|
1001 | if top < context: | |
|
1002 | top = max(0, fuzz - (context - top)) | |
|
1003 | else: | |
|
1004 | top = min(fuzz, top) | |
|
1005 | ||
|
994 | bot = min(fuzz, bot) | |
|
995 | top = min(fuzz, top) | |
|
1006 | 996 | return old[top:len(old)-bot], new[top:len(new)-bot], top |
|
1007 | 997 | return old, new, 0 |
|
1008 | 998 |
@@ -111,7 +111,15 b' Test unsupported combinations' | |||
|
111 | 111 | |
|
112 | 112 | Test commit editor |
|
113 | 113 | |
|
114 |
$ |
|
|
114 | $ cat > ../test.diff <<EOF | |
|
115 | > diff -r 07f494440405 -r 4e322f7ce8e3 a | |
|
116 | > --- a/a Thu Jan 01 00:00:00 1970 +0000 | |
|
117 | > +++ b/a Thu Jan 01 00:00:00 1970 +0000 | |
|
118 | > @@ -1,1 +1,2 @@ | |
|
119 | > -a | |
|
120 | > +b | |
|
121 | > +c | |
|
122 | > EOF | |
|
115 | 123 | $ HGEDITOR=cat hg import --bypass ../test.diff |
|
116 | 124 | applying ../test.diff |
|
117 | 125 | |
@@ -138,7 +146,7 b' Test patch.eol is handled' | |||
|
138 | 146 | $ hg --config patch.eol=auto import -d '0 0' -m 'test patch.eol' --bypass ../test.diff |
|
139 | 147 | applying ../test.diff |
|
140 | 148 | $ shortlog |
|
141 |
o 3: |
|
|
149 | o 3:c606edafba99 test 0 0 - default - test patch.eol | |
|
142 | 150 | | |
|
143 | 151 | @ 2:872023de769d test 0 0 - default - makeacrlf |
|
144 | 152 | | |
@@ -445,7 +445,7 b' Test fuzziness (ambiguous patch location' | |||
|
445 | 445 | $ hg import --no-commit -v fuzzy-tip.patch |
|
446 | 446 | applying fuzzy-tip.patch |
|
447 | 447 | patching file a |
|
448 |
Hunk #1 succeeded at |
|
|
448 | Hunk #1 succeeded at 2 with fuzz 1 (offset 0 lines). | |
|
449 | 449 | applied to working directory |
|
450 | 450 | $ hg revert -a |
|
451 | 451 | reverting a |
@@ -462,7 +462,7 b' test fuzziness with eol=auto' | |||
|
462 | 462 | $ hg --config patch.eol=auto import --no-commit -v fuzzy-tip.patch |
|
463 | 463 | applying fuzzy-tip.patch |
|
464 | 464 | patching file a |
|
465 |
Hunk #1 succeeded at |
|
|
465 | Hunk #1 succeeded at 2 with fuzz 1 (offset 0 lines). | |
|
466 | 466 | applied to working directory |
|
467 | 467 | $ cd .. |
|
468 | 468 | |
@@ -1029,6 +1029,19 b' Test corner case involving fuzz and skew' | |||
|
1029 | 1029 | > +line |
|
1030 | 1030 | > EOF |
|
1031 | 1031 | |
|
1032 | $ cat > 04-middle-of-file-completely-fuzzed.diff <<EOF | |
|
1033 | > diff --git a/a b/a | |
|
1034 | > --- a/a | |
|
1035 | > +++ b/a | |
|
1036 | > @@ -1,1 +1,1 @@ | |
|
1037 | > -2 | |
|
1038 | > +add some skew | |
|
1039 | > @@ -2,2 +2,3 @@ | |
|
1040 | > not matching, should fuzz | |
|
1041 | > ... a bit | |
|
1042 | > +line | |
|
1043 | > EOF | |
|
1044 | ||
|
1032 | 1045 | $ cat > a <<EOF |
|
1033 | 1046 | > 1 |
|
1034 | 1047 | > 2 |
@@ -1071,4 +1084,14 b' Test corner case involving fuzz and skew' | |||
|
1071 | 1084 | 3 |
|
1072 | 1085 | 4 |
|
1073 | 1086 | line |
|
1087 | applying 04-middle-of-file-completely-fuzzed.diff | |
|
1088 | patching file a | |
|
1089 | Hunk #1 succeeded at 2 (offset 1 lines). | |
|
1090 | Hunk #2 succeeded at 5 with fuzz 2 (offset 1 lines). | |
|
1091 | applied to working directory | |
|
1092 | 1 | |
|
1093 | add some skew | |
|
1094 | 3 | |
|
1095 | 4 | |
|
1096 | line | |
|
1074 | 1097 |
@@ -125,12 +125,10 b' Merge:' | |||
|
125 | 125 | merging with queue at: $TESTTMP/t2/.hg/refqueue (glob) |
|
126 | 126 | applying patcha |
|
127 | 127 | patching file a |
|
128 | Hunk #1 FAILED at 0 | |
|
129 | 1 out of 1 hunks FAILED -- saving rejects to file a.rej | |
|
130 | patch failed, unable to continue (try -v) | |
|
131 | patch failed, rejects left in working dir | |
|
128 | Hunk #1 succeeded at 2 with fuzz 1 (offset 0 lines). | |
|
129 | fuzz found when applying patch, stopping | |
|
132 | 130 | patch didn't work out, merging patcha |
|
133 |
|
|
|
131 | 1 files updated, 0 files merged, 1 files removed, 0 files unresolved | |
|
134 | 132 | 0 files updated, 2 files merged, 0 files removed, 0 files unresolved |
|
135 | 133 | (branch merge, don't forget to commit) |
|
136 | 134 | applying patcha2 |
General Comments 0
You need to be logged in to leave comments.
Login now