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

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

From: makl <makl_at_tigris.org>
Date: 2004-03-14 14:53:24 CET

[[[
Fix 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
       (non_recursively_tweak_entries): New function similar to
       recursively_tweak_entries but non recursive.
       (svn_wc__do_update_cleanup): Call non_recursively_tweak_entries
]]]

Index: subversion/libsvn_wc/adm_ops.c
===================================================================
--- subversion/libsvn_wc/adm_ops.c (revision 9041)
+++ subversion/libsvn_wc/adm_ops.c (working copy)
@@ -161,6 +161,69 @@
 
 
 
+/* The main non-recursive body of svn_wc__do_update_cleanup. */
+static svn_error_t *
+non_recursively_tweak_entries (svn_wc_adm_access_t *dirpath,
+ const char *base_url,
+ svn_revnum_t new_rev,
+ apr_pool_t *pool)
+{
+ apr_hash_t *entries;
+ apr_hash_index_t *hi;
+ apr_pool_t *subpool = svn_pool_create (pool);
+ svn_boolean_t write_required = FALSE;
+
+ /* Read DIRPATH's entries. */
+ SVN_ERR (svn_wc_entries_read (&entries, dirpath, TRUE, subpool));
+
+ /* Tweak "this_dir" */
+ SVN_ERR (svn_wc__tweak_entry (entries, SVN_WC_ENTRY_THIS_DIR,
+ base_url, new_rev, &write_required,
+ svn_wc_adm_access_pool (dirpath)));
+
+ /* Recursively loop over all children. */
+ for (hi = apr_hash_first (subpool, entries); hi; hi = apr_hash_next (hi))
+ {
+ const void *key;
+ void *val;
+ const char *name;
+ svn_wc_entry_t *current_entry;
+ const char *child_url = NULL;
+
+ apr_hash_this (hi, &key, NULL, &val);
+ name = key;
+ current_entry = val;
+
+ /* Ignore the "this dir" entry. */
+ if (! strcmp (name, SVN_WC_ENTRY_THIS_DIR))
+ continue;
+
+ /* Derive the new URL for the current (child) entry */
+ 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 (current_entry->kind == svn_node_file)
+ {
+ SVN_ERR (svn_wc__tweak_entry (entries, name,
+ child_url, new_rev, &write_required,
+ svn_wc_adm_access_pool (dirpath)));
+ }
+ }
+
+ /* Write a shiny new entries file to disk. */
+ if (write_required)
+ SVN_ERR (svn_wc__entries_write (entries, dirpath, subpool));
+
+ /* Cleanup */
+ svn_pool_destroy (subpool);
+
+ return SVN_NO_ERROR;
+}
+
+
+
 svn_error_t *
 svn_wc__do_update_cleanup (const char *path,
                            svn_wc_adm_access_t *adm_access,
@@ -200,15 +263,8 @@
       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 (non_recursively_tweak_entries (dir_access, base_url,
+ new_revision, pool));
       else
         SVN_ERR (recursively_tweak_entries (dir_access, base_url,
                                             new_revision, notify_func,
Index: subversion/tests/clients/cmdline/switch_tests.py
===================================================================
--- subversion/tests/clients/cmdline/switch_tests.py (revision 9041)
+++ 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 Sun Mar 14 14:51:36 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.