Create branch for the 'svnpatch' format work.



git-svn-id: https://svn.apache.org/repos/asf/subversion/branches/svnpatch-diff@865738 13f79535-47bb-0310-9956-ffa450edef68
Install --svnpatch command line option into 'svn diff' and provide
libsvn_client callbacks with svnpatch-format facilities when needed.

* subversion/svn/cl.h
  (svn_cl__longopt_t, svn_cl__opt_state_t): add command line option to enable
  svnpatch, and fix typo with 'svn_cl__no_diff_deleted'.

* subversion/libsvn_client/client.h
  Add SVN_CLIENT_SVNPATCH_VERSION macro that we need in the header.

* subversion/svn/main.c
  (svn_cl__options): provide the command line with svnpatch support, and fix
  typo with 'svn_cl__no_diff_deleted'.

* subversion/svn/diff-cmd.c
  (svn_cl__diff): enable svnpatch when calling svn_client_diff[_peg]4.

* notes/svnpatch
  Import the design document.

* subversion/include/svn_client.h
  (svn_client_diff4, svn_client_diff_peg4): add 'svnpatch_format' argument to
  the signatures.

* subversion/libsvn_wc/diff.c
  (dir_diff): new function similar to what file_diff() does for files.
  (directory_elements_diff): call dir_diff() when svnpatch'ing.

* subversion/libsvn_client/diff.c
  (diff_cmd_baton): provide the structure with svnpatch_format boolean type and
  an svnpatch buffer.
  (svnpatch_append): new function that helps to generate the svnpatch buffer.
  (diff_props_changed, diff_content_changed, diff_file_added,
  diff_file_deleted_with_diff, diff_file_deleted_no_diff, diff_dir_added,
  diff_dir_deleted): turn on sketchy svnpatch creation calls.
  (do_diff): allocate some room for svnpatch bytes, and output when using
  svnpatch_format before returning.
  (svn_client_diff4, svn_client_diff_peg4): add 'svnpatch_format' as in its
  declaration.
  (svn_client_diff3, svn_client_diff_peg3): disable 'svnpatch_format'

* subversion/tests/cmdline/diff_tests.py
  (diff_svnpatch): new test to illustrate 'svn diff --svnpatch' behaviour



git-svn-id: https://svn.apache.org/repos/asf/subversion/branches/svnpatch-diff@865813 13f79535-47bb-0310-9956-ffa450edef68
Add svn_stringbuf_appendformat, similar to svn_stringbuf_append{str,cstr,bytes}
except it uses variable-length argument like printf, and make use of it.

* subversion/include/svn_string.h
* subversion/libsvn_subr/svn_string.c
  (svn_stringbuf_appendformat): new function using variable-length argument,
  wrapping svn_stringbuf_append() + apr_pvsprintf().

* subversion/libsvn_client/diff.c
  (svnpatch_append): remove the function, useless against
  svn_stringbuf_appendformat.
  (diff_content_changed, diff_file_added, diff_file_deleted_with_diff,
  diff_file_deleted_no_diff, diff_dir_added, diff_dir_deleted): use
  svn_stringbuf_appendformat() now on when playing with the svnpatch buffer.
  (diff_props_changed): move svnpatch-buffer edition deeper.
  (display_prop_diffs): add svnpatch_format and svnpatch_buff arguments to
  satisfy svnpatch-diff needs, and edit svnpatch-buffer here.



git-svn-id: https://svn.apache.org/repos/asf/subversion/branches/svnpatch-diff@865832 13f79535-47bb-0310-9956-ffa450edef68
Import and tweak some ra_svn marshalling routines to manipulate svnpatch output
creation.

* subversion/include/svn_client.h
  (clnt_svnpatch): add defgroup for svnpatch routines.

* subversion/include/svn_client.h
* subversion/libsvn_client/util.c
  (svn_client_write_number, svn_client_write_string, svn_client_write_cstring,
  svn_client_write_word, svn_client_write_proplist, svn_client_start_list,
  svn_client_end_list, svn_client_write_tuple, svn_client_write_cmd): add
  functions to manipulate svnpatch output.
  (vwrite_tuple): add local function to format output.

* subversion/libsvn_client/diff.c
  (do_diff): no need to output the header when the svnpatch is empty.


