Noorul Islam K M <noo...@collab.net> writes:

> rhuij...@apache.org writes:
>
>>    if (changelist_name)
>>      {
>> -      return svn_cl__try
>> -              (svn_client_add_to_changelist(targets, changelist_name,
>> +      SVN_ERR(svn_cl__try(
>> +               svn_client_add_to_changelist(targets, changelist_name,
>>                                              depth, opt_state->changelists,
>>                                              ctx, pool),
>> -               NULL, opt_state->quiet,
>> +               &success, opt_state->quiet,
>>                 SVN_ERR_UNVERSIONED_RESOURCE,
>>                 SVN_ERR_WC_PATH_NOT_FOUND,
>> -               SVN_NO_ERROR);
>> +               SVN_NO_ERROR));
>>      }
>>    else
>>      {
>> -      return svn_cl__try
>> -              (svn_client_remove_from_changelists(targets, depth,
>> +      SVN_ERR(svn_cl__try(
>> +               svn_client_remove_from_changelists(targets, depth,
>>                                                    opt_state->changelists,
>>                                                    ctx, pool),
>> -               NULL, opt_state->quiet,
>> +               &success, opt_state->quiet,
>>                 SVN_ERR_UNVERSIONED_RESOURCE,
>>                 SVN_ERR_WC_PATH_NOT_FOUND,
>> -               SVN_NO_ERROR);
>> +               SVN_NO_ERROR));
>>      }
>> +
>> +  if (!success)
>> +    return svn_error_create(SVN_ERR_ILLEGAL_TARGET, NULL,
>> +                            _("Could not display info for all targets 
>> because "
>> +                              "some targets don't exist"));
>
> I think this should be something like this. 
>
> Could not add all targets to changelist because some targets don't exist
>
> I will add test cases for handling multiple targets.
>

Log

[[[
* subversion/svn/changelist-cmd.c
  (svn_cl__changelist): Tweak error message. Also display different
    error message for add and remove.

* subversion/tests/cmdline/changelist_tests.py
  (mix_existing_and_non_existent_target): New test, verify that svn cl
    errors out in desirable way if mixture for existing and non-existent
    targets are passed. 
  (test_list): Add new test.

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

Thanks and Regards
Noorul

Index: subversion/tests/cmdline/changelist_tests.py
===================================================================
--- subversion/tests/cmdline/changelist_tests.py        (revision 1146559)
+++ subversion/tests/cmdline/changelist_tests.py        (working copy)
@@ -1170,7 +1170,57 @@
                                      'changelist', unversioned,
                                       '--remove')
 
+def mix_existing_and_non_existent_target(sbox):
+  "mixture of existing and non-existent target"
 
+  sbox.build()
+  wc_dir = sbox.wc_dir
+  iota_path = os.path.join(wc_dir, 'iota')
+  bogus_path = os.path.join(wc_dir, 'A', 'bogus')
+
+  expected_err1 = "svn: warning: W155010: The node '" + \
+                  re.escape(os.path.abspath(bogus_path)) + \
+                  "' was not found.\n"
+
+  expected_err2 = expected_err1 + \
+                  ".*svn: E200009: Could not add targets to changelist " + \
+                  "because some targets don't exist\n"
+
+  expected_err_re = re.compile(expected_err2, re.DOTALL)
+  expected_adds = {
+    iota_path : 'testlist',
+    }
+
+  exit_code, output, error = svntest.main.run_svn(1, 'changelist', 'testlist',
+                                                  iota_path, bogus_path)
+
+  verify_changelist_output(output, expected_adds)
+
+  # Verify error
+  if not expected_err_re.match("".join(error)):
+    raise svntest.Failure('cl failed: expected error "%s", '
+                          'but received "%s"' %
+                          (expected_err2, "".join(error)))
+
+  expected_err2 = expected_err1 + \
+                  ".*svn: E200009: Could not remove targets from " + \
+                  "changelist because some targets don't exist\n"
+
+  expected_err_re = re.compile(expected_err2, re.DOTALL)
+  expected_removals = expected_adds
+
+  exit_code, output, error = svntest.main.run_svn(1, 'changelist',
+                                                  iota_path, bogus_path,
+                                                  "--remove")
+  
+  verify_changelist_output(output, None, expected_removals)
+
+  # Verify error
+  if not expected_err_re.match("".join(error)):
+    raise svntest.Failure('cl failed: expected error "%s", '
+                          'but received "%s"' %
+                          (expected_err2, "".join(error)))
+
 ########################################################################
 # Run the tests
 
@@ -1192,6 +1242,7 @@
               revert_deleted_in_changelist,
               add_remove_non_existent_target,
               add_remove_unversioned_target,
+              mix_existing_and_non_existent_target,
              ]
 
 if __name__ == '__main__':
Index: subversion/svn/changelist-cmd.c
===================================================================
--- subversion/svn/changelist-cmd.c     (revision 1146559)
+++ subversion/svn/changelist-cmd.c     (working copy)
@@ -107,6 +107,11 @@
                SVN_ERR_UNVERSIONED_RESOURCE,
                SVN_ERR_WC_PATH_NOT_FOUND,
                SVN_NO_ERROR));
+      
+      if (!success)
+        return svn_error_create(SVN_ERR_ILLEGAL_TARGET, NULL,
+                                _("Could not add targets to changelist "
+                                  "because some targets don't exist"));
     }
   else
     {
@@ -118,12 +123,12 @@
                SVN_ERR_UNVERSIONED_RESOURCE,
                SVN_ERR_WC_PATH_NOT_FOUND,
                SVN_NO_ERROR));
+      
+      if (!success)
+        return svn_error_create(SVN_ERR_ILLEGAL_TARGET, NULL,
+                                _("Could not remove targets from changelist "
+                                  "because some targets don't exist"));
     }
 
-  if (!success)
-    return svn_error_create(SVN_ERR_ILLEGAL_TARGET, NULL,
-                            _("Could not display info for all targets because "
-                              "some targets don't exist"));
-  else
     return SVN_NO_ERROR;
 }

Reply via email to