Merge r17485 and r18027 from trunk to the 1.3.x-r17485 backport branch.


git-svn-id: https://svn.apache.org/repos/asf/subversion/branches/1.3.x-r17485@858120 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/subversion/include/svn_ra.h b/subversion/include/svn_ra.h
index 13e3c4a..d44f495 100644
--- a/subversion/include/svn_ra.h
+++ b/subversion/include/svn_ra.h
@@ -1106,6 +1106,9 @@
  * svn_lock_t *) structures.  The hashtable -- and all keys and
  * values -- are allocated in @a pool.
  *
+ * @note It is not considered an error for @a path to not exist in HEAD.
+ * Such a search will simply return no locks.
+ *
  * @note This functionality is not available in pre-1.2 servers.  If the
  * server doesn't implement it, an @c SVN_ERR_RA_NOT_IMPLEMENTED error is
  * returned.
diff --git a/subversion/libsvn_ra_dav/fetch.c b/subversion/libsvn_ra_dav/fetch.c
index 61c3455..5ab9281 100644
--- a/subversion/libsvn_ra_dav/fetch.c
+++ b/subversion/libsvn_ra_dav/fetch.c
@@ -1615,8 +1615,8 @@
 
 
   /* We always run the report on the 'public' URL, which represents
-     HEAD anyway.  If the path doesn't exist in HEAD, then
-     svn_ra_get_locks() *should* fail.  Lock queries are always on HEAD. */
+     HEAD anyway.  If the path doesn't exist in HEAD, then there can't
+     possibly be a lock, so we just return no locks. */
   url = svn_path_url_add_component (ras->url, path, pool);
 
   err = svn_ra_dav__parsed_request(ras->sess, "REPORT", url,
@@ -1630,6 +1630,13 @@
                                    FALSE,
                                    pool);
 
+  if (err && err->apr_err == SVN_ERR_RA_DAV_PATH_NOT_FOUND)
+    {
+      svn_error_clear (err);
+      *locks = baton.lock_hash;
+      return SVN_NO_ERROR;
+    }
+
   /* ### Should svn_ra_dav__parsed_request() take care of storing auth
      ### info itself? */
   err = svn_ra_dav__maybe_store_auth_info_after_result(err, ras);
diff --git a/subversion/tests/clients/cmdline/basic_tests.py b/subversion/tests/clients/cmdline/basic_tests.py
index ece6ff2..278400e 100755
--- a/subversion/tests/clients/cmdline/basic_tests.py
+++ b/subversion/tests/clients/cmdline/basic_tests.py
@@ -1650,6 +1650,36 @@
 
 
 #----------------------------------------------------------------------
+# Issue #2442.
+def ls_nonhead(sbox):
+  "ls a path no longer in HEAD"
+
+  sbox.build()
+  wc_dir = sbox.wc_dir
+
+  # Delete A/D/rho and commit.
+  G_path = os.path.join(wc_dir, 'A', 'D', 'G')
+  svntest.actions.run_and_verify_svn("error scheduling A/D/G for deletion",
+                                     None, [], 'rm', G_path)
+  
+  expected_output = wc.State(wc_dir, {
+    'A/D/G' : Item(verb='Deleting'),
+    })
+
+  expected_status = svntest.actions.get_virginal_state(wc_dir, 1)
+  expected_status.remove('A/D/G', 'A/D/G/rho', 'A/D/G/pi', 'A/D/G/tau',)
+
+  svntest.actions.run_and_verify_commit(wc_dir,
+                                        expected_output, expected_status,
+                                        None, None, None, None, None,
+                                        wc_dir)
+
+  # Check that we can list a file in A/D/G at revision 1.
+  rho_url = sbox.repo_url + "/A/D/G/rho"
+  svntest.actions.run_and_verify_svn(None, '.* rho\n', [],
+                                     'ls', '--verbose', rho_url + '@1')
+  
+
 ########################################################################
 # Run the tests
 
@@ -1684,6 +1714,7 @@
               repos_root,
               basic_peg_revision,
               info_nonhead,
+              ls_nonhead
               ### todo: more tests needed:
               ### test "svn rm http://some_url"
               ### not sure this file is the right place, though.