Subversion 1.6.16
|
Contextual diffing. More...
#include <apr.h>
#include <apr_pools.h>
#include <apr_tables.h>
#include "svn_types.h"
#include "svn_io.h"
#include "svn_version.h"
#include "svn_string.h"
Go to the source code of this file.
Data Structures | |
struct | svn_diff_fns_t |
A vtable for reading data from the three datasources. 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... | |
Typedefs | |
typedef struct svn_diff_t | svn_diff_t |
An opaque type that represents a difference between either two or three datasources. | |
typedef enum svn_diff_datasource_e | svn_diff_datasource_e |
There are four types of datasources. | |
typedef struct svn_diff_fns_t | svn_diff_fns_t |
A vtable for reading data from the three datasources. | |
typedef struct svn_diff_output_fns_t | svn_diff_output_fns_t |
A vtable for displaying (or consuming) differences between datasources. | |
typedef enum svn_diff_conflict_display_style_t | svn_diff_conflict_display_style_t |
Style for displaying conflicts during diff3 output. | |
typedef enum svn_diff_file_ignore_space_t | svn_diff_file_ignore_space_t |
To what extent whitespace should be ignored when comparing lines. | |
typedef struct svn_diff_file_options_t | svn_diff_file_options_t |
Options to control the behaviour of the file diff routines. | |
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... | |
Functions | |
const svn_version_t * | svn_diff_version (void) |
Get libsvn_diff version information. | |
svn_error_t * | svn_diff_diff (svn_diff_t **diff, void *diff_baton, const svn_diff_fns_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. | |
svn_error_t * | svn_diff_diff3 (svn_diff_t **diff, void *diff_baton, const svn_diff_fns_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". | |
svn_error_t * | svn_diff_diff4 (svn_diff_t **diff, void *diff_baton, const svn_diff_fns_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". | |
svn_boolean_t | svn_diff_contains_conflicts (svn_diff_t *diff) |
Determine if a diff object contains conflicts. | |
svn_boolean_t | svn_diff_contains_diffs (svn_diff_t *diff) |
Determine if a diff object contains actual differences between the datasources. | |
svn_error_t * | svn_diff_output (svn_diff_t *diff, void *output_baton, const svn_diff_output_fns_t *output_fns) |
Given a vtable of output_fns/output_baton for consuming differences, output the differences in diff. | |
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. | |
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. | |
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. | |
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. | |
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. | |
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. | |
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. | |
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) |
Simliar to svn_file_diff4_2(), but with options set to a struct with default options. | |
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) |
A convenience function to produce unified diff output from the diff generated by svn_diff_file_diff(). | |
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. | |
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 . | |
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) |
A convenience function to produce diff3 output from the diff generated by svn_diff_file_diff3(). | |
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. | |
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. | |
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 orginal, modified and latest in-memory strings. | |
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. | |
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) |
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. | |
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) |
Output the diff generated by svn_diff_mem_string_diff3() in diff3 format on output_stream, using original, modified and latest for content changes. | |
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. |
Contextual diffing.
This is an internalized library for performing contextual diffs between sources of data.
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.
Style for displaying conflicts during diff3 output.
typedef enum svn_diff_datasource_e svn_diff_datasource_e |
There are four types of datasources.
In GNU diff3 terminology, the first three types correspond to the phrases "older", "mine", and "yours".
typedef enum svn_diff_file_ignore_space_t svn_diff_file_ignore_space_t |
To what extent whitespace should be ignored when comparing lines.
typedef struct svn_diff_file_options_t svn_diff_file_options_t |
Options to control the behaviour of the file diff routines.
typedef struct svn_diff_fns_t svn_diff_fns_t |
A vtable for reading data from the three datasources.
typedef struct svn_diff_output_fns_t svn_diff_output_fns_t |
A vtable for displaying (or consuming) differences between datasources.
Differences, similarities, and conflicts are described by lining up "ranges" of data.
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 77 of file svn_diff.h.
Style for displaying conflicts during diff3 output.
Definition at line 300 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".
Definition at line 84 of file svn_diff.h.
To what extent whitespace should be ignored when comparing lines.
Definition at line 342 of file svn_diff.h.
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 | ||
) |
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.
svn_error_t* svn_diff_diff3 | ( | svn_diff_t ** | diff, |
void * | diff_baton, | ||
const svn_diff_fns_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.
svn_error_t* svn_diff_diff4 | ( | svn_diff_t ** | diff, |
void * | diff_baton, | ||
const svn_diff_fns_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.
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.
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.
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.
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 | ||
) |
Simliar to svn_file_diff4_2(), but with options set to a struct with default options.
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.
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.
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.
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.
The following options are supported:
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.
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 | ||
) |
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.
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
.
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.
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 | ||
) |
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.
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.
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 orginal, modified and latest in-memory strings.
diff will be allocated in pool.
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.
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.
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 | ||
) |
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.
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 | ||
) |
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.
Outputs the header and markers in header_encoding.
original_header and modified header are used to fill the field after the "---" and "+++" header markers.
const svn_version_t* svn_diff_version | ( | void | ) |
Get libsvn_diff version information.