util.c revision 289177
1/*
2 * util.c: Subversion command line client utility functions. Any
3 * functions that need to be shared across subcommands should be put
4 * in here.
5 *
6 * ====================================================================
7 *    Licensed to the Apache Software Foundation (ASF) under one
8 *    or more contributor license agreements.  See the NOTICE file
9 *    distributed with this work for additional information
10 *    regarding copyright ownership.  The ASF licenses this file
11 *    to you under the Apache License, Version 2.0 (the
12 *    "License"); you may not use this file except in compliance
13 *    with the License.  You may obtain a copy of the License at
14 *
15 *      http://www.apache.org/licenses/LICENSE-2.0
16 *
17 *    Unless required by applicable law or agreed to in writing,
18 *    software distributed under the License is distributed on an
19 *    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
20 *    KIND, either express or implied.  See the License for the
21 *    specific language governing permissions and limitations
22 *    under the License.
23 * ====================================================================
24 */
25
26/* ==================================================================== */
27
28
29
30/*** Includes. ***/
31
32#include <string.h>
33#include <ctype.h>
34#include <assert.h>
35
36#include "svn_private_config.h"
37#include "svn_error.h"
38#include "svn_path.h"
39
40#include "cl.h"
41
42
43
44svn_error_t *
45svn_cl__args_to_target_array_print_reserved(apr_array_header_t **targets,
46                                            apr_getopt_t *os,
47                                            const apr_array_header_t *known_targets,
48                                            svn_client_ctx_t *ctx,
49                                            svn_boolean_t keep_last_origpath_on_truepath_collision,
50                                            apr_pool_t *pool)
51{
52  svn_error_t *err = svn_client_args_to_target_array2(targets,
53                                                      os,
54                                                      known_targets,
55                                                      ctx,
56                                                      keep_last_origpath_on_truepath_collision,
57                                                      pool);
58  if (err)
59    {
60      if (err->apr_err ==  SVN_ERR_RESERVED_FILENAME_SPECIFIED)
61        {
62          svn_handle_error2(err, stderr, FALSE, "svn: Skipping argument: ");
63          svn_error_clear(err);
64        }
65      else
66        return svn_error_trace(err);
67    }
68  return SVN_NO_ERROR;
69}
70
71svn_error_t *
72svn_cl__check_target_is_local_path(const char *target)
73{
74  if (svn_path_is_url(target))
75    return svn_error_createf(SVN_ERR_CL_ARG_PARSING_ERROR, NULL,
76                             _("'%s' is not a local path"), target);
77  return SVN_NO_ERROR;
78}
79
80const char *
81svn_cl__local_style_skip_ancestor(const char *parent_path,
82                                  const char *path,
83                                  apr_pool_t *pool)
84{
85  const char *relpath = NULL;
86
87  if (parent_path)
88    relpath = svn_dirent_skip_ancestor(parent_path, path);
89
90  return svn_dirent_local_style(relpath ? relpath : path, pool);
91}
92
93