Checkout Tools
  • last updated 1 hour ago
Constraints
Constraints: committers
 
Constraints: files
Constraints: dates
Teach 'patch' to read an svn:mergeinfo property change formatted as a normal

property diff.

Previously it could only read the pretty-printed format.

Part of issue #3747 "'svn diff' and 'svn patch' support of svn:mergeinfo".

* subversion/libsvn_diff/parse-diff.c

(parse_pretty_mergeinfo_line): Rename from 'parse_mergeinfo'. Don't munge

the hunk header object. Improve documentation.

(parse_next_hunk): When parsing pretty-printed mergeinfo, allow to fall

through to normal processing if pretty-print format is not found. If

a pretty-print hunk is found, return a hunk object. (Previously it

quietly processed it and moved on to the next hunk without informing

the caller.)

(parse_hunks): Instead of skipping storing any mergeinfo hunks, only

skip storing pretty-print-mergeinfo hunks, but do store those formatted

in the regular property diff format.

* subversion/tests/cmdline/patch_tests.py

(patch_mergeinfo_in_regular_prop_format): New test.

(test_list): Run it.

  1. … 1 more file in changeset.
Silence a -Wswitch warning in the reverse-patch code.

* subversion/libsvn_diff/parse-diff.c (svn_diff_parse_next_patch):

Add cases for all enumeration values to the switch statement.

Following up on r1720351, fix handling patch files that have more context

than the diff headers tell us in the same way as a shortage of context.

This change makes a bad patch in our testsuite visible, where we expected

bad behavior. This patch fixes that test and adds more testing.

* subversion/libsvn_client/patch.c

(hunk_info_t): Separate reported fuzz from matching fuzz as mixing them

causes errors.

(get_hunk_info): Store both fuzz values.

(apply_hunk): Use match fuzz for apply-magic.

(send_hunk_notification): Report fuzz with penalty.

* subversion/libsvn_diff/parse-diff.c

(parse_next_hunk): Parse extra context when that exists. Report this case

as fuzz penalty, like a fuzz shortage.

* subversion/tests/cmdline/patch_tests.py

(patch_empty_file): Fix patch to work as document. Expect the proper result.

Extract the original version as new test.

(missing_trailing_context): Extend test with reverse patching and too much

trailing context.

(patch_missed_trail): New test, with the original case of patch_empty_file.

Expect that it no longer ignores the 'replacement' line.

(test_list): Add patch_missed_trail.

  1. … 2 more files in changeset.
Resolve issue #4609, by extending the diff parser with some additional

verifications and a match penalty.

Temporarily keep this as private api to allow backporting this patch.

[Note: This introduces some new issues applying certain bad patches. These

issues are fixed in r1720359]

* subversion/include/private/svn_diff_private.h

(svn_diff_hunk__get_fuzz_penalty): New function.

* subversion/libsvn_client/patch.c

(match_hunk): Check for fuzz penalties.

* subversion/libsvn_diff/parse-diff.c

(svn_diff_hunk_t): Add two fields.

(add_or_delete_single_line): Safely initialize everything to 0.

(parse_next_hunk): Handle missing context lines by updating the number

of lines in the hunk and applying a fuzz penalty.

(svn_diff_hunk__get_fuzz_penalty): New function.

* subversion/tests/cmdline/patch_tests.py

(missing_trailing_context): Remove XFail. Expect fuzz.

  1. … 3 more files in changeset.
Use svn_io_file_get_offset() instead of svn_io_file_seek(APR_CUR) where it

makes sense.

* subversion/libsvn_client/patch.c

* subversion/libsvn_diff/parse-diff.c

* subversion/libsvn_repos/dump.c

* subversion/libsvn_subr/io.c

* subversion/libsvn_subr/stream.c

* subversion/tests/libsvn_subr/io-test.c

(tell_file, read_handler_base85, hunk_readline_original_or_modified,

svn_diff_hunk_readline_diff_text, parse_next_hunk, parse_binary_patch,

svn_diff_parse_next_patch, store_delta, svn_io_file_readline,

mark_handler_apr, test_file_readline, aligned_seek): Use

svn_io_file_get_offset() instead of svn_io_file_seek(0, APR_CUR).

  1. … 5 more files in changeset.
Following up on r1706817, make the diff parser continue parsing other property

changes after an 'svn:mergeinfo' property.

* subversion/libsvn_diff/parse-diff.c

(parse_next_hunk): Exit the mergeinfo hunk when we find no more mergeinfo.

