Subversion
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Data Structures | Typedefs | Enumerations | Functions
svn_diff.h File Reference

Contextual diffing. More...

#include <apr.h>
#include <apr_pools.h>
#include <apr_tables.h>
#include "svn_types.h"
#include "svn_io.h"
#include "svn_string.h"
#include "svn_mergeinfo.h"

Go to the source code of this file.

Data Structures

struct  svn_diff_fns2_t
 A vtable for reading data from the three datasources. More...
 
struct  svn_diff_fns_t
 Like svn_diff_fns2_t except with datasource_open() instead of datasources_open(). More...
 
struct  svn_diff_output_fns_t
 A vtable for displaying (or consuming) differences between datasources. More...
 
struct  svn_diff_file_options_t
 Options to control the behaviour of the file diff routines. More...
 
struct  svn_prop_patch_t
 Data type to manage parsing of properties in patches. More...
 
struct  svn_patch_t
 Data type to manage parsing of patches. More...
 

Typedefs

typedef struct svn_diff_t svn_diff_t
 An opaque type that represents a difference between either two or three datasources. More...
 
typedef enum svn_diff_datasource_e svn_diff_datasource_e
 There are four types of datasources. More...
 
typedef struct svn_diff_fns2_t svn_diff_fns2_t
 A vtable for reading data from the three datasources. More...
 
typedef struct svn_diff_fns_t svn_diff_fns_t
 Like svn_diff_fns2_t except with datasource_open() instead of datasources_open(). More...
 
typedef struct
svn_diff_output_fns_t 
svn_diff_output_fns_t
 A vtable for displaying (or consuming) differences between datasources. More...
 
typedef enum
svn_diff_conflict_display_style_t 
svn_diff_conflict_display_style_t
 Style for displaying conflicts during diff3 output. More...
 
typedef enum
svn_diff_file_ignore_space_t 
svn_diff_file_ignore_space_t
 To what extent whitespace should be ignored when comparing lines. More...
 
typedef struct
svn_diff_file_options_t 
svn_diff_file_options_t
 Options to control the behaviour of the file diff routines. More...
 
typedef enum
svn_diff_operation_kind_e 
svn_diff_operation_kind_t
 Describes what operation has been performed on a file. More...
 
typedef struct svn_diff_hunk_t svn_diff_hunk_t
 A single hunk inside a patch. More...
 
typedef struct svn_prop_patch_t svn_prop_patch_t
 Data type to manage parsing of properties in patches. More...
 
typedef struct svn_patch_t svn_patch_t
 Data type to manage parsing of patches. More...
 
typedef struct svn_patch_file_t svn_patch_file_t
 An opaque type representing an open patch file. More...
 

Enumerations

enum  svn_diff_datasource_e {
  svn_diff_datasource_original,
  svn_diff_datasource_modified,
  svn_diff_datasource_latest,
  svn_diff_datasource_ancestor
}
 There are four types of datasources. More...
 
enum  svn_diff_conflict_display_style_t {
  svn_diff_conflict_display_modified_latest,
  svn_diff_conflict_display_resolved_modified_latest,
  svn_diff_conflict_display_modified_original_latest,
  svn_diff_conflict_display_modified,
  svn_diff_conflict_display_latest,
  svn_diff_conflict_display_only_conflicts
}
 Style for displaying conflicts during diff3 output. More...
 
enum  svn_diff_file_ignore_space_t {
  svn_diff_file_ignore_space_none,
  svn_diff_file_ignore_space_change,
  svn_diff_file_ignore_space_all
}
 To what extent whitespace should be ignored when comparing lines. More...
 
enum  svn_diff_operation_kind_e {
  svn_diff_op_unchanged,
  svn_diff_op_added,
  svn_diff_op_deleted,
  svn_diff_op_copied,
  svn_diff_op_moved,
  svn_diff_op_modified
}
 Describes what operation has been performed on a file. More...
 

Functions

const svn_version_tsvn_diff_version (void)
 Get libsvn_diff version information. More...
 
svn_error_tsvn_diff_diff_2 (svn_diff_t **diff, void *diff_baton, const svn_diff_fns2_t *diff_fns, apr_pool_t *pool)
 Given a vtable of diff_fns/diff_baton for reading datasources, return a diff object in *diff that represents a difference between an "original" and "modified" datasource. More...
 
svn_error_tsvn_diff_diff (svn_diff_t **diff, void *diff_baton, const svn_diff_fns_t *diff_fns, apr_pool_t *pool)
 Like svn_diff_diff_2() but using svn_diff_fns_t instead of svn_diff_fns2_t. More...
 
svn_error_tsvn_diff_diff3_2 (svn_diff_t **diff, void *diff_baton, const svn_diff_fns2_t *diff_fns, apr_pool_t *pool)
 Given a vtable of diff_fns/diff_baton for reading datasources, return a diff object in *diff that represents a difference between three datasources: "original", "modified", and "latest". More...
 
svn_error_tsvn_diff_diff3 (svn_diff_t **diff, void *diff_baton, const svn_diff_fns_t *diff_fns, apr_pool_t *pool)
 Like svn_diff_diff3_2() but using svn_diff_fns_t instead of svn_diff_fns2_t. More...
 
svn_error_tsvn_diff_diff4_2 (svn_diff_t **diff, void *diff_baton, const svn_diff_fns2_t *diff_fns, apr_pool_t *pool)
 Given a vtable of diff_fns/diff_baton for reading datasources, return a diff object in *diff that represents a difference between two datasources: "original" and "latest", adjusted to become a full difference between "original", "modified" and "latest" using "ancestor". More...
 
svn_error_tsvn_diff_diff4 (svn_diff_t **diff, void *diff_baton, const svn_diff_fns_t *diff_fns, apr_pool_t *pool)
 Like svn_diff_diff4_2() but using svn_diff_fns_t instead of svn_diff_fns2_t. More...
 
svn_boolean_t svn_diff_contains_conflicts (svn_diff_t *diff)
 Determine if a diff object contains conflicts. More...
 
