Mercurial > public > mercurial-scm > hg
diff tests/test-import.t @ 16124:0e0060bf2f44 stable
patch: fuzz more aggressively to match patch(1) behaviour
The previous code was assuming a default context of 3 lines. When fuzzing, it
would take this value in account to reduce the amount of removed line from
hunks top or bottom. For instance, if a hunk has only 2 lines of bottom
context, fuzzing with fuzz=1 would do nothing and with fuzz=2 it would remove
one of those lines. A hunk with one line of bottom context could not be fuzzed
at all. patch(1) has apparently no such restrictions and takes the fuzz level
at face value.
- test-import.t: fuzz/offset changes at the beginning of file are explained by
the new fuzzing behaviour and match patch(1) ones. Patching locations are
different but those of my patch(1) do not make a lot of sense right now
(patched output are the same)
- test-import-bypass.t: more agressive fuzzing makes a patching supposed to
fail because of context, succeed. Change the diff to avoid this.
- test-mq-merge.t: more agressive fuzzing would allow the merged patch to apply
with fuzz, but fortunately we disallow this behaviour. The new output is
kept.
I have not enough experience with patch(1) fuzzing to know whether aligning our
implementation on it is a good or bad idea. Until now, it has been the
implementation reference. For instance, "qpush" tolerates fuzz (test-mq-merge.t
runs the special case of pushing merge revisions where fuzzing is forbidden).
author | Patrick Mezard <patrick@mezard.eu> |
---|---|
date | Mon, 13 Feb 2012 17:22:35 +0100 |
parents | b0c7525f826d |
children | fcb97d9a26cd |
line wrap: on
line diff
--- a/tests/test-import.t Mon Feb 13 16:47:31 2012 +0100 +++ b/tests/test-import.t Mon Feb 13 17:22:35 2012 +0100 @@ -445,7 +445,7 @@ $ hg import --no-commit -v fuzzy-tip.patch applying fuzzy-tip.patch patching file a - Hunk #1 succeeded at 1 with fuzz 2 (offset -2 lines). + Hunk #1 succeeded at 2 with fuzz 1 (offset 0 lines). applied to working directory $ hg revert -a reverting a @@ -462,7 +462,7 @@ $ hg --config patch.eol=auto import --no-commit -v fuzzy-tip.patch applying fuzzy-tip.patch patching file a - Hunk #1 succeeded at 1 with fuzz 2 (offset -2 lines). + Hunk #1 succeeded at 2 with fuzz 1 (offset 0 lines). applied to working directory $ cd .. @@ -1029,6 +1029,19 @@ > +line > EOF + $ cat > 04-middle-of-file-completely-fuzzed.diff <<EOF + > diff --git a/a b/a + > --- a/a + > +++ b/a + > @@ -1,1 +1,1 @@ + > -2 + > +add some skew + > @@ -2,2 +2,3 @@ + > not matching, should fuzz + > ... a bit + > +line + > EOF + $ cat > a <<EOF > 1 > 2 @@ -1071,4 +1084,14 @@ 3 4 line + applying 04-middle-of-file-completely-fuzzed.diff + patching file a + Hunk #1 succeeded at 2 (offset 1 lines). + Hunk #2 succeeded at 5 with fuzz 2 (offset 1 lines). + applied to working directory + 1 + add some skew + 3 + 4 + line