You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by st...@apache.org on 2015/01/24 19:56:39 UTC
svn commit: r1654561 - in /subversion/branches/pin-externals/subversion:
libsvn_client/copy.c tests/cmdline/externals_tests.py
Author: stsp
Date: Sat Jan 24 18:56:39 2015
New Revision: 1654561
URL: http://svn.apache.org/r1654561
Log:
On the pin-externals branch, while pinning externals use the correct
path for externals which were moved since the last-changed revision.
* subversion/libsvn_client/copy.c
(external_location_segments_receiver_baton,
external_location_segments_receiver): New.
(pin_externals_prop): Use svn_ra_get_location_segments() to determine
the path an external had at its last-changed revision. Use the obtained
path when pinning to the last changed revision in case the path differs
from external's path in the youngest revision.
An unfortunate side-effect is that relative externals may become absolute
when pinning, because I could not come up with a reliable way of
transforming a resolved absolute URL into relative external URL syntax.
* subversion/tests/cmdline/externals_tests.py
(copy_pin_externals): Verify the above behaviour.
Modified:
subversion/branches/pin-externals/subversion/libsvn_client/copy.c
subversion/branches/pin-externals/subversion/tests/cmdline/externals_tests.py
Modified: subversion/branches/pin-externals/subversion/libsvn_client/copy.c
URL: http://svn.apache.org/viewvc/subversion/branches/pin-externals/subversion/libsvn_client/copy.c?rev=1654561&r1=1654560&r2=1654561&view=diff
==============================================================================
--- subversion/branches/pin-externals/subversion/libsvn_client/copy.c (original)
+++ subversion/branches/pin-externals/subversion/libsvn_client/copy.c Sat Jan 24 18:56:39 2015
@@ -177,6 +177,27 @@ get_copy_pair_ancestors(const apr_array_
return SVN_NO_ERROR;
}
+struct external_location_segments_receiver_baton {
+ svn_revnum_t last_changed_rev;
+ const char *last_changed_repos_relpath;
+ apr_pool_t *result_pool;
+} external_location_segments_receiver_baton;
+
+/* Implements svn_location_segment_receiver_t. */
+static svn_error_t *
+external_location_segments_receiver(svn_location_segment_t *segment,
+ void *baton,
+ apr_pool_t *pool)
+{
+ struct external_location_segments_receiver_baton *b = baton;
+
+ if (segment->range_start <= b->last_changed_rev &&
+ segment->range_end >= b->last_changed_rev)
+ b->last_changed_repos_relpath = apr_pstrdup(b->result_pool, segment->path);
+
+ return SVN_NO_ERROR;
+}
+
/* Pin all externals listed in EXTERNALS_PROP_VAL to their last-changed
* revision. Return a new property value in *PINNED_EXTERNALS allocated
* in RESULT_POOL. LOCAL_ABSPATH_OR_URL is the path defining the
@@ -246,19 +267,61 @@ pin_externals_prop(svn_string_t **pinned
SVN_ERR(svn_ra_get_latest_revnum(external_ra_session,
&external_youngest_rev,
iterpool));
- /* ### If the path was copied/moved since it's last-changed revision,
- ### we should use the pre-copy/pre-move path.*/
+
SVN_ERR(svn_ra_stat(external_ra_session, "",
external_youngest_rev,
&dirent,
iterpool));
-
if (dirent == NULL)
return svn_error_createf(SVN_ERR_FS_NOT_FOUND, NULL,
_("Cannot determine last-changed revision "
"of '%s'"), resolved_url);
SVN_DBG(("external's last-changed revision: %lu", dirent->created_rev));
+ if (external_youngest_rev > dirent->created_rev)
+ {
+ struct external_location_segments_receiver_baton b;
+
+ /* Find the item's URL location as of the last-changed revision. */
+ b.last_changed_rev = dirent->created_rev;
+ b.last_changed_repos_relpath = NULL;
+ b.result_pool = iterpool;
+ SVN_ERR(svn_ra_get_location_segments(
+ external_ra_session, "", external_youngest_rev,
+ external_youngest_rev, dirent->created_rev,
+ external_location_segments_receiver, &b, iterpool));
+ if (b.last_changed_repos_relpath)
+ {
+ const char *external_repos_root_url;
+ const char *last_changed_url;
+
+ SVN_ERR(svn_ra_get_repos_root2(external_ra_session,
+ &external_repos_root_url,
+ iterpool));
+
+
+ last_changed_url = svn_uri_canonicalize(
+ apr_pstrcat(iterpool,
+ external_repos_root_url, "/",
+ b.last_changed_repos_relpath,
+ SVN_VA_NULL),
+ iterpool);
+ SVN_DBG(("external's last-changed URL: %s", last_changed_url));
+ if (strcmp(resolved_url, last_changed_url) != 0)
+ {
+ /* The external was at a different location at its
+ * last-changed revision so we must fix up ITEM->URL.
+ * ### BUG: Even if the external's URL was relative the
+ * ### pinned URL will be absolute because we have no good
+ * ### way of transforming the resolved last-changed URL
+ * ### into a relative one. */
+ item->url = last_changed_url;
+ }
+ }
+ }
+
+ SVN_DBG(("external's URL: %s", item->url));
+
if (item->revision.kind == svn_opt_revision_date)
{
item->revision.kind = svn_opt_revision_number;
Modified: subversion/branches/pin-externals/subversion/tests/cmdline/externals_tests.py
URL: http://svn.apache.org/viewvc/subversion/branches/pin-externals/subversion/tests/cmdline/externals_tests.py?rev=1654561&r1=1654560&r2=1654561&view=diff
==============================================================================
--- subversion/branches/pin-externals/subversion/tests/cmdline/externals_tests.py (original)
+++ subversion/branches/pin-externals/subversion/tests/cmdline/externals_tests.py Sat Jan 24 18:56:39 2015
@@ -3565,6 +3565,7 @@ def copy_pin_externals(sbox):
# Verify that externals have been pinned.
last_changed_rev_gamma = 1
+ A_copy_D_path = 'A_copy/D'
def verify_pinned_externals(base_path_or_url):
expected_output = [
'-r%d %s@%d gamma\n' % (last_changed_rev_gamma,
@@ -3601,9 +3602,9 @@ def copy_pin_externals(sbox):
'\n',
]
if svntest.sandbox.is_url(base_path_or_url):
- target = base_path_or_url + '/A_copy/D'
+ target = base_path_or_url + '/' + A_copy_D_path
else:
- target = sbox.ospath('A_copy/D')
+ target = sbox.ospath(A_copy_D_path)
svntest.actions.run_and_verify_svn(None, expected_output, [],
'propget', 'svn:externals',
target)
@@ -3676,18 +3677,30 @@ def copy_pin_externals(sbox):
external_url_for["A/B/gamma"] = '^/A/D/gamma-moved'
verify_pinned_externals(wc_dir)
+ # Clean up.
+ svntest.actions.run_and_verify_svn(None, None, [],
+ 'revert', '-R', wc_dir)
+ svntest.main.safe_rmtree(os.path.join(wc_dir, 'A_copy'))
+
sbox.simple_update()
sbox.simple_move('A/D', 'A/D-moved')
change_external(sbox.ospath('A/B'), '^/A/D-moved/gamma-moved gamma', commit=False)
sbox.simple_commit()
sbox.simple_update()
- # While gamma's path has changed by virtue of being moved along with
- # its parent A/D, gamma's last-changed rev should not have changed.
svntest.actions.run_and_verify_svn(None, None, [],
'copy',
wc_dir + '/A',
wc_dir + '/A_copy',
'--pin-externals')
+ # While gamma's path has changed by virtue of being moved along with
+ # its parent A/D, gamma's last-changed rev should not have changed.
+ # Therefore, the pinned external should resolve to the pre-move path,
+ # ie. '^/A/D/gamma-moved@11' instead of '^/A/D-moved/gamma-moved@11'.
+ #
+ # Note that the pinned external will use an absolute URLs in this case.
+ # See the "BUG:" comment in libsvn_client's pin_externals_prop() function.
+ external_url_for["A/B/gamma"] = ('%s/A/D/gamma-moved' % repo_url)
+ A_copy_D_path = 'A_copy/D-moved'
verify_pinned_externals(wc_dir)