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 2012/02/17 20:15:51 UTC
svn commit: r1245711 - in /subversion/trunk/subversion:
libsvn_wc/wc_db_private.h libsvn_wc/wc_db_wcroot.c
tests/cmdline/special_tests.py
Author: stsp
Date: Fri Feb 17 19:15:51 2012
New Revision: 1245711
URL: http://svn.apache.org/viewvc?rev=1245711&view=rev
Log:
For issues #4102 and #4120, both describing problems with symlinks
pointing to externals with various operations (add/status/diff and more),
change the way we resolve working copy roots for symlinks.
* subversion/libsvn_wc/wc_db_private.h
(svn_wc__db_t): Use svn_kind_t rather than svn_node_kind_t in the
parse cache. This allows symlinks to be represented.
* subversion/libsvn_wc/wc_db_wcroot.c
(get_path_kind): Return svn_kind_t instead of svn_node_kind_t. This allows
symlinks to be represented. This function used to force symlinks to always
be treated like directories, which prevents symlinks pointing to externals
from being handled as part of the external's parent working copy.
(svn_wc__db_wcroot_parse_local_abspath): If we locate a wcroot via a
symlink that points to a directory, first treat the symlink like a
normal file, i.e. walk upwards from the symlink's parent dir.
If we find a db, and the symlink is versioned in it, use this DB.
Else, try again, this time treating the symlink like a directory,
which means we'll find a nested wcroot in case the symlink points
to a nested working copy (e.g. an external).
This strategy allows versioned symlinks pointing to externals to work
within the external's parent wc, and also allows unversioned symlinks
to point to nested WCs (this is required for our test suite).
I had to introduce a 'goto' here to avoid major refactoring :(
This function should probably be refactored in a later commit
to get rid of the 'goto'.
* subversion/tests/cmdline/special_tests.py
(externals_as_symlink_targets): Remove XFail marker.
Modified:
subversion/trunk/subversion/libsvn_wc/wc_db_private.h
subversion/trunk/subversion/libsvn_wc/wc_db_wcroot.c
subversion/trunk/subversion/tests/cmdline/special_tests.py
Modified: subversion/trunk/subversion/libsvn_wc/wc_db_private.h
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/wc_db_private.h?rev=1245711&r1=1245710&r2=1245711&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/wc_db_private.h (original)
+++ subversion/trunk/subversion/libsvn_wc/wc_db_private.h Fri Feb 17 19:15:51 2012
@@ -54,7 +54,7 @@ struct svn_wc__db_t {
struct
{
svn_stringbuf_t *abspath;
- svn_node_kind_t kind;
+ svn_kind_t kind;
} parse_cache;
/* As we grow the state of this DB, allocate that state here. */
Modified: subversion/trunk/subversion/libsvn_wc/wc_db_wcroot.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/wc_db_wcroot.c?rev=1245711&r1=1245710&r2=1245711&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/wc_db_wcroot.c (original)
+++ subversion/trunk/subversion/libsvn_wc/wc_db_wcroot.c Fri Feb 17 19:15:51 2012
@@ -104,12 +104,13 @@ get_old_version(int *version,
Sets *KIND to svn_node_dir for symlinks. */
static svn_error_t *
-get_path_kind(svn_node_kind_t *kind,
+get_path_kind(svn_kind_t *kind,
svn_wc__db_t *db,
const char *local_abspath,
apr_pool_t *scratch_pool)
{
svn_boolean_t special;
+ svn_node_kind_t node_kind;
/* This implements a *really* simple LRU cache, where "simple" is defined
as "only one element". In other words, we remember the most recently
@@ -133,12 +134,10 @@ get_path_kind(svn_node_kind_t *kind,
svn_stringbuf_set(db->parse_cache.abspath, local_abspath);
}
- SVN_ERR(svn_io_check_special_path(local_abspath, &db->parse_cache.kind,
+ SVN_ERR(svn_io_check_special_path(local_abspath, &node_kind,
&special, scratch_pool));
- /* The wcroot could be a symlink to a directory. (Issue #2557, #3987) */
- if (special)
- db->parse_cache.kind = svn_node_dir;
+ db->parse_cache.kind = svn__kind_from_node_kind(node_kind, special);
*kind = db->parse_cache.kind;
return SVN_NO_ERROR;
@@ -366,7 +365,7 @@ svn_wc__db_wcroot_parse_local_abspath(sv
{
const char *local_dir_abspath;
const char *original_abspath = local_abspath;
- svn_node_kind_t kind;
+ svn_kind_t kind;
const char *build_relpath;
svn_wc__db_wcroot_t *probe_wcroot;
svn_wc__db_wcroot_t *found_wcroot = NULL;
@@ -402,7 +401,7 @@ svn_wc__db_wcroot_parse_local_abspath(sv
### into wc_db which references a file. calls for directories could
### get an early-exit in the hash lookup just above. */
SVN_ERR(get_path_kind(&kind, db, local_abspath, scratch_pool));
- if (kind != svn_node_dir)
+ if (kind != svn_kind_dir)
{
/* If the node specified by the path is NOT present, then it cannot
possibly be a directory containing ".svn/wc.db".
@@ -437,7 +436,7 @@ svn_wc__db_wcroot_parse_local_abspath(sv
many ancestors need to be scanned until we start hitting content
on the disk. Set ALWAYS_CHECK to keep looking for .svn/entries
rather than bailing out after the first check. */
- if (kind == svn_node_none)
+ if (kind == svn_kind_none)
always_check = TRUE;
/* Start the scanning at LOCAL_DIR_ABSPATH. */
@@ -511,6 +510,38 @@ svn_wc__db_wcroot_parse_local_abspath(sv
if (svn_dirent_is_root(local_abspath, strlen(local_abspath)))
{
/* Hit the root without finding a wcroot. */
+
+ /* The wcroot could be a symlink to a directory.
+ * (Issue #2557, #3987). If so, try again, this time scanning
+ * for a db within the directory the symlink points to,
+ * rather than within the symlink's parent directory. */
+ if (kind == svn_kind_symlink)
+ {
+ svn_node_kind_t resolved_kind;
+
+ local_abspath = original_abspath;
+
+ SVN_ERR(svn_io_check_resolved_path(local_abspath,
+ &resolved_kind,
+ scratch_pool));
+ if (resolved_kind == svn_node_dir)
+ {
+ /* Is this directory recorded in our hash? */
+ found_wcroot = apr_hash_get(db->dir_data, local_abspath,
+ APR_HASH_KEY_STRING);
+ if (found_wcroot)
+ break;
+
+try_symlink_as_dir:
+ kind = svn_kind_dir;
+ moved_upwards = FALSE;
+ local_dir_abspath = local_abspath;
+ build_relpath = "";
+
+ continue;
+ }
+ }
+
return svn_error_createf(SVN_ERR_WC_NOT_WORKING_COPY, NULL,
_("'%s' is not a working copy"),
svn_dirent_local_style(original_abspath,
@@ -584,6 +615,37 @@ svn_wc__db_wcroot_parse_local_abspath(sv
*local_relpath = svn_relpath_join(dir_relpath, build_relpath, result_pool);
}
+ if (kind == svn_kind_symlink)
+ {
+ svn_sqlite__stmt_t *stmt;
+ svn_boolean_t have_row;
+
+ /* Check if the symlink is versioned in this DB.
+ * If it is, use this wcroot. If it is not, and the symlink
+ * points to a directory, try to find a wcroot in that
+ * directory instead. */
+
+ SVN_ERR(svn_sqlite__get_statement(&stmt, (*wcroot)->sdb,
+ STMT_SELECT_NODE_INFO));
+ SVN_ERR(svn_sqlite__bindf(stmt, "is", (*wcroot)->wc_id, *local_relpath));
+ SVN_ERR(svn_sqlite__step(&have_row, stmt));
+ SVN_ERR(svn_sqlite__reset(stmt));
+
+ if (!have_row)
+ {
+ svn_node_kind_t resolved_kind;
+
+ SVN_ERR(svn_io_check_resolved_path(original_abspath,
+ &resolved_kind,
+ scratch_pool));
+ if (resolved_kind == svn_node_dir)
+ {
+ local_abspath = original_abspath;
+ goto try_symlink_as_dir;
+ }
+ }
+ }
+
/* We've found the appropriate WCROOT for the requested path. Stash
it into that path's directory. */
apr_hash_set(db->dir_data,
Modified: subversion/trunk/subversion/tests/cmdline/special_tests.py
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/tests/cmdline/special_tests.py?rev=1245711&r1=1245710&r2=1245711&view=diff
==============================================================================
--- subversion/trunk/subversion/tests/cmdline/special_tests.py (original)
+++ subversion/trunk/subversion/tests/cmdline/special_tests.py Fri Feb 17 19:15:51 2012
@@ -1023,7 +1023,6 @@ def replace_symlinks(sbox):
sbox.simple_update()
-@XFail()
@Issue(4102)
@SkipUnless(svntest.main.is_posix_os)
def externals_as_symlink_targets(sbox):