[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Re: [PATCH] [Issue 1751] file not switched if it is the same in source and destination

From: makl <makl_at_tigris.org>
Date: 2004-03-23 08:08:05 CET

Version 2 of the patch.

[[[
Fix remaining part of issue 1751. File not switched if it is the same
in source and destination.

Patch from <makl@tigris.org>

* subversion/tests/clients/cmdline/switch_tests.py
        (main): Remove XFAIL from nonrecursive_switching.
        (nonrecursive_switching): Extend the test to ensure that
        subdirectories are not switched.

* subversion/libsvn_wc/adm_ops.c
        (tweak_entries): Change of non_recursively_tweak_entries to be
        non recursiv if it is necessary.
        (svn_wc__do_update_cleanup): Call tweak_entries.
]]]

Index: subversion/libsvn_wc/adm_ops.c
===================================================================
--- subversion/libsvn_wc/adm_ops.c (revision 9193)
+++ subversion/libsvn_wc/adm_ops.c (working copy)
@@ -54,15 +54,16 @@
 /*** Finishing updates and commits. ***/
 
 
-/* The main recursive body of svn_wc__do_update_cleanup. */
+/* The main body of svn_wc__do_update_cleanup. */
 static svn_error_t *
-recursively_tweak_entries (svn_wc_adm_access_t *dirpath,
- const char *base_url,
- svn_revnum_t new_rev,
- svn_wc_notify_func_t notify_func,
- void *notify_baton,
- svn_boolean_t remove_missing_dirs,
- apr_pool_t *pool)
+tweak_entries (svn_wc_adm_access_t *dirpath,
+ const char *base_url,
+ svn_revnum_t new_rev,
+ svn_wc_notify_func_t notify_func,
+ void *notify_baton,
+ svn_boolean_t remove_missing_dirs,
+ svn_boolean_t recurse,
+ apr_pool_t *pool)
 {
   apr_hash_t *entries;
   apr_hash_index_t *hi;
@@ -70,7 +71,7 @@
   svn_boolean_t write_required = FALSE;
   
   /* Read DIRPATH's entries. */
- SVN_ERR (svn_wc_entries_read (&entries, dirpath, TRUE, subpool));
+ SVN_ERR (svn_wc_entries_read (&entries, dirpath, TRUE, pool));
 
   /* Tweak "this_dir" */
   SVN_ERR (svn_wc__tweak_entry (entries, SVN_WC_ENTRY_THIS_DIR,
@@ -78,7 +79,7 @@
                                 svn_wc_adm_access_pool (dirpath)));
 
   /* Recursively loop over all children. */
- for (hi = apr_hash_first (subpool, entries); hi; hi = apr_hash_next (hi))
+ for (hi = apr_hash_first (pool, entries); hi; hi = apr_hash_next (hi))
     {
       const void *key;
       void *val;
@@ -86,6 +87,8 @@
       svn_wc_entry_t *current_entry;
       const char *child_url = NULL;
 
+ svn_pool_clear (subpool);
+
       apr_hash_this (hi, &key, NULL, &val);
       name = key;
       current_entry = val;
@@ -98,19 +101,18 @@
       if (base_url)
         child_url = svn_path_url_add_component (base_url, name, subpool);
       
- /* If a file, or deleted or absent dir, then tweak the entry but
- don't recurse. */
+ /* If a file, or deleted or absent dir in recursive mode, then tweak the
+ entry but don't recurse. */
       if ((current_entry->kind == svn_node_file)
- || current_entry->deleted
- || current_entry->absent)
+ || (recurse && (current_entry->deleted || current_entry->absent)))
         {
           SVN_ERR (svn_wc__tweak_entry (entries, name,
                                         child_url, new_rev, &write_required,
                                         svn_wc_adm_access_pool (dirpath)));
         }
       
- /* If a directory... */
- else if (current_entry->kind == svn_node_dir)
+ /* If a directory and recursiv... */
+ else if (recurse && (current_entry->kind == svn_node_dir))
         {
           const char *child_path
             = svn_path_join (svn_wc_adm_access_path (dirpath), name, subpool);
@@ -142,9 +144,9 @@
               svn_wc_adm_access_t *child_access;
               SVN_ERR (svn_wc_adm_retrieve (&child_access, dirpath, child_path,
                                             subpool));
- SVN_ERR (recursively_tweak_entries
+ SVN_ERR (tweak_entries
                        (child_access, child_url, new_rev, notify_func,
- notify_baton, remove_missing_dirs, subpool));
+ notify_baton, remove_missing_dirs, TRUE, subpool));
             }
         }
     }