git-svn-id: https://svn.apache.org/repos/asf/subversion/branches/svnpatch-diff@865842 13f79535-47bb-0310-9956-ffa450edef68
* subversion/include/svn_string.h
* subversion/libsvn_subr/svn_string.c
* subversion/libsvn_client/util.c
  Rename svn_stringbuf_appendformat to svn_stringbuf_appendf.


* subversion/libsvn_client/diff.c
  Rename svn_stringbuf_appendformat to svn_stringbuf_appendf and
  svnpatch_buff to svnpatch_buf.

Suggested by: Daniel Rall
              Erik Hülsmann


git-svn-id: https://svn.apache.org/repos/asf/subversion/branches/svnpatch-diff@865843 13f79535-47bb-0310-9956-ffa450edef68
* subversion/tests/libsvn_subr/string-test.c
  (test24): add new test for svn_stringbuf_appendf().


git-svn-id: https://svn.apache.org/repos/asf/subversion/branches/svnpatch-diff@865846 13f79535-47bb-0310-9956-ffa450edef68
Move svnpatch generation from libsvn_client to libsvn_wc and get 'svn
diff --svnpatch' up and running for wc/wc diff.

What happens now in a wc/wc diff is libsvn_client opens an apr file
handler it passes to libsvn_wc to get filled up with ra_svn editor
commands, in clear-text.  It is libsvn_client's responsibility to
compute the temp file, that is, compress and base64'encode before
dumping to the outfile, likely stdout.

* subversion/include/svn_wc.h
  (svn_wc_diff4): provide with svnpatch facility
  (svn_wc_diff3): deprecate
  (svn_wc_write_number, svn_wc_write_string, svn_wc_write_cstring,
  svn_wc_write_word, svn_wc_write_proplist, svn_wc_start_list,
  svn_wc_end_list, svn_wc_write_tuple, svn_wc_write_cmd): svnpatch
  marshalling functions moved from libsvn_client (see below).

* subversion/include/svn_client.h
  (svn_client_write_number, svn_client_write_string,
  svn_client_write_cstring, svn_client_write_word,
  svn_client_write_proplist, svn_client_start_list, svn_client_end_list,
  svn_client_write_tuple, svn_client_write_cmd): move and tweak those
  functions into libsvn_wc (see above).

* subversion/libsvn_wc/diff.c
  (edit_baton, make_editor_baton): provide structure with a stream
  handler to an svnpatch_file, a list of diffables, and a token holder.
  (file_baton, dir_baton): provide structure with a token field.
  (make_token): new function to create tokens from edit_baton token.
  (make_dir_baton, make_file_baton): provide with token arg.
  (file_diff, dir_diff, directory_elements_diff): add some lines to fill
  our 'diffables' array.
  (svnpatch_open_root, svnpatch_open_directory,
  svnpatch_close_directory, svnpatch_add_directory,
  svnpatch_change_dir_prop, svnpatch_open_file, svnpatch_add_file,
  svnpatch_close_file, svnpatch_change_file_prop,
  svnpatch_delete_entry,svnpatch_apply_textdelta, svnpatch_close_edit):
  add svnpatch-specific editor functions.
  (get_svnpatch_diff_editor): initiate an svnpatch diff editor against
  static callbacks.
  (open_root, delete_entry, add_directory, open_directory, add_file,
  open_file, close_edit): disable token facility of
  make_{dir,file}_baton().
  (path_driver_cb_baton): new struct, baton to the callback func
  (path_driver_cb_func): new function, implements
  svn_delta_path_driver_cb_func_t to drive the editor.
  (svn_wc_diff4): new version deprecating svn_wc_diff3 with svnpatch
  support.
  (svn_wc_diff3): now calls svn_wc_diff4 with svnpatch disabled.

* subversion/libsvn_wc/util.c
  (svn_wc_write_number, svn_wc_write_string, svn_wc_write_cstring,
  svn_wc_write_word, svn_wc_write_proplist, svn_wc_start_list,
  svn_wc_end_list, svn_wc_write_tuple, svn_wc_write_cmd):
  move implementations from libsvn_client, and tweak to fit with a
  stream use.

* subversion/libsvn_client/util.c:
  (svn_client_write_number, svn_client_write_string,
  svn_client_write_cstring, svn_client_write_word,
  svn_client_write_proplist, svn_client_start_list, svn_client_end_list,
  svn_client_write_tuple, svn_client_write_cmd): move to libsvn_wc.

