Author: stsp
Date: Tue Aug 9 09:22:24 2011
New Revision: 1155279
URL: http://svn.apache.org/viewvc?rev=1155279&view=rev
Log:
Include the copyfrom revision provided to the file_added() diff callback
in git diff "copied" headers.
For now this is a no-op because the file_added() callback doesn't seem
to ever receive a copyfrom revision. Maybe because of issue #3711?
It does receive a copyfrom path though so maybe this is just a bug?
* subversion/libsvn_client/diff.c
(print_git_diff_header_copied, print_git_diff_header,
diff_content_changed): Add COPYFROM_REV argument and show it if it
is a valid revision number.
(display_prop_diffs, diff_file_changed, diff_file_added,
diff_file_deleted): Update callers, passing SVN_INVALID_REVNUM as
the copyfrom revision in most cases.
Modified:
subversion/trunk/subversion/libsvn_client/diff.c
Modified: subversion/trunk/subversion/libsvn_client/diff.c
URL:
http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_client/diff.c?rev=1155279&r1=1155278&r2=1155279&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_client/diff.c (original)
+++ subversion/trunk/subversion/libsvn_client/diff.c Tue Aug 9 09:22:24 2011
@@ -400,15 +400,22 @@ print_git_diff_header_deleted(svn_stream
* OS using HEADER_ENCODING. All allocations are done in RESULT_POOL. */
static svn_error_t *
print_git_diff_header_copied(svn_stream_t *os, const char *header_encoding,
- const char *copyfrom_path, const char *path,
+ const char *copyfrom_path,
+ svn_revnum_t copyfrom_rev,
+ const char *path,
apr_pool_t *result_pool)
{
SVN_ERR(svn_stream_printf_from_utf8(os, header_encoding, result_pool,
"diff --git a/%s b/%s%s",
copyfrom_path, path, APR_EOL_STR));
- SVN_ERR(svn_stream_printf_from_utf8(os, header_encoding, result_pool,
- "copy from %s%s", copyfrom_path,
- APR_EOL_STR));
+ if (copyfrom_rev != SVN_INVALID_REVNUM)
+ SVN_ERR(svn_stream_printf_from_utf8(os, header_encoding, result_pool,
+ "copy from %s@%ld%s", copyfrom_path,
+ copyfrom_rev, APR_EOL_STR));
+ else
+ SVN_ERR(svn_stream_printf_from_utf8(os, header_encoding, result_pool,
+ "copy from %s%s", copyfrom_path,
+ APR_EOL_STR));
SVN_ERR(svn_stream_printf_from_utf8(os, header_encoding, result_pool,
"copy to %s%s", path, APR_EOL_STR));
return SVN_NO_ERROR;
@@ -450,9 +457,10 @@ print_git_diff_header_modified(svn_strea
* 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 indicates where the diffed item
- * was copied from. RA_SESSION and WC_CTX are used to adjust paths in the
- * headers to be relative to the repository root.
+ * revisions being diffed. COPYFROM_PATH and COPYFROM_REV indicate where the
+ * diffed item was copied from.
+ * RA_SESSION and WC_CTX are used to adjust paths in the headers to be
+ * relative to the repository root.
* WC_ROOT_ABSPATH is the absolute path to the root directory of a working
* copy involved in a repos-wc diff, and may be NULL.
* Use SCRATCH_POOL for temporary allocations. */
@@ -465,6 +473,7 @@ print_git_diff_header(svn_stream_t *os,
svn_revnum_t rev1,
svn_revnum_t rev2,
const char *copyfrom_path,
+ svn_revnum_t copyfrom_rev,
const char *header_encoding,
svn_ra_session_t *ra_session,
svn_wc_context_t *wc_ctx,
@@ -484,7 +493,8 @@ print_git_diff_header(svn_stream_t *os,
else if (operation == svn_diff_op_copied)
{
SVN_ERR(print_git_diff_header_copied(os, header_encoding,
- copyfrom_path, repos_relpath2,
+ copyfrom_path, copyfrom_rev,
+ repos_relpath2,
scratch_pool));
*label1 = diff_label(apr_psprintf(scratch_pool, "a/%s", copyfrom_path),
rev1, scratch_pool);
@@ -605,6 +615,7 @@ display_prop_diffs(const apr_array_heade
SVN_ERR(print_git_diff_header(os, &label1, &label2,
svn_diff_op_modified,
path1, path2, rev1, rev2, NULL,
+ SVN_INVALID_REVNUM,
encoding, ra_session, wc_ctx,
wc_root_abspath, pool));
SVN_ERR(svn_stream_close(os));
@@ -899,6 +910,7 @@ diff_content_changed(const char *path,
const char *mimetype2,
svn_diff_operation_kind_t operation,
const char *copyfrom_path,
+ svn_revnum_t copyfrom_rev,
void *diff_baton)
{
struct diff_cmd_baton *diff_cmd_baton = diff_baton;
@@ -1028,6 +1040,7 @@ diff_content_changed(const char *path,
SVN_ERR(print_git_diff_header(os, &label1, &label2, operation,
tmp_path1, tmp_path2, rev1, rev2,
copyfrom_path,
+ copyfrom_rev,
diff_cmd_baton->header_encoding,
diff_cmd_baton->ra_session,
diff_cmd_baton->wc_ctx,
@@ -1098,7 +1111,8 @@ diff_file_changed(svn_wc_notify_state_t
SVN_ERR(diff_content_changed(path,
tmpfile1, tmpfile2, rev1, rev2,
mimetype1, mimetype2,
- svn_diff_op_modified, NULL, diff_baton));
+ svn_diff_op_modified, NULL,
+ SVN_INVALID_REVNUM, diff_baton));
if (prop_changes->nelts > 0)
SVN_ERR(diff_props_changed(prop_state, tree_conflicted,
path, FALSE, prop_changes,
@@ -1152,12 +1166,13 @@ diff_file_added(svn_wc_notify_state_t *c
tmpfile1, tmpfile2, rev1, rev2,
mimetype1, mimetype2,
svn_diff_op_copied, copyfrom_path,
- diff_baton));
+ copyfrom_revision, diff_baton));
else if (tmpfile1)
SVN_ERR(diff_content_changed(path,
tmpfile1, tmpfile2, rev1, rev2,
mimetype1, mimetype2,
- svn_diff_op_added, NULL, diff_baton));
+ svn_diff_op_added, NULL, SVN_INVALID_REVNUM,
+ diff_baton));
if (prop_changes->nelts > 0)
SVN_ERR(diff_props_changed(prop_state, tree_conflicted,
path, FALSE, prop_changes,
@@ -1208,7 +1223,8 @@ diff_file_deleted(svn_wc_notify_state_t
diff_cmd_baton->revnum1,
diff_cmd_baton->revnum2,
mimetype1, mimetype2,
- svn_diff_op_deleted, NULL, diff_baton));
+ svn_diff_op_deleted, NULL,
+ SVN_INVALID_REVNUM, diff_baton));
}
/* We don't list all the deleted properties. */