Index: subversion/clients/cmdline/cat-cmd.c =================================================================== --- subversion/clients/cmdline/cat-cmd.c (revision 14922) +++ subversion/clients/cmdline/cat-cmd.c (working copy) @@ -57,6 +57,7 @@ const char *target = ((const char **) (targets->elts))[i]; const char *truepath; svn_opt_revision_t peg_revision; + svn_boolean_t success; svn_pool_clear (subpool); SVN_ERR (svn_cl__check_cancel (ctx->cancel_baton)); @@ -65,9 +66,14 @@ SVN_ERR (svn_opt_parse_path (&peg_revision, &truepath, target, subpool)); - SVN_ERR (svn_client_cat2 (out, truepath, &peg_revision, - &(opt_state->start_revision), - ctx, subpool)); + SVN_ERR (svn_cl__try( svn_client_cat2 (out, truepath, &peg_revision, + &(opt_state->start_revision), + ctx, subpool), + &success, opt_state->quiet, + SVN_ERR_UNVERSIONED_RESOURCE, + SVN_ERR_ENTRY_NOT_FOUND, + SVN_ERR_CLIENT_IS_DIRECTORY, + SVN_NO_ERROR)); } svn_pool_destroy (subpool); Index: subversion/tests/clients/cmdline/cat_tests.py =================================================================== --- subversion/tests/clients/cmdline/cat_tests.py (revision 14922) +++ subversion/tests/clients/cmdline/cat_tests.py (working copy) @@ -84,6 +84,56 @@ None, svntest.SVNAnyOutput, 'cat', bogus_path) +def cat_skip_unversioned_file(sbox): + "cat should skip an unversioned resource" + sbox.build() + + wc_dir = sbox.wc_dir + dir_path = os.path.join(wc_dir, 'A/D') + new_file_path = os.path.join(dir_path, 'new') + open(new_file_path, 'w') + item_list = os.listdir(dir_path) + + # item_list has all the files and directories under 'dir_path' + # including .svn. But cat'ing of .svn just gives the + # output of 'svn help cat'. So skip .svn directory and continue. + + for file in item_list: + if file == '.svn': continue + item_to_cat = os.path.join(dir_path, file) + if item_to_cat == new_file_path: + expected_err = "svn: warning: '" + item_to_cat + "'" + \ + " is not under version control or doesn't exist\n" + svntest.actions.run_and_verify_svn(None, None, + expected_err, 'cat', item_to_cat) + elif os.path.isdir(item_to_cat): + expected_err = "svn: warning: '" + item_to_cat + "'" + \ + " refers to a directory\n" + svntest.actions.run_and_verify_svn(None, None, + expected_err, 'cat', item_to_cat) + else: + svntest.actions.run_and_verify_svn(None, + ["This is the file '"+file+"'."], + None, 'cat', item_to_cat) + + G_path = os.path.join(dir_path, 'G') + rho_path = os.path.join(G_path, 'rho') + + expected_out = ["This is the file 'rho'."] + expected_err1 = ["svn: warning: '" + G_path + "'" + " refers to a directory\n"] + svntest.actions.run_and_verify_svn(None, expected_out, expected_err1, + 'cat', rho_path, G_path) + + expected_err2 = ["svn: warning: '" + new_file_path + "'" + \ + " is not under version control or doesn't exist\n"] + svntest.actions.run_and_verify_svn(None, expected_out, expected_err2, + 'cat', rho_path, new_file_path) + + svntest.actions.run_and_verify_svn(None, expected_out, expected_err1 + \ + expected_err2, 'cat', rho_path, G_path, + new_file_path) + + ######################################################################## # Run the tests @@ -93,7 +143,8 @@ cat_local_directory, cat_remote_directory, cat_base, - cat_nonexistant_file + cat_nonexistant_file, + cat_skip_unversioned_file, ] if __name__ == '__main__':