* subversion/libsvn_client/diff.c:
  (display_prop_diffs, diff_cmd_baton, diff_props_changed,
  diff_content_changed, diff_file_added, diff_file_deleted_with_diff,
  diff_file_deleted_no_diff, diff_dir_added, diff_dir_deleted): take
  away svnpatch-buffer generation.  We're now doing this directly from
  libsvn_wc.
  (dump_svnpatch): new function
  (diff_wc_wc): switch to the use of svn_wc_diff4.
  (do_diff): invoke dump_svnpatch() before exit.
  (svn_client_diff4, svn_client_diff_peg4): open a unique svnpatch temp
  file before passing the handler to do_diff()


git-svn-id: https://svn.apache.org/repos/asf/subversion/branches/svnpatch-diff@865967 13f79535-47bb-0310-9956-ffa450edef68
* subversion/libsvn_wc/diff.c
  (file_diff): clarify a comment and fix bug when file is copied.

* subversion/tests/cmdline/diff_tests.py
  (diff_svnpatch): update the test with clear-text commands, using
  python libs to zlib-compress and base64-encode to compare.


git-svn-id: https://svn.apache.org/repos/asf/subversion/branches/svnpatch-diff@865989 13f79535-47bb-0310-9956-ffa450edef68
* subversion/tests/cmdline/diff_tests.py
  (diff_svnpatch): fix the expected_output array with a
  one-line-\n-terminated strings map workaround (thanks glasser!)


git-svn-id: https://svn.apache.org/repos/asf/subversion/branches/svnpatch-diff@865990 13f79535-47bb-0310-9956-ffa450edef68
This is the implementation of repos/wc svnpatch diff.  Although repos/wc
diff is mid-repos-related, libsvn_wc is the target library here.  This
allows some abstraction towards RA protocols.

(repos/wc diff-test to come)

* subversion/include/svn_wc.h
  (svn_wc_get_diff_editor4): add svnpatch_file argument to initiate an
  svnpatch-enabled edit baton.

* subversion/libsvn_wc/diff.c
  (edit_baton): add an svn_delta_editor_t diff_editor handler to
  svnpatch editor functions.
  (file_baton, make_file_baton): add a dir_baton pointer to the file's
  parent dir.
  (directory_elements_diff): move dir_diff() call to some more
  appropriate place, and add break when the directory is scheduled for
  deletion.
  (report_wc_file_as_added): address a file addition against svnpatch.
  (report_wc_directory_as_added): add an svn_wc_entry_t argument needed
  to deal with prop changes, and invoke svnpatch diff editor functions.
  (path_driver_cb_baton): add a dir_baton field to implement a
  workaround (see docstring).
  (path_driver_cb_func): move to some place more appropriate in the
  same file.
  (open_root, delete_entry, add_directory, open_directory, add_file,
  open_file): dump bytes to svnpatch temp-file;  no svnpatch diff editor
  function calls here to keep things clean.
  (close_directory): address svnpatch.  This is close to what we have in
  svn_wc_diff4 and might be factorized soon.
  (close_file, change_file_prop, change_dir_prop, close_edit): invoke
  svnpatch diff editor functions.
  (svn_wc_get_diff_editor4): add svnpatch_file new argument.
  (svn_wc_get_diff_editor3): update 4's new argument.
  (svn_wc_diff4): ensure token initialization and disable
  join_dir_baton.

* subversion/libsvn_client/diff.c
  (diff_repos_wc): update the call to svn_wc_get_diff_editor4 with
  svnpatch_file argument.


git-svn-id: https://svn.apache.org/repos/asf/subversion/branches/svnpatch-diff@866028 13f79535-47bb-0310-9956-ffa450edef68
Initialized merge tracking via "svnmerge" with revisions "1-25663" from 
http://svn.collab.net/repos/svn/trunk


git-svn-id: https://svn.apache.org/repos/asf/subversion/branches/svnpatch-diff@866029 13f79535-47bb-0310-9956-ffa450edef68
Merged revisions 25664-25955 via svnmerge from
http://svn.collab.net/repos/svn/trunk


git-svn-id: https://svn.apache.org/repos/asf/subversion/branches/svnpatch-diff@866030 13f79535-47bb-0310-9956-ffa450edef68
Add a few (sub)tests for wc/repos svnpatch diffs and fix binary support.

