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

[patch]: make svn delete remove the file

From: William Uther <will+_at_cs.cmu.edu>
Date: 2002-04-22 02:13:04 CEST

Hi all,

  This is a patch for issue 611. It fixes the problem for files, but not
dirs. After this patch, 'svn rm' will remove unmodified files. It will not
remove dirs. It will remove modified files if '--force' is passed.

  This is my first patch submitted, so if people could check it carefully,
that'd be good. It is similar to a by patch Yoshiki Hayashi. It also
includes changes to the tests where required.

Later,

\x/ill :-}

* delete.c (svn_client_delete): Now removes the working version of a file if
it's unmodified or if '--force' is passed. 'svn rm' never removes the
working version of a directory.

* main.c (svn_cl__cmd_table): Modified 'svn help rm' string to bring it in
line with new behaviour.

* update_tests.py (update_ignores_added): Changed tests to account for new
delete behaviour.

* commit_tests.py (test_standard_slew_of_changes): New test to test the
make_standard_slew_of_changes function by itself.
(test_list): Added new test to list of tests.
(make_standard_slew_of_changes, hudson_part_1, hudson_part_1_variation_2,
 commit_rmd_and_deleted_file): Changed tests to account for new 'svn delete'
behaviour.

Index: ./subversion/libsvn_client/delete.c
===================================================================
--- ./subversion/libsvn_client/delete.c
+++ ./subversion/libsvn_client/delete.c Sun Apr 21 19:35:16 2002
@@ -29,6 +29,7 @@
 #include "svn_string.h"
 #include "svn_error.h"
 #include "svn_path.h"
+#include "svn_io.h"
 #include "client.h"
 
 
@@ -48,6 +49,8 @@
 {
   apr_status_t apr_err;
   svn_string_t str;
+ enum svn_node_kind kind;
+ svn_boolean_t modified;
 
   str.data = path->data;
   str.len = path->len;
@@ -125,10 +128,15 @@
       return SVN_NO_ERROR;
     }
   
+ /* Get entries info BEFORE we remove it from the entries file */
+ SVN_ERR (svn_io_check_path (path->data, &kind, pool));
+ SVN_ERR (svn_wc_text_modified_p (&modified, path, pool));
+
   /* Mark the entry for deletion. */
   SVN_ERR (svn_wc_delete (path, notify_func, notify_baton, pool));
 
- if (force)
+ if ((kind == svn_node_file)
+ && (force || !modified))
     {
       /* Remove the file. */
       apr_err = apr_file_remove (path->data, pool);
Index: ./subversion/clients/cmdline/main.c
===================================================================
--- ./subversion/clients/cmdline/main.c
+++ ./subversion/clients/cmdline/main.c Sun Apr 21 19:03:31 2002
@@ -157,8 +157,9 @@
     "Remove files and directories from version control.\n"
     "usage: svn delete [TARGET | URL]\n\n"
     " If run on a working-copy TARGET, item is scheduled for deletion\n"
- " upon next commit. (The working item itself will only be
removed\n"
- " if --force is passed.) If run on URL, item is deleted from\n"
+ " upon next commit. (The working item itself will be removed\n"
+ " if it is a file and either the file is unmodified or\n"
+ " --force is passed.) If run on URL, item is deleted from\n"
     " repository via an immediate commit.\n",
     {svn_cl__force_opt, 'm', 'F', svn_cl__targets_opt,
      svn_cl__auth_username_opt, svn_cl__auth_password_opt} },
Index: ./subversion/tests/clients/cmdline/update_tests.py
===================================================================
--- ./subversion/tests/clients/cmdline/update_tests.py
+++ ./subversion/tests/clients/cmdline/update_tests.py Sun Apr 21
18:30:23 2002
@@ -393,7 +393,7 @@
   # Schedule another file, say, 'gamma', for replacement.
   gamma_path = os.path.join(wc_dir, 'A', 'D', 'gamma')
   svntest.main.run_svn(None, 'delete', gamma_path)
