mirror of
https://github.com/facebook/sapling.git
synced 2024-10-07 15:27:13 +03:00
patch: add fuzz config flag (issue4697)
This commit is contained in:
parent
b62d73dc41
commit
7c6674833f
@ -1093,6 +1093,11 @@ command or with Mercurial Queues extension.
|
||||
of line, patch line endings are preserved.
|
||||
Default: strict.
|
||||
|
||||
``fuzz``
|
||||
The number of lines of 'fuzz' to allow when applying patches. This
|
||||
controls how much context the patcher is allowed to ignore when
|
||||
trying to apply a patch.
|
||||
Default: 2
|
||||
|
||||
``paths``
|
||||
---------
|
||||
|
@ -773,7 +773,7 @@ class patchfile(object):
|
||||
for x, s in enumerate(self.lines):
|
||||
self.hash.setdefault(s, []).append(x)
|
||||
|
||||
for fuzzlen in xrange(3):
|
||||
for fuzzlen in xrange(self.ui.configint("patch", "fuzz", 2) + 1):
|
||||
for toponly in [True, False]:
|
||||
old, oldstart, new, newstart = h.fuzzit(fuzzlen, toponly)
|
||||
oldstart = oldstart + self.offset + self.skew
|
||||
|
@ -492,6 +492,13 @@ Test fuzziness (ambiguous patch location, fuzz=2)
|
||||
$ echo line0 >> a
|
||||
$ hg ci -m brancha
|
||||
created new head
|
||||
$ hg import --config patch.fuzz=0 -v fuzzy-tip.patch
|
||||
applying fuzzy-tip.patch
|
||||
patching file a
|
||||
Hunk #1 FAILED at 0
|
||||
1 out of 1 hunks FAILED -- saving rejects to file a.rej
|
||||
abort: patch failed to apply
|
||||
[255]
|
||||
$ hg import --no-commit -v fuzzy-tip.patch
|
||||
applying fuzzy-tip.patch
|
||||
patching file a
|
||||
|
Loading…
Reference in New Issue
Block a user