This allows finding more property changes.

* subversion/tests/cmdline/patch_tests.py

(patch_with_mergeinfo): Remove XFail marker.

  1. … 1 more file in changeset.
When parsing diffs note a possible file mode on git index lines to allow

seeing if we are processing git symlinks or Subversion symlinks in all

scenarios.

Extend our diff code to produce proper index lines when we are diffing

symlinks.

* subversion/libsvn_client/diff.c

(maybe_print_mode_change): Print index line when there is no mode change and

shas are available.

(print_git_diff_header): Pass shas.

(display_prop_diffs): Update caller.

(transform_link_to_git): Calculate sha over the link when transformed.

(diff_content_changed): Update caller.

* subversion/libsvn_diff/parse-diff.c

(parse_next_hunk): Minor consistency fix. Ignore '\' lines outside hunks.

(git_index): New function.

(transitions): Add parser transitions to note index line.

(svn_diff_parse_next_patch): Remove "index " hacks.

* subversion/tests/cmdline/diff_tests.py

(diff_symlinks): Update expected result.

  1. … 2 more files in changeset.
In the diff parser: parse the symlink status from the mode flags.

* subversion/include/svn_diff.h

(svn_patch_t): Rename executable bits to _bits and add

symlink bit variables.

* subversion/libsvn_client/patch.c

(contradictory_executability): Update caller.

(init_patch_target): Don't call contradictory_executability when no

executable change is described in the mode change. Update caller.

(apply_one_patch): Update caller.

* subversion/libsvn_diff/parse-diff.c

(parse_bits_into_executability): Rename to...

(parse_git_mode_bits): ... this and also parse symlink info.

(git_old_mode,

git_new_mode,

git_new_file,

git_deleted_file): Update caller.

(svn_diff_parse_next_patch): Update initialization. Reverse new bits

when using a reverse diff.

* subversion/tests/libsvn_diff/parse-diff-test.c

(test_parse_git_diff,

test_parse_git_tree_and_text_diff): Update caller. Add assertions.

  1. … 3 more files in changeset.
Following up on r1705080, fix a few more final-eol edge cases where different

read operations reported EOF at different times, resulting in content

mismatches.

* subversion/libsvn_client/patch.c

(readline_prop,

readline_symlink): Report EOF after the last line, not at the last line.

* subversion/libsvn_diff/parse-diff.c

(hunk_readline_original_or_modified): Always report EOF after the last line,

not only in final-eol mode.

  1. … 1 more file in changeset.
Make it possible to possible to apply git style mode changes and binary file

patches at the same time.

The patch to parse-diff.c was provided by danielsh.

* subversion/libsvn_diff/parse-diff.c

(transitions): Add transition to combine patch types.

* subversion/tests/cmdline/patch_tests.py

(patch_add_remove_executable): New testcase for this (and another) issue.

  1. … 1 more file in changeset.
Fix potential unbounded memory usage in patch parser.

* subversion/libsvn_diff/parse-diff.c

(hunk_readline_original_or_modified): Add LAST_POOL and use for allocations

in loop body. Clear LAST_POOL on every iteration. It's not ITERPOOL because

we use data allocated in LAST_POOL out of the loop body.

Following up on r1705856, don't force the patch operation to modified

when encountering a binary patch. Binary patches can apply in other

cases, such as file deletes.

* subversion/libsvn_diff/parse-diff.c

(binary_patch_start,

parse_binary_patch): Don't force operation type to modified.

Stop applying some kinds of property changes during 'svn patch' that should

have been stopped by a conflict.

Properties were deleted even if the original value didn't match. This

catches some hidden bugs in the svn:executable handling.

* subversion/include/private/svn_diff_private.h

(svn_diff_hunk__create_adds_single_line,

svn_diff_hunk__create_deletes_single_line): Constify argument.

* subversion/libsvn_client/patch.c

(prop_patch_target_t): Add boolean.

(apply_one_patch): Always push diff items to allow notifying conflicts.

Set skip if nothing changed

(install_patched_prop_targets): If skipping the property don't change its

value.

* subversion/libsvn_diff/parse-diff.c

(svn_diff_hunk_t,

svn_diff_binary_patch_t): Constify pointer.

(svn_diff_hunk__create_adds_single_line,

svn_diff_hunk__create_deletes_single_line): Create reversed hunks, to allow

reading them back as not reversed.

* subversion/tests/cmdline/patch_tests.py