@@ -200,20 +202,13 @@
       SVN_ERR (svn_wc_adm_retrieve (&dir_access, adm_access, path, pool));
 
       if (! recursive)
- {
- svn_boolean_t write_required = FALSE;
- SVN_ERR (svn_wc_entries_read (&entries, dir_access, TRUE, pool));
- SVN_ERR (svn_wc__tweak_entry (entries, SVN_WC_ENTRY_THIS_DIR,
- base_url, new_revision, &write_required,
- svn_wc_adm_access_pool (dir_access)));
- if (write_required)
- SVN_ERR (svn_wc__entries_write (entries, dir_access, pool));
- }
+ SVN_ERR (tweak_entries (dir_access, base_url, new_revision,
+ NULL, NULL, FALSE,
+ FALSE, pool));
       else
- SVN_ERR (recursively_tweak_entries (dir_access, base_url,
- new_revision, notify_func,
- notify_baton, remove_missing_dirs,
- pool));
+ SVN_ERR (tweak_entries (dir_access, base_url, new_revision,
+ notify_func, notify_baton, remove_missing_dirs,
+ TRUE, pool));
     }
 
   else
Index: subversion/tests/clients/cmdline/switch_tests.py
===================================================================
--- subversion/tests/clients/cmdline/switch_tests.py (revision 9193)
+++ subversion/tests/clients/cmdline/switch_tests.py (working copy)
@@ -636,9 +636,12 @@
   wc1_new_file = os.path.join(wc1_dir, 'branch', 'version1', 'newfile')
   wc2_new_file = os.path.join(wc2_dir, 'newfile')
   wc2_mu_file = os.path.join(wc2_dir, 'mu')
+ wc2_B_dir = os.path.join(wc2_dir, 'B')
+ wc2_C_dir = os.path.join(wc2_dir, 'C')
+ wc2_D_dir = os.path.join(wc2_dir, 'D')
   
   # Check out the trunk as "wc2"
- svntest.main.run_svn(None, 'co', '-N', trunk_url, wc2_dir)
+ svntest.main.run_svn(None, 'co', trunk_url, wc2_dir)
 
   # Make a branch, and add a new file, in "wc_dir" and repository
   svntest.main.run_svn(None, 'mkdir', '-m', '', branch_url)
@@ -652,6 +655,25 @@
   svntest.actions.run_and_verify_svn(None, None, [],
                                      'switch', '-N', version1_url, wc2_dir)
 
+ # Check the URLs of the (not switched) directories.
+ out, err = svntest.actions.run_and_verify_svn(None, None, [],
+ 'info', wc2_B_dir)
+ if out[1].find('/A/B') == -1:
+ print out[1]
+ raise svntest.Failure
+
+ out, err = svntest.actions.run_and_verify_svn(None, None, [],
+ 'info', wc2_C_dir)
+ if out[1].find('/A/C') == -1:
+ print out[1]
+ raise svntest.Failure
+
+ out, err = svntest.actions.run_and_verify_svn(None, None, [],
+ 'info', wc2_D_dir)
+ if out[1].find('/A/D') == -1:
+ print out[1]
+ raise svntest.Failure
+
   # Check the URLs of the switched files.
   # ("svn status -u" might be a better check: it fails when newfile's URL
   # is bad, and shows "S" when mu's URL is wrong.)
@@ -744,7 +766,7 @@
               relocate_deleted_and_missing,
               delete_subdir,
               XFail(file_dir_file),
- XFail(nonrecursive_switching),
+ nonrecursive_switching,
               failed_anchor_is_target,
              ]
 

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Tue Mar 23 08:06:11 2004

This is an archived mail posted to the Subversion Dev mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.