Skip to content

Commit 05a669d

Browse files
authored
Merge pull request #6183 from dra27/processing-patches-2.2
[2.2 backport] Fix highly embarrassing mistake in patch transformation
2 parents b03afad + 7e24595 commit 05a669d

File tree

3 files changed

+10
-4
lines changed

3 files changed

+10
-4
lines changed

master_changes.md

+1
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ users)
9090
## Shell
9191

9292
## Internal
93+
* Fix error in `OpamSystem.transform_patch` - patches were only applied when debugging [#6182 @dra27 regression since #3449]
9394

9495
## Internal: Windows
9596

src/core/opamSystem.ml

+7-4
Original file line numberDiff line numberDiff line change
@@ -1485,10 +1485,12 @@ let translate_patch ~dir orig corrected =
14851485
process_state_transition `Header state transforms |> List.rev
14861486
in
14871487
let transforms = fold_lines `Header 1 [] in
1488-
if transforms = [] then
1488+
if transforms = [] then begin
1489+
log ~level:1 "No patch translation needed for %s -> %s" orig corrected;
14891490
copy_file orig corrected
1490-
else begin
1491+
end else begin
14911492
seek_in ch 0;
1493+
log ~level:1 "Transforming patch %s to %s" orig corrected;
14921494
let ch_out =
14931495
try open_out_bin corrected
14941496
with Sys_error _ ->
@@ -1503,12 +1505,13 @@ let translate_patch ~dir orig corrected =
15031505
else
15041506
(id, (fun s -> s ^ "\r"), strip 1)
15051507
in
1506-
if OpamConsole.debug () then
1508+
if OpamConsole.debug () then begin
15071509
let log_transform (first_line, last_line, add_cr) =
15081510
let indicator = if add_cr then '+' else '-' in
15091511
log ~level:3 "Transform %d-%d %c\\r" first_line last_line indicator
15101512
in
1511-
List.iter log_transform transforms;
1513+
List.iter log_transform transforms
1514+
end;
15121515
let rec fold_lines n transforms =
15131516
match input_line ch with
15141517
| line ->

tests/lib/patcher.expected

+2
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ PATCH No CRLF adaptation necessary for b/test1
77
PATCH No CRLF adaptation necessary for b/test2
88
PATCH No CRLF adaptation necessary for b/test3
99
PATCH No CRLF adaptation necessary for b/will-null-file
10+
PATCH No patch translation needed for input.patch -> output.patch
1011
Before patch state of c:
1112
./always-crlf: CRLF
1213
./always-lf: LF
@@ -44,6 +45,7 @@ PATCH No CRLF adaptation necessary for b/test1
4445
PATCH Adding \r to patch chunks for b/test2
4546
PATCH No CRLF adaptation necessary for b/test3
4647
PATCH Adding \r to patch chunks for b/will-null-file
48+
PATCH Transforming patch input.patch to output.patch
4749
PATCH Transform 32-36 +\r
4850
PATCH Transform 62-67 +\r
4951
PATCH Transform 82-87 +\r

0 commit comments

Comments
 (0)