svn_boolean_t svn_diff_contains_diffs (svn_diff_t *diff)
 Determine if a diff object contains actual differences between the datasources. More...
 
svn_error_tsvn_diff_output2 (svn_diff_t *diff, void *output_baton, const svn_diff_output_fns_t *output_fns, svn_cancel_func_t cancel_func, void *cancel_baton)
 Given a vtable of output_fns/output_baton for consuming differences, output the differences in diff. More...
 
svn_error_tsvn_diff_output (svn_diff_t *diff, void *output_baton, const svn_diff_output_fns_t *output_fns)
 Similar to svn_diff_output2(), but without cancel support. More...
 
svn_diff_file_options_tsvn_diff_file_options_create (apr_pool_t *pool)
 Allocate a svn_diff_file_options_t structure in pool, initializing it with default values. More...
 
svn_error_tsvn_diff_file_options_parse (svn_diff_file_options_t *options, const apr_array_header_t *args, apr_pool_t *pool)
 Parse args, an array of const char * command line switches and adjust options accordingly. More...
 
svn_error_tsvn_diff_file_diff_2 (svn_diff_t **diff, const char *original, const char *modified, const svn_diff_file_options_t *options, apr_pool_t *pool)
 A convenience function to produce a diff between two files. More...
 
svn_error_tsvn_diff_file_diff (svn_diff_t **diff, const char *original, const char *modified, apr_pool_t *pool)
 Similar to svn_file_diff_2(), but with options set to a struct with default options. More...
 
svn_error_tsvn_diff_file_diff3_2 (svn_diff_t **diff, const char *original, const char *modified, const char *latest, const svn_diff_file_options_t *options, apr_pool_t *pool)
 A convenience function to produce a diff between three files. More...
 
svn_error_tsvn_diff_file_diff3 (svn_diff_t **diff, const char *original, const char *modified, const char *latest, apr_pool_t *pool)
 Similar to svn_diff_file_diff3_2(), but with options set to a struct with default options. More...
 
svn_error_tsvn_diff_file_diff4_2 (svn_diff_t **diff, const char *original, const char *modified, const char *latest, const char *ancestor, const svn_diff_file_options_t *options, apr_pool_t *pool)
 A convenience function to produce a diff between four files. More...
 
svn_error_tsvn_diff_file_diff4 (svn_diff_t **diff, const char *original, const char *modified, const char *latest, const char *ancestor, apr_pool_t *pool)
 Similar to svn_file_diff4_2(), but with options set to a struct with default options. More...
 
svn_error_tsvn_diff_file_output_unified4 (svn_stream_t *output_stream, svn_diff_t *diff, const char *original_path, const char *modified_path, const char *original_header, const char *modified_header, const char *header_encoding, const char *relative_to_dir, svn_boolean_t show_c_function, int context_size, svn_cancel_func_t cancel_func, void *cancel_baton, apr_pool_t *scratch_pool)
 A convenience function to produce unified diff output from the diff generated by svn_diff_file_diff(). More...
 
svn_error_tsvn_diff_file_output_unified3 (svn_stream_t *output_stream, svn_diff_t *diff, const char *original_path, const char *modified_path, const char *original_header, const char *modified_header, const char *header_encoding, const char *relative_to_dir, svn_boolean_t show_c_function, apr_pool_t *pool)
 Similar to svn_diff_file_output_unified4(), but without cancel support and with context_size set to -1. More...
 
svn_error_tsvn_diff_file_output_unified2 (svn_stream_t *output_stream, svn_diff_t *diff, const char *original_path, const char *modified_path, const char *original_header, const char *modified_header, const char *header_encoding, apr_pool_t *pool)
 Similar to svn_diff_file_output_unified3(), but with relative_to_dir set to NULL and show_c_function to false. More...
 
svn_error_tsvn_diff_file_output_unified (svn_stream_t *output_stream, svn_diff_t *diff, const char *original_path, const char *modified_path, const char *original_header, const char *modified_header, apr_pool_t *pool)
 Similar to svn_diff_file_output_unified2(), but with header_encoding set to APR_LOCALE_CHARSET. More...
 
svn_error_tsvn_diff_file_output_merge3 (svn_stream_t *output_stream, svn_diff_t *diff, const char *original_path, const char *modified_path, const char *latest_path, const char *conflict_original, const char *conflict_modified, const char *conflict_latest, const char *conflict_separator, svn_diff_conflict_display_style_t conflict_style, svn_cancel_func_t cancel_func, void *cancel_baton, apr_pool_t *scratch_pool)
 A convenience function to produce diff3 output from the diff generated by svn_diff_file_diff3(). More...
 
svn_error_tsvn_diff_file_output_merge2 (svn_stream_t *output_stream, svn_diff_t *diff, const char *original_path, const char *modified_path, const char *latest_path, const char *conflict_original, const char *conflict_modified, const char *conflict_latest, const char *conflict_separator, svn_diff_conflict_display_style_t conflict_style, apr_pool_t *pool)
 Similar to svn_diff_file_output_merge3, but without cancel support. More...
 
svn_error_tsvn_diff_file_output_merge (svn_stream_t *output_stream, svn_diff_t *diff, const char *original_path, const char *modified_path, const char *latest_path, const char *conflict_original, const char *conflict_modified, const char *conflict_latest, const char *conflict_separator, svn_boolean_t display_original_in_conflict, svn_boolean_t display_resolved_conflicts, apr_pool_t *pool)
 Similar to svn_diff_file_output_merge2, but with display_original_in_conflict and display_resolved_conflicts booleans instead of the conflict_style enum. More...
 
svn_error_tsvn_diff_output_binary (svn_stream_t *output_stream, svn_stream_t *original, svn_stream_t *latest, svn_cancel_func_t cancel_func, void *cancel_baton, apr_pool_t *scratch_pool)
 Creates a git-like binary diff hunk describing the differences between original and latest. More...
 
svn_error_tsvn_diff_mem_string_diff (svn_diff_t **diff, const svn_string_t *original, const svn_string_t *modified, const svn_diff_file_options_t *options, apr_pool_t *pool)
 Generate diff output from the original and modified in-memory strings. More...
 
