In the command-line client, forbid
[svn.git] / subversion / libsvn_client / mergeinfo.h
blobdbeeed31683bfd6da198bce56266a7e4fa671f62
1 /*
2 * mergeinfo.h : Client library-internal mergeinfo APIs.
4 * ====================================================================
5 * Copyright (c) 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 #ifndef SVN_LIBSVN_CLIENT_MERGEINFO_H
20 #define SVN_LIBSVN_CLIENT_MERGEINFO_H
23 /*** Data Structures ***/
26 /* Structure used by discover_and_merge_children() and consumers of the
27 children_with_mergeinfo array it populates. The struct describes
28 working copy paths that meet one or more of the following criteria:
30 1) Path has explicit mergeinfo
31 2) Path is switched
32 3) Path has an immediate child which is switched or otherwise
33 missing from the WC.
34 4) Path has a sibling which is switched or otherwise missing
35 from the WC.
37 typedef struct svn_client__merge_path_t
39 const char *path;
40 svn_boolean_t missing_child; /* PATH has an immediate child which is
41 missing. */
42 svn_boolean_t switched; /* PATH is switched. */
43 svn_boolean_t has_noninheritable; /* PATH has svn:mergeinfo set on it which
44 includes non-inheritable revision
45 ranges. */
46 svn_boolean_t absent; /* PATH is absent from the WC, probably
47 due to authz restrictions. */
48 const svn_string_t *propval; /* Working mergeinfo for PATH at start
49 of merge. May be NULL. */
50 apr_array_header_t *remaining_ranges; /* Per path remaining ranges list. */
51 apr_hash_t *pre_merge_mergeinfo; /* mergeinfo on a path prior to a
52 merge.*/
53 svn_boolean_t indirect_mergeinfo;
54 svn_boolean_t scheduled_for_deletion; /* PATH is scheduled for deletion. */
55 } svn_client__merge_path_t;
59 /*** Functions ***/
61 /* Find explicit or inherited WC mergeinfo for WCPATH, and return it
62 in *MERGEINFO (NULL if no mergeinfo is set). Set *INHERITED to
63 whether the mergeinfo was inherited (TRUE or FALSE).
65 INHERIT indicates whether explicit, explicit or inherited, or only
66 inherited mergeinfo for WCPATH is retrieved.
68 Don't look for inherited mergeinfo any higher than LIMIT_PATH
69 (ignored if NULL).
71 Set *WALKED_PATH to the path climbed from WCPATH to find inherited
72 mergeinfo, or "" if none was found. (ignored if NULL). */
73 svn_error_t *
74 svn_client__get_wc_mergeinfo(apr_hash_t **mergeinfo,
75 svn_boolean_t *inherited,
76 svn_boolean_t pristine,
77 svn_mergeinfo_inheritance_t inherit,
78 const svn_wc_entry_t *entry,
79 const char *wcpath,
80 const char *limit_path,
81 const char **walked_path,
82 svn_wc_adm_access_t *adm_access,
83 svn_client_ctx_t *ctx,
84 apr_pool_t *pool);
86 /* Obtain any mergeinfo for the root-relative repository filesystem path
87 REL_PATH from the repository, and set it in *TARGET_MERGEINFO.
89 INHERIT indicates whether explicit, explicit or inherited, or only
90 inherited mergeinfo for REL_PATH is obtained.
92 If there is no mergeinfo available for REL_PATH, or if the server
93 doesn't support a mergeinfo capability and SQUELCH_INCAPABLE is
94 TRUE, set *TARGET_MERGEINFO to NULL. */
95 svn_error_t *
96 svn_client__get_repos_mergeinfo(svn_ra_session_t *ra_session,
97 apr_hash_t **target_mergeinfo,
98 const char *rel_path,
99 svn_revnum_t rev,
100 svn_mergeinfo_inheritance_t inherit,
101 svn_boolean_t squelch_incapable,
102 apr_pool_t *pool);
104 /* Retrieve the direct mergeinfo for the TARGET_WCPATH from the WC's
105 mergeinfo prop, or that inherited from its nearest ancestor if the
106 target has no info of its own.
108 If no mergeinfo can be obtained from the WC or REPOS_ONLY is TRUE,
109 get it from the repository (opening a new RA session if RA_SESSION
110 is NULL). Store any mergeinfo obtained for TARGET_WCPATH -- which
111 is reflected by ENTRY -- in *TARGET_MERGEINFO, if no mergeinfo is
112 found *TARGET_MERGEINFO is NULL.
114 INHERIT indicates whether explicit, explicit or inherited, or only
115 inherited mergeinfo for TARGET_WCPATH is retrieved.
117 If TARGET_WCPATH inherited its mergeinfo from a working copy ancestor
118 or if it was obtained from the repository, set *INDIRECT to TRUE, set it
119 to FALSE *otherwise. */
120 svn_error_t *
121 svn_client__get_wc_or_repos_mergeinfo(apr_hash_t **target_mergeinfo,
122 const svn_wc_entry_t *entry,
123 svn_boolean_t *indirect,
124 svn_boolean_t repos_only,
125 svn_mergeinfo_inheritance_t inherit,
126 svn_ra_session_t *ra_session,
127 const char *target_wcpath,
128 svn_wc_adm_access_t *adm_access,
129 svn_client_ctx_t *ctx,
130 apr_pool_t *pool);
132 /* Set *MERGEINFO_P to a hash of mergeinfo constructed solely from the
133 natural history of PATH_OR_URL@PEG_REVISION. RA_SESSION is an RA
134 session whose session URL maps to PATH_OR_URL's URL, or NULL.
135 ADM_ACCESS is a working copy administrative access baton which can
136 be used to fetch information about PATH_OR_URL (if PATH_OR_URL is a
137 working copy path), or NULL. If RANGE_YOUNGEST and RANGE_OLDEST
138 are valid, use them to bound the revision ranges of returned
139 mergeinfo. */
140 svn_error_t *
141 svn_client__get_history_as_mergeinfo(apr_hash_t **mergeinfo_p,
142 const char *path_or_url,
143 const svn_opt_revision_t *peg_revision,
144 svn_revnum_t range_youngest,
145 svn_revnum_t range_oldest,
146 svn_ra_session_t *ra_session,
147 svn_wc_adm_access_t *adm_access,
148 svn_client_ctx_t *ctx,
149 apr_pool_t *pool);
151 /* Parse any mergeinfo from the WCPATH's ENTRY and store it in
152 MERGEINFO. If PRISTINE is true parse the pristine mergeinfo,
153 working otherwise. If no record of any mergeinfo exists, set
154 MERGEINFO to NULL. Does not acount for inherited mergeinfo. */
155 svn_error_t *
156 svn_client__parse_mergeinfo(apr_hash_t **mergeinfo,
157 const svn_wc_entry_t *entry,
158 const char *wcpath,
159 svn_boolean_t pristine,
160 svn_wc_adm_access_t *adm_access,
161 svn_client_ctx_t *ctx,
162 apr_pool_t *pool);
164 /* Write MERGEINFO into the WC for WCPATH. If MERGEINFO is NULL,
165 remove any SVN_PROP_MERGEINFO for WCPATH. If MERGEINFO is empty,
166 record an empty property value (e.g. ""). */
167 svn_error_t *
168 svn_client__record_wc_mergeinfo(const char *wcpath,
169 apr_hash_t *mergeinfo,
170 svn_wc_adm_access_t *adm_access,
171 apr_pool_t *pool);
173 /* Elide any svn:mergeinfo set on TARGET_PATH to its nearest working
174 copy (or possibly repository) ancestor with equivalent mergeinfo.
176 If WC_ELISION_LIMIT_PATH is NULL check up to the root of the working copy
177 for an elision destination, if none is found check the repository,
178 otherwise check as far as WC_ELISION_LIMIT_PATH within the working copy.
179 TARGET_PATH and WC_ELISION_LIMIT_PATH, if it exists, must both be absolute
180 or relative to the working directory.
182 Elision occurs if:
184 A) WCPATH has empty mergeinfo and no parent path with explicit mergeinfo
185 can be found in either the WC or the repository (WC_ELISION_LIMIT_PATH
186 must be NULL for this to occur).
188 B) WCPATH has empty mergeinfo and its nearest parent also has empty
189 mergeinfo.
191 C) WCPATH has the same mergeinfo as its nearest parent when that parent's
192 mergeinfo is adjusted for the path difference between the two, e.g.:
194 WCPATH's Parent's
195 WCPATH's Nearest Parent's Path Adjusted
196 WCPATH mergeinfo parent Mergeinfo Difference Mergeinfo
197 ------- --------- --------- --------- ---------- ---------
198 A_COPY/D/H '/A/D/H:3' A_COPY '/A:3' 'D/H' '/A/D/H:3'
200 If Elision occurs remove the svn:mergeinfo property from TARGET_WCPATH. */
201 svn_error_t *
202 svn_client__elide_mergeinfo(const char *target_wcpath,
203 const char *wc_elision_limit_path,
204 const svn_wc_entry_t *entry,
205 svn_wc_adm_access_t *adm_access,
206 svn_client_ctx_t *ctx,
207 apr_pool_t *pool);
209 /* For each path in CHILDREN_WITH_MERGEINFO which is an immediate child of
210 TARGET_WCPATH, check if that path's mergeinfo elides to TARGET_WCPATH.
211 If it does elide, clear all mergeinfo from the path.
213 CHILDREN_WITH_MERGEINFO is filled with child paths (struct
214 merge_path_t *) of TARGET_WCPATH which have svn:mergeinfo set on
215 them, arranged in depth first order (see
216 discover_and_merge_children). */
217 svn_error_t *
218 svn_client__elide_children(apr_array_header_t *children_with_mergeinfo,
219 const char *target_wcpath,
220 const svn_wc_entry_t *entry,
221 svn_wc_adm_access_t *adm_access,
222 svn_client_ctx_t *ctx,
223 apr_pool_t *pool);
225 /* A wrapper which calls svn_client__elide_mergeinfo() on each child
226 in CHILDREN_WITH_MERGEINFO_HASH in depth-first. */
227 svn_error_t *
228 svn_client__elide_mergeinfo_for_tree(apr_hash_t *children_with_mergeinfo,
229 svn_wc_adm_access_t *adm_access,
230 svn_client_ctx_t *ctx,
231 apr_pool_t *pool);
234 #endif /* SVN_LIBSVN_CLIENT_MERGEINFO_H */