Remove no-longer-used svn_*_get_mergeinfo_for_tree APIs.
[svn.git] / subversion / libsvn_subr / kitchensink.c
blob50c2b58ea3bfde6bcf882858b5c402abebb33909
1 /*
2 * kitchensink.c : When no place else seems to fit...
4 * ====================================================================
5 * Copyright (c) 2006-2007 CollabNet. All rights reserved.
7 * This software is licensed as described in the file COPYING, which
8 * you should have received as part of this distribution. The terms
9 * are also available at http://subversion.tigris.org/license-1.html.
10 * If newer versions of this license are posted there, you may use a
11 * newer version instead, at your option.
13 * This software consists of voluntary contributions made by many
14 * individuals. For exact contribution history, see the revision
15 * history and logs, available at http://subversion.tigris.org/.
16 * ====================================================================
19 #include <apr_pools.h>
20 #include <apr_uuid.h>
22 #include "svn_types.h"
23 #include "svn_error.h"
24 #include "svn_mergeinfo.h"
25 #include "svn_private_config.h"
27 svn_error_t *
28 svn_revnum_parse(svn_revnum_t *rev,
29 const char *str,
30 const char **endptr)
32 char *end;
34 svn_revnum_t result = strtol(str, &end, 10);
36 if (endptr)
37 *endptr = end;
39 if (str == end)
40 return svn_error_createf(SVN_ERR_REVNUM_PARSE_FAILURE, NULL,
41 _("Invalid revision number found parsing '%s'"),
42 str);
44 if (result < 0)
46 /* The end pointer from strtol() is valid, but a negative revision
47 number is invalid, so move the end pointer back to the
48 beginning of the string. */
49 if (endptr)
50 *endptr = str;
52 return svn_error_createf(SVN_ERR_REVNUM_PARSE_FAILURE, NULL,
53 _("Negative revision number found parsing '%s'"),
54 str);
57 *rev = result;
59 return SVN_NO_ERROR;
62 const char *
63 svn_uuid_generate(apr_pool_t *pool)
65 apr_uuid_t uuid;
66 char *uuid_str = apr_pcalloc(pool, APR_UUID_FORMATTED_LENGTH + 1);
67 apr_uuid_get(&uuid);
68 apr_uuid_format(uuid_str, &uuid);
69 return uuid_str;
72 const char *
73 svn_depth_to_word(svn_depth_t depth)
75 switch (depth)
77 case svn_depth_exclude:
78 return "exclude";
79 case svn_depth_unknown:
80 return "unknown";
81 case svn_depth_empty:
82 return "empty";
83 case svn_depth_files:
84 return "files";
85 case svn_depth_immediates:
86 return "immediates";
87 case svn_depth_infinity:
88 return "infinity";
89 default:
90 return "INVALID-DEPTH";
95 svn_depth_t
96 svn_depth_from_word(const char *word)
98 if (strcmp(word, "exclude") == 0)
99 return svn_depth_exclude;
100 if (strcmp(word, "unknown") == 0)
101 return svn_depth_unknown;
102 if (strcmp(word, "empty") == 0)
103 return svn_depth_empty;
104 if (strcmp(word, "files") == 0)
105 return svn_depth_files;
106 if (strcmp(word, "immediates") == 0)
107 return svn_depth_immediates;
108 if (strcmp(word, "infinity") == 0)
109 return svn_depth_infinity;
110 /* There's no special value for invalid depth, and no convincing
111 reason to make one yet, so just fall back to unknown depth.
112 If you ever change that convention, check callers to make sure
113 they're not depending on it (e.g., option parsing in main() ).
115 return svn_depth_unknown;
118 const char *
119 svn_inheritance_to_word(svn_mergeinfo_inheritance_t inherit)
121 switch (inherit)
123 case svn_mergeinfo_inherited:
124 return "inherited";
125 case svn_mergeinfo_nearest_ancestor:
126 return "nearest-ancestor";
127 default:
128 return "explicit";
133 svn_mergeinfo_inheritance_t
134 svn_inheritance_from_word(const char *word)
136 if (strcmp(word, "inherited") == 0)
137 return svn_mergeinfo_inherited;
138 if (strcmp(word, "nearest-ancestor") == 0)
139 return svn_mergeinfo_nearest_ancestor;
140 return svn_mergeinfo_explicit;