svn_error_tsvn_diff_mem_string_diff3 (svn_diff_t **diff, const svn_string_t *original, const svn_string_t *modified, const svn_string_t *latest, const svn_diff_file_options_t *options, apr_pool_t *pool)
 Generate diff output from the original, modified and latest in-memory strings. More...
 
svn_error_tsvn_diff_mem_string_diff4 (svn_diff_t **diff, const svn_string_t *original, const svn_string_t *modified, const svn_string_t *latest, const svn_string_t *ancestor, const svn_diff_file_options_t *options, apr_pool_t *pool)
 Generate diff output from the original, modified and latest in-memory strings, using ancestor. More...
 
svn_error_tsvn_diff_mem_string_output_unified3 (svn_stream_t *output_stream, svn_diff_t *diff, svn_boolean_t with_diff_header, const char *hunk_delimiter, const char *original_header, const char *modified_header, const char *header_encoding, const svn_string_t *original, const svn_string_t *modified, int context_size, svn_cancel_func_t cancel_func, void *cancel_baton, apr_pool_t *scratch_pool)
 Outputs the diff object generated by svn_diff_mem_string_diff() in unified diff format on output_stream, using original and modified for the text in the output. More...
 
svn_error_tsvn_diff_mem_string_output_unified2 (svn_stream_t *output_stream, svn_diff_t *diff, svn_boolean_t with_diff_header, const char *hunk_delimiter, const char *original_header, const char *modified_header, const char *header_encoding, const svn_string_t *original, const svn_string_t *modified, apr_pool_t *pool)
 Similar to svn_diff_mem_string_output_unified3() but without cancel support and with context_size set to -1. More...
 
svn_error_tsvn_diff_mem_string_output_unified (svn_stream_t *output_stream, svn_diff_t *diff, const char *original_header, const char *modified_header, const char *header_encoding, const svn_string_t *original, const svn_string_t *modified, apr_pool_t *pool)
 Similar to svn_diff_mem_string_output_unified2() but with with_diff_header always set to TRUE and hunk_delimiter always set to NULL. More...
 
svn_error_tsvn_diff_mem_string_output_merge3 (svn_stream_t *output_stream, svn_diff_t *diff, const svn_string_t *original, const svn_string_t *modified, const svn_string_t *latest, const char *conflict_original, const char *conflict_modified, const char *conflict_latest, const char *conflict_separator, svn_diff_conflict_display_style_t style, svn_cancel_func_t cancel_func, void *cancel_baton, apr_pool_t *scratch_pool)
 Output the diff generated by svn_diff_mem_string_diff3() in diff3 format on output_stream, using original, modified and latest for content changes. More...
 
svn_error_tsvn_diff_mem_string_output_merge2 (svn_stream_t *output_stream, svn_diff_t *diff, const svn_string_t *original, const svn_string_t *modified, const svn_string_t *latest, const char *conflict_original, const char *conflict_modified, const char *conflict_latest, const char *conflict_separator, svn_diff_conflict_display_style_t style, apr_pool_t *pool)
 Similar to svn_diff_mem_string_output_merge2(), but without cancel support. More...
 
svn_error_tsvn_diff_mem_string_output_merge (svn_stream_t *output_stream, svn_diff_t *diff, const svn_string_t *original, const svn_string_t *modified, const svn_string_t *latest, const char *conflict_original, const char *conflict_modified, const char *conflict_latest, const char *conflict_separator, svn_boolean_t display_original_in_conflict, svn_boolean_t display_resolved_conflicts, apr_pool_t *pool)
 Similar to svn_diff_mem_string_output_merge2, but with display_original_in_conflict and display_resolved_conflicts booleans instead of the conflict_style enum. More...
 
svn_error_tsvn_diff_hunk_readline_diff_text (svn_diff_hunk_t *hunk, svn_stringbuf_t **stringbuf, const char **eol, svn_boolean_t *eof, apr_pool_t *result_pool, apr_pool_t *scratch_pool)
 Allocate *stringbuf in result_pool, and read into it one line of the diff text of hunk. More...
 
svn_error_tsvn_diff_hunk_readline_original_text (svn_diff_hunk_t *hunk, svn_stringbuf_t **stringbuf, const char **eol, svn_boolean_t *eof, apr_pool_t *result_pool, apr_pool_t *scratch_pool)
 Allocate *stringbuf in result_pool, and read into it one line of the original text of hunk. More...
 
svn_error_tsvn_diff_hunk_readline_modified_text (svn_diff_hunk_t *hunk, svn_stringbuf_t **stringbuf, const char **eol, svn_boolean_t *eof, apr_pool_t *result_pool, apr_pool_t *scratch_pool)
 Like svn_diff_hunk_readline_original_text(), but it returns lines from the modified text of the hunk. More...
 
void svn_diff_hunk_reset_diff_text (svn_diff_hunk_t *hunk)
 Reset the diff text of hunk so it can be read again from the start. More...
 
void svn_diff_hunk_reset_original_text (svn_diff_hunk_t *hunk)
 Reset the original text of hunk so it can be read again from the start. More...
 
void svn_diff_hunk_reset_modified_text (svn_diff_hunk_t *hunk)
 Reset the modified text of hunk so it can be read again from the start. More...
 
svn_linenum_t svn_diff_hunk_get_original_start (const svn_diff_hunk_t *hunk)
 Return the line offset of the original hunk text, as parsed from the hunk header. More...
 
svn_linenum_t svn_diff_hunk_get_original_length (const svn_diff_hunk_t *hunk)
 Return the number of lines in the original hunk text, as parsed from the hunk header. More...
 
svn_linenum_t svn_diff_hunk_get_modified_start (const svn_diff_hunk_t *hunk)
 Return the line offset of the modified hunk text, as parsed from the hunk header. More...
 
svn_linenum_t svn_diff_hunk_get_modified_length (const svn_diff_hunk_t *hunk)
 Return the number of lines in the modified hunk text, as parsed from the hunk header. More...
 
