You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by rh...@apache.org on 2011/04/08 15:19:59 UTC
svn commit: r1090240 - in /subversion/trunk/subversion: include/svn_wc.h
libsvn_wc/update_editor.c svn/notify.c tests/cmdline/checkout_tests.py
tests/cmdline/svntest/wc.py tests/cmdline/switch_tests.py
tests/cmdline/update_tests.py
Author: rhuijben
Date: Fri Apr 8 13:19:59 2011
New Revision: 1090240
URL: http://svn.apache.org/viewvc?rev=1090240&view=rev
Log:
Properly skip obstructing working copies when adding files and directories
in the update editor.
* subversion/include/svn_wc.h
(svn_wc_notify_action_t): Rename value to better describe its usage.
* subversion/libsvn_wc/update_editor.c
(add_directory,
add_file): An addition that has status normal must be an obstructing
working copy, so directly skip it to make sure we don't change anything
inside. Remove old detection code. Simplify tree conflict constraints.
* subversion/svn/notify.c
(notify): Add notification for svn_wc_notify_update_skip_obstruction.
* subversion/tests/cmdline/checkout_tests.py
(forced_checkout_with_versioned_obstruction): Expect a skip instead of an
error. Use output parser.
* subversion/tests/cmdline/svntest/wc.py
(_re_parse_skipped,
_re_parse_co_skipped): Catch skip with explanation
* subversion/tests/cmdline/switch_tests.py
(forced_switch_failures): Expect skip instead of an error and update
later output.
* subversion/tests/cmdline/update_tests.py
(forced_update_failures): Expect skip instead of an error.
Modified:
subversion/trunk/subversion/include/svn_wc.h
subversion/trunk/subversion/libsvn_wc/update_editor.c
subversion/trunk/subversion/svn/notify.c
subversion/trunk/subversion/tests/cmdline/checkout_tests.py
subversion/trunk/subversion/tests/cmdline/svntest/wc.py
subversion/trunk/subversion/tests/cmdline/switch_tests.py
subversion/trunk/subversion/tests/cmdline/update_tests.py
Modified: subversion/trunk/subversion/include/svn_wc.h
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/include/svn_wc.h?rev=1090240&r1=1090239&r2=1090240&view=diff
==============================================================================
--- subversion/trunk/subversion/include/svn_wc.h (original)
+++ subversion/trunk/subversion/include/svn_wc.h Fri Apr 8 13:19:59 2011
@@ -1099,9 +1099,10 @@ typedef enum svn_wc_notify_action_t
/** Starting an update operation. @since New in 1.7. */
svn_wc_notify_update_started,
- /** An update tried to add a file or directory at path but an
- * unversioned obstruction was found. @since New in 1.7. */
- svn_wc_notify_update_obstruction,
+ /** An update tried to add a file or directory at a path where
+ * a separate working copy was found. @since New in 1.7. */
+ svn_wc_notify_update_skip_obstruction,
+
/** An update operation removed an external working copy.
* @since New in 1.7. */
svn_wc_notify_update_external_removed,
Modified: subversion/trunk/subversion/libsvn_wc/update_editor.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/update_editor.c?rev=1090240&r1=1090239&r2=1090240&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/update_editor.c (original)
+++ subversion/trunk/subversion/libsvn_wc/update_editor.c Fri Apr 8 13:19:59 2011
@@ -2054,6 +2054,37 @@ add_directory(const char *path,
versioned_locally_and_present = FALSE;
}
+ else if (wc_kind == svn_wc__db_kind_dir
+ && status == svn_wc__db_status_normal)
+ {
+ /* !! We found the root of a separate working copy obstructing the wc !!
+
+ If the directory would be part of our own working copy then
+ we wouldn't have been called as an add_directory().
+
+ The only thing we can do is add a not-present node, to allow
+ a future update to bring in the new files when the problem is
+ resolved. Note that svn_wc__db_base_add_not_present_node()
+ explicitly adds the node into the parent's node database. */
+
+ SVN_ERR(svn_wc__db_base_add_not_present_node(eb->db, db->local_abspath,
+ db->new_relpath,
+ eb->repos_root,
+ eb->repos_uuid,
+ *eb->target_revision,
+ svn_wc__db_kind_file,
+ NULL, NULL,
+ pool));
+
+ remember_skipped_tree(eb, db->local_abspath, pool);
+ db->skip_this = TRUE;
+ db->already_notified = TRUE;
+
+ do_notification(eb, db->local_abspath, svn_node_dir,
+ svn_wc_notify_update_skip_obstruction, pool);
+
+ return SVN_NO_ERROR;
+ }
else if (wc_kind == svn_wc__db_kind_unknown)
versioned_locally_and_present = FALSE; /* Tree conflict ACTUAL-only node */
else
@@ -2116,7 +2147,6 @@ add_directory(const char *path,
A dir added with history is a tree conflict. */
- svn_boolean_t local_is_dir;
svn_boolean_t local_is_non_dir;
svn_wc__db_status_t add_status = svn_wc__db_status_normal;
@@ -2128,50 +2158,10 @@ add_directory(const char *path,
pool, pool));
- /* Is there something that is a file? */
- local_is_dir = (wc_kind == svn_wc__db_kind_dir
- && status != svn_wc__db_status_deleted);
-
/* Is there *something* that is not a dir? */
local_is_non_dir = (wc_kind != svn_wc__db_kind_dir
&& status != svn_wc__db_status_deleted);
- if (local_is_dir)
- {
- const char *wcroot_abspath;
-
- SVN_ERR(svn_wc__db_get_wcroot(&wcroot_abspath, eb->db,
- db->local_abspath, pool, pool));
-
- if (! strcmp(wcroot_abspath, db->local_abspath))
- {
- /* Problem: We have a separate working copy in place where
- we would like to add a new node.
-
- Any change to this node would change the sub-working copy
- instead of our own working copy!!!
-
- So, the only safe thing to do is to return with an error. A
- future update will resolve this problem, because the
- parent directory will be marked incomplete.
- */
-
- /* ### In 1.6 we provided a bit more information on
- what kind of working copy was found */
- err = svn_error_createf(
- SVN_ERR_WC_OBSTRUCTED_UPDATE, NULL,
- _("Failed to add directory '%s': a separate "
- "working copy with the same name already exists"),
- svn_dirent_local_style(db->local_abspath, pool));
-
- db->already_notified = TRUE;
- do_notification(eb, db->local_abspath, svn_node_dir,
- svn_wc_notify_update_obstruction, pool);
-
- return svn_error_return(err);
- }
- }
-
/* Do tree conflict checking if
* - if there is a local copy.
* - if this is a switch operation
@@ -2179,20 +2169,10 @@ add_directory(const char *path,
*
* During switch, local adds at the same path as incoming adds get
* "lost" in that switching back to the original will no longer have the
- * local add. So switch always alerts the user with a tree conflict.
- *
- * Allow pulling absent/exluded/not_present nodes back in.
- *
- * ### We would also like to be checking copyfrom infos to not flag tree
- * conflicts on two copies with identical history. But at the time of
- * writing, add_directory() does not get any copyfrom information. */
- if (! db->shadowed
- && (eb->switch_relpath != NULL
- || local_is_non_dir
- || add_status == svn_wc__db_status_copied
- || add_status == svn_wc__db_status_moved_here
- )
- )
+ * local add. So switch always alerts the user with a tree conflict. */
+ if (eb->switch_relpath != NULL
+ || local_is_non_dir
+ || add_status != svn_wc__db_status_added)
{
SVN_ERR(check_tree_conflict(&tree_conflict, eb,
db->local_abspath,
@@ -2201,18 +2181,10 @@ add_directory(const char *path,
svn_node_dir, db->new_relpath, pool));
}
-
if (tree_conflict == NULL)
- {
- /* We have a node in WORKING and we've decided not to flag a
- * conflict, so merge it with the incoming add. */
- db->add_existed = TRUE;
- }
+ db->add_existed = TRUE; /* Take over WORKING */
else
- {
- /* Add the node as deleted */
- db->shadowed = TRUE;
- }
+ db->shadowed = TRUE; /* Only update BASE */
}
else if (kind != svn_node_none)
{
@@ -2899,6 +2871,39 @@ add_file(const char *path,
versioned_locally_and_present = FALSE;
}
+ else if (wc_kind == svn_wc__db_kind_dir
+ && status == svn_wc__db_status_normal)
+ {
+ /* !! We found the root of a separate working copy obstructing the wc !!
+
+ If the directory would be part of our own working copy then
+ we wouldn't have been called as an add_file().
+
+ The only thing we can do is add a not-present node, to allow
+ a future update to bring in the new files when the problem is
+ resolved. Note that svn_wc__db_base_add_not_present_node()
+ explicitly adds the node into the parent's node database. */
+
+ SVN_ERR(svn_wc__db_base_add_not_present_node(eb->db, fb->local_abspath,
+ fb->new_relpath,
+ eb->repos_root,
+ eb->repos_uuid,
+ *eb->target_revision,
+ svn_wc__db_kind_file,
+ NULL, NULL,
+ pool));
+
+ remember_skipped_tree(eb, fb->local_abspath, pool);
+ fb->skip_this = TRUE;
+ fb->already_notified = TRUE;
+
+ do_notification(eb, fb->local_abspath, svn_node_file,
+ svn_wc_notify_update_skip_obstruction, scratch_pool);
+
+ svn_pool_destroy(scratch_pool);
+
+ return SVN_NO_ERROR;
+ }
else if (wc_kind == svn_wc__db_kind_unknown)
versioned_locally_and_present = FALSE; /* Tree conflict ACTUAL-only node */
else
@@ -2979,46 +2984,17 @@ add_file(const char *path,
local_is_file = (wc_kind == svn_wc__db_kind_file
|| wc_kind == svn_wc__db_kind_symlink);
- if (local_is_file)
- {
- svn_boolean_t wc_root;
- svn_boolean_t switched;
-
- SVN_ERR(svn_wc__check_wc_root(&wc_root, NULL, &switched,
- eb->db, fb->local_abspath, scratch_pool));
-
- err = NULL;
-
- if (switched && !eb->switch_relpath)
- {
- err = svn_error_createf(
- SVN_ERR_WC_OBSTRUCTED_UPDATE, NULL,
- _("Switched file '%s' does not match "
- "expected URL '%s'"),
- svn_dirent_local_style(fb->local_abspath, pool),
- svn_path_url_add_component2(eb->repos_root,
- fb->new_relpath, pool));
- }
-
- if (err != NULL)
- {
- fb->already_notified = TRUE;
- do_notification(eb, fb->local_abspath, svn_node_file,
- svn_wc_notify_update_obstruction, scratch_pool);
-
- svn_pool_clear(scratch_pool);
- return svn_error_return(err);
- }
- }
-
- /* Don't perform tree conflict checking if
- * - if we are in a deleted subtree
- * - if this is a normal file addition and we we are switching
- */
- if (! fb->shadowed
- && (eb->switch_relpath != NULL
- || !local_is_file
- || status != svn_wc__db_status_added))
+ /* Do tree conflict checking if
+ * - if there is a local copy.
+ * - if this is a switch operation
+ * - the node kinds mismatch
+ *
+ * During switch, local adds at the same path as incoming adds get
+ * "lost" in that switching back to the original will no longer have the
+ * local add. So switch always alerts the user with a tree conflict. */
+ if (eb->switch_relpath != NULL
+ || !local_is_file
+ || status != svn_wc__db_status_added)
{
SVN_ERR(check_tree_conflict(&tree_conflict, eb,
fb->local_abspath,
@@ -3029,14 +3005,9 @@ add_file(const char *path,
}
if (tree_conflict == NULL)
- /* We have a node in WORKING and we've decided not to flag a
- * conflict, so merge it with the incoming add. */
- fb->add_existed = TRUE;
+ fb->add_existed = TRUE; /* Take over WORKING */
else
- /* We have a tree conflict of a local add vs. an incoming add.
- * We want to update BASE only, scheduling WORKING as a replace
- * of BASE so that WORKING/ACTUAL stay unchanged. */
- fb->shadowed = TRUE;
+ fb->shadowed = TRUE; /* Only update BASE */
}
else if (kind != svn_node_none)
@@ -3048,6 +3019,7 @@ add_file(const char *path,
* if unversioned obstructions are allowed. */
if (! (kind == svn_node_file && eb->allow_unver_obstructions))
{
+ /* Bring in the node as deleted */ /* ### Obstructed Conflict */
fb->shadowed = TRUE;
/* Mark a conflict */
Modified: subversion/trunk/subversion/svn/notify.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/svn/notify.c?rev=1090240&r1=1090239&r2=1090240&view=diff
==============================================================================
--- subversion/trunk/subversion/svn/notify.c (original)
+++ subversion/trunk/subversion/svn/notify.c Fri Apr 8 13:19:59 2011
@@ -149,7 +149,13 @@ notify(void *baton, const svn_wc_notify_
goto print_error;
}
break;
-
+ case svn_wc_notify_update_skip_obstruction:
+ nb->skipped_paths++;
+ if ((err = svn_cmdline_printf(
+ pool, _("Skipped '%s' -- An obstructing working copy was found\n"),
+ path_local)))
+ goto print_error;
+ break;
case svn_wc_notify_update_delete:
case svn_wc_notify_update_external_removed:
nb->received_some_change = TRUE;
Modified: subversion/trunk/subversion/tests/cmdline/checkout_tests.py
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/tests/cmdline/checkout_tests.py?rev=1090240&r1=1090239&r2=1090240&view=diff
==============================================================================
--- subversion/trunk/subversion/tests/cmdline/checkout_tests.py (original)
+++ subversion/trunk/subversion/tests/cmdline/checkout_tests.py Fri Apr 8 13:19:59 2011
@@ -473,19 +473,27 @@ def forced_checkout_with_versioned_obstr
# Checkout the entire first repos into the fresh dir. This should
# fail because A is already checked out. (Ideally, we'd silently
# incorporate A's working copy into its parent working copy.)
- exit_code, sout, serr = svntest.actions.run_and_verify_svn(
- "Expected error during co", None, svntest.verify.AnyOutput,
- "co", "--force", repo_url, fresh_wc_dir)
-
- test_stderr("Failed to add directory '.*A'.*already exists", serr)
+ expected_output = svntest.wc.State(fresh_wc_dir, {
+ 'iota' : Item(status='A '),
+ 'A' : Item(verb='Skipped'),
+ })
+ expected_wc = svntest.main.greek_state.copy()
+ svntest.actions.run_and_verify_checkout(repo_url, fresh_wc_dir,
+ expected_output, expected_wc,
+ None, None, None, None,
+ '--force')
# Checkout the entire first repos into the other dir. This should
# fail because it's a different repository.
- exit_code, sout, serr = svntest.actions.run_and_verify_svn(
- "Expected error during co", None, svntest.verify.AnyOutput,
- "co", "--force", repo_url, other_wc_dir)
-
- test_stderr("(Failed to add directory|UUID mismatch:).*'.*A'", serr)
+ expected_output = svntest.wc.State(other_wc_dir, {
+ 'iota' : Item(status='A '),
+ 'A' : Item(verb='Skipped'),
+ })
+ expected_wc = svntest.main.greek_state.copy()
+ svntest.actions.run_and_verify_checkout(repo_url, other_wc_dir,
+ expected_output, expected_wc,
+ None, None, None, None,
+ '--force')
#ensure that other_wc_dir_A is not affected by this forced checkout.
svntest.actions.run_and_verify_svn("empty status output", None,
Modified: subversion/trunk/subversion/tests/cmdline/svntest/wc.py
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/tests/cmdline/svntest/wc.py?rev=1090240&r1=1090239&r2=1090240&view=diff
==============================================================================
--- subversion/trunk/subversion/tests/cmdline/svntest/wc.py (original)
+++ subversion/trunk/subversion/tests/cmdline/svntest/wc.py Fri Apr 8 13:19:59 2011
@@ -83,7 +83,7 @@ _re_parse_status = re.compile('^([?!MACD
'((?P<wc_rev>\d+|-|\?) +(\d|-|\?)+ +(\S+) +)?'
'(?P<path>.+)$')
-_re_parse_skipped = re.compile("^Skipped.* '(.+)'\n")
+_re_parse_skipped = re.compile("^Skipped[^']* '(.+)'( --.*)?\n")
_re_parse_summarize = re.compile("^([MAD ][M ]) (.+)\n")
@@ -91,7 +91,7 @@ _re_parse_checkout = re.compile('^([RMAG
'([B ])'
'([CAUD ])\s+'
'(.+)')
-_re_parse_co_skipped = re.compile('^(Restored|Skipped)\s+\'(.+)\'')
+_re_parse_co_skipped = re.compile('^(Restored|Skipped)\s+\'(.+)\'( --.*)?')
_re_parse_co_restored = re.compile('^(Restored)\s+\'(.+)\'')
# Lines typically have a verb followed by whitespace then a path.
Modified: subversion/trunk/subversion/tests/cmdline/switch_tests.py
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/tests/cmdline/switch_tests.py?rev=1090240&r1=1090239&r2=1090240&view=diff
==============================================================================
--- subversion/trunk/subversion/tests/cmdline/switch_tests.py (original)
+++ subversion/trunk/subversion/tests/cmdline/switch_tests.py Fri Apr 8 13:19:59 2011
@@ -1553,11 +1553,19 @@ def forced_switch_failures(sbox):
# Try the forced switch. A/D/G/I obstructs the dir A/D/G/I coming
# from the repos, causing an error.
# svn switch --force url/A/D/H A/D/G
- expected_error = ('Failed to add directory.*' + re.escape(A_D_G_I) +
- '.*a separate working copy.*already exists')
+ expected_output = svntest.wc.State(wc_dir, {
+ 'A/D/G/chi' : Item(status='A '),
+ 'A/D/G/tau' : Item(status='D '),
+ 'A/D/G/omega' : Item(status='A '),
+ 'A/D/G/psi' : Item(status='A '),
+ 'A/D/G/I' : Item(verb='Skipped'),
+ 'A/D/G/rho' : Item(status='D '),
+ 'A/D/G/pi' : Item(status='D '),
+ })
- actions.run_and_verify_switch(wc_dir, A_D_G, url_A_D_H, None, None, None,
- expected_error, None, None, None, None,
+ actions.run_and_verify_switch(wc_dir, A_D_G, url_A_D_H, expected_output,
+ None, None, None,
+ None, None, None, None,
False, '--force', '--ignore-ancestry')
# Delete all three obstructions and finish the update.
@@ -1580,9 +1588,7 @@ def forced_switch_failures(sbox):
# svn up
expected_output = svntest.wc.State(wc_dir, {
'A/C/H/I' : Item(status='A '),
- 'A/D/G/omega' : Item(status='A '),
'A/D/G/I' : Item(status='A '),
- 'A/D/G/psi' : Item(status='A '),
'A/D/H/I' : Item(status='A '),
})
Modified: subversion/trunk/subversion/tests/cmdline/update_tests.py
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/tests/cmdline/update_tests.py?rev=1090240&r1=1090239&r2=1090240&view=diff
==============================================================================
--- subversion/trunk/subversion/tests/cmdline/update_tests.py (original)
+++ subversion/trunk/subversion/tests/cmdline/update_tests.py Fri Apr 8 13:19:59 2011
@@ -2313,13 +2313,12 @@ def forced_update_failures(sbox):
expected_output, expected_disk, None, None, None, None)
# svn up --force wc_dir_backup/A/C
- expected_error = (
- "svn: E155000: Failed to add directory .*I.*working copy with the same name "
- + "already exists"
- )
+ expected_output = svntest.wc.State(wc_dir_backup, {
+ 'A/C/I' : Item(verb='Skipped'),
+ })
- actions.run_and_verify_update(wc_dir_backup, None, None, None,
- expected_error, None, None, None, None, False, '--force', backup_A_C)
+ actions.run_and_verify_update(wc_dir_backup, expected_output, None, None,
+ None, None, None, None, None, False, '--force', backup_A_C)
#----------------------------------------------------------------------