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

[PATCH] Fix regression in 'svn cl' add and remove operations on non-existent target.

From: Noorul Islam K M <noorul_at_collab.net>
Date: Tue, 12 Jul 2011 12:48:56 +0530

Using 1.6 client
================
noorul_at_noorul:/tmp/wc/repos$ ls a
ls: cannot access a: No such file or directory
noorul_at_noorul:/tmp/wc/repos$ svn cl testlist a
svn: warning: 'a' is not under version control
noorul_at_noorul:/tmp/wc/repos$ svn cl a --remove
svn: warning: 'a' is not under version control
noorul_at_noorul:/tmp/wc/repos$ touch a
noorul_at_noorul:/tmp/wc/repos$ ls a
a
noorul_at_noorul:/tmp/wc/repos$ svn cl testlist a
svn: warning: 'a' is not under version control
noorul_at_noorul:/tmp/wc/repos$ svn cl a --remove
svn: warning: 'a' is not under version control

Using 1.7 client
================
noorul_at_noorul:/tmp/wc/repos1$ ls a
ls: cannot access a: No such file or directory
noorul_at_noorul:/tmp/wc/repos1$ ~/projects/subversion/builds/trunk/bin/svn cl testlist a
noorul_at_noorul:/tmp/wc/repos1$ ~/projects/subversion/builds/trunk/bin/svn cl a --remove
noorul_at_noorul:/tmp/wc/repos1$ touch a
noorul_at_noorul:/tmp/wc/repos1$ ls a
a
noorul_at_noorul:/tmp/wc/repos1$ ~/projects/subversion/builds/trunk/bin/svn cl testlist a
noorul_at_noorul:/tmp/wc/repos1$ ~/projects/subversion/builds/trunk/bin/svn cl a --remove

The attached patch fixes this regression.

Log
[[[

Fix regression in 'svn cl' add/remove operations on
non-existent/unversioned target.

* subversion/libsvn_wc/adm_ops.c
  (svn_wc_set_changelist2): If the target is unversioned/non-existent
    then return error (SVN_ERR_UNVERSIONED_RESOURCE).

* subversion/tests/cmdline/changelist_tests.py
  (add_remove_non_existent_target, add_remove_unversioned_target):
    New tests.
  (test_list): Run them.

Patch by: Noorul Islam K M <noorul{_AT_}collab.net>
Found by: danielsh
]]]

Index: subversion/tests/cmdline/changelist_tests.py
===================================================================
--- subversion/tests/cmdline/changelist_tests.py (revision 1145455)
+++ subversion/tests/cmdline/changelist_tests.py (working copy)
@@ -1132,8 +1132,44 @@
                                      'revert', '-R', sbox.ospath('A'))
   svntest.actions.run_and_verify_info(expected_infos, sbox.ospath('A/mu'))
 
+def add_remove_non_existent_target(sbox):
+ "add and remove non-existent target to changelist"
 
+ sbox.build(read_only = True)
+ wc_dir = sbox.wc_dir
+ bogus_path = os.path.join(wc_dir, 'A', 'bogus')
 
+ expected_err = "svn: warning: W200005: '" + \
+ re.escape(os.path.abspath(bogus_path)) + \
+ "' is not under version control"
+
+ svntest.actions.run_and_verify_svn2(None, None, expected_err, 0,
+ 'changelist', 'testlist',
+ bogus_path)
+
+ svntest.actions.run_and_verify_svn2(None, None, expected_err, 0,
+ 'changelist', bogus_path,
+ '--remove')
+
+def add_remove_unversioned_target(sbox):
+ "add and remove unversioned target to changelist"
+
+ sbox.build(read_only = True)
+ unversioned = sbox.ospath('unversioned')
+ svntest.main.file_write(unversioned, "dummy contents", 'w+')
+
+ expected_err = "svn: warning: W200005: '" + \
+ re.escape(os.path.abspath(unversioned)) + \
+ "' is not under version control"
+
+ svntest.actions.run_and_verify_svn2(None, None, expected_err, 0,
+ 'changelist', 'testlist',
+ unversioned)
+
+ svntest.actions.run_and_verify_svn2(None, None, expected_err, 0,
+ 'changelist', unversioned,
+ '--remove')
+
 ########################################################################
 # Run the tests
 
@@ -1153,6 +1189,8 @@
               move_added_keeps_changelist,
               change_to_dir,
               revert_deleted_in_changelist,
+ add_remove_non_existent_target,
+ add_remove_unversioned_target,
              ]
 
 if __name__ == '__main__':
Index: subversion/libsvn_wc/adm_ops.c
===================================================================
--- subversion/libsvn_wc/adm_ops.c (revision 1145455)
+++ subversion/libsvn_wc/adm_ops.c (working copy)
@@ -2200,11 +2200,21 @@
                        void *notify_baton,
                        apr_pool_t *scratch_pool)
 {
+ svn_node_kind_t kind;
+
   /* Assert that we aren't being asked to set an empty changelist. */
   SVN_ERR_ASSERT(! (new_changelist && new_changelist[0] == '\0'));
 
   SVN_ERR_ASSERT(svn_dirent_is_absolute(local_abspath));
 
+ SVN_ERR(svn_wc_read_kind(&kind, wc_ctx, local_abspath, FALSE, scratch_pool));
+
+ if (kind == svn_node_none)
+ return svn_error_createf(SVN_ERR_UNVERSIONED_RESOURCE, NULL,
+ _("'%s' is not under version control"),
+ svn_dirent_local_style(local_abspath,
+ scratch_pool));
+
   SVN_ERR(svn_wc__db_op_set_changelist(wc_ctx->db, local_abspath,
                                        new_changelist, changelist_filter,
                                        depth, notify_func, notify_baton,
Received on 2011-07-12 09:21:28 CEST

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.