svn_linenum_t svn_diff_hunk_get_leading_context (const svn_diff_hunk_t *hunk)
 Return the number of lines of leading context of hunk, i.e. More...
 
svn_linenum_t svn_diff_hunk_get_trailing_context (const svn_diff_hunk_t *hunk)
 Return the number of lines of trailing context of hunk, i.e. More...
 
svn_error_tsvn_diff_open_patch_file (svn_patch_file_t **patch_file, const char *local_abspath, apr_pool_t *result_pool)
 Open patch_file at local_abspath. More...
 
svn_error_tsvn_diff_parse_next_patch (svn_patch_t **patch, svn_patch_file_t *patch_file, svn_boolean_t reverse, svn_boolean_t ignore_whitespace, apr_pool_t *result_pool, apr_pool_t *scratch_pool)
 Return the next *patch in patch_file. More...
 
svn_error_tsvn_diff_close_patch_file (svn_patch_file_t *patch_file, apr_pool_t *scratch_pool)
 Dispose of patch_file. More...
 

Detailed Description

Contextual diffing.

This is an internalized library for performing contextual diffs between sources of data.

Note
This is different than Subversion's binary-diffing engine. That API lives in svn_delta.h – see the "text deltas" section. A "text delta" is way of representing precise binary diffs between strings of data. The Subversion client and server send text deltas to one another during updates and commits.

This API, however, is (or will be) used for performing contextual merges between files in the working copy. During an update or merge, 3-way file merging is needed. And 'svn diff' needs to show the differences between 2 files.

The nice thing about this API is that it's very general. It operates on any source of data (a "datasource") and calculates contextual differences on "tokens" within the data. In our particular usage, the datasources are files and the tokens are lines. But the possibilities are endless.

Definition in file svn_diff.h.

Typedef Documentation

Style for displaying conflicts during diff3 output.

Since
New in 1.6.

There are four types of datasources.

In GNU diff3 terminology, the first three types correspond to the phrases "older", "mine", and "yours".

To what extent whitespace should be ignored when comparing lines.

Since
New in 1.4.

Options to control the behaviour of the file diff routines.

Since
New in 1.4.
Note
This structure may be extended in the future, so to preserve binary compatibility, users must not allocate structs of this type themselves.
See Also
svn_diff_file_options_create().
Note
Although its name suggests otherwise, this structure is used to pass options to file as well as in-memory diff functions.

A vtable for reading data from the three datasources.

Since
New in 1.7.

Like svn_diff_fns2_t except with datasource_open() instead of datasources_open().

Deprecated:
Provided for backward compatibility with the 1.6 API.

A single hunk inside a patch.

The lines of text comprising the hunk can be interpreted in three ways:

  • diff text The hunk as it appears in the unidiff patch file, including the hunk header line ("@@ ... @@")
  • original text The text the patch was based on.
  • modified text The result of patching the original text.

For example, consider a hunk with the following diff text:

  @@ -1,5 +1,5 @@
   #include <stdio.h>
   int main(int argc, char *argv[]) {
  -        printf("Hello World!\n");
  +        printf("I like Subversion!\n");
   } 

The original text of this hunk is:

  #include <stdio.h>
  int main(int argc, char *argv[]) {
          printf("Hello World!\n");
  } 

And the modified text is:

  #include <stdio.h>
  int main(int argc, char *argv[]) {
          printf("I like Subversion!\n");
  } 
See Also
svn_diff_hunk_readline_diff_text()
svn_diff_hunk_readline_original_text()
svn_diff_hunk_readline_modified_text()
Since
New in 1.7.

Definition at line 1077 of file svn_diff.h.

Describes what operation has been performed on a file.

Since
New in 1.7.

A vtable for displaying (or consuming) differences between datasources.

Differences, similarities, and conflicts are described by lining up "ranges" of data.

Any of the function pointers in this vtable may be NULL to ignore the corresponding kinds of output.

Note
These callbacks describe data ranges in units of "tokens". A "token" is whatever you've defined it to be in your datasource svn_diff_fns_t vtable.
typedef struct svn_diff_t svn_diff_t

An opaque type that represents a difference between either two or three datasources.

This object is returned by svn_diff_diff(), svn_diff_diff3() and svn_diff_diff4(), and consumed by a number of other routines.

Definition at line 82 of file svn_diff.h.

An opaque type representing an open patch file.

Since
New in 1.7.

Definition at line 1257 of file svn_diff.h.

typedef struct svn_patch_t svn_patch_t

Data type to manage parsing of patches.

API users should not allocate structures of this type directly.

Since
New in 1.7.

Data type to manage parsing of properties in patches.

API users should not allocate structures of this type directly.

Since
New in 1.7.

Enumeration Type Documentation

Style for displaying conflicts during diff3 output.

Since
New in 1.6.
Enumerator
svn_diff_conflict_display_modified_latest 

Display modified and latest, with conflict markers.

svn_diff_conflict_display_resolved_modified_latest 

Like svn_diff_conflict_display_modified_latest, but with an extra effort to identify common sequences between modified and latest.

svn_diff_conflict_display_modified_original_latest 

Display modified, original, and latest, with conflict markers.

svn_diff_conflict_display_modified 

Just display modified, with no markers.

svn_diff_conflict_display_latest 

Just display latest, with no markers.

svn_diff_conflict_display_only_conflicts 

Like svn_diff_conflict_display_modified_original_latest, but only* showing conflicts.

Definition at line 383 of file svn_diff.h.

There are four types of datasources.

In GNU diff3 terminology, the first three types correspond to the phrases "older", "mine", and "yours".

Enumerator
svn_diff_datasource_original 

The oldest form of the data.

svn_diff_datasource_modified 

The same data, but potentially changed by the user.

svn_diff_datasource_latest 

The latest version of the data, possibly different than the user's modified version.

svn_diff_datasource_ancestor 

The common ancestor of original and modified.

Definition at line 89 of file svn_diff.h.

To what extent whitespace should be ignored when comparing lines.

Since
New in 1.4.
Enumerator
svn_diff_file_ignore_space_none 

Ignore no whitespace.

