You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by cm...@apache.org on 2018/11/28 21:25:35 UTC
svn commit: r1847678 [7/25] - in /subversion/branches/swig-py3: ./ build/
build/ac-macros/ build/generator/ build/generator/templates/ build/win32/
contrib/client-side/ contrib/client-side/svn_load_dirs/
contrib/client-side/svnmerge/ contrib/hook-scrip...
Modified: subversion/branches/swig-py3/subversion/libsvn_client/diff.c
URL: http://svn.apache.org/viewvc/subversion/branches/swig-py3/subversion/libsvn_client/diff.c?rev=1847678&r1=1847677&r2=1847678&view=diff
==============================================================================
--- subversion/branches/swig-py3/subversion/libsvn_client/diff.c (original)
+++ subversion/branches/swig-py3/subversion/libsvn_client/diff.c Wed Nov 28 21:25:32 2018
@@ -23,6 +23,9 @@
/* ==================================================================== */
+/* We define this here to remove any further warnings about the usage of
+ experimental functions in this file. */
+#define SVN_EXPERIMENTAL
/*** Includes. ***/
@@ -66,6 +69,31 @@
_("Path '%s' must be an immediate child of " \
"the directory '%s'"), path, relative_to_dir)
+/* State provided by the diff drivers; used by the diff writer */
+typedef struct diff_driver_info_t
+{
+ /* The anchor to prefix before wc paths */
+ const char *anchor;
+
+ /* Relative path of ra session from repos_root_url.
+
+ Used only in printing git diff headers. The repository-root-relative
+ path of ... ### what user-visible property of the diff? */
+ const char *session_relpath;
+
+ /* Used only in printing git diff headers. Used to find the
+ repository-root-relative path of a WC path. */
+ svn_wc_context_t *wc_ctx;
+
+ /* The original targets passed to the diff command. We may need
+ these to construct distinctive diff labels when comparing the
+ same relative path in the same revision, under different anchors
+ (for example, when comparing a trunk against a branch). */
+ const char *orig_path_1;
+ const char *orig_path_2;
+} diff_driver_info_t;
+
+
/* Calculate the repository relative path of DIFF_RELPATH, using
* SESSION_RELPATH and WC_CTX, and return the result in *REPOS_RELPATH.
* ORIG_TARGET is the related original target passed to the diff command,
@@ -120,25 +148,47 @@ make_repos_relpath(const char **repos_re
return SVN_NO_ERROR;
}
-/* Adjust *INDEX_PATH, *ORIG_PATH_1 and *ORIG_PATH_2, representing the changed
- * node and the two original targets passed to the diff command, to handle the
- * case when we're dealing with different anchors. RELATIVE_TO_DIR is the
- * directory the diff target should be considered relative to.
- * ANCHOR is the local path where the diff editor is anchored. The resulting
- * values are allocated in RESULT_POOL and temporary allocations are performed
- * in SCRATCH_POOL. */
+/* Adjust paths to handle the case when we're dealing with different anchors.
+ *
+ * Set *INDEX_PATH to the new relative path. Set *LABEL_PATH1 and
+ * *LABEL_PATH2 to that path annotated with the unique parts of ORIG_PATH_1
+ * and ORIG_PATH_2 respectively, like this:
+ *
+ * INDEX_PATH: "path"
+ * LABEL_PATH1: "path\t(.../branches/branch1)"
+ * LABEL_PATH2: "path\t(.../trunk)"
+ *
+ * Make the output paths relative to RELATIVE_TO_DIR (if not null) by
+ * removing it from the beginning of (ANCHOR + RELPATH).
+ *
+ * ANCHOR (if not null) is the local path where the diff editor is anchored.
+ * RELPATH is the path to the changed node within the diff editor, so
+ * relative to ANCHOR.
+ *
+ * RELATIVE_TO_DIR and ANCHOR are of the same form -- either absolute local
+ * paths or relative paths relative to the same base.
+ *
+ * ORIG_PATH_1 and ORIG_PATH_2 represent the two original target paths or
+ * URLs passed to the diff command.
+ *
+ * Allocate results in RESULT_POOL (or as a pointer to RELPATH) and
+ * temporary data in SCRATCH_POOL.
+ */
static svn_error_t *
adjust_paths_for_diff_labels(const char **index_path,
- const char **orig_path_1,
- const char **orig_path_2,
+ const char **label_path1,
+ const char **label_path2,
const char *relative_to_dir,
const char *anchor,
+ const char *relpath,
+ const char *orig_path_1,
+ const char *orig_path_2,
apr_pool_t *result_pool,
apr_pool_t *scratch_pool)
{
- const char *new_path = *index_path;
- const char *new_path1 = *orig_path_1;
- const char *new_path2 = *orig_path_2;
+ const char *new_path = relpath;
+ const char *new_path1 = orig_path_1;
+ const char *new_path2 = orig_path_2;
if (anchor)
new_path = svn_dirent_join(anchor, new_path, result_pool);
@@ -177,6 +227,7 @@ adjust_paths_for_diff_labels(const char
/* ### BH: We can now just construct the repos_relpath, etc. as the
anchor is available. See also make_repos_relpath() */
+ /* Remove the common prefix of NEW_PATH1 and NEW_PATH2. */
is_url1 = svn_path_is_url(new_path1);
is_url2 = svn_path_is_url(new_path2);
@@ -220,8 +271,8 @@ adjust_paths_for_diff_labels(const char
new_path2 = apr_psprintf(result_pool, "%s\t(.../%s)", new_path, new_path2);
*index_path = new_path;
- *orig_path_1 = new_path1;
- *orig_path_2 = new_path2;
+ *label_path1 = new_path1;
+ *label_path2 = new_path2;
return SVN_NO_ERROR;
}
@@ -383,28 +434,33 @@ maybe_print_mode_change(svn_stream_t *os
}
/* Print a git diff header showing the OPERATION to the stream OS using
- * HEADER_ENCODING. Return suitable diff labels for the git diff in *LABEL1
- * and *LABEL2. REPOS_RELPATH1 and REPOS_RELPATH2 are relative to reposroot.
- * are the paths passed to the original diff command. REV1 and REV2 are
- * revisions being diffed. COPYFROM_PATH and COPYFROM_REV indicate where the
+ * HEADER_ENCODING.
+ *
+ * Return suitable diff labels for the git diff in *LABEL1 and *LABEL2.
+ *
+ * REV1 and REV2 are the revisions being diffed.
+ * COPYFROM_PATH and COPYFROM_REV indicate where the
* diffed item was copied from.
* Use SCRATCH_POOL for temporary allocations. */
static svn_error_t *
print_git_diff_header(svn_stream_t *os,
const char **label1, const char **label2,
svn_diff_operation_kind_t operation,
- const char *repos_relpath1,
- const char *repos_relpath2,
svn_revnum_t rev1,
svn_revnum_t rev2,
+ const char *diff_relpath,
const char *copyfrom_path,
svn_revnum_t copyfrom_rev,
apr_hash_t *left_props,
apr_hash_t *right_props,
const char *git_index_shas,
const char *header_encoding,
+ const diff_driver_info_t *ddi,
apr_pool_t *scratch_pool)
{
+ const char *repos_relpath1;
+ const char *repos_relpath2;
+ const char *copyfrom_repos_relpath = NULL;
svn_boolean_t exec_bit1 = (svn_prop_get_value(left_props,
SVN_PROP_EXECUTABLE) != NULL);
svn_boolean_t exec_bit2 = (svn_prop_get_value(right_props,
@@ -414,6 +470,26 @@ print_git_diff_header(svn_stream_t *os,
svn_boolean_t symlink_bit2 = (svn_prop_get_value(right_props,
SVN_PROP_SPECIAL) != NULL);
+ SVN_ERR(make_repos_relpath(&repos_relpath1, diff_relpath,
+ ddi->orig_path_1,
+ ddi->session_relpath,
+ ddi->wc_ctx,
+ ddi->anchor,
+ scratch_pool, scratch_pool));
+ SVN_ERR(make_repos_relpath(&repos_relpath2, diff_relpath,
+ ddi->orig_path_2,
+ ddi->session_relpath,
+ ddi->wc_ctx,
+ ddi->anchor,
+ scratch_pool, scratch_pool));
+ if (copyfrom_path)
+ SVN_ERR(make_repos_relpath(©from_repos_relpath, copyfrom_path,
+ ddi->orig_path_2,
+ ddi->session_relpath,
+ ddi->wc_ctx,
+ ddi->anchor,
+ scratch_pool, scratch_pool));
+
if (operation == svn_diff_op_deleted)
{
SVN_ERR(print_git_diff_header_deleted(os, header_encoding,
@@ -487,6 +563,24 @@ print_git_diff_header(svn_stream_t *os,
return SVN_NO_ERROR;
}
+/* Print the "Index:" and "=====" lines.
+ * Show the paths in platform-independent format ('/' separators)
+ */
+static svn_error_t *
+print_diff_index_header(svn_stream_t *outstream,
+ const char *header_encoding,
+ const char *index_path,
+ const char *suffix,
+ apr_pool_t *scratch_pool)
+{
+ SVN_ERR(svn_stream_printf_from_utf8(outstream,
+ header_encoding, scratch_pool,
+ "Index: %s%s" APR_EOL_STR
+ SVN_DIFF__EQUAL_STRING APR_EOL_STR,
+ index_path, suffix));
+ return SVN_NO_ERROR;
+}
+
/* A helper func that writes out verbal descriptions of property diffs
to OUTSTREAM. Of course, OUTSTREAM will probably be whatever was
passed to svn_client_diff7(), which is probably stdout.
@@ -494,24 +588,20 @@ print_git_diff_header(svn_stream_t *os,
### FIXME needs proper docstring
If USE_GIT_DIFF_FORMAT is TRUE, pring git diff headers, which always
- show paths relative to the repository root. RA_SESSION and WC_CTX are
- needed to normalize paths relative the repository root, and are ignored
- if USE_GIT_DIFF_FORMAT is FALSE.
+ show paths relative to the repository root. DDI->session_relpath and
+ DDI->wc_ctx are needed to normalize paths relative the repository root,
+ and are ignored if USE_GIT_DIFF_FORMAT is FALSE.
If @a pretty_print_mergeinfo is true, then describe 'svn:mergeinfo'
property changes in a human-readable form that says what changes were
merged or reverse merged; otherwise (or if the mergeinfo property values
don't parse correctly) display them just like any other property.
-
- ANCHOR is the local path where the diff editor is anchored. */
+ */
static svn_error_t *
display_prop_diffs(const apr_array_header_t *propchanges,
apr_hash_t *left_props,
apr_hash_t *right_props,
const char *diff_relpath,
- const char *anchor,
- const char *orig_path1,
- const char *orig_path2,
svn_revnum_t rev1,
svn_revnum_t rev2,
const char *encoding,
@@ -520,32 +610,28 @@ display_prop_diffs(const apr_array_heade
svn_boolean_t show_diff_header,
svn_boolean_t use_git_diff_format,
svn_boolean_t pretty_print_mergeinfo,
- const char *ra_session_relpath,
+ const diff_driver_info_t *ddi,
svn_cancel_func_t cancel_func,
void *cancel_baton,
- svn_wc_context_t *wc_ctx,
apr_pool_t *scratch_pool)
{
const char *repos_relpath1 = NULL;
- const char *repos_relpath2 = NULL;
- const char *index_path = diff_relpath;
- const char *adjusted_path1 = orig_path1;
- const char *adjusted_path2 = orig_path2;
+ const char *index_path;
+ const char *label_path1, *label_path2;
if (use_git_diff_format)
{
- SVN_ERR(make_repos_relpath(&repos_relpath1, diff_relpath, orig_path1,
- ra_session_relpath, wc_ctx, anchor,
- scratch_pool, scratch_pool));
- SVN_ERR(make_repos_relpath(&repos_relpath2, diff_relpath, orig_path2,
- ra_session_relpath, wc_ctx, anchor,
+ SVN_ERR(make_repos_relpath(&repos_relpath1, diff_relpath, ddi->orig_path_1,
+ ddi->session_relpath, ddi->wc_ctx, ddi->anchor,
scratch_pool, scratch_pool));
}
/* If we're creating a diff on the wc root, path would be empty. */
- SVN_ERR(adjust_paths_for_diff_labels(&index_path, &adjusted_path1,
- &adjusted_path2,
- relative_to_dir, anchor,
+ SVN_ERR(adjust_paths_for_diff_labels(&index_path,
+ &label_path1, &label_path2,
+ relative_to_dir, ddi->anchor,
+ diff_relpath,
+ ddi->orig_path_1, ddi->orig_path_2,
scratch_pool, scratch_pool));
if (show_diff_header)
@@ -553,27 +639,21 @@ display_prop_diffs(const apr_array_heade
const char *label1;
const char *label2;
- label1 = diff_label(adjusted_path1, rev1, scratch_pool);
- label2 = diff_label(adjusted_path2, rev2, scratch_pool);
-
- /* ### Should we show the paths in platform specific format,
- * ### diff_content_changed() does not! */
+ label1 = diff_label(label_path1, rev1, scratch_pool);
+ label2 = diff_label(label_path2, rev2, scratch_pool);
- SVN_ERR(svn_stream_printf_from_utf8(outstream, encoding, scratch_pool,
- "Index: %s" APR_EOL_STR
- SVN_DIFF__EQUAL_STRING APR_EOL_STR,
- index_path));
+ SVN_ERR(print_diff_index_header(outstream, encoding,
+ index_path, "", scratch_pool));
if (use_git_diff_format)
SVN_ERR(print_git_diff_header(outstream, &label1, &label2,
svn_diff_op_modified,
- repos_relpath1, repos_relpath2,
- rev1, rev2, NULL,
- SVN_INVALID_REVNUM,
- left_props,
- right_props,
+ rev1, rev2,
+ diff_relpath,
+ NULL, SVN_INVALID_REVNUM,
+ left_props, right_props,
NULL,
- encoding, scratch_pool));
+ encoding, ddi, scratch_pool));
/* --- label1
* +++ label2 */
@@ -605,24 +685,6 @@ display_prop_diffs(const apr_array_heade
/*** Callbacks for 'svn diff', invoked by the repos-diff editor. ***/
-/* State provided by the diff drivers; used by the diff writer */
-typedef struct diff_driver_info_t
-{
- /* The anchor to prefix before wc paths */
- const char *anchor;
-
- /* Relative path of ra session from repos_root_url */
- const char *session_relpath;
-
- /* The original targets passed to the diff command. We may need
- these to construct distinctive diff labels when comparing the
- same relative path in the same revision, under different anchors
- (for example, when comparing a trunk against a branch). */
- const char *orig_path_1;
- const char *orig_path_2;
-} diff_driver_info_t;
-
-
/* Diff writer state */
typedef struct diff_writer_info_t
{
@@ -680,8 +742,6 @@ typedef struct diff_writer_info_t
/* Empty files for creating diffs or NULL if not used yet */
const char *empty_file;
- svn_wc_context_t *wc_ctx;
-
svn_cancel_func_t cancel_func;
void *cancel_baton;
@@ -717,9 +777,6 @@ diff_props_changed(const char *diff_relp
* dir_props_changed(). */
SVN_ERR(display_prop_diffs(props, left_props, right_props,
diff_relpath,
- dwi->ddi.anchor,
- dwi->ddi.orig_path_1,
- dwi->ddi.orig_path_2,
rev1,
rev2,
dwi->header_encoding,
@@ -728,10 +785,9 @@ diff_props_changed(const char *diff_relp
show_diff_header,
dwi->use_git_diff_format,
dwi->pretty_print_mergeinfo,
- dwi->ddi.session_relpath,
+ &dwi->ddi,
dwi->cancel_func,
dwi->cancel_baton,
- dwi->wc_ctx,
scratch_pool));
}
@@ -795,9 +851,12 @@ transform_link_to_git(const char **new_t
}
/* Show differences between TMPFILE1 and TMPFILE2. DIFF_RELPATH, REV1, and
- REV2 are used in the headers to indicate the file and revisions. If either
- MIMETYPE1 or MIMETYPE2 indicate binary content, don't show a diff,
- but instead print a warning message.
+ REV2 are used in the headers to indicate the file and revisions.
+
+ If either side has an svn:mime-type property that indicates 'binary'
+ content, then if DWI->force_binary is set, attempt to produce the
+ diff in the usual way, otherwise produce a 'GIT binary diff' in git mode
+ or print a warning message in non-git mode.
If FORCE_DIFF is TRUE, always write a diff, even for empty diffs.
@@ -822,9 +881,8 @@ diff_content_changed(svn_boolean_t *wrot
svn_stream_t *outstream = dwi->outstream;
const char *label1, *label2;
svn_boolean_t mt1_binary = FALSE, mt2_binary = FALSE;
- const char *index_path = diff_relpath;
- const char *path1 = dwi->ddi.orig_path_1;
- const char *path2 = dwi->ddi.orig_path_2;
+ const char *index_path;
+ const char *label_path1, *label_path2;
const char *mimetype1 = svn_prop_get_value(left_props, SVN_PROP_MIME_TYPE);
const char *mimetype2 = svn_prop_get_value(right_props, SVN_PROP_MIME_TYPE);
const char *index_shas = NULL;
@@ -834,12 +892,15 @@ diff_content_changed(svn_boolean_t *wrot
return SVN_NO_ERROR;
/* Generate the diff headers. */
- SVN_ERR(adjust_paths_for_diff_labels(&index_path, &path1, &path2,
+ SVN_ERR(adjust_paths_for_diff_labels(&index_path,
+ &label_path1, &label_path2,
rel_to_dir, dwi->ddi.anchor,
+ diff_relpath,
+ dwi->ddi.orig_path_1, dwi->ddi.orig_path_2,
scratch_pool, scratch_pool));
- label1 = diff_label(path1, rev1, scratch_pool);
- label2 = diff_label(path2, rev2, scratch_pool);
+ label1 = diff_label(label_path1, rev1, scratch_pool);
+ label2 = diff_label(label_path2, rev2, scratch_pool);
/* Possible easy-out: if either mime-type is binary and force was not
specified, don't attempt to generate a viewable diff at all.
@@ -879,12 +940,8 @@ diff_content_changed(svn_boolean_t *wrot
if (! dwi->force_binary && (mt1_binary || mt2_binary))
{
/* Print out the diff header. */
- SVN_ERR(svn_stream_printf_from_utf8(outstream,
- dwi->header_encoding, scratch_pool,
- "Index: %s" APR_EOL_STR
- SVN_DIFF__EQUAL_STRING APR_EOL_STR,
- index_path));
-
+ SVN_ERR(print_diff_index_header(outstream, dwi->header_encoding,
+ index_path, "", scratch_pool));
*wrote_header = TRUE;
/* ### Print git diff headers. */
@@ -893,40 +950,17 @@ diff_content_changed(svn_boolean_t *wrot
{
svn_stream_t *left_stream;
svn_stream_t *right_stream;
- const char *repos_relpath1;
- const char *repos_relpath2;
- const char *copyfrom_repos_relpath = NULL;
-
- SVN_ERR(make_repos_relpath(&repos_relpath1, diff_relpath,
- dwi->ddi.orig_path_1,
- dwi->ddi.session_relpath,
- dwi->wc_ctx,
- dwi->ddi.anchor,
- scratch_pool, scratch_pool));
- SVN_ERR(make_repos_relpath(&repos_relpath2, diff_relpath,
- dwi->ddi.orig_path_2,
- dwi->ddi.session_relpath,
- dwi->wc_ctx,
- dwi->ddi.anchor,
- scratch_pool, scratch_pool));
- if (copyfrom_path)
- SVN_ERR(make_repos_relpath(©from_repos_relpath, copyfrom_path,
- dwi->ddi.orig_path_2,
- dwi->ddi.session_relpath,
- dwi->wc_ctx,
- dwi->ddi.anchor,
- scratch_pool, scratch_pool));
- SVN_ERR(print_git_diff_header(outstream, &label1, &label2,
+
+ SVN_ERR(print_git_diff_header(outstream,
+ &label1, &label2,
operation,
- repos_relpath1, repos_relpath2,
rev1, rev2,
- copyfrom_repos_relpath,
- copyfrom_rev,
- left_props,
- right_props,
+ diff_relpath,
+ copyfrom_path, copyfrom_rev,
+ left_props, right_props,
index_shas,
dwi->header_encoding,
- scratch_pool));
+ &dwi->ddi, scratch_pool));
SVN_ERR(svn_stream_open_readonly(&left_stream, tmpfile1,
scratch_pool, scratch_pool));
@@ -983,11 +1017,9 @@ diff_content_changed(svn_boolean_t *wrot
int exitcode;
/* Print out the diff header. */
- SVN_ERR(svn_stream_printf_from_utf8(outstream,
- dwi->header_encoding, scratch_pool,
- "Index: %s" APR_EOL_STR
- SVN_DIFF__EQUAL_STRING APR_EOL_STR,
- index_path));
+ SVN_ERR(print_diff_index_header(outstream, dwi->header_encoding,
+ index_path, "", scratch_pool));
+ *wrote_header = TRUE;
/* ### Do we want to add git diff headers here too? I'd say no. The
* ### 'Index' and '===' line is something subversion has added. The rest
@@ -1040,10 +1072,6 @@ diff_content_changed(svn_boolean_t *wrot
scratch_pool),
NULL, NULL, scratch_pool));
}
-
- /* If we have printed a diff for this path, mark it as visited. */
- if (exitcode == 1)
- *wrote_header = TRUE;
}
else /* use libsvn_diff to generate the diff */
{
@@ -1058,49 +1086,22 @@ diff_content_changed(svn_boolean_t *wrot
|| svn_diff_contains_diffs(diff))
{
/* Print out the diff header. */
- SVN_ERR(svn_stream_printf_from_utf8(outstream,
- dwi->header_encoding, scratch_pool,
- "Index: %s" APR_EOL_STR
- SVN_DIFF__EQUAL_STRING APR_EOL_STR,
- index_path));
+ SVN_ERR(print_diff_index_header(outstream, dwi->header_encoding,
+ index_path, "", scratch_pool));
+ *wrote_header = TRUE;
if (dwi->use_git_diff_format)
{
- const char *repos_relpath1;
- const char *repos_relpath2;
- const char *copyfrom_repos_relpath = NULL;
-
- SVN_ERR(make_repos_relpath(&repos_relpath1, diff_relpath,
- dwi->ddi.orig_path_1,
- dwi->ddi.session_relpath,
- dwi->wc_ctx,
- dwi->ddi.anchor,
- scratch_pool, scratch_pool));
- SVN_ERR(make_repos_relpath(&repos_relpath2, diff_relpath,
- dwi->ddi.orig_path_2,
- dwi->ddi.session_relpath,
- dwi->wc_ctx,
- dwi->ddi.anchor,
- scratch_pool, scratch_pool));
- if (copyfrom_path)
- SVN_ERR(make_repos_relpath(©from_repos_relpath,
- copyfrom_path,
- dwi->ddi.orig_path_2,
- dwi->ddi.session_relpath,
- dwi->wc_ctx,
- dwi->ddi.anchor,
- scratch_pool, scratch_pool));
- SVN_ERR(print_git_diff_header(outstream, &label1, &label2,
+ SVN_ERR(print_git_diff_header(outstream,
+ &label1, &label2,
operation,
- repos_relpath1, repos_relpath2,
rev1, rev2,
- copyfrom_repos_relpath,
- copyfrom_rev,
- left_props,
- right_props,
+ diff_relpath,
+ copyfrom_path, copyfrom_rev,
+ left_props, right_props,
index_shas,
dwi->header_encoding,
- scratch_pool));
+ &dwi->ddi, scratch_pool));
}
/* Output the actual diff */
@@ -1112,10 +1113,6 @@ diff_content_changed(svn_boolean_t *wrot
dwi->options.for_internal->context_size,
dwi->cancel_func, dwi->cancel_baton,
scratch_pool));
-
- /* If we have printed a diff for this path, mark it as visited. */
- if (dwi->use_git_diff_format || svn_diff_contains_diffs(diff))
- *wrote_header = TRUE;
}
}
@@ -1190,11 +1187,9 @@ diff_file_added(const char *relpath,
index_path = svn_dirent_join(dwi->ddi.anchor, relpath,
scratch_pool);
- SVN_ERR(svn_stream_printf_from_utf8(dwi->outstream,
- dwi->header_encoding, scratch_pool,
- "Index: %s (added)" APR_EOL_STR
- SVN_DIFF__EQUAL_STRING APR_EOL_STR,
- index_path));
+ SVN_ERR(print_diff_index_header(dwi->outstream, dwi->header_encoding,
+ index_path, " (added)",
+ scratch_pool));
wrote_header = TRUE;
return SVN_NO_ERROR;
}
@@ -1280,11 +1275,9 @@ diff_file_deleted(const char *relpath,
index_path = svn_dirent_join(dwi->ddi.anchor, relpath,
scratch_pool);
- SVN_ERR(svn_stream_printf_from_utf8(dwi->outstream,
- dwi->header_encoding, scratch_pool,
- "Index: %s (deleted)" APR_EOL_STR
- SVN_DIFF__EQUAL_STRING APR_EOL_STR,
- index_path));
+ SVN_ERR(print_diff_index_header(dwi->outstream, dwi->header_encoding,
+ index_path, " (deleted)",
+ scratch_pool));
}
else
{
@@ -1547,11 +1540,22 @@ check_diff_target_exists(const char *url
/** Prepare a repos repos diff between PATH_OR_URL1 and
* PATH_OR_URL2@PEG_REVISION, in the revision range REVISION1:REVISION2.
- * Return URLs and peg revisions in *URL1, *REV1 and in *URL2, *REV2.
- * Return suitable anchors in *ANCHOR1 and *ANCHOR2, and targets in
- * *TARGET1 and *TARGET2, based on *URL1 and *URL2.
- * Indicate the corresponding node kinds in *KIND1 and *KIND2, and verify
+ *
+ * Return the resolved URL and peg revision pairs in *URL1, *REV1 and in
+ * *URL2, *REV2.
+ *
+ * Return suitable anchor URL and target pairs in *ANCHOR1, *TARGET1 and
+ * in *ANCHOR2, *TARGET2, corresponding to *URL1 and *URL2.
+ *
+ * (The choice of anchor URLs here appears to be: start with *URL1, *URL2;
+ * then take the parent dir on both sides, unless either of *URL1 or *URL2
+ * is the repository root or the parent dir of *URL1 is unreadable.)
+ *
+ * Set *KIND1 and *KIND2 to the node kinds of *URL1 and *URL2, and verify
* that at least one of the diff targets exists.
+ *
+ * Set *RA_SESSION to an RA session parented at the URL *ANCHOR1.
+ *
* Use client context CTX. Do all allocations in POOL. */
static svn_error_t *
diff_prepare_repos_repos(const char **url1,
@@ -1823,12 +1827,14 @@ unsupported_diff_error(svn_error_t *chil
PATH1 and PATH2 are both working copy paths. REVISION1 and
REVISION2 are their respective revisions.
+ For now, require PATH1=PATH2, REVISION1='base', REVISION2='working',
+ otherwise return an error.
+
+ Anchor DIFF_PROCESSOR at the requested diff targets.
+
All other options are the same as those passed to svn_client_diff7(). */
static svn_error_t *
-diff_wc_wc(const char **root_relpath,
- svn_boolean_t *root_is_dir,
- struct diff_driver_info_t *ddi,
- const char *path1,
+diff_wc_wc(const char *path1,
const svn_opt_revision_t *revision1,
const char *path2,
const svn_opt_revision_t *revision2,
@@ -1859,20 +1865,7 @@ diff_wc_wc(const char **root_relpath,
"or between the working versions of two paths"
)));
- if (ddi)
- {
- svn_node_kind_t kind;
-
- SVN_ERR(svn_wc_read_kind2(&kind, ctx->wc_ctx, abspath1,
- TRUE, FALSE, scratch_pool));
-
- if (kind != svn_node_dir)
- ddi->anchor = svn_dirent_dirname(path1, scratch_pool);
- else
- ddi->anchor = path1;
- }
-
- SVN_ERR(svn_wc__diff7(root_relpath, root_is_dir,
+ SVN_ERR(svn_wc__diff7(TRUE,
ctx->wc_ctx, abspath1, depth,
ignore_ancestry, changelists,
diff_processor,
@@ -1889,11 +1882,31 @@ diff_wc_wc(const char **root_relpath,
and the actual two paths compared are determined by following copy
history from PATH_OR_URL2.
+ If DDI is null, anchor the DIFF_PROCESSOR at the requested diff
+ targets. (This case is used by diff-summarize.)
+
+ If DDI is non-null: Set DDI->orig_path_* to the two diff target URLs as
+ resolved at the given revisions; set DDI->anchor to an anchor WC path
+ if either of PATH_OR_URL* is given as a WC path, else to null; set
+ DDI->session_relpath to the repository-relpath of the anchor URL for
+ DDI->orig_path_1. Anchor the DIFF_PROCESSOR at the anchor chosen
+ for the underlying diff implementation if the target on either side
+ is a file, else at the actual requested targets.
+
+ (The choice of WC anchor implementated here for DDI->anchor appears to
+ be: choose PATH_OR_URL2 (if it's a WC path) or else PATH_OR_URL1 (if
+ it's a WC path); then take its parent dir unless both resolved URLs
+ refer to directories.)
+
+ (For the choice of URL anchor for DDI->session_relpath, see
+ diff_prepare_repos_repos().)
+
+ ### Bizarre anchoring. TODO: always anchor DIFF_PROCESSOR at the
+ requested targets.
+
All other options are the same as those passed to svn_client_diff7(). */
static svn_error_t *
-diff_repos_repos(const char **root_relpath,
- svn_boolean_t *root_is_dir,
- struct diff_driver_info_t *ddi,
+diff_repos_repos(struct diff_driver_info_t *ddi,
const char *path_or_url1,
const char *path_or_url2,
const svn_opt_revision_t *revision1,
@@ -1985,14 +1998,16 @@ diff_repos_repos(const char **root_relpa
target1 = str_tmp;
diff_processor = svn_diff__tree_processor_reverse_create(diff_processor,
- NULL,
scratch_pool);
}
/* Filter the first path component using a filter processor, until we fixed
the diff processing to handle this directly */
- if (root_relpath)
- *root_relpath = apr_pstrdup(result_pool, target1);
+ if (!ddi)
+ {
+ diff_processor = svn_diff__tree_processor_filter_create(
+ diff_processor, target1, scratch_pool);
+ }
else if ((kind1 != svn_node_file && kind2 != svn_node_file)
&& target1[0] != '\0')
{
@@ -2059,11 +2074,17 @@ diff_repos_repos(const char **root_relpa
If REVERSE is TRUE, the diff will be reported in reverse.
+ If DDI is null, anchor the DIFF_PROCESSOR at the requested diff
+ targets. (This case is used by diff-summarize.)
+
+ If DDI is non-null: Set DDI->orig_path_* to the URLs of the two diff
+ targets as resolved at the given revisions; set DDI->anchor to a WC path
+ anchor for PATH2; set DDI->session_relpath to the repository-relpath of
+ the URL of that same anchor WC path.
+
All other options are the same as those passed to svn_client_diff7(). */
static svn_error_t *
-diff_repos_wc(const char **root_relpath,
- svn_boolean_t *root_is_dir,
- struct diff_driver_info_t *ddi,
+diff_repos_wc(struct diff_driver_info_t *ddi,
const char *path_or_url1,
const svn_opt_revision_t *revision1,
const svn_opt_revision_t *peg_revision1,
@@ -2141,11 +2162,6 @@ diff_repos_wc(const char **root_relpath,
target = "";
}
- if (root_relpath)
- *root_relpath = apr_pstrdup(result_pool, target);
- if (root_is_dir)
- *root_is_dir = (*target == '\0');
-
/* Fetch the URL of the anchor directory. */
SVN_ERR(svn_dirent_get_absolute(&anchor_abspath, anchor, scratch_pool));
SVN_ERR(svn_wc__node_get_url(&anchor_url, ctx->wc_ctx, anchor_abspath,
@@ -2154,7 +2170,7 @@ diff_repos_wc(const char **root_relpath,
target_url = NULL;
}
- else /* is_copy && revision2->kind == svn_opt_revision_base */
+ else /* is_copy && revision2->kind != svn_opt_revision_base */
{
#if 0
svn_node_kind_t kind;
@@ -2243,10 +2259,14 @@ diff_repos_wc(const char **root_relpath,
anchor_url,
result_pool);
}
+ else
+ {
+ diff_processor = svn_diff__tree_processor_filter_create(
+ diff_processor, target, scratch_pool);
+ }
if (reverse)
- diff_processor = svn_diff__tree_processor_reverse_create(
- diff_processor, NULL, scratch_pool);
+ diff_processor = svn_diff__tree_processor_reverse_create(diff_processor, scratch_pool);
/* Use the diff editor to generate the diff. */
SVN_ERR(svn_ra_has_capability(ra_session, &server_supports_depth,
@@ -2322,12 +2342,84 @@ diff_repos_wc(const char **root_relpath,
return SVN_NO_ERROR;
}
+/* Run diff on shelf SHELF_NAME, if it exists.
+ */
+static svn_error_t *
+diff_shelf(const char *shelf_name,
+ const char *target_abspath,
+ svn_depth_t depth,
+ svn_boolean_t ignore_ancestry,
+ const svn_diff_tree_processor_t *diff_processor,
+ svn_client_ctx_t *ctx,
+ apr_pool_t *scratch_pool)
+{
+ svn_error_t *err;
+ svn_client__shelf_t *shelf;
+ svn_client__shelf_version_t *shelf_version;
+ const char *wc_relpath;
+
+ err = svn_client__shelf_open_existing(&shelf,
+ shelf_name, target_abspath,
+ ctx, scratch_pool);
+ if (err && err->apr_err == SVN_ERR_ILLEGAL_TARGET)
+ {
+ svn_error_clear(err);
+ return SVN_NO_ERROR;
+ }
+ else
+ SVN_ERR(err);
+
+ SVN_ERR(svn_client__shelf_version_open(&shelf_version,
+ shelf, shelf->max_version,
+ scratch_pool, scratch_pool));
+ wc_relpath = svn_dirent_skip_ancestor(shelf->wc_root_abspath, target_abspath);
+ SVN_ERR(svn_client__shelf_diff(shelf_version, wc_relpath,
+ depth, ignore_ancestry,
+ diff_processor, scratch_pool));
+ SVN_ERR(svn_client__shelf_close(shelf, scratch_pool));
+
+ return SVN_NO_ERROR;
+}
+
+/* Run diff on all shelves named in CHANGELISTS by a changelist name
+ * of the form "svn:shelf:SHELF_NAME", if they exist.
+ */
+static svn_error_t *
+diff_shelves(const apr_array_header_t *changelists,
+ const char *target_abspath,
+ svn_depth_t depth,
+ svn_boolean_t ignore_ancestry,
+ const svn_diff_tree_processor_t *diff_processor,
+ svn_client_ctx_t *ctx,
+ apr_pool_t *scratch_pool)
+{
+ static const char PREFIX[] = "svn:shelf:";
+ static const int PREFIX_LEN = 10;
+ int i;
+
+ if (! changelists)
+ return SVN_NO_ERROR;
+ for (i = 0; i < changelists->nelts; i++)
+ {
+ const char *cl = APR_ARRAY_IDX(changelists, i, const char *);
+
+ if (strncmp(cl, PREFIX, PREFIX_LEN) == 0)
+ {
+ const char *shelf_name = cl + PREFIX_LEN;
+
+ SVN_ERR(diff_shelf(shelf_name, target_abspath,
+ depth, ignore_ancestry,
+ diff_processor, ctx, scratch_pool));
+ }
+ }
+
+ return SVN_NO_ERROR;
+}
+
/* This is basically just the guts of svn_client_diff[_summarize][_peg]6(). */
static svn_error_t *
-do_diff(const char **root_relpath,
- svn_boolean_t *root_is_dir,
- diff_driver_info_t *ddi,
+do_diff(diff_driver_info_t *ddi,
const char *path_or_url1,
const char *path_or_url2,
const svn_opt_revision_t *revision1,
@@ -2355,8 +2447,7 @@ do_diff(const char **root_relpath,
if (is_repos2)
{
/* Ignores changelists. */
- SVN_ERR(diff_repos_repos(root_relpath, root_is_dir,
- ddi,
+ SVN_ERR(diff_repos_repos(ddi,
path_or_url1, path_or_url2,
revision1, revision2,
peg_revision, depth, ignore_ancestry,
@@ -2366,7 +2457,7 @@ do_diff(const char **root_relpath,
}
else /* path_or_url2 is a working copy path */
{
- SVN_ERR(diff_repos_wc(root_relpath, root_is_dir, ddi,
+ SVN_ERR(diff_repos_wc(ddi,
path_or_url1, revision1,
no_peg_revision ? revision1
: peg_revision,
@@ -2381,7 +2472,7 @@ do_diff(const char **root_relpath,
{
if (is_repos2)
{
- SVN_ERR(diff_repos_wc(root_relpath, root_is_dir, ddi,
+ SVN_ERR(diff_repos_wc(ddi,
path_or_url2, revision2,
no_peg_revision ? revision2
: peg_revision,
@@ -2405,19 +2496,51 @@ do_diff(const char **root_relpath,
SVN_ERR(svn_dirent_get_absolute(&abspath2, path_or_url2,
scratch_pool));
- /* ### What about ddi? */
+ if (ddi)
+ {
+ svn_node_kind_t kind1, kind2;
+
+ SVN_ERR(svn_io_check_resolved_path(abspath1, &kind1,
+ scratch_pool));
+ SVN_ERR(svn_io_check_resolved_path(abspath2, &kind2,
+ scratch_pool));
+ if (kind1 == svn_node_dir && kind2 == svn_node_dir)
+ {
+ ddi->anchor = "";
+ }
+ else
+ {
+ ddi->anchor = svn_dirent_basename(abspath1, NULL);
+ }
+ ddi->orig_path_1 = path_or_url1;
+ ddi->orig_path_2 = path_or_url2;
+ }
+
/* Ignores changelists, ignore_ancestry */
- SVN_ERR(svn_client__arbitrary_nodes_diff(root_relpath, root_is_dir,
- abspath1, abspath2,
+ SVN_ERR(svn_client__arbitrary_nodes_diff(abspath1, abspath2,
depth,
diff_processor,
- ctx,
- result_pool, scratch_pool));
+ ctx, scratch_pool));
}
else
{
- SVN_ERR(diff_wc_wc(root_relpath, root_is_dir, ddi,
- path_or_url1, revision1,
+ if (ddi)
+ {
+ ddi->anchor = path_or_url1;
+ ddi->orig_path_1 = path_or_url1;
+ ddi->orig_path_2 = path_or_url2;
+ }
+
+ {
+ const char *abspath1;
+
+ SVN_ERR(svn_dirent_get_absolute(&abspath1, path_or_url1,
+ scratch_pool));
+ SVN_ERR(diff_shelves(changelists, abspath1,
+ depth, ignore_ancestry,
+ diff_processor, ctx, scratch_pool));
+ }
+ SVN_ERR(diff_wc_wc(path_or_url1, revision1,
path_or_url2, revision2,
depth, ignore_ancestry, changelists,
diff_processor, ctx,
@@ -2493,6 +2616,115 @@ create_diff_writer_info(diff_writer_info
return SVN_NO_ERROR;
}
+/* Set up *DIFF_PROCESSOR and *DDI for normal and git-style diffs (but not
+ * summary diffs).
+ */
+static svn_error_t *
+get_diff_processor(svn_diff_tree_processor_t **diff_processor,
+ struct diff_driver_info_t **ddi,
+ const apr_array_header_t *options,
+ const char *relative_to_dir,
+ svn_boolean_t no_diff_added,
+ svn_boolean_t no_diff_deleted,
+ svn_boolean_t show_copies_as_adds,
+ svn_boolean_t ignore_content_type,
+ svn_boolean_t ignore_properties,
+ svn_boolean_t properties_only,
+ svn_boolean_t use_git_diff_format,
+ svn_boolean_t pretty_print_mergeinfo,
+ const char *header_encoding,
+ svn_stream_t *outstream,
+ svn_stream_t *errstream,
+ svn_client_ctx_t *ctx,
+ apr_pool_t *pool)
+{
+ diff_writer_info_t *dwi = apr_pcalloc(pool, sizeof(*dwi));
+ svn_diff_tree_processor_t *processor;
+
+ /* setup callback and baton */
+
+ SVN_ERR(create_diff_writer_info(dwi, options,
+ ctx->config, pool));
+ dwi->pool = pool;
+ dwi->outstream = outstream;
+ dwi->errstream = errstream;
+ dwi->header_encoding = header_encoding;
+
+ dwi->force_binary = ignore_content_type;
+ dwi->ignore_properties = ignore_properties;
+ dwi->properties_only = properties_only;
+ dwi->relative_to_dir = relative_to_dir;
+ dwi->use_git_diff_format = use_git_diff_format;
+ dwi->no_diff_added = no_diff_added;
+ dwi->no_diff_deleted = no_diff_deleted;
+ dwi->show_copies_as_adds = show_copies_as_adds;
+ dwi->pretty_print_mergeinfo = pretty_print_mergeinfo;
+
+ dwi->cancel_func = ctx->cancel_func;
+ dwi->cancel_baton = ctx->cancel_baton;
+
+ dwi->ddi.wc_ctx = ctx->wc_ctx;
+ dwi->ddi.session_relpath = NULL;
+ dwi->ddi.anchor = NULL;
+
+ processor = svn_diff__tree_processor_create(dwi, pool);
+
+ processor->dir_added = diff_dir_added;
+ processor->dir_changed = diff_dir_changed;
+ processor->dir_deleted = diff_dir_deleted;
+
+ processor->file_added = diff_file_added;
+ processor->file_changed = diff_file_changed;
+ processor->file_deleted = diff_file_deleted;
+
+ *diff_processor = processor;
+ *ddi = &dwi->ddi;
+ return SVN_NO_ERROR;
+}
+
+svn_error_t *
+svn_client__get_diff_writer_svn(
+ svn_diff_tree_processor_t **diff_processor,
+ const char *anchor,
+ const char *orig_path_1,
+ const char *orig_path_2,
+ const apr_array_header_t *options,
+ const char *relative_to_dir,
+ svn_boolean_t no_diff_added,
+ svn_boolean_t no_diff_deleted,
+ svn_boolean_t show_copies_as_adds,
+ svn_boolean_t ignore_content_type,
+ svn_boolean_t ignore_properties,
+ svn_boolean_t properties_only,
+ svn_boolean_t pretty_print_mergeinfo,
+ const char *header_encoding,
+ svn_stream_t *outstream,
+ svn_stream_t *errstream,
+ svn_client_ctx_t *ctx,
+ apr_pool_t *pool)
+{
+ struct diff_driver_info_t *ddi;
+
+ SVN_ERR(get_diff_processor(diff_processor, &ddi,
+ options,
+ relative_to_dir,
+ no_diff_added,
+ no_diff_deleted,
+ show_copies_as_adds,
+ ignore_content_type,
+ ignore_properties,
+ properties_only,
+ FALSE /*use_git_diff_format*/,
+ pretty_print_mergeinfo,
+ header_encoding,
+ outstream, errstream,
+ ctx, pool));
+ ddi->anchor = anchor;
+ ddi->orig_path_1 = orig_path_1;
+ ddi->orig_path_2 = orig_path_2;
+ return SVN_NO_ERROR;
+}
+
/*----------------------------------------------------------------------- */
/*** Public Interfaces. ***/
@@ -2553,10 +2785,9 @@ svn_client_diff7(const apr_array_header_
svn_client_ctx_t *ctx,
apr_pool_t *pool)
{
- diff_writer_info_t dwi = { 0 };
svn_opt_revision_t peg_revision;
- const svn_diff_tree_processor_t *diff_processor;
- svn_diff_tree_processor_t *processor;
+ svn_diff_tree_processor_t *diff_processor;
+ struct diff_driver_info_t *ddi;
if (ignore_properties && properties_only)
return svn_error_create(SVN_ERR_INCORRECT_PARAMS, NULL,
@@ -2566,51 +2797,26 @@ svn_client_diff7(const apr_array_header_
/* We will never do a pegged diff from here. */
peg_revision.kind = svn_opt_revision_unspecified;
- /* setup callback and baton */
- dwi.ddi.orig_path_1 = path_or_url1;
- dwi.ddi.orig_path_2 = path_or_url2;
-
- SVN_ERR(create_diff_writer_info(&dwi, options,
- ctx->config, pool));
- dwi.pool = pool;
- dwi.outstream = outstream;
- dwi.errstream = errstream;
- dwi.header_encoding = header_encoding;
-
- dwi.force_binary = ignore_content_type;
- dwi.ignore_properties = ignore_properties;
- dwi.properties_only = properties_only;
- dwi.relative_to_dir = relative_to_dir;
- dwi.use_git_diff_format = use_git_diff_format;
- dwi.no_diff_added = no_diff_added;
- dwi.no_diff_deleted = no_diff_deleted;
- dwi.show_copies_as_adds = show_copies_as_adds;
- dwi.pretty_print_mergeinfo = pretty_print_mergeinfo;
-
- dwi.cancel_func = ctx->cancel_func;
- dwi.cancel_baton = ctx->cancel_baton;
-
- dwi.wc_ctx = ctx->wc_ctx;
- dwi.ddi.session_relpath = NULL;
- dwi.ddi.anchor = NULL;
-
- processor = svn_diff__tree_processor_create(&dwi, pool);
-
- processor->dir_added = diff_dir_added;
- processor->dir_changed = diff_dir_changed;
- processor->dir_deleted = diff_dir_deleted;
-
- processor->file_added = diff_file_added;
- processor->file_changed = diff_file_changed;
- processor->file_deleted = diff_file_deleted;
-
- diff_processor = processor;
-
/* --show-copies-as-adds and --git imply --notice-ancestry */
if (show_copies_as_adds || use_git_diff_format)
ignore_ancestry = FALSE;
- return svn_error_trace(do_diff(NULL, NULL, &dwi.ddi,
+ SVN_ERR(get_diff_processor(&diff_processor, &ddi,
+ options,
+ relative_to_dir,
+ no_diff_added,
+ no_diff_deleted,
+ show_copies_as_adds,
+ ignore_content_type,
+ ignore_properties,
+ properties_only,
+ use_git_diff_format,
+ pretty_print_mergeinfo,
+ header_encoding,
+ outstream, errstream,
+ ctx, pool));
+
+ return svn_error_trace(do_diff(ddi,
path_or_url1, path_or_url2,
revision1, revision2,
&peg_revision, TRUE /* no_peg_revision */,
@@ -2643,60 +2849,34 @@ svn_client_diff_peg7(const apr_array_hea
svn_client_ctx_t *ctx,
apr_pool_t *pool)
{
- diff_writer_info_t dwi = { 0 };
- const svn_diff_tree_processor_t *diff_processor;
- svn_diff_tree_processor_t *processor;
+ svn_diff_tree_processor_t *diff_processor;
+ struct diff_driver_info_t *ddi;
if (ignore_properties && properties_only)
return svn_error_create(SVN_ERR_INCORRECT_PARAMS, NULL,
_("Cannot ignore properties and show only "
"properties at the same time"));
- /* setup callback and baton */
- dwi.ddi.orig_path_1 = path_or_url;
- dwi.ddi.orig_path_2 = path_or_url;
-
- SVN_ERR(create_diff_writer_info(&dwi, options,
- ctx->config, pool));
- dwi.pool = pool;
- dwi.outstream = outstream;
- dwi.errstream = errstream;
- dwi.header_encoding = header_encoding;
-
- dwi.force_binary = ignore_content_type;
- dwi.ignore_properties = ignore_properties;
- dwi.properties_only = properties_only;
- dwi.relative_to_dir = relative_to_dir;
- dwi.use_git_diff_format = use_git_diff_format;
- dwi.no_diff_added = no_diff_added;
- dwi.no_diff_deleted = no_diff_deleted;
- dwi.show_copies_as_adds = show_copies_as_adds;
- dwi.pretty_print_mergeinfo = pretty_print_mergeinfo;
-
- dwi.cancel_func = ctx->cancel_func;
- dwi.cancel_baton = ctx->cancel_baton;
-
- dwi.wc_ctx = ctx->wc_ctx;
- dwi.ddi.session_relpath = NULL;
- dwi.ddi.anchor = NULL;
-
- processor = svn_diff__tree_processor_create(&dwi, pool);
-
- processor->dir_added = diff_dir_added;
- processor->dir_changed = diff_dir_changed;
- processor->dir_deleted = diff_dir_deleted;
-
- processor->file_added = diff_file_added;
- processor->file_changed = diff_file_changed;
- processor->file_deleted = diff_file_deleted;
-
- diff_processor = processor;
-
/* --show-copies-as-adds and --git imply --notice-ancestry */
if (show_copies_as_adds || use_git_diff_format)
ignore_ancestry = FALSE;
- return svn_error_trace(do_diff(NULL, NULL, &dwi.ddi,
+ SVN_ERR(get_diff_processor(&diff_processor, &ddi,
+ options,
+ relative_to_dir,
+ no_diff_added,
+ no_diff_deleted,
+ show_copies_as_adds,
+ ignore_content_type,
+ ignore_properties,
+ properties_only,
+ use_git_diff_format,
+ pretty_print_mergeinfo,
+ header_encoding,
+ outstream, errstream,
+ ctx, pool));
+
+ return svn_error_trace(do_diff(ddi,
path_or_url, path_or_url,
start_revision, end_revision,
peg_revision, FALSE /* no_peg_revision */,
@@ -2718,19 +2898,17 @@ svn_client_diff_summarize2(const char *p
svn_client_ctx_t *ctx,
apr_pool_t *pool)
{
- const svn_diff_tree_processor_t *diff_processor;
+ svn_diff_tree_processor_t *diff_processor;
svn_opt_revision_t peg_revision;
- const char **p_root_relpath;
/* We will never do a pegged diff from here. */
peg_revision.kind = svn_opt_revision_unspecified;
- SVN_ERR(svn_client__get_diff_summarize_callbacks(
- &diff_processor, &p_root_relpath,
+ SVN_ERR(svn_client__get_diff_summarize_callbacks(&diff_processor,
summarize_func, summarize_baton,
- path_or_url1, pool, pool));
+ pool, pool));
- return svn_error_trace(do_diff(p_root_relpath, NULL, NULL,
+ return svn_error_trace(do_diff(NULL,
path_or_url1, path_or_url2,
revision1, revision2,
&peg_revision, TRUE /* no_peg_revision */,
@@ -2752,15 +2930,13 @@ svn_client_diff_summarize_peg2(const cha
svn_client_ctx_t *ctx,
apr_pool_t *pool)
{
- const svn_diff_tree_processor_t *diff_processor;
- const char **p_root_relpath;
+ svn_diff_tree_processor_t *diff_processor;
- SVN_ERR(svn_client__get_diff_summarize_callbacks(
- &diff_processor, &p_root_relpath,
+ SVN_ERR(svn_client__get_diff_summarize_callbacks(&diff_processor,
summarize_func, summarize_baton,
- path_or_url, pool, pool));
+ pool, pool));
- return svn_error_trace(do_diff(p_root_relpath, NULL, NULL,
+ return svn_error_trace(do_diff(NULL,
path_or_url, path_or_url,
start_revision, end_revision,
peg_revision, FALSE /* no_peg_revision */,
Propchange: subversion/branches/swig-py3/subversion/libsvn_client/diff.c
------------------------------------------------------------------------------
p = v
Modified: subversion/branches/swig-py3/subversion/libsvn_client/diff_local.c
URL: http://svn.apache.org/viewvc/subversion/branches/swig-py3/subversion/libsvn_client/diff_local.c?rev=1847678&r1=1847677&r2=1847678&view=diff
==============================================================================
--- subversion/branches/swig-py3/subversion/libsvn_client/diff_local.c (original)
+++ subversion/branches/swig-py3/subversion/libsvn_client/diff_local.c Wed Nov 28 21:25:32 2018
@@ -647,20 +647,17 @@ do_dir_diff(const char *left_abspath,
}
svn_error_t *
-svn_client__arbitrary_nodes_diff(const char **root_relpath,
- svn_boolean_t *root_is_dir,
- const char *left_abspath,
+svn_client__arbitrary_nodes_diff(const char *left_abspath,
const char *right_abspath,
svn_depth_t depth,
const svn_diff_tree_processor_t *diff_processor,
svn_client_ctx_t *ctx,
- apr_pool_t *result_pool,
apr_pool_t *scratch_pool)
{
svn_node_kind_t left_kind;
svn_node_kind_t right_kind;
- const char *left_root_abspath;
- const char *right_root_abspath;
+ const char *left_root_abspath = left_abspath;
+ const char *right_root_abspath = right_abspath;
svn_boolean_t left_before_right = TRUE; /* Future argument? */
if (depth == svn_depth_unknown)
@@ -671,28 +668,6 @@ svn_client__arbitrary_nodes_diff(const c
if (left_kind == svn_node_dir && right_kind == svn_node_dir)
{
- left_root_abspath = left_abspath;
- right_root_abspath = right_abspath;
-
- if (root_relpath)
- *root_relpath = "";
- if (root_is_dir)
- *root_is_dir = TRUE;
- }
- else
- {
- svn_dirent_split(&left_root_abspath, root_relpath, left_abspath,
- scratch_pool);
- right_root_abspath = svn_dirent_dirname(right_abspath, scratch_pool);
-
- if (root_relpath)
- *root_relpath = apr_pstrdup(result_pool, *root_relpath);
- if (root_is_dir)
- *root_is_dir = FALSE;
- }
-
- if (left_kind == svn_node_dir && right_kind == svn_node_dir)
- {
SVN_ERR(do_dir_diff(left_abspath, right_abspath,
left_root_abspath, right_root_abspath,
FALSE, FALSE, left_before_right,
@@ -710,79 +685,48 @@ svn_client__arbitrary_nodes_diff(const c
else if (left_kind == svn_node_file || left_kind == svn_node_dir
|| right_kind == svn_node_file || right_kind == svn_node_dir)
{
- void *dir_baton;
- svn_boolean_t skip = FALSE;
- svn_boolean_t skip_children = FALSE;
- svn_diff_source_t *left_src;
- svn_diff_source_t *right_src;
-
- left_src = svn_diff__source_create(SVN_INVALID_REVNUM, scratch_pool);
- right_src = svn_diff__source_create(SVN_INVALID_REVNUM, scratch_pool);
-
- /* The root is replaced... */
- /* Report delete and/or add */
-
- SVN_ERR(diff_processor->dir_opened(&dir_baton, &skip, &skip_children, "",
- left_src,
- right_src,
- NULL /* copyfrom_src */,
- NULL,
- diff_processor,
- scratch_pool, scratch_pool));
-
- if (skip)
- return SVN_NO_ERROR;
- else if (!skip_children)
+ /* The root is added/deleted/replaced. Report delete and/or add. */
+ if (left_before_right)
{
- if (left_before_right)
- {
- if (left_kind == svn_node_file)
- SVN_ERR(do_file_diff(left_abspath, right_abspath,
- left_root_abspath, right_root_abspath,
- TRUE, FALSE, NULL /* parent_baton */,
- diff_processor, ctx, scratch_pool));
- else if (left_kind == svn_node_dir)
- SVN_ERR(do_dir_diff(left_abspath, right_abspath,
- left_root_abspath, right_root_abspath,
- TRUE, FALSE, left_before_right,
- depth, NULL /* parent_baton */,
- diff_processor, ctx, scratch_pool));
- }
-
- if (right_kind == svn_node_file)
+ if (left_kind == svn_node_file)
SVN_ERR(do_file_diff(left_abspath, right_abspath,
left_root_abspath, right_root_abspath,
- FALSE, TRUE, NULL /* parent_baton */,
+ TRUE, FALSE, NULL /* parent_baton */,
diff_processor, ctx, scratch_pool));
- else if (right_kind == svn_node_dir)
+ else if (left_kind == svn_node_dir)
SVN_ERR(do_dir_diff(left_abspath, right_abspath,
left_root_abspath, right_root_abspath,
- FALSE, TRUE, left_before_right,
+ TRUE, FALSE, left_before_right,
depth, NULL /* parent_baton */,
diff_processor, ctx, scratch_pool));
-
- if (! left_before_right)
- {
- if (left_kind == svn_node_file)
- SVN_ERR(do_file_diff(left_abspath, right_abspath,
- left_root_abspath, right_root_abspath,
- TRUE, FALSE, NULL /* parent_baton */,
- diff_processor, ctx, scratch_pool));
- else if (left_kind == svn_node_dir)
- SVN_ERR(do_dir_diff(left_abspath, right_abspath,
- left_root_abspath, right_root_abspath,
- TRUE, FALSE, left_before_right,
- depth, NULL /* parent_baton */,
- diff_processor, ctx, scratch_pool));
- }
}
- SVN_ERR(diff_processor->dir_closed("",
- left_src,
- right_src,
- dir_baton,
- diff_processor,
- scratch_pool));
+ if (right_kind == svn_node_file)
+ SVN_ERR(do_file_diff(left_abspath, right_abspath,
+ left_root_abspath, right_root_abspath,
+ FALSE, TRUE, NULL /* parent_baton */,
+ diff_processor, ctx, scratch_pool));
+ else if (right_kind == svn_node_dir)
+ SVN_ERR(do_dir_diff(left_abspath, right_abspath,
+ left_root_abspath, right_root_abspath,
+ FALSE, TRUE, left_before_right,
+ depth, NULL /* parent_baton */,
+ diff_processor, ctx, scratch_pool));
+
+ if (! left_before_right)
+ {
+ if (left_kind == svn_node_file)
+ SVN_ERR(do_file_diff(left_abspath, right_abspath,
+ left_root_abspath, right_root_abspath,
+ TRUE, FALSE, NULL /* parent_baton */,
+ diff_processor, ctx, scratch_pool));
+ else if (left_kind == svn_node_dir)
+ SVN_ERR(do_dir_diff(left_abspath, right_abspath,
+ left_root_abspath, right_root_abspath,
+ TRUE, FALSE, left_before_right,
+ depth, NULL /* parent_baton */,
+ diff_processor, ctx, scratch_pool));
+ }
}
else
return svn_error_createf(SVN_ERR_NODE_UNEXPECTED_KIND, NULL,
Modified: subversion/branches/swig-py3/subversion/libsvn_client/diff_summarize.c
URL: http://svn.apache.org/viewvc/subversion/branches/swig-py3/subversion/libsvn_client/diff_summarize.c?rev=1847678&r1=1847677&r2=1847678&view=diff
==============================================================================
--- subversion/branches/swig-py3/subversion/libsvn_client/diff_summarize.c (original)
+++ subversion/branches/swig-py3/subversion/libsvn_client/diff_summarize.c Wed Nov 28 21:25:32 2018
@@ -36,11 +36,6 @@
/* Diff callbacks baton. */
struct summarize_baton_t {
- apr_pool_t *baton_pool; /* For allocating skip_path */
-
- /* The target path of the diff, relative to the anchor; "" if target == anchor. */
- const char *skip_relpath;
-
/* The summarize callback passed down from the API */
svn_client_diff_summarize_func_t summarize_func;
@@ -49,9 +44,8 @@ struct summarize_baton_t {
};
/* Call B->summarize_func with B->summarize_func_baton, passing it a
- * summary object composed from PATH (but made to be relative to the target
- * of the diff), SUMMARIZE_KIND, PROP_CHANGED (or FALSE if the action is an
- * add or delete) and NODE_KIND. */
+ * summary object composed from PATH, SUMMARIZE_KIND, PROP_CHANGED (or
+ * FALSE if the action is an add or delete) and NODE_KIND. */
static svn_error_t *
send_summary(struct summarize_baton_t *b,
const char *path,
@@ -65,9 +59,7 @@ send_summary(struct summarize_baton_t *b
SVN_ERR_ASSERT(summarize_kind != svn_client_diff_summarize_kind_normal
|| prop_changed);
- /* PATH is relative to the anchor of the diff, but SUM->path needs to be
- relative to the target of the diff. */
- sum->path = svn_relpath_skip_ancestor(b->skip_relpath, path);
+ sum->path = path;
sum->summarize_kind = summarize_kind;
if (summarize_kind == svn_client_diff_summarize_kind_modified
|| summarize_kind == svn_client_diff_summarize_kind_normal)
@@ -265,18 +257,15 @@ diff_file_deleted(const char *relpath,
svn_error_t *
svn_client__get_diff_summarize_callbacks(
- const svn_diff_tree_processor_t **diff_processor,
- const char ***p_root_relpath,
+ svn_diff_tree_processor_t **diff_processor,
svn_client_diff_summarize_func_t summarize_func,
void *summarize_baton,
- const char *original_target,
apr_pool_t *result_pool,
apr_pool_t *scratch_pool)
{
svn_diff_tree_processor_t *dp;
struct summarize_baton_t *b = apr_pcalloc(result_pool, sizeof(*b));
- b->baton_pool = result_pool;
b->summarize_func = summarize_func;
b->summarize_func_baton = summarize_baton;
@@ -293,7 +282,6 @@ svn_client__get_diff_summarize_callbacks
dp->dir_added = diff_dir_added;
*diff_processor = dp;
- *p_root_relpath = &b->skip_relpath;
return SVN_NO_ERROR;
}
Modified: subversion/branches/swig-py3/subversion/libsvn_client/export.c
URL: http://svn.apache.org/viewvc/subversion/branches/swig-py3/subversion/libsvn_client/export.c?rev=1847678&r1=1847677&r2=1847678&view=diff
==============================================================================
--- subversion/branches/swig-py3/subversion/libsvn_client/export.c (original)
+++ subversion/branches/swig-py3/subversion/libsvn_client/export.c Wed Nov 28 21:25:32 2018
@@ -453,12 +453,12 @@ export_node(void *baton,
* If PATH exists but is a file, then error with SVN_ERR_WC_NOT_WORKING_COPY.
*
* If PATH is a already a directory, then error with
- * SVN_ERR_WC_OBSTRUCTED_UPDATE, unless FORCE, in which case just
+ * SVN_ERR_WC_OBSTRUCTED_UPDATE, unless OVERWRITE, in which case just
* export into PATH with no error.
*/
static svn_error_t *
open_root_internal(const char *path,
- svn_boolean_t force,
+ svn_boolean_t overwrite,
svn_wc_notify_func2_t notify_func,
void *notify_baton,
apr_pool_t *pool)
@@ -472,7 +472,7 @@ open_root_internal(const char *path,
return svn_error_createf(SVN_ERR_WC_NOT_WORKING_COPY, NULL,
_("'%s' exists and is not a directory"),
svn_dirent_local_style(path, pool));
- else if ((kind != svn_node_dir) || (! force))
+ else if ((kind != svn_node_dir) || (! overwrite))
return svn_error_createf(SVN_ERR_WC_OBSTRUCTED_UPDATE, NULL,
_("'%s' already exists"),
svn_dirent_local_style(path, pool));
@@ -501,7 +501,7 @@ struct edit_baton
const char *repos_root_url;
const char *root_path;
const char *root_url;
- svn_boolean_t force;
+ svn_boolean_t overwrite;
svn_revnum_t *target_revision;
apr_hash_t *externals;
const char *native_eol;
@@ -587,7 +587,7 @@ open_root(void *edit_baton,
struct edit_baton *eb = edit_baton;
struct dir_baton *db = apr_pcalloc(pool, sizeof(*db));
- SVN_ERR(open_root_internal(eb->root_path, eb->force,
+ SVN_ERR(open_root_internal(eb->root_path, eb->overwrite,
eb->notify_func, eb->notify_baton, pool));
/* Build our dir baton. */
@@ -621,7 +621,7 @@ add_directory(const char *path,
return svn_error_createf(SVN_ERR_WC_NOT_WORKING_COPY, NULL,
_("'%s' exists and is not a directory"),
svn_dirent_local_style(full_path, pool));
- else if (! (kind == svn_node_dir && eb->force))
+ else if (! (kind == svn_node_dir && eb->overwrite))
return svn_error_createf(SVN_ERR_WC_OBSTRUCTED_UPDATE, NULL,
_("'%s' already exists"),
svn_dirent_local_style(full_path, pool));
@@ -1077,7 +1077,7 @@ add_directory_ev2(void *baton,
return svn_error_createf(SVN_ERR_WC_NOT_WORKING_COPY, NULL,
_("'%s' exists and is not a directory"),
svn_dirent_local_style(full_path, scratch_pool));
- else if (! (kind == svn_node_dir && eb->force))
+ else if (! (kind == svn_node_dir && eb->overwrite))
return svn_error_createf(SVN_ERR_WC_OBSTRUCTED_UPDATE, NULL,
_("'%s' already exists"),
svn_dirent_local_style(full_path, scratch_pool));
@@ -1141,7 +1141,7 @@ get_editor_ev2(const svn_delta_editor_t
exb, result_pool));
/* Create the root of the export. */
- SVN_ERR(open_root_internal(eb->root_path, eb->force, eb->notify_func,
+ SVN_ERR(open_root_internal(eb->root_path, eb->overwrite, eb->notify_func,
eb->notify_baton, scratch_pool));
return SVN_NO_ERROR;
@@ -1153,7 +1153,6 @@ export_file_ev2(const char *from_url,
struct edit_baton *eb,
svn_client__pathrev_t *loc,
svn_ra_session_t *ra_session,
- svn_boolean_t overwrite,
apr_pool_t *scratch_pool)
{
apr_hash_t *props;
@@ -1177,7 +1176,7 @@ export_file_ev2(const char *from_url,
SVN_ERR(svn_io_check_path(to_path, &to_kind, scratch_pool));
if ((to_kind == svn_node_file || to_kind == svn_node_unknown) &&
- ! overwrite)
+ ! eb->overwrite)
return svn_error_createf(SVN_ERR_ILLEGAL_TARGET, NULL,
_("Destination file '%s' exists, and "
"will not be overwritten unless forced"),
@@ -1207,7 +1206,6 @@ export_file(const char *from_url,
struct edit_baton *eb,
svn_client__pathrev_t *loc,
svn_ra_session_t *ra_session,
- svn_boolean_t overwrite,
apr_pool_t *scratch_pool)
{
apr_hash_t *props;
@@ -1232,7 +1230,7 @@ export_file(const char *from_url,
SVN_ERR(svn_io_check_path(to_path, &to_kind, scratch_pool));
if ((to_kind == svn_node_file || to_kind == svn_node_unknown) &&
- ! overwrite)
+ ! eb->overwrite)
return svn_error_createf(SVN_ERR_ILLEGAL_TARGET, NULL,
_("Destination file '%s' exists, and "
"will not be overwritten unless forced"),
@@ -1289,7 +1287,6 @@ export_directory(const char *from_url,
struct edit_baton *eb,
svn_client__pathrev_t *loc,
svn_ra_session_t *ra_session,
- svn_boolean_t overwrite,
svn_boolean_t ignore_externals,
svn_boolean_t ignore_keywords,
svn_depth_t depth,
@@ -1344,7 +1341,7 @@ export_directory(const char *from_url,
SVN_ERR(svn_io_check_path(to_path, &kind, scratch_pool));
if (kind == svn_node_none)
SVN_ERR(open_root_internal
- (to_path, overwrite, ctx->notify_func2,
+ (to_path, eb->overwrite, ctx->notify_func2,
ctx->notify_baton2, scratch_pool));
if (! ignore_externals && depth == svn_depth_infinity)
@@ -1415,7 +1412,7 @@ svn_client_export5(svn_revnum_t *result_
SVN_ERR(svn_ra_get_repos_root2(ra_session, &eb->repos_root_url, pool));
eb->root_path = to_path;
eb->root_url = loc->url;
- eb->force = overwrite;
+ eb->overwrite = overwrite;
eb->target_revision = &edit_revision;
eb->externals = apr_hash_make(pool);
eb->native_eol = native_eol;
@@ -1431,15 +1428,15 @@ svn_client_export5(svn_revnum_t *result_
{
if (!ENABLE_EV2_IMPL)
SVN_ERR(export_file(from_url, to_path, eb, loc, ra_session,
- overwrite, pool));
+ pool));
else
SVN_ERR(export_file_ev2(from_url, to_path, eb, loc,
- ra_session, overwrite, pool));
+ ra_session, pool));
}
else if (kind == svn_node_dir)
{
SVN_ERR(export_directory(from_url, to_path,
- eb, loc, ra_session, overwrite,
+ eb, loc, ra_session,
ignore_externals, ignore_keywords, depth,
native_eol, ctx, pool));
}
Modified: subversion/branches/swig-py3/subversion/libsvn_client/info.c
URL: http://svn.apache.org/viewvc/subversion/branches/swig-py3/subversion/libsvn_client/info.c?rev=1847678&r1=1847677&r2=1847678&view=diff
==============================================================================
--- subversion/branches/swig-py3/subversion/libsvn_client/info.c (original)
+++ subversion/branches/swig-py3/subversion/libsvn_client/info.c Wed Nov 28 21:25:32 2018
@@ -167,7 +167,8 @@ build_info_from_dirent(svn_client_info2_
#define DIRENT_FIELDS (SVN_DIRENT_KIND | \
SVN_DIRENT_CREATED_REV | \
SVN_DIRENT_TIME | \
- SVN_DIRENT_LAST_AUTHOR)
+ SVN_DIRENT_LAST_AUTHOR | \
+ SVN_DIRENT_SIZE)
/* Helper func for recursively fetching svn_dirent_t's from a remote
@@ -253,17 +254,17 @@ same_resource_in_head(svn_boolean_t *sam
apr_pool_t *pool)
{
svn_error_t *err;
- svn_opt_revision_t start_rev, peg_rev;
+ svn_opt_revision_t operative_rev, peg_rev;
const char *head_url;
- start_rev.kind = svn_opt_revision_head;
- peg_rev.kind = svn_opt_revision_number;
- peg_rev.value.number = rev;
+ peg_rev.kind = svn_opt_revision_head;
+ operative_rev.kind = svn_opt_revision_number;
+ operative_rev.value.number = rev;
err = svn_client__repos_locations(&head_url, NULL, NULL, NULL,
ra_session,
url, &peg_rev,
- &start_rev, NULL,
+ &operative_rev, NULL,
ctx, pool);
if (err &&
((err->apr_err == SVN_ERR_CLIENT_UNRELATED_RESOURCES) ||
Modified: subversion/branches/swig-py3/subversion/libsvn_client/list.c
URL: http://svn.apache.org/viewvc/subversion/branches/swig-py3/subversion/libsvn_client/list.c?rev=1847678&r1=1847677&r2=1847678&view=diff
==============================================================================
--- subversion/branches/swig-py3/subversion/libsvn_client/list.c (original)
+++ subversion/branches/swig-py3/subversion/libsvn_client/list.c Wed Nov 28 21:25:32 2018
@@ -394,7 +394,7 @@ list_internal(const char *path_or_url,
svn_membuf__create(&scratch_buffer, 256, pool);
/* Report the dirent for the target. */
- if (match_patterns(svn_dirent_dirname(fs_path, pool), patterns,
+ if (match_patterns(svn_dirent_basename(fs_path, pool), patterns,
&scratch_buffer))
SVN_ERR(list_func(baton, "", dirent, locks
? (svn_hash_gets(locks, fs_path))