diff options
author | Hisham Muhammad <hisham@gobolinux.org> | 2015-10-19 16:50:13 -0200 |
---|---|---|
committer | Hisham Muhammad <hisham@gobolinux.org> | 2015-10-19 16:50:13 -0200 |
commit | 9c99043149e7578fbbfedbbdc7950a3c1f61ba6e (patch) | |
tree | d5eefcceedcd72df8222ae40232545df34827964 | |
parent | a65eb6572a24ecfe69f39a8046281fba5007fd50 (diff) | |
parent | 7886cffec0721ecfb733384946d7a4399c43b897 (diff) | |
download | luarocks-9c99043149e7578fbbfedbbdc7950a3c1f61ba6e.tar.gz luarocks-9c99043149e7578fbbfedbbdc7950a3c1f61ba6e.tar.bz2 luarocks-9c99043149e7578fbbfedbbdc7950a3c1f61ba6e.zip |
Merge pull request #440 from mpeterv/fix-patch-error
Fix patch error message when source is different
-rw-r--r-- | src/luarocks/tools/patch.lua | 17 |
1 files changed, 6 insertions, 11 deletions
diff --git a/src/luarocks/tools/patch.lua b/src/luarocks/tools/patch.lua index 9e5074ad..debaf636 100644 --- a/src/luarocks/tools/patch.lua +++ b/src/luarocks/tools/patch.lua | |||
@@ -460,16 +460,15 @@ local function find_hunks(file, hunks) | |||
460 | end | 460 | end |
461 | 461 | ||
462 | local function check_patched(file, hunks) | 462 | local function check_patched(file, hunks) |
463 | local matched = true | ||
464 | local lineno = 1 | 463 | local lineno = 1 |
465 | local ok, err = pcall(function() | 464 | local ok, err = pcall(function() |
466 | if #file == 0 then | 465 | if #file == 0 then |
467 | error 'nomatch' | 466 | error('nomatch', 0) |
468 | end | 467 | end |
469 | for hno, h in ipairs(hunks) do | 468 | for hno, h in ipairs(hunks) do |
470 | -- skip to line just before hunk starts | 469 | -- skip to line just before hunk starts |
471 | if #file < h.starttgt then | 470 | if #file < h.starttgt then |
472 | error 'nomatch' | 471 | error('nomatch', 0) |
473 | end | 472 | end |
474 | lineno = h.starttgt | 473 | lineno = h.starttgt |
475 | for _, hline in ipairs(h.text) do | 474 | for _, hline in ipairs(h.text) do |
@@ -478,22 +477,18 @@ local function check_patched(file, hunks) | |||
478 | local line = file[lineno] | 477 | local line = file[lineno] |
479 | lineno = lineno + 1 | 478 | lineno = lineno + 1 |
480 | if #line == 0 then | 479 | if #line == 0 then |
481 | error 'nomatch' | 480 | error('nomatch', 0) |
482 | end | 481 | end |
483 | if endlstrip(line) ~= endlstrip(hline:sub(2)) then | 482 | if endlstrip(line) ~= endlstrip(hline:sub(2)) then |
484 | warning(format("file is not patched - failed hunk: %d", hno)) | 483 | warning(format("file is not patched - failed hunk: %d", hno)) |
485 | error 'nomatch' | 484 | error('nomatch', 0) |
486 | end | 485 | end |
487 | end | 486 | end |
488 | end | 487 | end |
489 | end | 488 | end |
490 | end) | 489 | end) |
491 | if err == 'nomatch' then | 490 | -- todo: display failed hunk, i.e. expected/found |
492 | matched = false | 491 | return err ~= 'nomatch' |
493 | end | ||
494 | -- todo: display failed hunk, i.e. expected/found | ||
495 | |||
496 | return matched | ||
497 | end | 492 | end |
498 | 493 | ||
499 | local function patch_hunks(srcname, tgtname, hunks) | 494 | local function patch_hunks(srcname, tgtname, hunks) |