svn_diff_file_ignore_space_change 

Ignore changes in sequences of whitespace characters, treating each sequence of whitespace characters as a single space.

svn_diff_file_ignore_space_all 

Ignore all whitespace characters.

Definition at line 445 of file svn_diff.h.

Describes what operation has been performed on a file.

Since
New in 1.7.

Definition at line 1026 of file svn_diff.h.

Function Documentation

svn_error_t* svn_diff_close_patch_file ( svn_patch_file_t patch_file,
apr_pool_t *  scratch_pool 
)

Dispose of patch_file.

Use scratch_pool for all temporary allocations.

Since
New in 1.7.
svn_boolean_t svn_diff_contains_conflicts ( svn_diff_t diff)

Determine if a diff object contains conflicts.

If it does, return TRUE, else return FALSE.

svn_boolean_t svn_diff_contains_diffs ( svn_diff_t diff)

Determine if a diff object contains actual differences between the datasources.

If so, return TRUE, else return FALSE.

svn_error_t* svn_diff_diff ( svn_diff_t **  diff,
void *  diff_baton,
const svn_diff_fns_t diff_fns,
apr_pool_t *  pool 
)

Like svn_diff_diff_2() but using svn_diff_fns_t instead of svn_diff_fns2_t.

Deprecated:
Provided for backward compatibility with the 1.6 API.
svn_error_t* svn_diff_diff3 ( svn_diff_t **  diff,
void *  diff_baton,
const svn_diff_fns_t diff_fns,
apr_pool_t *  pool 
)

Like svn_diff_diff3_2() but using svn_diff_fns_t instead of svn_diff_fns2_t.

Deprecated:
Provided for backward compatibility with the 1.6 API.
svn_error_t* svn_diff_diff3_2 ( svn_diff_t **  diff,
void *  diff_baton,
const svn_diff_fns2_t diff_fns,
apr_pool_t *  pool 
)

Given a vtable of diff_fns/diff_baton for reading datasources, return a diff object in *diff that represents a difference between three datasources: "original", "modified", and "latest".

Do all allocation in pool.

Since
New in 1.7.
svn_error_t* svn_diff_diff4 ( svn_diff_t **  diff,
void *  diff_baton,
const svn_diff_fns_t diff_fns,
apr_pool_t *  pool 
)

Like svn_diff_diff4_2() but using svn_diff_fns_t instead of svn_diff_fns2_t.

Deprecated:
Provided for backward compatibility with the 1.6 API.
svn_error_t* svn_diff_diff4_2 ( svn_diff_t **  diff,
void *  diff_baton,
const svn_diff_fns2_t diff_fns,
apr_pool_t *  pool 
)

Given a vtable of diff_fns/diff_baton for reading datasources, return a diff object in *diff that represents a difference between two datasources: "original" and "latest", adjusted to become a full difference between "original", "modified" and "latest" using "ancestor".

Do all allocation in pool.

Since
New in 1.7.
svn_error_t* svn_diff_diff_2 ( svn_diff_t **  diff,
void *  diff_baton,
const svn_diff_fns2_t diff_fns,
apr_pool_t *  pool 
)

Given a vtable of diff_fns/diff_baton for reading datasources, return a diff object in *diff that represents a difference between an "original" and "modified" datasource.

Do all allocation in pool.

Since
New in 1.7.
svn_error_t* svn_diff_file_diff ( svn_diff_t **  diff,
const char *  original,
const char *  modified,
apr_pool_t *  pool 
)

Similar to svn_file_diff_2(), but with options set to a struct with default options.

Deprecated:
Provided for backwards compatibility with the 1.3 API.
svn_error_t* svn_diff_file_diff3 ( svn_diff_t **  diff,
const char *  original,
const char *  modified,
const char *  latest,
apr_pool_t *  pool 
)

Similar to svn_diff_file_diff3_2(), but with options set to a struct with default options.

Deprecated:
Provided for backwards compatibility with the 1.3 API.
svn_error_t* svn_diff_file_diff3_2 ( svn_diff_t **  diff,
const char *  original,
const char *  modified,
const char *  latest,
const svn_diff_file_options_t options,
apr_pool_t *  pool 
)

A convenience function to produce a diff between three files.

Since
New in 1.4.

Return a diff object in *diff (allocated from pool) that represents the difference between an original file, modified file, and latest file.

Compare lines according to the relevant fields of options.

svn_error_t* svn_diff_file_diff4 ( svn_diff_t **  diff,
const char *  original,
const char *  modified,
const char *  latest,
const char *  ancestor,
apr_pool_t *  pool 
)

Similar to svn_file_diff4_2(), but with options set to a struct with default options.

Deprecated:
Provided for backwards compatibility with the 1.3 API.
svn_error_t* svn_diff_file_diff4_2 ( svn_diff_t **  diff,
const char *  original,
const char *  modified,
const char *  latest,
const char *  ancestor,
const svn_diff_file_options_t options,
apr_pool_t *  pool 
)

A convenience function to produce a diff between four files.

Since
New in 1.4.

Return a diff object in *diff (allocated from pool) that represents the difference between an original file, modified file, latest and ancestor file. (The file arguments must be full paths to the files.)

Compare lines according to the relevant fields of options.

svn_error_t* svn_diff_file_diff_2 ( svn_diff_t **  diff,
const char *  original,
const char *  modified,
const svn_diff_file_options_t options,
apr_pool_t *  pool 
)

A convenience function to produce a diff between two files.

Since
New in 1.4.

Return a diff object in *diff (allocated from pool) that represents the difference between an original file and modified file. (The file arguments must be full paths to the files.)

Compare lines according to the relevant fields of options.

svn_diff_file_options_t* svn_diff_file_options_create ( apr_pool_t *  pool)

Allocate a svn_diff_file_options_t structure in pool, initializing it with default values.

Since
New in 1.4.
svn_error_t* svn_diff_file_options_parse ( svn_diff_file_options_t options,
const apr_array_header_t *  args,
apr_pool_t *  pool 
)

Parse args, an array of const char * command line switches and adjust options accordingly.