* subversion/libsvn_wc/diff.c
  (directory_elements_diff): avoid including a path twice to the
  diffables' array.
  (transmit_svndiff): new static function that helps generating svndiff
  editor commands (apply-textdelta + textdelta-chunk/end) from roughly
  only the path of the file and an editor.
  (report_wc_file_as_added): avoid segfault on a null pointer.
  (delete_entry): also consider eb->reverse order for directories.
  (add_file): write add-file command to svnpatch.
  (close_file): fix binary support and make use of transmit_svndiff().

* subversion/tests/cmdline/diff_tests.py
  (diff_svnpatch): add wc/repos tests and focus on svnpatch block checks
  instead of considering unidiff too.


git-svn-id: https://svn.apache.org/repos/asf/subversion/branches/svnpatch-diff@866109 13f79535-47bb-0310-9956-ffa450edef68
Merged revisions 25956-26036 via svnmerge from 
http://svn.collab.net/repos/svn/trunk


git-svn-id: https://svn.apache.org/repos/asf/subversion/branches/svnpatch-diff@866114 13f79535-47bb-0310-9956-ffa450edef68
A bunch of bytes to implement the repos/repos svnpatch diff.

* subversion/libsvn_wc/diff.c
  (transmit_svndiff): use svn_stream_empty instead of an empty file to
  generate diffs against null.
  (svnpatch_open_root, svnpatch_open_directory, svnpatch_add_directory,
  directory_elements_diff): fix depth argument when calling
  make_dir_baton (calls broken from a previous merge).

* subversion/libsvn_client/repos_diff.c
  (SAVEPOINT_RELEASED): new macro to deal with released savepoints.
  (edit_baton): provide with svnpatch members, token holder, a
  diff_editor, and a savepoint offset.
  (dir_baton, file_baton): provide with token and savepoint members.
  (make_token): new function to generate tokens.
  (make_dir_baton): add token argument
  (make_file_baton): add token and parent_baton argument.
  (svnpatch_savepoint, svnpatch_release_savepoint, svnpatch_rollback):
  new set of functions to introduce savepoints and rollback facility to
  editor-command-dumping.
  (svnpatch_close_file, svnpatch_change_file_prop,
  svnpatch_delete_entry, svndiff_write_handler, svndiff_close_handler,
  svnpatch_apply_textdelta, svnpatch_close_edit): add editor functions
  to deal with svnpatch serialiazed editor commands to repos/repos
  diffs.
  (transmit_svndiff): new function to short-drive an editor in dumping
  txdelta editor commands.
  (open_root, delete_entry, add_directory, open_directory, add_file,
  open_file, close_file, change_file_prop, change_dir_prop): set up
  support for svnpatch.
  (get_svnpatch_diff_editor): new command to create a diff editor.
  (svn_client__get_diff_editor): set up support for svnpatch and call
  get_svnpatch_diff_editor.

* subversion/libsvn_client/client.h
  (svn_client__get_diff_editor): add svnpatch_file argument.

* subversion/libsvn_client/merge.c
  (do_merge): update the call to svn_client__get_diff_editor with
  svnpatch support disabled.

* subversion/libsvn_client/diff.c
  (diff_repos_repos): update the call to svn_client__get_diff_editor to
  support svnpatch.


git-svn-id: https://svn.apache.org/repos/asf/subversion/branches/svnpatch-diff@866122 13f79535-47bb-0310-9956-ffa450edef68
Fix some repos/wc discrepancies and add two repos/repos tests.

* subversion/libsvn_wc/diff.c:
  (include apr_md5.h to calculate file checksums)
  (transmit_prop_deltas): new function to help dump property changes
  editor commands, in repos/wc diffs.
  (svnpatch_delete_entry): test reverse_order before writing command.
  (path_driver_cb_func): wrap a call to svnpatch_delete_entry with a
  fancy workaround.
  (add_directory): fix token creation and make use of reverse_order to
  deduce between add or del.
  (close_directory, close_file): make use of transmit_prop_deltas.
  (close_file): overwrite the text_checksum argument with a new one we
  calculate with svn_io_file_checksum against base-text or temp file.
  (add_file): check against reverse_order too, for accuracy.
  (change_dir_prop, change_file_prop): remove calls to diff_editor
  functions; we're doing this in close_directory and close_file now
  since we need some processing before being able to choose the right
  direction.

* subversion/tests/cmdline/diff_tests.py:
  (diff_svnpatch): a two repos/repos tests, and fix some previous
  repos/wc tests.


