Author: rhuijben
Date: Fri Jan 11 09:49:38 2013
New Revision: 1431957

URL: http://svn.apache.org/viewvc?rev=1431957&view=rev
Log:
Resolve a small restore issue found while writing a test for issue #4288.

* subversion/libsvn_wc/adm_crawler.c
  (svn_wc_restore): Avoid unneeded db call.
  (report_revisions_and_depths): Don't try to restore nodes below a
     non-directory. This wil fail if one of the ancestors is a file.

* subversion/tests/cmdline/update_tests.py
  (update_replace_obstruction): New partial test for issue #4288, showing the
    restore issue.
  (test_list): Add test

Modified:
    subversion/trunk/subversion/libsvn_wc/adm_crawler.c
    subversion/trunk/subversion/tests/cmdline/update_tests.py

Modified: subversion/trunk/subversion/libsvn_wc/adm_crawler.c
URL: 
http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/adm_crawler.c?rev=1431957&r1=1431956&r2=1431957&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/adm_crawler.c (original)
+++ subversion/trunk/subversion/libsvn_wc/adm_crawler.c Fri Jan 11 09:49:38 2013
@@ -104,6 +104,7 @@ svn_wc_restore(svn_wc_context_t *wc_ctx,
   svn_wc__db_status_t status;
   svn_kind_t kind;
   svn_node_kind_t disk_kind;
+  const svn_checksum_t *checksum;
 
   SVN_ERR(svn_io_check_path(local_abspath, &disk_kind, scratch_pool));
 
@@ -113,27 +114,19 @@ svn_wc_restore(svn_wc_context_t *wc_ctx,
                              svn_dirent_local_style(local_abspath,
                                                     scratch_pool));
 
-
-
   SVN_ERR(svn_wc__db_read_info(&status, &kind, NULL, NULL, NULL, NULL, NULL,
-                               NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
+                               NULL, NULL, NULL, &checksum, NULL, NULL, NULL, 
NULL,
                                NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
                                NULL, NULL, NULL, NULL,
                                wc_ctx->db, local_abspath,
                                scratch_pool, scratch_pool));
 
-  if (status == svn_wc__db_status_added)
-    SVN_ERR(svn_wc__db_scan_addition(&status, NULL, NULL, NULL, NULL, NULL,
-                                     NULL, NULL, NULL, NULL, NULL,
-                                     wc_ctx->db, local_abspath,
-                                     scratch_pool, scratch_pool));
-
   if (status != svn_wc__db_status_normal
-      && status != svn_wc__db_status_copied
-      && status != svn_wc__db_status_moved_here
-      && !(kind == svn_kind_dir
-           && (status == svn_wc__db_status_added
-               || status == svn_wc__db_status_incomplete)))
+      && !((status == svn_wc__db_status_added 
+            || status == svn_wc__db_status_incomplete)
+           && (kind == svn_kind_dir
+               || (kind == svn_kind_file && checksum != NULL)
+               /* || (kind == svn_kind_symlink && target)*/)))
     {
       return svn_error_createf(SVN_ERR_WC_PATH_UNEXPECTED_STATUS, NULL,
                                _("The node '%s' can not be restored."),
@@ -278,7 +271,11 @@ report_revisions_and_depths(svn_wc__db_t
                   || SVN__APR_STATUS_IS_ENOTDIR(err->apr_err)))
         {
           svn_error_clear(err);
-          dirents = apr_hash_make(scratch_pool);
+          /* There is no directory, and if we could create the directory
+             we would have already created it when walking the parent
+             directory */
+          restore_files = FALSE;
+          dirents = NULL;
         }
       else
         SVN_ERR(err);

Modified: subversion/trunk/subversion/tests/cmdline/update_tests.py
URL: 
http://svn.apache.org/viewvc/subversion/trunk/subversion/tests/cmdline/update_tests.py?rev=1431957&r1=1431956&r2=1431957&view=diff
==============================================================================
--- subversion/trunk/subversion/tests/cmdline/update_tests.py (original)
+++ subversion/trunk/subversion/tests/cmdline/update_tests.py Fri Jan 11 
09:49:38 2013
@@ -5814,6 +5814,47 @@ def update_with_parents_and_exclude(sbox
                                         '--parents',
                                         sbox.ospath('A/B'))
 
+@Issue(4288)
+@XFail()
+def update_replace_obstruction(sbox):
+  "delete shouldn't cause update failure"
+
+  sbox.build()
+  wc_dir = sbox.wc_dir
+
+  # r2
+  sbox.simple_rm('A/B','iota')
+  sbox.simple_commit()
+
+  # r3
+  sbox.simple_mkdir('iota')
+  sbox.simple_copy('A/D/gamma', 'A/B')
+  sbox.simple_commit()
+
+  sbox.simple_update('', 1)
+
+  # Create obstructions
+  svntest.main.safe_rmtree(sbox.ospath('A/B'))
+  os.remove(sbox.ospath('iota'))
+  os.mkdir(sbox.ospath('iota'))
+  svntest.main.file_append(sbox.ospath('A/B'), "Obstruction")
+
+  # ### This expected result is not OK yet, currently the update
+  # ### just fails with an error before doing any work
+  expected_status = svntest.actions.get_virginal_state(wc_dir, 2)
+  expected_disk = svntest.main.greek_state.copy()
+  expected_output = svntest.wc.State(wc_dir, {
+  })
+
+  # And now update to delete B and iota
+  svntest.actions.run_and_verify_update(wc_dir,
+                                        expected_output,
+                                        expected_disk,
+                                        expected_status,
+                                        None, None, None,
+                                        None, None, 1,
+                                        '-r', '2', wc_dir)
+
 
 #######################################################################
 # Run the tests
@@ -5889,6 +5930,7 @@ test_list = [ None,
               update_move_text_mod,
               update_nested_move_text_mod,
               update_with_parents_and_exclude,
+              update_replace_obstruction,
              ]
 
 if __name__ == '__main__':


Reply via email to