(patch_prop_madness): Tweak expectations. Expect conflicts on property

mismatches, but (currently) not on final EOL only changes.

  1. … 3 more files in changeset.
Properly calculate the length of the diff header in the new generated hunks.

The value of 'sizeof(hunk_header[add]) - 1' is 3 on my compiler.

(pointer size -1)

* subversion/libsvn_diff/parse-diff.c

(add_or_delete_single_line): Use the actual header instead of just the

first 3 (or 7) bytes.

* subversion/libsvn_diff/parse-diff.c

(add_or_delete_single_line): Following up on r1705668, use right member name.

Following up on r1705391, r1705503, create the fake diff hunks in a form that

represents the properties in their canonical format, and fix some issues when

applying svn:executable changes in a reverse diff.

* subversion/include/private/svn_diff_private.h

(svn_diff_hunk__create_adds_single_line,

svn_diff_hunk__create_deletes_single_line): Tweak comments.

* subversion/libsvn_diff/parse-diff.c

(add_or_delete_single_line): Update how not having a final EOL is recorded.

(svn_diff_parse_next_patch): Handle reversing mode change diffs.

* subversion/tests/cmdline/patch_tests.py

(patch_adds_executability_nocontents): Extend test.

  1. … 2 more files in changeset.
Followup to r1705391:

* subversion/libsvn_diff/parse-diff.c

(add_or_delete_single_line): Fix uninitialized variable.

Found by: rhuijben

patch: Parse 'old mode' / 'new mode' line from git diffs and translate them

to svn:executable propchanges.

This merges the 'patch-exec' branch into trunk.

---

The following are the major changes. See the branch for detailed changes.

* subversion/include/svn_diff.h

(svn_patch_t.old_executable_p, svn_patch_t.new_executable_p): New members.

* subversion/libsvn_client/patch.c

(contradictory_executability): New function.

(init_patch_target, apply_one_patch):

Translate mode changes to svn:executable changes.

* subversion/include/private/svn_diff_private.h

(svn_diff_hunk__create_adds_single_line,

svn_diff_hunk__create_deletes_single_line): New functions.

* subversion/libsvn_diff/parse-diff.c

(add_or_delete_single_line,

svn_diff_hunk__create_adds_single_line,

svn_diff_hunk__create_deletes_single_line): New functions.

(parse_state::state_old_mode_seen,

parse_state::state_git_mode_seen): New enumerators.

(parse_bits_into_executability, git_old_mode, git_new_mode): New functions.

(git_deleted_file, git_new_file): Parse file mode.

(transitions): Parse "old mode" and "new mode" lines.

* subversion/tests/cmdline/patch_tests.py,

* subversion/tests/libsvn_diff/parse-diff-test.c:

Add unit tests.

  1. … 7 more files in changeset.
* subversion/libsvn_diff/parse-diff.c

(svn_diff_parse_next_patch): Only attempt to parse an "index" line if the

line wasn't otherwise recognized.

.

This seems to have no effect on trunk's behaviour, but will make

a difference for an upcoming change on the 'patch-exec' branch.

Following up on r1705038, r1705080, r1705102 separate the handling of final

eols for original and modified versions to be able to apply add/remove final

eol diffs from both forwards and backwards diffs.

* subversion/libsvn_diff/parse-diff.c

(svn_diff_hunk_t): Split boolean.

(svn_diff_hunk_readline_original_text,

svn_diff_hunk_readline_modified_text): Pass the right boolean.

(svn_diff_hunk_readline_diff_text): Always end the diff text with an EOL.

(parse_next_hunk): Use last line info to set the flag only for

the needed type.

* subversion/tests/cmdline/patch_tests.py

(patch_final_eol): New test.

(test_list): Add test.

  1. … 1 more file in changeset.
Following up on r1705038, r1705080 avoid an unneeded seek when the caller

doesn't need the EOL value. And apply the same behavior to the function that

is used for creating reject files.

* subversion/libsvn_diff/parse-diff.c

(hunk_readline_original_or_modified): Avoid unneeded work. Don't duplicate

EOL type as that is a static value anyway.

(svn_diff_hunk_readline_diff_text): Add final EOL unless we explicitly don't

want one, just like the other similar functions.

Following up on r1705038, also report missing final EOLs if the caller is not

interested in EOL details.

* subversion/libsvn_diff/parse-diff.c

(hunk_readline_original_or_modified): Always fetch eols. Only add an eol if

there is an actual line.

