2 * checkout.c : read a repository and drive a checkout editor.
4 * ====================================================================
5 * Licensed to the Apache Software Foundation (ASF) under one
6 * or more contributor license agreements. See the NOTICE file
7 * distributed with this work for additional information
8 * regarding copyright ownership. The ASF licenses this file
9 * to you under the Apache License, Version 2.0 (the
10 * "License"); you may not use this file except in compliance
11 * with the License. You may obtain a copy of the License at
13 * http://www.apache.org/licenses/LICENSE-2.0
15 * Unless required by applicable law or agreed to in writing,
16 * software distributed under the License is distributed on an
17 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
18 * KIND, either express or implied. See the License for the
19 * specific language governing permissions and limitations
21 * ====================================================================
27 #include "svn_dirent_uri.h"
28 #include "svn_private_config.h"
32 svn_ra_local__split_URL(svn_repos_t **repos,
33 const char **repos_url,
38 svn_error_t *err = SVN_NO_ERROR;
39 const char *repos_dirent;
40 const char *repos_root_dirent;
41 svn_stringbuf_t *urlbuf;
43 SVN_ERR(svn_uri_get_dirent_from_file_url(&repos_dirent, URL, pool));
45 /* Search for a repository in the full path. */
46 repos_root_dirent = svn_repos_find_root_path(repos_dirent, pool);
47 if (!repos_root_dirent)
48 return svn_error_createf(SVN_ERR_RA_LOCAL_REPOS_OPEN_FAILED, NULL,
49 _("Unable to open repository '%s'"), URL);
51 /* Attempt to open a repository at URL. */
52 err = svn_repos_open2(repos, repos_root_dirent, NULL, pool);
54 return svn_error_createf(SVN_ERR_RA_LOCAL_REPOS_OPEN_FAILED, err,
55 _("Unable to open repository '%s'"), URL);
57 /* Assert capabilities directly, since client == server. */
59 apr_array_header_t *caps = apr_array_make(pool, 1, sizeof(const char *));
60 APR_ARRAY_PUSH(caps, const char *) = SVN_RA_CAPABILITY_MERGEINFO;
61 SVN_ERR(svn_repos_remember_client_capabilities(*repos, caps));
64 /* = apr_pstrcat(pool,
66 svn_dirent_skip_ancestor(repos_root_dirent, repos_dirent),
67 (const char *)NULL); */
68 *fs_path = &repos_dirent[strlen(repos_root_dirent)];
70 if (**fs_path == '\0')
73 /* Remove the path components after the root dirent from the original URL,
74 to get a URL to the repository root.
76 We don't use svn_uri_get_file_url_from_dirent() here as that would
77 transform several uris to form a differently formed url than
78 svn_uri_canonicalize would.
80 E.g. file://localhost/C:/dir -> file:///C:/dir
81 (a transform that was originally supported directly by this function,
82 before the implementation moved)
85 file:///dir -> file:///E:/dir (When E: is the current disk)
87 urlbuf = svn_stringbuf_create(URL, pool);
88 svn_path_remove_components(urlbuf,
89 svn_path_component_count(repos_dirent)
90 - svn_path_component_count(repos_root_dirent));
91 *repos_url = urlbuf->data;
93 /* Configure hook script environment variables. */
94 SVN_ERR(svn_repos_hooks_setenv(*repos, NULL, pool));