options is assumed to be initialized with default values. pool is used for temporary allocation.

Since
New in 1.4.

The following options are supported:

  • –ignore-space-change, -b
  • –ignore-all-space, -w
  • –ignore-eol-style
  • –show-c-function, -p
    Since
    New in 1.5.
  • –context, -U ARG
    Since
    New in 1.9.
  • –unified, -u (for compatibility, does nothing).
svn_error_t* svn_diff_file_output_merge ( svn_stream_t output_stream,
svn_diff_t diff,
const char *  original_path,
const char *  modified_path,
const char *  latest_path,
const char *  conflict_original,
const char *  conflict_modified,
const char *  conflict_latest,
const char *  conflict_separator,
svn_boolean_t  display_original_in_conflict,
svn_boolean_t  display_resolved_conflicts,
apr_pool_t *  pool 
)

Similar to svn_diff_file_output_merge2, but with display_original_in_conflict and display_resolved_conflicts booleans instead of the conflict_style enum.

If both booleans are false, acts like svn_diff_conflict_display_modified_latest; if display_original_in_conflict is true, acts like svn_diff_conflict_display_modified_original_latest; if display_resolved_conflicts is true, acts like svn_diff_conflict_display_resolved_modified_latest. The booleans may not both be true.

Deprecated:
Provided for backward compatibility with the 1.5 API.
svn_error_t* svn_diff_file_output_merge2 ( svn_stream_t output_stream,
svn_diff_t diff,
const char *  original_path,
const char *  modified_path,
const char *  latest_path,
const char *  conflict_original,
const char *  conflict_modified,
const char *  conflict_latest,
const char *  conflict_separator,
svn_diff_conflict_display_style_t  conflict_style,
apr_pool_t *  pool 
)

Similar to svn_diff_file_output_merge3, but without cancel support.

Since
New in 1.6.
Deprecated:
Provided for backward compatibility with the 1.8 API.
svn_error_t* svn_diff_file_output_merge3 ( svn_stream_t output_stream,
svn_diff_t diff,
const char *  original_path,
const char *  modified_path,
const char *  latest_path,
const char *  conflict_original,
const char *  conflict_modified,
const char *  conflict_latest,
const char *  conflict_separator,
svn_diff_conflict_display_style_t  conflict_style,
svn_cancel_func_t  cancel_func,
void *  cancel_baton,
apr_pool_t *  scratch_pool 
)

A convenience function to produce diff3 output from the diff generated by svn_diff_file_diff3().

Output a diff between original_path, modified_path and latest_path in merged format to output_stream. Optionally supply conflict_modified, conflict_original, conflict_separator and/or conflict_latest to be displayed as conflict markers in the output. If conflict_original, conflict_modified, conflict_latest and/or conflict_separator is NULL, a default marker will be displayed. conflict_style dictates how conflicts are displayed. Uses scratch_pool for temporary allocations.

If not NULL, call cancel_func with cancel_baton once or multiple times while processing larger diffs.

Since
New in 1.9.
svn_error_t* svn_diff_file_output_unified ( svn_stream_t output_stream,
svn_diff_t diff,
const char *  original_path,
const char *  modified_path,
const char *  original_header,
const char *  modified_header,
apr_pool_t *  pool 
)

Similar to svn_diff_file_output_unified2(), but with header_encoding set to APR_LOCALE_CHARSET.

Deprecated:
Provided for backward compatibility with the 1.2 API.
svn_error_t* svn_diff_file_output_unified2 ( svn_stream_t output_stream,
svn_diff_t diff,
const char *  original_path,
const char *  modified_path,
const char *  original_header,
const char *  modified_header,
const char *  header_encoding,
apr_pool_t *  pool 
)

Similar to svn_diff_file_output_unified3(), but with relative_to_dir set to NULL and show_c_function to false.

Deprecated:
Provided for backwards compatibility with the 1.4 API.
svn_error_t* svn_diff_file_output_unified3 ( svn_stream_t output_stream,
svn_diff_t diff,
const char *  original_path,
const char *  modified_path,
const char *  original_header,
const char *  modified_header,
const char *  header_encoding,
const char *  relative_to_dir,
svn_boolean_t  show_c_function,
apr_pool_t *  pool 
)

Similar to svn_diff_file_output_unified4(), but without cancel support and with context_size set to -1.

Since
New in 1.5.
Deprecated:
Provided for backwards compatibility with the 1.8 API.
svn_error_t* svn_diff_file_output_unified4 ( svn_stream_t output_stream,
svn_diff_t diff,
const char *  original_path,
const char *  modified_path,
const char *  original_header,
const char *  modified_header,
const char *  header_encoding,
const char *  relative_to_dir,
svn_boolean_t  show_c_function,
int  context_size,
svn_cancel_func_t  cancel_func,
void *  cancel_baton,
apr_pool_t *  scratch_pool 
)

A convenience function to produce unified diff output from the diff generated by svn_diff_file_diff().

Output a diff between original_path and modified_path in unified context diff format to output_stream. Optionally supply original_header and/or modified_header to be displayed in the header of the output. If original_header or modified_header is NULL, a default header will be displayed, consisting of path and last modified time. Output all headers and markers in header_encoding. If relative_to_dir is not NULL, the original_path and modified_path will have the relative_to_dir stripped from the front of the respective paths. If relative_to_dir is NULL, paths will be not be modified. If relative_to_dir is not NULL but relative_to_dir is not a parent path of the target, an error is returned. Finally, if relative_to_dir is a URL, an error will be returned.

If context_size is not negative, then this number of context lines will be used in the generated diff output. Otherwise the legacy compile time default will be used.

If not NULL, call cancel_func with cancel_baton once or multiple times while processing larger diffs.

Since
New in 1.9.
svn_linenum_t svn_diff_hunk_get_leading_context ( const svn_diff_hunk_t hunk)

Return the number of lines of leading context of hunk, i.e.

the number of lines starting with ' ' before the first line that starts with a '+' or '-'.

Since
New in 1.7.
svn_linenum_t svn_diff_hunk_get_modified_length ( const svn_diff_hunk_t hunk)

