Author: stsp
Date: Tue Apr 10 17:30:52 2012
New Revision: 1311876
URL: http://svn.apache.org/viewvc?rev=1311876&view=rev
Log:
With 'svn diff --old X --new Y', properly display properties in the case
where X/foo is a removed file and Y/foo is a directory with properties.
* subversion/tests/cmdline/diff_tests.py
(diff_two_working_copies): Test the above scenario.
* subversion/libsvn_client/diff.c
(arbitrary_diff_walker): Rename LOCAL_ABSPATH1 parameter to LOCAL_ABSPATH.
This parameters is the path begin crawled, and can be on either side of
the diff depending on b->recursing_within_added_subtree. Properly set up
LOCAL_ABSPATH1 to point to the old side of the diff when recursing into
an added subtree. Before this change, LOCAL_ABSPATH1 and LOCAL_ABSPATH2
ended up being equal in this case, so property diffs were not detected.
Modified:
subversion/trunk/subversion/libsvn_client/diff.c
subversion/trunk/subversion/tests/cmdline/diff_tests.py
Modified: subversion/trunk/subversion/libsvn_client/diff.c
URL:
http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_client/diff.c?rev=1311876&r1=1311875&r2=1311876&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_client/diff.c (original)
+++ subversion/trunk/subversion/libsvn_client/diff.c Tue Apr 10 17:30:52 2012
@@ -1952,7 +1952,7 @@ struct arbitrary_diff_walker_baton {
/* Forward declaration needed because this function has a cyclic
* dependency with do_arbitrary_dirs_diff(). */
static svn_error_t *
-arbitrary_diff_walker(void *baton, const char *local_abspath1,
+arbitrary_diff_walker(void *baton, const char *local_abspath,
const apr_finfo_t *finfo,
apr_pool_t *scratch_pool);
@@ -2009,12 +2009,14 @@ do_arbitrary_dirs_diff(const char *local
/* An implementation of svn_io_walk_func_t. */
static svn_error_t *
-arbitrary_diff_walker(void *baton, const char *local_abspath1,
+arbitrary_diff_walker(void *baton, const char *local_abspath,
const apr_finfo_t *finfo,
apr_pool_t *scratch_pool)
{
struct arbitrary_diff_walker_baton *b = baton;
+ const char *local_abspath1;
const char *local_abspath2;
+ svn_node_kind_t kind1;
svn_node_kind_t kind2;
const char *child_relpath;
apr_hash_t *dirents1;
@@ -2031,15 +2033,15 @@ arbitrary_diff_walker(void *baton, const
return SVN_NO_ERROR;
if (b->recursing_within_added_subtree)
- child_relpath = svn_dirent_skip_ancestor(b->root2_abspath, local_abspath1);
+ child_relpath = svn_dirent_skip_ancestor(b->root2_abspath, local_abspath);
else
- child_relpath = svn_dirent_skip_ancestor(b->root1_abspath, local_abspath1);
+ child_relpath = svn_dirent_skip_ancestor(b->root1_abspath, local_abspath);
if (!child_relpath)
return SVN_NO_ERROR;
if (b->recursing_within_adm_dir)
{
- if (svn_dirent_skip_ancestor(b->adm_dir_abspath, local_abspath1))
+ if (svn_dirent_skip_ancestor(b->adm_dir_abspath, local_abspath))
return SVN_NO_ERROR;
else
{
@@ -2047,25 +2049,29 @@ arbitrary_diff_walker(void *baton, const
b->adm_dir_abspath = NULL;
}
}
- else if (strcmp(svn_dirent_basename(local_abspath1, scratch_pool),
+ else if (strcmp(svn_dirent_basename(local_abspath, scratch_pool),
SVN_WC_ADM_DIR_NAME) == 0)
{
b->recursing_within_adm_dir = TRUE;
- b->adm_dir_abspath = apr_pstrdup(b->pool, local_abspath1);
+ b->adm_dir_abspath = apr_pstrdup(b->pool, local_abspath);
return SVN_NO_ERROR;
}
- if (b->recursing_within_added_subtree)
- dirents1 = apr_hash_make(scratch_pool);
- else
- SVN_ERR(svn_io_get_dirents3(&dirents1, local_abspath1,
- TRUE, /* only_check_type */
- scratch_pool, scratch_pool));
+ local_abspath1 = svn_dirent_join(b->root1_abspath, child_relpath,
+ scratch_pool);
+ SVN_ERR(svn_io_check_resolved_path(local_abspath1, &kind1, scratch_pool));
local_abspath2 = svn_dirent_join(b->root2_abspath, child_relpath,
scratch_pool);
SVN_ERR(svn_io_check_resolved_path(local_abspath2, &kind2, scratch_pool));
+ if (kind1 == svn_node_dir)
+ SVN_ERR(svn_io_get_dirents3(&dirents1, local_abspath1,
+ TRUE, /* only_check_type */
+ scratch_pool, scratch_pool));
+ else
+ dirents1 = apr_hash_make(scratch_pool);
+
if (kind2 == svn_node_dir)
{
apr_hash_t *original_props;
Modified: subversion/trunk/subversion/tests/cmdline/diff_tests.py
URL:
http://svn.apache.org/viewvc/subversion/trunk/subversion/tests/cmdline/diff_tests.py?rev=1311876&r1=1311875&r2=1311876&view=diff
==============================================================================
--- subversion/trunk/subversion/tests/cmdline/diff_tests.py (original)
+++ subversion/trunk/subversion/tests/cmdline/diff_tests.py Tue Apr 10 17:30:52
2012
@@ -3808,6 +3808,9 @@ def diff_two_working_copies(sbox):
svntest.main.file_append(sbox.ospath('A/B/F'), 'new text\n')
sbox.simple_add('A/B/F')
sbox.simple_propset('newprop', 'propval-new\n', 'A/B/F')
+ sbox.simple_rm('A/D/G/pi')
+ sbox.simple_mkdir('A/D/G/pi')
+ sbox.simple_propset('newprop', 'propval', 'A/D/G/pi')
src_label = os.path.basename(wc_dir_old)
dst_label = os.path.basename(wc_dir)
@@ -3844,6 +3847,13 @@ def diff_two_working_copies(sbox):
src_label, dst_label) + \
make_diff_prop_header('A/D/gamma') + \
make_diff_prop_added("newprop", "propval") + \
+ make_diff_header('A/D/G/pi', 'working copy',
+ 'working copy',
+ src_label, dst_label) + [
+ "@@ -1 +0,0 @@\n",
+ "-This is the file 'pi'.\n",
+ ] + make_diff_prop_header('A/D/G/pi') + \
+ make_diff_prop_added("newprop", "propval") + \
make_diff_header('A/D/H/chi', 'working copy',
'working copy',
src_label, dst_label) + [