git-svn-id: https://svn.apache.org/repos/asf/subversion/branches/svnpatch-diff@866135 13f79535-47bb-0310-9956-ffa450edef68
Merged revisions 26037-26061 via svnmerge from 
http://svn.collab.net/repos/svn/trunk


git-svn-id: https://svn.apache.org/repos/asf/subversion/branches/svnpatch-diff@866137 13f79535-47bb-0310-9956-ffa450edef68
Empty skeleton in preparation for 'svn patch' implementation.

* subversion/svn/cl.h
  (svn_cl__opt_state_t): rephrase svnpatch opt docstring to fit width.
  (svn_opt_subcommand_t): add svn_cl__patch subcommand declaration.

* subversion/svn/main.c
  (svn_cl__cmd_table): add a new patch element to subcommand dispatch
  table, i.e. the cmdline help.

* subversion/svn/patch-cmd.c:
  New file, cmdline implementation of the new 'patch' subcommand.

* subversion/include/svn_client.h
  (svn_client_patch): new function, the client's interface to 'patch'.

* subversion/libsvn_client/patch.c:
  New file, wraps the (yet to come) wc 'patch' implementation.


git-svn-id: https://svn.apache.org/repos/asf/subversion/branches/svnpatch-diff@866140 13f79535-47bb-0310-9956-ffa450edef68
Implementation of 'svn patch' guts.

* subversion/svn/patch-cmd.c
  (svn_cl__patch): set up the command line notifier for 'svn patch'.

* subversion/svn/main.c
  (svn_cl__cmd_table): provide 'patch' with svn_cl__force_opt option.

* subversion/include/svn_client.h
  (svn_client_patch): add the 'force' argument.

* subversion/include/svn_wc.h
  (svn_wc_read_item, svn_wc_parse_tuple, svn_wc_read_tuple,
  svn_wc_apply_patch): New functions to deal with svnpatch-reading.

* subversion/libsvn_wc/util.c
  (readbuf_getchar_skip_whitespace, read_string, read_item,
  vparse_tuple): New helper functions.
  (svn_wc_read_item, svn_wc_parse_tuple, svn_wc_read_tuple): New
  functions to read Editor Commands chunks.

* subversion/libsvn_wc/patch.c
  Similar to what libsvn_ra_svn/editorp.c does with ra_svn-based
  communications.
  New file.  Read Editor Commands from a decoded patch file and drive
  the editor.

* subversion/libsvn_client/patch.c
  A lot of this file was imported from both merge.c and repos_diff.c.
  (patch_cmd_baton): analogous to merge_cmd_baton.
  (patch_callbacks, merge_props_changed, merge_file_changed,
  merge_file_added, merge_file_deleted, merge_dir_added,
  merge_dir_deleted): add svn_wc_diff_callbacks2_t functions to merge
  changes from the (svn)patch.
  (merge_delete_notify_baton_t, merge_delete_notify_func):
  Notify-wrapper and its baton from merge.c.
  (edit_baton, dir_baton, file_baton, make_dir_baton, make_file_baton,
  make_editor_baton): new baton structures/functions dealing with tree
  traversal.
  (create_empty_file, get_path_access, get_parent_access,
  get_empty_file): helper functions from repos_diff.c.
  (open_root, delete_entry, add_directory, open_directory,
  add_file, open_file, window_handler, apply_textdelta, close_file,
  close_directory, change_file_prop, change_dir_prop, close_edit):
  Editor functions, imported from repos_diff.c.
  (extract_svnpatch): Pull out the svnpatch block from patches and
  decode data (uncompress + base64-decode).
  (svn_client_patch): add 'force' flag and define the function to call
  svn_wc_apply_patch.


git-svn-id: https://svn.apache.org/repos/asf/subversion/branches/svnpatch-diff@866284 13f79535-47bb-0310-9956-ffa450edef68
* notes/svnpatch:
  Clarify what we're doing at the moment regarding patch application and
  Unidiff, and add a new part entitled 'patch and merge in subversion'.

* subversion/include/svn_client.h
  (svn_client_patch): fix docstring accordingly to the use.

* subversion/tests/cmdline/getopt_tests_data/svn_help_stdout:
* subversion/tests/cmdline/getopt_tests_data/svn--help_stdout:
  add the new 'patch' subcommand so that getopt_tests.py 4 and 5 both
  get a nice PASS.


git-svn-id: https://svn.apache.org/repos/asf/subversion/branches/svnpatch-diff@866343 13f79535-47bb-0310-9956-ffa450edef68