log.txt
Index: build.conf
===================================================================
--- build.conf	(revision 14076)
+++ build.conf	(working copy)
@@ -57,6 +57,7 @@
         subversion/tests/clients/cmdline/utf8_tests.py
         subversion/tests/clients/cmdline/history_tests.py
         subversion/tests/clients/cmdline/lock_tests.py
+        subversion/tests/clients/cmdline/cat_tests.py
 
 bdb-test-scripts =
 
Index: subversion/libsvn_client/cat.c
===================================================================
--- subversion/libsvn_client/cat.c	(revision 14081)
+++ subversion/libsvn_client/cat.c	(working copy)
@@ -37,6 +37,8 @@
 
 /*** Code. ***/
 
+/* Helper function to handle copying a potentially translated verison of BASE
+   or WORKING revision of a file to an output stream. */
 static svn_error_t *
 cat_local_file (const char *path,
                 svn_stream_t *output,
@@ -58,24 +60,23 @@
 
   SVN_ERR (svn_wc_entry (&entry, path, adm_access, FALSE, pool));
 
+  if (! entry)
+    return svn_error_createf (SVN_ERR_UNVERSIONED_RESOURCE, NULL,
+                              _("'%s' is not under version control "
+                                "or doesn't exist"),
+                              svn_path_local_style (path, pool));
+
   if (entry->kind != svn_node_file)
     return svn_error_createf(SVN_ERR_CLIENT_IS_DIRECTORY, NULL,
                              _("'%s' refers to a directory"), path);
 
   if (revision->kind != svn_opt_revision_working)
     {
-      SVN_ERR (svn_wc_get_pristine_copy_path (path, &base, pool));
       SVN_ERR (svn_wc_get_prop_diffs (NULL, &props, path, adm_access, pool));
     }
   else
     {
-      svn_wc_status2_t *status;
-      
-      base = path;
       SVN_ERR (svn_wc_prop_list (&props, path, adm_access, pool));
-      SVN_ERR (svn_wc_status2 (&status, path, adm_access, pool));
-      if (status->text_status != svn_wc_status_normal)
-        local_mod = TRUE;
     }
 
   eol_style = apr_hash_get (props, SVN_PROP_EOL_STYLE,
@@ -84,7 +85,28 @@
                            APR_HASH_KEY_STRING);
   special = apr_hash_get (props, SVN_PROP_SPECIAL,
                           APR_HASH_KEY_STRING);
-  
+
+  if (special)
+    {
+      svn_string_t *resolved_path;
+      SVN_ERR (svn_io_read_link (&resolved_path, path, pool));
+      path = resolved_path->data;
+    }
+
+  if (revision->kind != svn_opt_revision_working)
+    {
+      SVN_ERR (svn_wc_get_pristine_copy_path (path, &base, pool));
+    }
+  else
+    {
+      svn_wc_status2_t *status;
+
+      base = path;
+      SVN_ERR (svn_wc_status2 (&status, path, adm_access, pool));
+      if (status->text_status != svn_wc_status_normal)
+        local_mod = TRUE;
+    }
+
   if (eol_style)
     svn_subst_eol_style_from_value (&style, &eol, eol_style->data);
   
@@ -163,9 +185,10 @@
     {
       svn_wc_adm_access_t *adm_access;
     
-      SVN_ERR (svn_wc_adm_probe_open3 (&adm_access, NULL, path_or_url, FALSE,
-                                       0, ctx->cancel_func, ctx->cancel_baton,
-                                       pool));
+      SVN_ERR (svn_wc_adm_open3 (&adm_access, NULL,
+                                 svn_path_dirname (path_or_url, pool), FALSE,
+                                 0, ctx->cancel_func, ctx->cancel_baton,
+                                 pool));
 
       SVN_ERR (cat_local_file (path_or_url, out, adm_access, revision, pool));
 
Index: subversion/tests/clients/cmdline/cat_tests.py
===================================================================
--- subversion/tests/clients/cmdline/cat_tests.py	(revision 0)
+++ subversion/tests/clients/cmdline/cat_tests.py	(revision 0)
@@ -0,0 +1,104 @@
+#!/usr/bin/env python
+#
+#  cat_tests.py:  testing cat cases.
+#
+#  Subversion is a tool for revision control. 
+#  See http://subversion.tigris.org for more information.
+#    
+# ====================================================================
+# Copyright (c) 2000-2004 CollabNet.  All rights reserved.
+#
+# This software is licensed as described in the file COPYING, which
+# you should have received as part of this distribution.  The terms
+# are also available at http://subversion.tigris.org/license-1.html.
+# If newer versions of this license are posted there, you may use a
+# newer version instead, at your option.
+#
+######################################################################
+
+# General modules
+import os
+
+# Our testing module
+import svntest
+
+
+# (abbreviation)
+Skip = svntest.testcase.Skip
+XFail = svntest.testcase.XFail
+Item = svntest.wc.StateItem
+
+ 
+######################################################################
+# Tests
+#
+#   Each test must return on success or raise on failure.
+
+
+#----------------------------------------------------------------------
+
+def cat_local_directory(sbox):
+  "cat a local directory"
+  sbox.build()
+ 
+  A_path = os.path.join(sbox.wc_dir, 'A')
+  
+  svntest.actions.run_and_verify_svn('No error where one is expected',
+                                     None, svntest.SVNAnyOutput, 'cat', A_path)
+
+def cat_remote_directory(sbox):
+  "cat a remote directory"
+  sbox.build()
+ 
+  A_url = svntest.main.current_repo_url + '/A'
+  
+  svntest.actions.run_and_verify_svn('No error where one is expected',
+                                     None, svntest.SVNAnyOutput, 'cat', A_url)
+
+def cat_base(sbox):
+  "cat a file at revision BASE"
+  sbox.build()
+ 
+  wc_dir = sbox.wc_dir
+
+  mu_path = os.path.join(wc_dir, 'A', 'mu')
+  svntest.main.file_append(mu_path, 'Appended text')
+  
+  outlines, errlines = svntest.main.run_svn(0, 'cat', mu_path)
+
+  # Verify the expected output
+  expected_output = svntest.main.greek_state.desc['A/mu'].contents
+  if len(outlines) != 1 or outlines[0] != expected_output:
+    raise svntest.Failure ('Cat failed: expected "%s", but received "%s"' % \
+      (expected_output, outlines[0]))
+
+def cat_nonexistant_file(sbox):
+  "cat a nonexistant file"
+  sbox.build()
+
+  wc_dir = sbox.wc_dir
+
+  bogus_path = os.path.join(wc_dir, 'A', 'bogus')
+
+  svntest.actions.run_and_verify_svn('No error where one is expected',
+                                     None, svntest.SVNAnyOutput, 'cat',
+                                     bogus_path)
+
+########################################################################
+# Run the tests
+
+
+# list all tests here, starting with None:
+test_list = [ None,
+              cat_local_directory,
+              cat_remote_directory,
+              cat_base,
+              cat_nonexistant_file
+             ]
+
+if __name__ == '__main__':
+  svntest.main.run_tests(test_list)
+  # NOTREACHED
+
+
+### End of file.

Property changes on: subversion/tests/clients/cmdline/cat_tests.py
___________________________________________________________________
Name: svn:executable
   + *

