On 31/03/13 00:39, Daniel Shahaf wrote:
Gabriela Gibson wrote on Sat, Mar 30, 2013 at 21:31:31 +0000:
Code inspection tells me that oldrev_str can become the @a suffix
parameter to the svn_io_open_uniquely_named() call in
preserve_pre_merge_files(), in which case [\t ()] are all inappropriate
characters.
I assume the "label" you refer to is the text following the
<<<<<</======/>>>>>> conflict markers?
I was trying to change the label for the working copy in a 3-way merge
to show the relative file path.
Take 2 below:
[[[
Change "mine_label" passed to external diff3-cmd to list relative
path of file.
* subversion/include/svn_io.h
(svn_io_run_diff3_4): Fix comment, re-version function.
(svn_io_run_diff3_3): Change comment to reflect deprecation.
* subversion/libsvn_subr/deprecated.c
(svn_io_run_diff3_3): Move function from io.c.
* subversion/libsvn_subr/io.c
(svn_io_run_diff3_3): Move function to deprecated.c.
(svn_io_run_diff3_4): Add parameter for use in "mine_label".
* subversion/libsvn_wc/merge.c
(do_text_merge_external): Add new parameter.
]]]
Index: subversion/include/svn_io.h
===================================================================
--- subversion/include/svn_io.h (revision 1463012)
+++ subversion/include/svn_io.h (working copy)
@@ -1819,15 +1819,16 @@ svn_io_run_diff(const char *dir,
const char *diff_cmd,
apr_pool_t *pool);
-
-
/** Invoke the configured @c diff3 program, in utf8-encoded @a dir
* like this:
*
- * diff3 -E -m @a mine @a older @a yours > @a merged
+ * diff3 -E -m -L @a relpath + @a mine_label -L @a older_label \
+ * -L @a yours_label @a mine @a older @a yours > @a merged
*
* (See the diff3 documentation for details.)
*
+ * If @a relpath is NULL, then use @a mine_label alone.
+ *
* If @a user_args is non-NULL, replace "-E" with the <tt>const char*</tt>
* elements that @a user_args contains.
*
@@ -1853,6 +1854,27 @@ svn_io_run_diff(const char *dir,
*
* Do all allocation in @a pool.
*
+ * @since New in 1.8.
+ */
+svn_error_t *
+svn_io_run_diff3_4(int *exitcode,
+ const char *dir,
+ const char *mine,
+ const char *older,
+ const char *yours,
+ const char *mine_label,
+ const char *older_label,
+ const char *yours_label,
+ apr_file_t *merged,
+ const char *diff3_cmd,
+ const char *relpath,
+ const apr_array_header_t *user_args,
+ apr_pool_t *pool);
+
+/** Similar to svn_io_run_diff3_4(), but with @a relpath not provided
+ * encoded in internal encoding used by APR.
+ *
+ * @deprecated Provided for backwards compatibility with the 1.5 API.
* @since New in 1.4.
*/
svn_error_t *
Index: subversion/libsvn_subr/deprecated.c
===================================================================
--- subversion/libsvn_subr/deprecated.c (revision 1463012)
+++ subversion/libsvn_subr/deprecated.c (working copy)
@@ -713,6 +713,30 @@ svn_io_run_diff(const char *dir,
}
svn_error_t *
+svn_io_run_diff3_3(int *exitcode,
+ const char *dir,
+ const char *mine,
+ const char *older,
+ const char *yours,
+ const char *mine_label,
+ const char *older_label,
+ const char *yours_label,
+ apr_file_t *merged,
+ const char *diff3_cmd,
+ const apr_array_header_t *user_args,
+ apr_pool_t *pool)
+{
+ SVN_ERR(svn_path_cstring_to_utf8(&diff3_cmd, diff3_cmd, pool));
+
+ return svn_error_trace(svn_io_run_diff3_4(exitcode, dir,
+ mine, older, yours,
+ mine_label, older_label,
+ yours_label, merged,
+ diff3_cmd, NULL,
+ user_args, pool));
+}
+
+svn_error_t *
svn_io_run_diff3_2(int *exitcode,
const char *dir,
const char *mine,
Index: subversion/libsvn_subr/io.c
===================================================================
--- subversion/libsvn_subr/io.c (revision 1463012)
+++ subversion/libsvn_subr/io.c (working copy)
@@ -2921,9 +2921,8 @@ svn_io_run_diff2(const char *dir,
return SVN_NO_ERROR;
}
-
svn_error_t *
-svn_io_run_diff3_3(int *exitcode,
+svn_io_run_diff3_4(int *exitcode,
const char *dir,
const char *mine,
const char *older,
@@ -2933,6 +2932,7 @@ svn_error_t *
const char *yours_label,
apr_file_t *merged,
const char *diff3_cmd,
+ const char *relpath,
const apr_array_header_t *user_args,
apr_pool_t *pool)
{
@@ -2975,8 +2976,13 @@ svn_error_t *
#endif
}
args[i++] = "-m";
+
args[i++] = "-L";
- args[i++] = mine_label;
+ if (relpath)
+ args[i++] = apr_psprintf(pool, "%s\t%s", relpath, mine_label);
+ else
+ args[i++] = mine_label;
+
args[i++] = "-L";
args[i++] = older_label; /* note: this label is ignored if
using 2-part markers, which is the
@@ -3047,7 +3053,6 @@ svn_error_t *
return SVN_NO_ERROR;
}
-
/* Canonicalize a string for hashing. Modifies KEY in place. */
static APR_INLINE char *
fileext_tolower(char *key)
Index: subversion/libsvn_wc/merge.c
===================================================================
--- subversion/libsvn_wc/merge.c (revision 1463012)
+++ subversion/libsvn_wc/merge.c (working copy)
@@ -430,6 +430,7 @@ do_text_merge(svn_boolean_t *contains_conflicts,
return SVN_NO_ERROR;
}
+
/* Same as do_text_merge() above, but use the external diff3
* command DIFF3_CMD to perform the merge. Pass MERGE_OPTIONS
* to the diff3 command. Do all allocations in POOL. */
@@ -444,14 +445,15 @@ do_text_merge_external(svn_boolean_t *contains_con
const char *target_label,
const char *left_label,
const char *right_label,
+ const char *relpath,
apr_pool_t *scratch_pool)
{
int exit_code;
- SVN_ERR(svn_io_run_diff3_3(&exit_code, ".",
+ SVN_ERR(svn_io_run_diff3_4(&exit_code, ".",
detranslated_target, left_abspath, right_abspath,
target_label, left_label, right_label,
- result_f, diff3_cmd,
+ result_f, diff3_cmd, relpath,
merge_options, scratch_pool));
*contains_conflicts = exit_code == 1;
@@ -827,6 +829,8 @@ merge_text_file(svn_skel_t **work_items,
const char *result_target;
const char *base_name;
const char *temp_dir;
+ const char *relpath = svn_dirent_skip_ancestor(mt->wri_abspath,
+ mt->local_abspath);
svn_skel_t *work_item;
*work_items = NULL;
@@ -855,6 +859,7 @@ merge_text_file(svn_skel_t **work_items,
target_label,
left_label,
right_label,
+ relpath,
pool));
else /* Use internal merge. */
SVN_ERR(do_text_merge(&contains_conflicts,