1251881Speter/**
2251881Speter * @copyright
3251881Speter * ====================================================================
4251881Speter *    Licensed to the Apache Software Foundation (ASF) under one
5251881Speter *    or more contributor license agreements.  See the NOTICE file
6251881Speter *    distributed with this work for additional information
7251881Speter *    regarding copyright ownership.  The ASF licenses this file
8251881Speter *    to you under the Apache License, Version 2.0 (the
9251881Speter *    "License"); you may not use this file except in compliance
10251881Speter *    with the License.  You may obtain a copy of the License at
11251881Speter *
12251881Speter *      http://www.apache.org/licenses/LICENSE-2.0
13251881Speter *
14251881Speter *    Unless required by applicable law or agreed to in writing,
15251881Speter *    software distributed under the License is distributed on an
16251881Speter *    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17251881Speter *    KIND, either express or implied.  See the License for the
18251881Speter *    specific language governing permissions and limitations
19251881Speter *    under the License.
20251881Speter * ====================================================================
21251881Speter * @endcopyright
22251881Speter */
23251881Speter
24251881Speter
25251881Speter#ifndef SVN_DIFF_PRIVATE_H
26251881Speter#define SVN_DIFF_PRIVATE_H
27251881Speter
28251881Speter#include <apr_pools.h>
29251881Speter#include <apr_tables.h>
30251881Speter
31251881Speter#include "svn_types.h"
32251881Speter#include "svn_io.h"
33251881Speter
34251881Speter#ifdef __cplusplus
35251881Speterextern "C" {
36251881Speter#endif /* __cplusplus */
37251881Speter
38251881Speter
39251881Speter
40251881Speter/* The separator string used below the "Index:" or similar line of
41251881Speter * Subversion's Unidiff-like diff format.  */
42251881Speter#define SVN_DIFF__EQUAL_STRING \
43251881Speter  "==================================================================="
44251881Speter
45251881Speter/* The separator string used below the "Properties on ..." line of
46251881Speter * Subversion's Unidiff-like diff format.  */
47251881Speter#define SVN_DIFF__UNDER_STRING \
48251881Speter  "___________________________________________________________________"
49251881Speter
50251881Speter/* The string used to mark a line in a hunk that doesn't end with a newline,
51251881Speter * when diffing a file.  Intentionally not marked for translation, for wider
52251881Speter * interoperability with patch(1) programs. */
53251881Speter#define SVN_DIFF__NO_NEWLINE_AT_END_OF_FILE \
54251881Speter          "\\ No newline at end of file"
55251881Speter
56251881Speter/* The string used to mark a line in a hunk that doesn't end with a newline,
57251881Speter * when diffing a Subversion property. */
58251881Speter#define SVN_DIFF__NO_NEWLINE_AT_END_OF_PROPERTY \
59251881Speter          "\\ No newline at end of property"
60251881Speter
61251881Speter/* Write a unidiff "---" and "+++" header to OUTPUT_STREAM.
62251881Speter *
63251881Speter * Write "---" followed by a space and OLD_HEADER and a newline,
64251881Speter * then "+++" followed by a space and NEW_HEADER and a newline.
65251881Speter *
66251881Speter * The text will be encoded into HEADER_ENCODING.
67251881Speter */
68251881Spetersvn_error_t *
69251881Spetersvn_diff__unidiff_write_header(svn_stream_t *output_stream,
70251881Speter                               const char *header_encoding,
71251881Speter                               const char *old_header,
72251881Speter                               const char *new_header,
73251881Speter                               apr_pool_t *scratch_pool);
74251881Speter
75251881Speter/* Display property changes in pseudo-Unidiff format.
76251881Speter *
77251881Speter * Write to @a outstream the changes described by @a propchanges based on
78251881Speter * original properties @a original_props.
79251881Speter *
80251881Speter * Write all mark-up text (headers and so on) using the character encoding
81251881Speter * @a encoding.
82251881Speter *
83251881Speter *   ### I think the idea is: we want the output to use @a encoding, and
84251881Speter *       we will assume the text of the user's files and the values of any
85251881Speter *       user-defined properties are already using @a encoding, so we don't
86251881Speter *       want to re-code the *whole* output.
87251881Speter *       So, shouldn't we also convert all prop names and all 'svn:*' prop
88251881Speter *       values to @a encoding, since we know those are stored in UTF-8?
89251881Speter *
90251881Speter * @a original_props is a hash mapping (const char *) property names to
91251881Speter * (svn_string_t *) values.  @a propchanges is an array of svn_prop_t
92251881Speter * representing the new values for any of the properties that changed, with
93251881Speter * a NULL value to represent deletion.
94251881Speter *
95251881Speter * If @a pretty_print_mergeinfo is true, then describe 'svn:mergeinfo'
96251881Speter * property changes in a human-readable form that says what changes were
97251881Speter * merged or reverse merged; otherwise (or if the mergeinfo property values
98251881Speter * don't parse correctly) display them just like any other property.
99251881Speter *
100289180Speter * Pass @a context_size, @a cancel_func and @a cancel_baton to the diff
101289180Speter * output functions.
102289180Speter *
103286506Speter * Use @a scratch_pool for temporary allocations.
104251881Speter */
105251881Spetersvn_error_t *
106251881Spetersvn_diff__display_prop_diffs(svn_stream_t *outstream,
107251881Speter                             const char *encoding,
108251881Speter                             const apr_array_header_t *propchanges,
109251881Speter                             apr_hash_t *original_props,
110251881Speter                             svn_boolean_t pretty_print_mergeinfo,
111289180Speter                             int context_size,
112289180Speter                             svn_cancel_func_t cancel_func,
113289180Speter                             void *cancel_baton,
114286506Speter                             apr_pool_t *scratch_pool);
115251881Speter
116362181Sdim/** Create a hunk object that adds a single line without newline.  Return the
117362181Sdim * new object in @a *hunk.
118362181Sdim *
119362181Sdim * @a line is the added text, without a trailing newline.
120362181Sdim *
121362181Sdim * The hunk will be associated with @a patch.
122362181Sdim */
123362181Sdimsvn_error_t *
124362181Sdimsvn_diff_hunk__create_adds_single_line(svn_diff_hunk_t **hunk,
125362181Sdim                                       const char *line,
126362181Sdim                                       const svn_patch_t *patch,
127362181Sdim                                       apr_pool_t *result_pool,
128362181Sdim                                       apr_pool_t *scratch_pool);
129251881Speter
130362181Sdim/** Create a hunk object that deletes a single line without newline.  Return
131362181Sdim * the new object in @a *hunk.
132362181Sdim *
133362181Sdim * @a line is the deleted text, without a trailing newline.
134362181Sdim *
135362181Sdim * The hunk will be associated with @a patch.
136362181Sdim */
137362181Sdimsvn_error_t *
138362181Sdimsvn_diff_hunk__create_deletes_single_line(svn_diff_hunk_t **hunk,
139362181Sdim                                          const char *line,
140362181Sdim                                          const svn_patch_t *patch,
141362181Sdim                                          apr_pool_t *result_pool,
142362181Sdim                                          apr_pool_t *scratch_pool);
143362181Sdim
144362181Sdim/** Fetches the penalty fuzz of the diff hunk. The patch file parser applies
145362181Sdim * an additional penalty on some cases of bad patch files. These cases may
146362181Sdim * include errors as headers that aren't consistent with bodies, etc.
147362181Sdim */
148362181Sdimsvn_linenum_t
149362181Sdimsvn_diff_hunk__get_fuzz_penalty(const svn_diff_hunk_t *hunk);
150362181Sdim
151251881Speter#ifdef __cplusplus
152251881Speter}
153251881Speter#endif /* __cplusplus */
154251881Speter
155251881Speter#endif /* SVN_DIFF_PRIVATE_H */
156