Return the number of lines in the modified hunk text, as parsed from the hunk header.

Since
New in 1.7.
svn_linenum_t svn_diff_hunk_get_modified_start ( const svn_diff_hunk_t hunk)

Return the line offset of the modified hunk text, as parsed from the hunk header.

Since
New in 1.7.
svn_linenum_t svn_diff_hunk_get_original_length ( const svn_diff_hunk_t hunk)

Return the number of lines in the original hunk text, as parsed from the hunk header.

Since
New in 1.7.
svn_linenum_t svn_diff_hunk_get_original_start ( const svn_diff_hunk_t hunk)

Return the line offset of the original hunk text, as parsed from the hunk header.

Since
New in 1.7.
svn_linenum_t svn_diff_hunk_get_trailing_context ( const svn_diff_hunk_t hunk)

Return the number of lines of trailing context of hunk, i.e.

the number of lines starting with ' ' after the last line that starts with a '+' or '-'.

Since
New in 1.7.
svn_error_t* svn_diff_hunk_readline_diff_text ( svn_diff_hunk_t hunk,
svn_stringbuf_t **  stringbuf,
const char **  eol,
svn_boolean_t eof,
apr_pool_t *  result_pool,
apr_pool_t *  scratch_pool 
)

Allocate *stringbuf in result_pool, and read into it one line of the diff text of hunk.

The hunk header is not returned only the unidiff data lines (starting with '+', '-', or ' ') are returned. If the hunk is being interpreted in reverse (i.e. the reverse parameter of svn_diff_parse_next_patch() was TRUE), the diff text will be returned in reversed form. The line-terminator is detected automatically and stored in *eol if eol is not NULL. If EOF is reached, set *eof to TRUE, and set *eol to NULL if the hunk does not end with a newline character and eol is not NULL. Temporary allocations will be performed in scratch_pool.

Note
The hunk header information can be retrieved with the following functions:
See Also
svn_diff_hunk_get_original_start()
svn_diff_hunk_get_original_length()
svn_diff_hunk_get_modified_start()
svn_diff_hunk_get_modified_length()
Since
New in 1.7.
svn_error_t* svn_diff_hunk_readline_modified_text ( svn_diff_hunk_t hunk,
svn_stringbuf_t **  stringbuf,
const char **  eol,
svn_boolean_t eof,
apr_pool_t *  result_pool,
apr_pool_t *  scratch_pool 
)

Like svn_diff_hunk_readline_original_text(), but it returns lines from the modified text of the hunk.

See Also
svn_diff_hunk_t
Since
New in 1.7.
svn_error_t* svn_diff_hunk_readline_original_text ( svn_diff_hunk_t hunk,
svn_stringbuf_t **  stringbuf,
const char **  eol,
svn_boolean_t eof,
apr_pool_t *  result_pool,
apr_pool_t *  scratch_pool 
)

Allocate *stringbuf in result_pool, and read into it one line of the original text of hunk.

The line-terminator is detected automatically and stored in *eol if eol is not NULL. If EOF is reached, set *eof to TRUE, and set *eol to NULL if the hunk text does not end with a newline character and eol is not NULL. Temporary allocations will be performed in scratch_pool.

See Also
svn_diff_hunk_t
Since
New in 1.7.
void svn_diff_hunk_reset_diff_text ( svn_diff_hunk_t hunk)

Reset the diff text of hunk so it can be read again from the start.

Since
New in 1.7.
void svn_diff_hunk_reset_modified_text ( svn_diff_hunk_t hunk)

Reset the modified text of hunk so it can be read again from the start.

Since
New in 1.7.
void svn_diff_hunk_reset_original_text ( svn_diff_hunk_t hunk)

Reset the original text of hunk so it can be read again from the start.

Since
New in 1.7.
svn_error_t* svn_diff_mem_string_diff ( svn_diff_t **  diff,
const svn_string_t original,
const svn_string_t modified,
const svn_diff_file_options_t options,
apr_pool_t *  pool 
)

Generate diff output from the original and modified in-memory strings.

diff will be allocated from pool.

Since
New in 1.5.
svn_error_t* svn_diff_mem_string_diff3 ( svn_diff_t **  diff,
const svn_string_t original,
const svn_string_t modified,
const svn_string_t latest,
const svn_diff_file_options_t options,
apr_pool_t *  pool 
)

Generate diff output from the original, modified and latest in-memory strings.

diff will be allocated in pool.

Since
New in 1.5.
svn_error_t* svn_diff_mem_string_diff4 ( svn_diff_t **  diff,
const svn_string_t original,
const svn_string_t modified,
const svn_string_t latest,
const svn_string_t ancestor,
const svn_diff_file_options_t options,
apr_pool_t *  pool 
)

Generate diff output from the original, modified and latest in-memory strings, using ancestor.

diff will be allocated in pool.

Since
New in 1.5.
svn_error_t* svn_diff_mem_string_output_merge ( svn_stream_t output_stream,
svn_diff_t diff,
const svn_string_t original,
const svn_string_t modified,
const svn_string_t latest,
const char *  conflict_original,
const char *  conflict_modified,
const char *  conflict_latest,
const char *  conflict_separator,
svn_boolean_t  display_original_in_conflict,
svn_boolean_t  display_resolved_conflicts,
apr_pool_t *  pool 
)

Similar to svn_diff_mem_string_output_merge2, but with display_original_in_conflict and display_resolved_conflicts booleans instead of the conflict_style enum.

If both booleans are false, acts like svn_diff_conflict_display_modified_latest; if display_original_in_conflict is true, acts like svn_diff_conflict_display_modified_original_latest; if display_resolved_conflicts is true, acts like svn_diff_conflict_display_resolved_modified_latest. The booleans may not both be true.

Deprecated:
Provided for backward compatibility with the 1.5 API.
svn_error_t* svn_diff_mem_string_output_merge2 ( svn_stream_t output_stream,
svn_diff_t diff,
const svn_string_t original,
const svn_string_t modified,
const svn_string_t latest,
const char *  conflict_original,
const char *  conflict_modified,
const char *  conflict_latest,
const char *  conflict_separator,
svn_diff_conflict_display_style_t  style,
apr_pool_t *  pool 
)

