1/**
2 * @copyright
3 * ====================================================================
4 *    Licensed to the Apache Software Foundation (ASF) under one
5 *    or more contributor license agreements.  See the NOTICE file
6 *    distributed with this work for additional information
7 *    regarding copyright ownership.  The ASF licenses this file
8 *    to you under the Apache License, Version 2.0 (the
9 *    "License"); you may not use this file except in compliance
10 *    with the License.  You may obtain a copy of the License at
11 *
12 *      http://www.apache.org/licenses/LICENSE-2.0
13 *
14 *    Unless required by applicable law or agreed to in writing,
15 *    software distributed under the License is distributed on an
16 *    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17 *    KIND, either express or implied.  See the License for the
18 *    specific language governing permissions and limitations
19 *    under the License.
20 * ====================================================================
21 * @endcopyright
22 */
23
24
25#ifndef SVN_DIFF_PRIVATE_H
26#define SVN_DIFF_PRIVATE_H
27
28#include <apr_pools.h>
29#include <apr_tables.h>
30
31#include "svn_types.h"
32#include "svn_io.h"
33
34#ifdef __cplusplus
35extern "C" {
36#endif /* __cplusplus */
37
38
39
40/* The separator string used below the "Index:" or similar line of
41 * Subversion's Unidiff-like diff format.  */
42#define SVN_DIFF__EQUAL_STRING \
43  "==================================================================="
44
45/* The separator string used below the "Properties on ..." line of
46 * Subversion's Unidiff-like diff format.  */
47#define SVN_DIFF__UNDER_STRING \
48  "___________________________________________________________________"
49
50/* The string used to mark a line in a hunk that doesn't end with a newline,
51 * when diffing a file.  Intentionally not marked for translation, for wider
52 * interoperability with patch(1) programs. */
53#define SVN_DIFF__NO_NEWLINE_AT_END_OF_FILE \
54          "\\ No newline at end of file"
55
56/* The string used to mark a line in a hunk that doesn't end with a newline,
57 * when diffing a Subversion property. */
58#define SVN_DIFF__NO_NEWLINE_AT_END_OF_PROPERTY \
59          "\\ No newline at end of property"
60
61/* Write a unidiff "---" and "+++" header to OUTPUT_STREAM.
62 *
63 * Write "---" followed by a space and OLD_HEADER and a newline,
64 * then "+++" followed by a space and NEW_HEADER and a newline.
65 *
66 * The text will be encoded into HEADER_ENCODING.
67 */
68svn_error_t *
69svn_diff__unidiff_write_header(svn_stream_t *output_stream,
70                               const char *header_encoding,
71                               const char *old_header,
72                               const char *new_header,
73                               apr_pool_t *scratch_pool);
74
75/* Display property changes in pseudo-Unidiff format.
76 *
77 * Write to @a outstream the changes described by @a propchanges based on
78 * original properties @a original_props.
79 *
80 * Write all mark-up text (headers and so on) using the character encoding
81 * @a encoding.
82 *
83 *   ### I think the idea is: we want the output to use @a encoding, and
84 *       we will assume the text of the user's files and the values of any
85 *       user-defined properties are already using @a encoding, so we don't
86 *       want to re-code the *whole* output.
87 *       So, shouldn't we also convert all prop names and all 'svn:*' prop
88 *       values to @a encoding, since we know those are stored in UTF-8?
89 *
90 * @a original_props is a hash mapping (const char *) property names to
91 * (svn_string_t *) values.  @a propchanges is an array of svn_prop_t
92 * representing the new values for any of the properties that changed, with
93 * a NULL value to represent deletion.
94 *
95 * If @a pretty_print_mergeinfo is true, then describe 'svn:mergeinfo'
96 * property changes in a human-readable form that says what changes were
97 * merged or reverse merged; otherwise (or if the mergeinfo property values
98 * don't parse correctly) display them just like any other property.
99 *
100 * Pass @a context_size, @a cancel_func and @a cancel_baton to the diff
101 * output functions.
102 *
103 * Use @a scratch_pool for temporary allocations.
104 */
105svn_error_t *
106svn_diff__display_prop_diffs(svn_stream_t *outstream,
107                             const char *encoding,
108                             const apr_array_header_t *propchanges,
109                             apr_hash_t *original_props,
110                             svn_boolean_t pretty_print_mergeinfo,
111                             int context_size,
112                             svn_cancel_func_t cancel_func,
113                             void *cancel_baton,
114                             apr_pool_t *scratch_pool);
115
116/** Create a hunk object that adds a single line without newline.  Return the
117 * new object in @a *hunk.
118 *
119 * @a line is the added text, without a trailing newline.
120 *
121 * The hunk will be associated with @a patch.
122 */
123svn_error_t *
124svn_diff_hunk__create_adds_single_line(svn_diff_hunk_t **hunk,
125                                       const char *line,
126                                       const svn_patch_t *patch,
127                                       apr_pool_t *result_pool,
128                                       apr_pool_t *scratch_pool);
129
130/** Create a hunk object that deletes a single line without newline.  Return
131 * the new object in @a *hunk.
132 *
133 * @a line is the deleted text, without a trailing newline.
134 *
135 * The hunk will be associated with @a patch.
136 */
137svn_error_t *
138svn_diff_hunk__create_deletes_single_line(svn_diff_hunk_t **hunk,
139                                          const char *line,
140                                          const svn_patch_t *patch,
141                                          apr_pool_t *result_pool,
142                                          apr_pool_t *scratch_pool);
143
144/** Fetches the penalty fuzz of the diff hunk. The patch file parser applies
145 * an additional penalty on some cases of bad patch files. These cases may
146 * include errors as headers that aren't consistent with bodies, etc.
147 */
148svn_linenum_t
149svn_diff_hunk__get_fuzz_penalty(const svn_diff_hunk_t *hunk);
150
151#ifdef __cplusplus
152}
153#endif /* __cplusplus */
154
155#endif /* SVN_DIFF_PRIVATE_H */
156