- svntest.main.file_append(gamma_path, "\nThis is a new 'gamma' now.")
+ svntest.main.file_append(gamma_path, "This is a new 'gamma' now.")
   svntest.main.run_svn(None, 'add', gamma_path)
   
   # Now update. "zeta at revision 0" should *not* be reported at all,
@@ -410,7 +410,7 @@
   my_greek_tree.append(['A/B/zeta', "This is the file 'zeta'.", {}, {}])
   for item in my_greek_tree:
     if item[0] == 'A/D/gamma':
- item[1] = "This is the file 'gamma'.\nThis is a new 'gamma' now."
+ item[1] = "This is a new 'gamma' now."
     if item[0] == 'A/D/G/rho':
       item[1] = "This is the file 'rho'.\nMore stuff in rho."
   expected_disk_tree = svntest.tree.build_generic_tree(my_greek_tree)
Index: ./subversion/tests/clients/cmdline/commit_tests.py
===================================================================
--- ./subversion/tests/clients/cmdline/commit_tests.py
+++ ./subversion/tests/clients/cmdline/commit_tests.py Sun Apr 21
18:47:50 2002
@@ -119,6 +119,7 @@
   svntest.main.run_svn(None, 'rm', os.path.join('A', 'D', 'gamma'))
   
   # Replace one of the removed files
+ svntest.main.file_append(os.path.join('A', 'D', 'H', 'chi'), "new chi")
   svntest.main.run_svn(None, 'add', os.path.join('A', 'D', 'H', 'chi'))
   
   # Make textual mods to two files
@@ -152,6 +153,19 @@
 #
 # Each test must return 0 on success or non-zero on failure.
 
+#----------------------------------------------------------------------
+
+def test_standard_slew_of_changes(sbox):
+ "test standard changes."
+
+ if sbox.build():
+ return 1
+
+ wc_dir = sbox.wc_dir
+
+ # Make standard slew of changes to working copy.
+ return make_standard_slew_of_changes(wc_dir)
+
 
 #----------------------------------------------------------------------
 
@@ -665,8 +679,9 @@
   expected_output_tree = svntest.tree.build_generic_tree(\
     [ [gamma_path, None, {}, {'status' : 'D ' }] ])
 
- # Expected disk tree: everything.
+ # Expected disk tree: everything but gamma.
   my_greek_tree = svntest.main.copy_greek_tree()
+ my_greek_tree.pop(path_index(my_greek_tree, 'A/D/gamma'))
   expected_disk_tree = svntest.tree.build_generic_tree(my_greek_tree)
   
   # Expected status after update: totally clean revision 2, minus gamma.
@@ -784,7 +799,11 @@
                                             wc_dir):
     return 1
 
- # Now gamma should be marked as `deleted' under the hood.
+ # Now gamma should be marked as `deleted' under the hood,
+ # and the file deleted.
+ # Re-create gamma, so there is a file to add.
+ svntest.main.file_append(gamma_path, "This is the file 'gamma'.")
+
   # Go ahead and re-add gamma, so that is *also* scheduled for addition.
   svntest.main.run_svn(None, 'add', gamma_path)
 
@@ -1276,9 +1295,6 @@
   # 'svn remove' mu
   svntest.main.run_svn(None, 'rm', mu_path)
 
- # Now, physically remove mu from disk
- os.unlink(mu_path)
-
   # Commit, hoping to see no errors
   out, err = svntest.main.run_svn(None, 'commit', '-m', '"logmsg"',
mu_path)
   if len(err) != 0:
@@ -1292,6 +1308,7 @@
 
 # list all tests here, starting with None:
 test_list = [ None,
+ test_standard_slew_of_changes,
               commit_one_file,
               commit_one_new_file,
               commit_multiple_targets,

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Mon Apr 22 02:25:39 2002

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