Similar to svn_diff_mem_string_output_merge2(), but without cancel support.

Since
New in 1.6.
Deprecated:
Provided for backwards compatibility with the 1.8 API.
svn_error_t* svn_diff_mem_string_output_merge3 ( svn_stream_t output_stream,
svn_diff_t diff,
const svn_string_t original,
const svn_string_t modified,
const svn_string_t latest,
const char *  conflict_original,
const char *  conflict_modified,
const char *  conflict_latest,
const char *  conflict_separator,
svn_diff_conflict_display_style_t  style,
svn_cancel_func_t  cancel_func,
void *  cancel_baton,
apr_pool_t *  scratch_pool 
)

Output the diff generated by svn_diff_mem_string_diff3() in diff3 format on output_stream, using original, modified and latest for content changes.

Use the conflict markers conflict_original, conflict_modified, conflict_latest and conflict_separator or the default one for each of these if NULL is passed.

conflict_style dictates how conflicts are displayed.

If not NULL, call cancel_func with cancel_baton once or multiple times while processing larger diffs.

Uses scratch_pool for temporary allocations.

Since
New in 1.9.
svn_error_t* svn_diff_mem_string_output_unified ( svn_stream_t output_stream,
svn_diff_t diff,
const char *  original_header,
const char *  modified_header,
const char *  header_encoding,
const svn_string_t original,
const svn_string_t modified,
apr_pool_t *  pool 
)

Similar to svn_diff_mem_string_output_unified2() but with with_diff_header always set to TRUE and hunk_delimiter always set to NULL.

Since
New in 1.5.
Deprecated:
Provided for backwards compatibility with the 1.8 API.
svn_error_t* svn_diff_mem_string_output_unified2 ( svn_stream_t output_stream,
svn_diff_t diff,
svn_boolean_t  with_diff_header,
const char *  hunk_delimiter,
const char *  original_header,
const char *  modified_header,
const char *  header_encoding,
const svn_string_t original,
const svn_string_t modified,
apr_pool_t *  pool 
)

Similar to svn_diff_mem_string_output_unified3() but without cancel support and with context_size set to -1.

Since
New in 1.7. Hunk delimiter "##" has the special meaning since 1.8.
Deprecated:
Provided for backwards compatibility with the 1.8 API.
svn_error_t* svn_diff_mem_string_output_unified3 ( svn_stream_t output_stream,
svn_diff_t diff,
svn_boolean_t  with_diff_header,
const char *  hunk_delimiter,
const char *  original_header,
const char *  modified_header,
const char *  header_encoding,
const svn_string_t original,
const svn_string_t modified,
int  context_size,
svn_cancel_func_t  cancel_func,
void *  cancel_baton,
apr_pool_t *  scratch_pool 
)

Outputs the diff object generated by svn_diff_mem_string_diff() in unified diff format on output_stream, using original and modified for the text in the output.

If with_diff_header is TRUE, write a diff header ("---" and "+++" lines), using original_header and modified_header to fill the field after the "---" and "+++" markers; otherwise original_header and modified_header are ignored and may be NULL.

Outputs the header and hunk delimiters in header_encoding. A hunk_delimiter can optionally be specified. If hunk_delimiter is NULL, use the default hunk delimiter "@@".

As a special case, if the hunk delimiter is "##", then for an incomplete final line use the text "\ No newline at end of property" instead of "\ No newline at end of file".

If context_size is not negative, then this number of context lines will be used in the generated diff output. Otherwise the legacy compile time default will be used.

If not NULL, call cancel_func with cancel_baton once or multiple times while processing larger diffs.

Uses scratch_pool for temporary allocations.

Since
New in 1.9
svn_error_t* svn_diff_open_patch_file ( svn_patch_file_t **  patch_file,
const char *  local_abspath,
apr_pool_t *  result_pool 
)

Open patch_file at local_abspath.

Allocate patch_file in result_pool.

Since
New in 1.7.
svn_error_t* svn_diff_output ( svn_diff_t diff,
void *  output_baton,
const svn_diff_output_fns_t output_fns 
)

Similar to svn_diff_output2(), but without cancel support.

Deprecated:
Provided for backwards compatibility with the 1.8 API.
svn_error_t* svn_diff_output2 ( svn_diff_t diff,
void *  output_baton,
const svn_diff_output_fns_t output_fns,
svn_cancel_func_t  cancel_func,
void *  cancel_baton 
)

Given a vtable of output_fns/output_baton for consuming differences, output the differences in diff.

If not NULL, call cancel_func with cancel_baton once or multiple times while processing larger diffs.

Since
New in 1.9.
svn_error_t* svn_diff_output_binary ( svn_stream_t output_stream,
svn_stream_t original,
svn_stream_t latest,
svn_cancel_func_t  cancel_func,
void *  cancel_baton,
apr_pool_t *  scratch_pool 
)

Creates a git-like binary diff hunk describing the differences between original and latest.

It does this by either producing either the literal content of both versions in a compressed format, or by describing one way transforms.

Either original or latest may be NULL to describe that the version didn't exist.

Writes the output to output_stream.

If not NULL, call cancel_func with cancel_baton once or multiple times while processing larger diffs.

Since
New in 1.9.
svn_error_t* svn_diff_parse_next_patch ( svn_patch_t **  patch,
svn_patch_file_t patch_file,
svn_boolean_t  reverse,
svn_boolean_t  ignore_whitespace,
apr_pool_t *  result_pool,
apr_pool_t *  scratch_pool 
)

Return the next *patch in patch_file.

If no patch can be found, set *patch to NULL. If reverse is TRUE, invert the patch while parsing it. If ignore_whitespace is TRUE, allow patches with no leading whitespace to be parsed. Allocate results in result_pool. Use scratch_pool for all other allocations.

Since
New in 1.7.
const svn_version_t* svn_diff_version ( void  )

Get libsvn_diff version information.

Since
New in 1.1.