* subversion/tests/cmdline/patch_tests.py

(patch_delete_missing_eol): New test.

(test_list): Add test.

  1. … 1 more file in changeset.
`When parsing hunks in the diff parser, report a final EOL if the patch

declares that there should be one.

The patch code doesn't have access to this information, so we should handle

this while parsing the patch to hunks.

* subversion/libsvn_diff/parse-diff.c

(svn_diff_hunk_t): Add boolean.

(hunk_readline_original_or_modified): Add argument. Report an EOL when

there should be one, but isn't (caused by EOF).

(svn_diff_hunk_readline_original_text,

svn_diff_hunk_readline_modified_text): Update caller.

(parse_next_hunk): Remember no final EOL markers.

* subversion/tests/cmdline/patch_tests.py

(patch_lacking_trailing_eol): Update expected result to the original expected

result.

(patch_lacking_trailing_eol_on_context): Remove XFail marker.

  1. … 1 more file in changeset.
Fix some issues on applying --git diffs in reverse mode.

* subversion/libsvn_diff/parse-diff.c

(parse_next_hunk): Properly record prop diffs as reversed.

(transitions): Handle binary diffs after a delete.

* subversion/tests/cmdline/patch_tests.py

(patch_delete_nodes): Add test on add and delete scenarios including

properties and binary diffs.

  1. … 1 more file in changeset.
Fix an issue in the diff parsing code where a delete or add in

a 'svn diff --git' was not properly applied in

'svn diff --reverse-diff'

This patch will be tested in a future regression test that currently

requires binary patch support.

* subversion/libsvn_diff/parse-diff.c

(svn_diff_parse_next_patch): Properly reverse add and delete operations.

* subversion/libsvn_diff/parse-diff.c

(parse_binary_patch): Add brackets to correct a precedence bug in a

logical expression, detected by gcc -Wparentheses

In the diff parser: apply the reverse flag even for binary diffs.

* subversion/libsvn_diff/parse-diff.c

(parse_binary_patch): Add reverse argument and use it to reverse

offsets when requested.

(svn_diff_parse_next_patch): Update caller.

Complete the parsing routines for parsing git-like binary blobs. This patch

completes the parsing, but leaves out the patch application code as that

needs a bit more work before committing.

* subversion/include/svn_diff.h

(svn_diff_get_binary_diff_original_stream,

svn_diff_get_binary_diff_result_stream): New functions.

* subversion/include/svn_error_codes.h

(SVN_ERR_DIFF_UNEXPECTED_DATA): New error.

* subversion/libsvn_diff/binary_diff.c

(includes): Add svn_private_config.h and diff.h.

(base85_value,

svn_diff__base85_decode_line): New functions.

* subversion/libsvn_diff/diff.h

(svn_diff__base85_decode_line): New function.

* subversion/libsvn_diff/parse-diff.c

(includes): Add svn_private_config.h and diff.h.

(base85_baton_t): New struct.

(read_handler_base85,

close_handler_base85,

get_base85_data_stream): New functions.

(length_verify_baton_t): New struct.

(read_handler_length_verify,

close_handler_length_verify,

get_verify_length_stream): New functions.

(svn_diff_get_binary_diff_original_stream,

svn_diff_get_binary_diff_result_stream): New functions.

(parse_binary_patch): Properly set apr_file in binary patch. Switch src and

dest to the same order as used by git.

* subversion/tests/cmdline/patch_tests.py

(patch_binary_file): Update expected ordering.

  1. … 5 more files in changeset.
* subversion/libsvn_diff/parse-diff.c

(parse_binary_patch): Folowing up on r1703925, fix variable reference.

Start parsing binary diffs in svn patch. This handles the blocks and

records the locations for future processing.

* subversion/include/svn_diff.h

(svn_diff_binary_patch_t): New opaque struct.

(svn_patch_t): Extend struct with pointer.

* subversion/libsvn_diff/binary_diff.c

(svn_diff_output_binary): Don't write unneeded blank line that looks

ugly before a property diff.

* subversion/libsvn_diff/parse-diff.c

(svn_diff_binary_patch_t): New struct.

(parse_state): Add value.

(binary_patch_start): New function.

(parse_binary_patch): New function.

(transitions): Add binary batch handling.

(svn_diff_parse_next_patch): Parse binary diffs.

* subversion/tests/cmdline/patch_tests.py

(patch_binary_file): Tweak expected result. One index line for one target.

  1. … 3 more files in changeset.