Index: subversion/include/svn_path.h
===================================================================
--- subversion/include/svn_path.h	(revision 10198)
+++ subversion/include/svn_path.h	(arbetskopia)
@@ -118,6 +118,10 @@
  */
 char *svn_path_dirname (const char *path, apr_pool_t *pool);
 
+/** Return the number of components in the canonicalized @a path. */
+apr_size_t
+svn_path_component_count (const char *path);
+
 /** Add a @a component (a null-terminated C-string) to the
  * canonicalized @a path.  @a component is allowed to contain
  * directory separators.
@@ -134,6 +138,9 @@
 /** Remove one component off the end of the canonicalized @a path. */
 void svn_path_remove_component (svn_stringbuf_t *path);
 
+/** Remove @a n components off the end of the canonizalized @a path.
+ * Equivalent to call @c svn_remove_component @a n times. */
+void svn_path_remove_components (svn_stringbuf_t *path, apr_size_t n);
 
 /** Divide the canonicalized @a path into @a *dirpath and @a
  * *base_name, allocated in @a pool.
Index: subversion/libsvn_ra_local/ra_plugin.c
===================================================================
--- subversion/libsvn_ra_local/ra_plugin.c	(revision 10198)
+++ subversion/libsvn_ra_local/ra_plugin.c	(arbetskopia)
@@ -207,6 +207,7 @@
                     apr_pool_t *pool)
 {
   svn_ra_local__session_baton_t *session;
+  svn_stringbuf_t *urlbuf;
   
   /* Allocate and stash the session_baton args we have already. */
   session = apr_pcalloc (pool, sizeof(*session));
@@ -223,9 +224,14 @@
                                       session->pool),
              "Unable to open an ra_local session to URL");
 
-  /* Encode the repos_url into repos_root for get_repos_root. */
-  session->repos_root = svn_path_uri_encode (session->repos_url, pool);
-
+  /* Get the prefix of the repository URL that is the URL to the repository
+     root.  Note that this must be a prefix of the URL used to open
+     the session by the caller. */
+  urlbuf = svn_stringbuf_create (repos_URL, session->pool);
+  svn_path_remove_components (urlbuf,
+                              svn_path_component_count (session->fs_path));
+  session->repos_root = urlbuf->data;
+                                                    
   /* Cache the filesystem object from the repos here for
      convenience. */
   session->fs = svn_repos_fs (session->repos);
Index: subversion/libsvn_subr/path.c
===================================================================
--- subversion/libsvn_subr/path.c	(revision 10198)
+++ subversion/libsvn_subr/path.c	(arbetskopia)
@@ -264,6 +264,32 @@
 
 
 
+apr_size_t
+svn_path_component_count (const char *path)
+{
+  apr_size_t count = 0;
+
+  assert (is_canonical (path, strlen (path)));
+
+  while (*path)
+    {
+      const char *start;
+
+      while (*path == '/')
+        ++path;
+
+      start = path;
+      
+      while (*path && *path != '/')
+        ++path;
+
+      if (path != start)
+        ++count;
+    }
+
+  return count;
+}
+
 /* Return the length of substring necessary to encompass the entire
  * previous path segment in PATH, which should be a LEN byte string.
  *
@@ -318,7 +344,17 @@
   path->data[path->len] = '\0';
 }
 
+void
+svn_path_remove_components (svn_stringbuf_t *path, apr_size_t n)
+{
+  while (n > 0)
+    {
+      svn_path_remove_component (path);
+      n--;
+    }
+}
 
+
 char *
 svn_path_dirname (const char *path, apr_pool_t *pool)
 {
