cl.h revision 262253
1251881Speter/*
2251881Speter * cl.h:  shared stuff in the command line program
3251881Speter *
4251881Speter * ====================================================================
5251881Speter *    Licensed to the Apache Software Foundation (ASF) under one
6251881Speter *    or more contributor license agreements.  See the NOTICE file
7251881Speter *    distributed with this work for additional information
8251881Speter *    regarding copyright ownership.  The ASF licenses this file
9251881Speter *    to you under the Apache License, Version 2.0 (the
10251881Speter *    "License"); you may not use this file except in compliance
11251881Speter *    with the License.  You may obtain a copy of the License at
12251881Speter *
13251881Speter *      http://www.apache.org/licenses/LICENSE-2.0
14251881Speter *
15251881Speter *    Unless required by applicable law or agreed to in writing,
16251881Speter *    software distributed under the License is distributed on an
17251881Speter *    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
18251881Speter *    KIND, either express or implied.  See the License for the
19251881Speter *    specific language governing permissions and limitations
20251881Speter *    under the License.
21251881Speter * ====================================================================
22251881Speter */
23251881Speter
24251881Speter/* ==================================================================== */
25251881Speter
26251881Speter
27251881Speter
28251881Speter#ifndef SVN_CL_H
29251881Speter#define SVN_CL_H
30251881Speter
31251881Speter/*** Includes. ***/
32251881Speter#include <apr_tables.h>
33251881Speter#include <apr_getopt.h>
34251881Speter
35251881Speter#include "svn_wc.h"
36251881Speter#include "svn_client.h"
37251881Speter#include "svn_string.h"
38251881Speter#include "svn_opt.h"
39251881Speter#include "svn_auth.h"
40251881Speter#include "svn_cmdline.h"
41251881Speter
42251881Speter#ifdef __cplusplus
43251881Speterextern "C" {
44251881Speter#endif /* __cplusplus */
45251881Speter
46251881Speter
47251881Speter/*** Option processing ***/
48251881Speter
49251881Speter/* --accept actions */
50251881Spetertypedef enum svn_cl__accept_t
51251881Speter{
52251881Speter  /* invalid accept action */
53251881Speter  svn_cl__accept_invalid = -2,
54251881Speter
55251881Speter  /* unspecified accept action */
56251881Speter  svn_cl__accept_unspecified = -1,
57251881Speter
58251881Speter  /* Leave conflicts alone, for later resolution. */
59251881Speter  svn_cl__accept_postpone,
60251881Speter
61251881Speter  /* Resolve the conflict with the pre-conflict base file. */
62251881Speter  svn_cl__accept_base,
63251881Speter
64251881Speter  /* Resolve the conflict with the current working file. */
65251881Speter  svn_cl__accept_working,
66251881Speter
67251881Speter  /* Resolve the conflicted hunks by choosing the corresponding text
68251881Speter     from the pre-conflict working copy file. */
69251881Speter  svn_cl__accept_mine_conflict,
70251881Speter
71251881Speter  /* Resolve the conflicted hunks by choosing the corresponding text
72251881Speter     from the post-conflict base copy file. */
73251881Speter  svn_cl__accept_theirs_conflict,
74251881Speter
75251881Speter  /* Resolve the conflict by taking the entire pre-conflict working
76251881Speter     copy file. */
77251881Speter  svn_cl__accept_mine_full,
78251881Speter
79251881Speter  /* Resolve the conflict by taking the entire post-conflict base file. */
80251881Speter  svn_cl__accept_theirs_full,
81251881Speter
82251881Speter  /* Launch user's editor and resolve conflict with edited file. */
83251881Speter  svn_cl__accept_edit,
84251881Speter
85251881Speter  /* Launch user's resolver and resolve conflict with edited file. */
86251881Speter  svn_cl__accept_launch
87251881Speter
88251881Speter} svn_cl__accept_t;
89251881Speter
90251881Speter/* --accept action user input words */
91251881Speter#define SVN_CL__ACCEPT_POSTPONE "postpone"
92251881Speter#define SVN_CL__ACCEPT_BASE "base"
93251881Speter#define SVN_CL__ACCEPT_WORKING "working"
94251881Speter#define SVN_CL__ACCEPT_MINE_CONFLICT "mine-conflict"
95251881Speter#define SVN_CL__ACCEPT_THEIRS_CONFLICT "theirs-conflict"
96251881Speter#define SVN_CL__ACCEPT_MINE_FULL "mine-full"
97251881Speter#define SVN_CL__ACCEPT_THEIRS_FULL "theirs-full"
98251881Speter#define SVN_CL__ACCEPT_EDIT "edit"
99251881Speter#define SVN_CL__ACCEPT_LAUNCH "launch"
100251881Speter
101251881Speter/* Return the svn_cl__accept_t value corresponding to WORD, using exact
102251881Speter * case-sensitive string comparison. Return svn_cl__accept_invalid if WORD
103251881Speter * is empty or is not one of the known values. */
104251881Spetersvn_cl__accept_t
105251881Spetersvn_cl__accept_from_word(const char *word);
106251881Speter
107251881Speter
108251881Speter/*** Mergeinfo flavors. ***/
109251881Speter
110251881Speter/* --show-revs values */
111251881Spetertypedef enum svn_cl__show_revs_t {
112251881Speter  svn_cl__show_revs_invalid = -1,
113251881Speter  svn_cl__show_revs_merged,
114251881Speter  svn_cl__show_revs_eligible
115251881Speter} svn_cl__show_revs_t;
116251881Speter
117251881Speter/* --show-revs user input words */
118251881Speter#define SVN_CL__SHOW_REVS_MERGED   "merged"
119251881Speter#define SVN_CL__SHOW_REVS_ELIGIBLE "eligible"
120251881Speter
121251881Speter/* Return svn_cl__show_revs_t value corresponding to word. */
122251881Spetersvn_cl__show_revs_t
123251881Spetersvn_cl__show_revs_from_word(const char *word);
124251881Speter
125251881Speter
126251881Speter/*** Command dispatch. ***/
127251881Speter
128251881Speter/* Hold results of option processing that are shared by multiple
129251881Speter   commands. */
130251881Spetertypedef struct svn_cl__opt_state_t
131251881Speter{
132251881Speter  /* An array of svn_opt_revision_range_t *'s representing revisions
133251881Speter     ranges indicated on the command-line via the -r and -c options.
134251881Speter     For each range in the list, if only one revision was provided
135251881Speter     (-rN), its 'end' member remains 'svn_opt_revision_unspecified'.
136251881Speter     This array always has at least one element, even if that is a
137251881Speter     null range in which both ends are 'svn_opt_revision_unspecified'. */
138251881Speter  apr_array_header_t *revision_ranges;
139251881Speter
140251881Speter  /* These are simply a copy of the range start and end values present
141251881Speter     in the first item of the revision_ranges list. */
142251881Speter  svn_opt_revision_t start_revision;
143251881Speter  svn_opt_revision_t end_revision;
144251881Speter
145251881Speter  /* Flag which is only set if the '-c' option was used. */
146251881Speter  svn_boolean_t used_change_arg;
147251881Speter
148251881Speter  /* Flag which is only set if the '-r' option was used. */
149251881Speter  svn_boolean_t used_revision_arg;
150251881Speter
151251881Speter  /* Max number of log messages to get back from svn_client_log2. */
152251881Speter  int limit;
153251881Speter
154251881Speter  /* After option processing is done, reflects the switch actually
155251881Speter     given on the command line, or svn_depth_unknown if none. */
156251881Speter  svn_depth_t depth;
157251881Speter
158251881Speter  /* Was --no-unlock specified? */
159251881Speter  svn_boolean_t no_unlock;
160251881Speter
161251881Speter  const char *message;           /* log message */
162251881Speter  svn_boolean_t force;           /* be more forceful, as in "svn rm -f ..." */
163251881Speter  svn_boolean_t force_log;       /* force validity of a suspect log msg file */
164251881Speter  svn_boolean_t incremental;     /* yield output suitable for concatenation */
165251881Speter  svn_boolean_t quiet;           /* sssh...avoid unnecessary output */
166251881Speter  svn_boolean_t non_interactive; /* do no interactive prompting */
167251881Speter  svn_boolean_t version;         /* print version information */
168251881Speter  svn_boolean_t verbose;         /* be verbose */
169251881Speter  svn_boolean_t update;          /* contact the server for the full story */
170251881Speter  svn_boolean_t strict;          /* do strictly what was requested */
171251881Speter  svn_stringbuf_t *filedata;     /* contents of file used as option data */
172251881Speter  const char *encoding;          /* the locale/encoding of the data*/
173251881Speter  svn_boolean_t help;            /* print usage message */
174251881Speter  const char *auth_username;     /* auth username */ /* UTF-8! */
175251881Speter  const char *auth_password;     /* auth password */ /* UTF-8! */
176251881Speter  const char *extensions;        /* subprocess extension args */ /* UTF-8! */
177251881Speter  apr_array_header_t *targets;   /* target list from file */ /* UTF-8! */
178251881Speter  svn_boolean_t xml;             /* output in xml, e.g., "svn log --xml" */
179251881Speter  svn_boolean_t no_ignore;       /* disregard default ignores & svn:ignore's */
180251881Speter  svn_boolean_t no_auth_cache;   /* do not cache authentication information */
181251881Speter  struct
182251881Speter    {
183251881Speter  const char *diff_cmd;              /* the external diff command to use */
184251881Speter  svn_boolean_t internal_diff;       /* override diff_cmd in config file */
185251881Speter  svn_boolean_t no_diff_added;       /* do not show diffs for deleted files */
186251881Speter  svn_boolean_t no_diff_deleted;     /* do not show diffs for deleted files */
187251881Speter  svn_boolean_t show_copies_as_adds; /* do not diff copies with their source */
188251881Speter  svn_boolean_t notice_ancestry;     /* notice ancestry for diff-y operations */
189251881Speter  svn_boolean_t summarize;           /* create a summary of a diff */
190251881Speter  svn_boolean_t use_git_diff_format; /* Use git's extended diff format */
191251881Speter  svn_boolean_t ignore_properties;   /* ignore properties */
192251881Speter  svn_boolean_t properties_only;     /* Show properties only */
193251881Speter  svn_boolean_t patch_compatible;    /* Output compatible with GNU patch */
194251881Speter    } diff;
195251881Speter  svn_boolean_t ignore_ancestry; /* ignore ancestry for merge-y operations */
196251881Speter  svn_boolean_t ignore_externals;/* ignore externals definitions */
197251881Speter  svn_boolean_t stop_on_copy;    /* don't cross copies during processing */
198251881Speter  svn_boolean_t dry_run;         /* try operation but make no changes */
199251881Speter  svn_boolean_t revprop;         /* operate on a revision property */
200251881Speter  const char *merge_cmd;         /* the external merge command to use */
201251881Speter  const char *editor_cmd;        /* the external editor command to use */
202251881Speter  svn_boolean_t record_only;     /* whether to record mergeinfo */
203251881Speter  const char *old_target;        /* diff target */
204251881Speter  const char *new_target;        /* diff target */
205251881Speter  svn_boolean_t relocate;        /* rewrite urls (svn switch) */
206251881Speter  const char *config_dir;        /* over-riding configuration directory */
207251881Speter  apr_array_header_t *config_options; /* over-riding configuration options */
208251881Speter  svn_boolean_t autoprops;       /* enable automatic properties */
209251881Speter  svn_boolean_t no_autoprops;    /* disable automatic properties */
210251881Speter  const char *native_eol;        /* override system standard eol marker */
211251881Speter  svn_boolean_t remove;          /* deassociate a changelist */
212251881Speter  apr_array_header_t *changelists; /* changelist filters */
213251881Speter  const char *changelist;        /* operate on this changelist
214251881Speter                                    THIS IS TEMPORARY (LAST OF CHANGELISTS) */
215251881Speter  svn_boolean_t keep_changelists;/* don't remove changelists after commit */
216251881Speter  svn_boolean_t keep_local;      /* delete path only from repository */
217251881Speter  svn_boolean_t all_revprops;    /* retrieve all revprops */
218251881Speter  svn_boolean_t no_revprops;     /* retrieve no revprops */
219251881Speter  apr_hash_t *revprop_table;     /* table of revision properties to get/set */
220251881Speter  svn_boolean_t parents;         /* create intermediate directories */
221251881Speter  svn_boolean_t use_merge_history; /* use/display extra merge information */
222251881Speter  svn_cl__accept_t accept_which;   /* how to handle conflicts */
223251881Speter  svn_cl__show_revs_t show_revs;   /* mergeinfo flavor */
224251881Speter  svn_depth_t set_depth;           /* new sticky ambient depth value */
225251881Speter  svn_boolean_t reintegrate;      /* use "reintegrate" merge-source heuristic */
226251881Speter  svn_boolean_t trust_server_cert; /* trust server SSL certs that would
227251881Speter                                      otherwise be rejected as "untrusted" */
228251881Speter  int strip; /* number of leading path components to strip */
229251881Speter  svn_boolean_t ignore_keywords;   /* do not expand keywords */
230251881Speter  svn_boolean_t reverse_diff;      /* reverse a diff (e.g. when patching) */
231251881Speter  svn_boolean_t ignore_whitespace; /* don't account for whitespace when
232251881Speter                                      patching */
233251881Speter  svn_boolean_t show_diff;         /* produce diff output (maps to --diff) */
234251881Speter  svn_boolean_t allow_mixed_rev;   /* Allow operation on mixed-revision WC */
235251881Speter  svn_boolean_t include_externals; /* Recurses (in)to file & dir externals */
236251881Speter  svn_boolean_t show_inherited_props;  /* get inherited properties */
237251881Speter  apr_array_header_t* search_patterns; /* pattern arguments for --search */
238251881Speter} svn_cl__opt_state_t;
239251881Speter
240251881Speter
241251881Spetertypedef struct svn_cl__cmd_baton_t
242251881Speter{
243251881Speter  svn_cl__opt_state_t *opt_state;
244251881Speter  svn_client_ctx_t *ctx;
245251881Speter} svn_cl__cmd_baton_t;
246251881Speter
247251881Speter
248251881Speter/* Declare all the command procedures */
249251881Spetersvn_opt_subcommand_t
250251881Speter  svn_cl__add,
251251881Speter  svn_cl__blame,
252251881Speter  svn_cl__cat,
253251881Speter  svn_cl__changelist,
254251881Speter  svn_cl__checkout,
255251881Speter  svn_cl__cleanup,
256251881Speter  svn_cl__commit,
257251881Speter  svn_cl__copy,
258251881Speter  svn_cl__delete,
259251881Speter  svn_cl__diff,
260251881Speter  svn_cl__export,
261251881Speter  svn_cl__help,
262251881Speter  svn_cl__import,
263251881Speter  svn_cl__info,
264251881Speter  svn_cl__lock,
265251881Speter  svn_cl__log,
266251881Speter  svn_cl__list,
267251881Speter  svn_cl__merge,
268251881Speter  svn_cl__mergeinfo,
269251881Speter  svn_cl__mkdir,
270251881Speter  svn_cl__move,
271251881Speter  svn_cl__patch,
272251881Speter  svn_cl__propdel,
273251881Speter  svn_cl__propedit,
274251881Speter  svn_cl__propget,
275251881Speter  svn_cl__proplist,
276251881Speter  svn_cl__propset,
277251881Speter  svn_cl__relocate,
278251881Speter  svn_cl__revert,
279251881Speter  svn_cl__resolve,
280251881Speter  svn_cl__resolved,
281251881Speter  svn_cl__status,
282251881Speter  svn_cl__switch,
283251881Speter  svn_cl__unlock,
284251881Speter  svn_cl__update,
285251881Speter  svn_cl__upgrade;
286251881Speter
287251881Speter
288251881Speter/* See definition in svn.c for documentation. */
289251881Speterextern const svn_opt_subcommand_desc2_t svn_cl__cmd_table[];
290251881Speter
291251881Speter/* See definition in svn.c for documentation. */
292251881Speterextern const int svn_cl__global_options[];
293251881Speter
294251881Speter/* See definition in svn.c for documentation. */
295251881Speterextern const apr_getopt_option_t svn_cl__options[];
296251881Speter
297251881Speter
298251881Speter/* A helper for the many subcommands that wish to merely warn when
299251881Speter * invoked on an unversioned, nonexistent, or otherwise innocuously
300251881Speter * errorful resource.  Meant to be wrapped with SVN_ERR().
301251881Speter *
302251881Speter * If ERR is null, return SVN_NO_ERROR.
303251881Speter *
304251881Speter * Else if ERR->apr_err is one of the error codes supplied in varargs,
305251881Speter * then handle ERR as a warning (unless QUIET is true), clear ERR, and
306251881Speter * return SVN_NO_ERROR, and push the value of ERR->apr_err into the
307251881Speter * ERRORS_SEEN array, if ERRORS_SEEN is not NULL.
308251881Speter *
309251881Speter * Else return ERR.
310251881Speter *
311251881Speter * Typically, error codes like SVN_ERR_UNVERSIONED_RESOURCE,
312251881Speter * SVN_ERR_ENTRY_NOT_FOUND, etc, are supplied in varargs.  Don't
313251881Speter * forget to terminate the argument list with SVN_NO_ERROR.
314251881Speter */
315251881Spetersvn_error_t *
316251881Spetersvn_cl__try(svn_error_t *err,
317251881Speter            apr_array_header_t *errors_seen,
318251881Speter            svn_boolean_t quiet,
319251881Speter            ...);
320251881Speter
321251881Speter
322251881Speter/* Our cancellation callback. */
323251881Spetersvn_error_t *
324251881Spetersvn_cl__check_cancel(void *baton);
325251881Speter
326251881Speter
327251881Speter
328251881Speter/* Various conflict-resolution callbacks. */
329251881Speter
330251881Speter/* Opaque baton type for svn_cl__conflict_func_interactive(). */
331251881Spetertypedef struct svn_cl__interactive_conflict_baton_t
332251881Speter  svn_cl__interactive_conflict_baton_t;
333251881Speter
334251881Speter/* Conflict stats for operations such as update and merge. */
335251881Spetertypedef struct svn_cl__conflict_stats_t svn_cl__conflict_stats_t;
336251881Speter
337251881Speter/* Return a new, initialized, conflict stats structure, allocated in
338251881Speter * POOL. */
339251881Spetersvn_cl__conflict_stats_t *
340251881Spetersvn_cl__conflict_stats_create(apr_pool_t *pool);
341251881Speter
342251881Speter/* Update CONFLICT_STATS to reflect that a conflict on PATH_LOCAL of kind
343251881Speter * CONFLICT_KIND is resolved.  (There is no support for updating the
344251881Speter * 'skipped paths' stats, since skips cannot be 'resolved'.) */
345251881Spetervoid
346251881Spetersvn_cl__conflict_stats_resolved(svn_cl__conflict_stats_t *conflict_stats,
347251881Speter                                const char *path_local,
348251881Speter                                svn_wc_conflict_kind_t conflict_kind);
349251881Speter
350251881Speter
351251881Speter/* Create and return an baton for use with svn_cl__conflict_func_interactive
352251881Speter * in *B, allocated from RESULT_POOL, and initialised with the values
353251881Speter * ACCEPT_WHICH, CONFIG, EDITOR_CMD, CANCEL_FUNC and CANCEL_BATON. */
354251881Spetersvn_error_t *
355251881Spetersvn_cl__get_conflict_func_interactive_baton(
356251881Speter  svn_cl__interactive_conflict_baton_t **b,
357251881Speter  svn_cl__accept_t accept_which,
358251881Speter  apr_hash_t *config,
359251881Speter  const char *editor_cmd,
360251881Speter  svn_cl__conflict_stats_t *conflict_stats,
361251881Speter  svn_cancel_func_t cancel_func,
362251881Speter  void *cancel_baton,
363251881Speter  apr_pool_t *result_pool);
364251881Speter
365251881Speter/* A callback capable of doing interactive conflict resolution.
366251881Speter
367251881Speter   The BATON must come from svn_cl__get_conflict_func_interactive_baton().
368251881Speter   Resolves based on the --accept option if one was given to that function,
369251881Speter   otherwise prompts the user to choose one of the three fulltexts, edit
370251881Speter   the merged file on the spot, or just skip the conflict (to be resolved
371251881Speter   later), among other options.
372251881Speter
373251881Speter   Implements svn_wc_conflict_resolver_func2_t.
374251881Speter */
375251881Spetersvn_error_t *
376251881Spetersvn_cl__conflict_func_interactive(svn_wc_conflict_result_t **result,
377251881Speter                                  const svn_wc_conflict_description2_t *desc,
378251881Speter                                  void *baton,
379251881Speter                                  apr_pool_t *result_pool,
380251881Speter                                  apr_pool_t *scratch_pool);
381251881Speter
382251881Speter
383251881Speter/*** Command-line output functions -- printing to the user. ***/
384251881Speter
385251881Speter/* Print out commit information found in COMMIT_INFO to the console.
386251881Speter * POOL is used for temporay allocations.
387251881Speter * COMMIT_INFO should not be NULL.
388251881Speter *
389251881Speter * This function implements svn_commit_callback2_t.
390251881Speter */
391251881Spetersvn_error_t *
392251881Spetersvn_cl__print_commit_info(const svn_commit_info_t *commit_info,
393251881Speter                          void *baton,
394251881Speter                          apr_pool_t *pool);
395251881Speter
396251881Speter
397251881Speter/* Convert the date in DATA to a human-readable UTF-8-encoded string
398251881Speter * *HUMAN_CSTRING, or set the latter to "(invalid date)" if DATA is not
399251881Speter * a valid date.  DATA should be as expected by svn_time_from_cstring().
400251881Speter *
401251881Speter * Do all allocations in POOL.
402251881Speter */
403251881Spetersvn_error_t *
404251881Spetersvn_cl__time_cstring_to_human_cstring(const char **human_cstring,
405251881Speter                                      const char *data,
406251881Speter                                      apr_pool_t *pool);
407251881Speter
408251881Speter
409251881Speter/* Print STATUS for PATH to stdout for human consumption.  Prints in
410251881Speter   abbreviated format by default, or DETAILED format if flag is set.
411251881Speter
412251881Speter   When SUPPRESS_EXTERNALS_PLACEHOLDERS is set, avoid printing
413251881Speter   externals placeholder lines ("X lines").
414251881Speter
415251881Speter   When DETAILED is set, use SHOW_LAST_COMMITTED to toggle display of
416251881Speter   the last-committed-revision and last-committed-author.
417251881Speter
418251881Speter   If SKIP_UNRECOGNIZED is TRUE, this function will not print out
419251881Speter   unversioned items found in the working copy.
420251881Speter
421251881Speter   When DETAILED is set, and REPOS_LOCKS is set, treat missing repository locks
422251881Speter   as broken WC locks.
423251881Speter
424251881Speter   Increment *TEXT_CONFLICTS, *PROP_CONFLICTS, or *TREE_CONFLICTS if
425251881Speter   a conflict was encountered.
426251881Speter
427262253Speter   Use TARGET_ABSPATH and TARGET_PATH to shorten PATH into something
428262253Speter   relative to the target as necessary.
429251881Speter*/
430251881Spetersvn_error_t *
431262253Spetersvn_cl__print_status(const char *target_abspath,
432262253Speter                     const char *target_path,
433251881Speter                     const char *path,
434251881Speter                     const svn_client_status_t *status,
435251881Speter                     svn_boolean_t suppress_externals_placeholders,
436251881Speter                     svn_boolean_t detailed,
437251881Speter                     svn_boolean_t show_last_committed,
438251881Speter                     svn_boolean_t skip_unrecognized,
439251881Speter                     svn_boolean_t repos_locks,
440251881Speter                     unsigned int *text_conflicts,
441251881Speter                     unsigned int *prop_conflicts,
442251881Speter                     unsigned int *tree_conflicts,
443251881Speter                     svn_client_ctx_t *ctx,
444251881Speter                     apr_pool_t *pool);
445251881Speter
446251881Speter
447251881Speter/* Print STATUS for PATH in XML to stdout.  Use POOL for temporary
448251881Speter   allocations.
449251881Speter
450262253Speter   Use TARGET_ABSPATH and TARGET_PATH to shorten PATH into something
451262253Speter   relative to the target as necessary.
452251881Speter */
453251881Spetersvn_error_t *
454262253Spetersvn_cl__print_status_xml(const char *target_abspath,
455262253Speter                         const char *target_path,
456251881Speter                         const char *path,
457251881Speter                         const svn_client_status_t *status,
458251881Speter                         svn_client_ctx_t *ctx,
459251881Speter                         apr_pool_t *pool);
460251881Speter
461251881Speter/* Output a commit xml element to *OUTSTR.  If *OUTSTR is NULL, allocate it
462251881Speter   first from POOL, otherwise append to it.  If AUTHOR or DATE is
463251881Speter   NULL, it will be omitted. */
464251881Spetervoid
465251881Spetersvn_cl__print_xml_commit(svn_stringbuf_t **outstr,
466251881Speter                         svn_revnum_t revision,
467251881Speter                         const char *author,
468251881Speter                         const char *date,
469251881Speter                         apr_pool_t *pool);
470251881Speter
471251881Speter/* Output an XML "<lock>" element describing LOCK to *OUTSTR.  If *OUTSTR is
472251881Speter   NULL, allocate it first from POOL, otherwise append to it. */
473251881Spetervoid
474251881Spetersvn_cl__print_xml_lock(svn_stringbuf_t **outstr,
475251881Speter                       const svn_lock_t *lock,
476251881Speter                       apr_pool_t *pool);
477251881Speter
478251881Speter/* Do the following things that are commonly required before accessing revision
479251881Speter   properties.  Ensure that REVISION is specified explicitly and is not
480251881Speter   relative to a working-copy item.  Ensure that exactly one target is
481251881Speter   specified in TARGETS.  Set *URL to the URL of the target.  Return an
482251881Speter   appropriate error if any of those checks or operations fail. Use CTX for
483251881Speter   accessing the working copy
484251881Speter */
485251881Spetersvn_error_t *
486251881Spetersvn_cl__revprop_prepare(const svn_opt_revision_t *revision,
487251881Speter                        const apr_array_header_t *targets,
488251881Speter                        const char **URL,
489251881Speter                        svn_client_ctx_t *ctx,
490251881Speter                        apr_pool_t *pool);
491251881Speter
492251881Speter/* Search for a merge tool command in environment variables,
493251881Speter   and use it to perform the merge of the four given files.
494251881Speter   WC_PATH is the path of the file that is in conflict, relative
495251881Speter   to the merge target.
496251881Speter   Use POOL for all allocations.
497251881Speter
498251881Speter   CONFIG is a hash of svn_config_t * items keyed on a configuration
499251881Speter   category (SVN_CONFIG_CATEGORY_CONFIG et al), and may be NULL.
500251881Speter
501251881Speter   Upon success, set *REMAINS_IN_CONFLICT to indicate whether the
502251881Speter   merge result contains conflict markers.
503251881Speter   */
504251881Spetersvn_error_t *
505251881Spetersvn_cl__merge_file_externally(const char *base_path,
506251881Speter                              const char *their_path,
507251881Speter                              const char *my_path,
508251881Speter                              const char *merged_path,
509251881Speter                              const char *wc_path,
510251881Speter                              apr_hash_t *config,
511251881Speter                              svn_boolean_t *remains_in_conflict,
512251881Speter                              apr_pool_t *pool);
513251881Speter
514251881Speter/* Like svn_cl__merge_file_externally, but using a built-in merge tool
515251881Speter * with help from an external editor specified by EDITOR_CMD. */
516251881Spetersvn_error_t *
517251881Spetersvn_cl__merge_file(const char *base_path,
518251881Speter                   const char *their_path,
519251881Speter                   const char *my_path,
520251881Speter                   const char *merged_path,
521251881Speter                   const char *wc_path,
522251881Speter                   const char *path_prefix,
523251881Speter                   const char *editor_cmd,
524251881Speter                   apr_hash_t *config,
525251881Speter                   svn_boolean_t *remains_in_conflict,
526251881Speter                   apr_pool_t *scratch_pool);
527251881Speter
528251881Speter
529251881Speter/*** Notification functions to display results on the terminal. */
530251881Speter
531251881Speter/* Set *NOTIFY_FUNC_P and *NOTIFY_BATON_P to a notifier/baton for all
532251881Speter * operations, allocated in POOL.
533251881Speter */
534251881Spetersvn_error_t *
535251881Spetersvn_cl__get_notifier(svn_wc_notify_func2_t *notify_func_p,
536251881Speter                     void **notify_baton_p,
537251881Speter                     svn_cl__conflict_stats_t *conflict_stats,
538251881Speter                     apr_pool_t *pool);
539251881Speter
540251881Speter/* Make the notifier for use with BATON print the appropriate summary
541251881Speter * line at the end of the output.
542251881Speter */
543251881Spetersvn_error_t *
544251881Spetersvn_cl__notifier_mark_checkout(void *baton);
545251881Speter
546251881Speter/* Make the notifier for use with BATON print the appropriate summary
547251881Speter * line at the end of the output.
548251881Speter */
549251881Spetersvn_error_t *
550251881Spetersvn_cl__notifier_mark_export(void *baton);
551251881Speter
552251881Speter/* Make the notifier for use with BATON print the appropriate notifications
553251881Speter * for a wc to repository copy
554251881Speter */
555251881Spetersvn_error_t *
556251881Spetersvn_cl__notifier_mark_wc_to_repos_copy(void *baton);
557251881Speter
558251881Speter/* Baton for use with svn_cl__check_externals_failed_notify_wrapper(). */
559251881Speterstruct svn_cl__check_externals_failed_notify_baton
560251881Speter{
561251881Speter  svn_wc_notify_func2_t wrapped_func; /* The "real" notify_func2. */
562251881Speter  void *wrapped_baton;                /* The "real" notify_func2 baton. */
563251881Speter  svn_boolean_t had_externals_error;  /* Did something fail in an external? */
564251881Speter};
565251881Speter
566251881Speter/* Notification function wrapper (implements `svn_wc_notify_func2_t').
567251881Speter   Use with an svn_cl__check_externals_failed_notify_baton BATON. */
568251881Spetervoid
569251881Spetersvn_cl__check_externals_failed_notify_wrapper(void *baton,
570251881Speter                                              const svn_wc_notify_t *n,
571251881Speter                                              apr_pool_t *pool);
572251881Speter
573251881Speter/* Print the conflict stats accumulated in BATON, which is the
574251881Speter * notifier baton from svn_cl__get_notifier().
575251881Speter * Return any error encountered during printing.
576251881Speter */
577251881Spetersvn_error_t *
578251881Spetersvn_cl__notifier_print_conflict_stats(void *baton, apr_pool_t *scratch_pool);
579251881Speter
580251881Speter
581251881Speter/*** Log message callback stuffs. ***/
582251881Speter
583251881Speter/* Allocate in POOL a baton for use with svn_cl__get_log_message().
584251881Speter
585251881Speter   OPT_STATE is the set of command-line options given.
586251881Speter
587251881Speter   BASE_DIR is a directory in which to create temporary files if an
588251881Speter   external editor is used to edit the log message.  If BASE_DIR is
589251881Speter   NULL, the current working directory (`.') will be used, and
590251881Speter   therefore the user must have the proper permissions on that
591251881Speter   directory.  ### todo: What *should* happen in the NULL case is that
592251881Speter   we ask APR to tell us where a suitable tmp directory is (like, /tmp
593251881Speter   on Unix and C:\Windows\Temp on Win32 or something), and use it.
594251881Speter   But APR doesn't yet have that capability.
595251881Speter
596251881Speter   CONFIG is a client configuration hash of svn_config_t * items keyed
597251881Speter   on config categories, and may be NULL.
598251881Speter
599251881Speter   NOTE: While the baton itself will be allocated from POOL, the items
600251881Speter   add to it are added by reference, not duped into POOL!*/
601251881Spetersvn_error_t *
602251881Spetersvn_cl__make_log_msg_baton(void **baton,
603251881Speter                           svn_cl__opt_state_t *opt_state,
604251881Speter                           const char *base_dir,
605251881Speter                           apr_hash_t *config,
606251881Speter                           apr_pool_t *pool);
607251881Speter
608251881Speter/* A function of type svn_client_get_commit_log3_t. */
609251881Spetersvn_error_t *
610251881Spetersvn_cl__get_log_message(const char **log_msg,
611251881Speter                        const char **tmp_file,
612251881Speter                        const apr_array_header_t *commit_items,
613251881Speter                        void *baton,
614251881Speter                        apr_pool_t *pool);
615251881Speter
616251881Speter/* Handle the cleanup of a log message, using the data in the
617251881Speter   LOG_MSG_BATON, in the face of COMMIT_ERR.  This may mean removing a
618251881Speter   temporary file left by an external editor, or it may be a complete
619251881Speter   no-op.  COMMIT_ERR may be NULL to indicate to indicate that the
620251881Speter   function should act as though no commit error occurred. Use POOL
621251881Speter   for temporary allocations.
622251881Speter
623251881Speter   All error returns from this function are guaranteed to at least
624251881Speter   include COMMIT_ERR, and perhaps additional errors attached to the
625251881Speter   end of COMMIT_ERR's chain.  */
626251881Spetersvn_error_t *
627251881Spetersvn_cl__cleanup_log_msg(void *log_msg_baton,
628251881Speter                        svn_error_t *commit_err,
629251881Speter                        apr_pool_t *pool);
630251881Speter
631251881Speter/* Add a message about --force if appropriate */
632251881Spetersvn_error_t *
633251881Spetersvn_cl__may_need_force(svn_error_t *err);
634251881Speter
635251881Speter/* Write the STRING to the stdio STREAM, returning an error if it fails.
636251881Speter
637251881Speter   This function is equal to svn_cmdline_fputs() minus the utf8->local
638251881Speter   encoding translation.  */
639251881Spetersvn_error_t *
640251881Spetersvn_cl__error_checked_fputs(const char *string, FILE* stream);
641251881Speter
642251881Speter/* If STRING is non-null, append it, wrapped in a simple XML CDATA element
643251881Speter   named TAGNAME, to the string SB.  Use POOL for temporary allocations. */
644251881Spetervoid
645251881Spetersvn_cl__xml_tagged_cdata(svn_stringbuf_t **sb,
646251881Speter                         apr_pool_t *pool,
647251881Speter                         const char *tagname,
648251881Speter                         const char *string);
649251881Speter
650251881Speter/* Print the XML prolog and document root element start-tag to stdout, using
651251881Speter   TAGNAME as the root element name.  Use POOL for temporary allocations. */
652251881Spetersvn_error_t *
653251881Spetersvn_cl__xml_print_header(const char *tagname, apr_pool_t *pool);
654251881Speter
655251881Speter/* Print the XML document root element end-tag to stdout, using TAGNAME as the
656251881Speter   root element name.  Use POOL for temporary allocations. */
657251881Spetersvn_error_t *
658251881Spetersvn_cl__xml_print_footer(const char *tagname, apr_pool_t *pool);
659251881Speter
660251881Speter
661251881Speter/* For use in XML output, return a non-localised string representation
662251881Speter * of KIND, being "none" or "dir" or "file" or, in any other case,
663251881Speter * the empty string. */
664251881Speterconst char *
665251881Spetersvn_cl__node_kind_str_xml(svn_node_kind_t kind);
666251881Speter
667251881Speter/* Return a (possibly localised) string representation of KIND, being "none" or
668251881Speter   "dir" or "file" or, in any other case, the empty string. */
669251881Speterconst char *
670251881Spetersvn_cl__node_kind_str_human_readable(svn_node_kind_t kind);
671251881Speter
672251881Speter
673251881Speter/** Provides an XML name for a given OPERATION.
674251881Speter * Note: POOL is currently not used.
675251881Speter */
676251881Speterconst char *
677251881Spetersvn_cl__operation_str_xml(svn_wc_operation_t operation, apr_pool_t *pool);
678251881Speter
679251881Speter/** Return a possibly localized human readable string for
680251881Speter * a given OPERATION.
681251881Speter * Note: POOL is currently not used.
682251881Speter */
683251881Speterconst char *
684251881Spetersvn_cl__operation_str_human_readable(svn_wc_operation_t operation,
685251881Speter                                     apr_pool_t *pool);
686251881Speter
687251881Speter
688251881Speter/* What use is a property name intended for.
689251881Speter   Used by svn_cl__check_svn_prop_name to customize error messages. */
690251881Spetertypedef enum svn_cl__prop_use_e
691251881Speter  {
692251881Speter    svn_cl__prop_use_set,       /* setting the property */
693251881Speter    svn_cl__prop_use_edit,      /* editing the property */
694251881Speter    svn_cl__prop_use_use        /* using the property name */
695251881Speter  }
696251881Spetersvn_cl__prop_use_t;
697251881Speter
698251881Speter/* If PROPNAME looks like but is not identical to one of the svn:
699251881Speter * poperties, raise an error and suggest a better spelling. Names that
700251881Speter * raise errors look like this:
701251881Speter *
702251881Speter *   - start with svn: but do not exactly match a known property; or,
703251881Speter *   - start with a 3-letter prefix that differs in only one letter
704251881Speter *     from "svn:", and the rest exactly matches a known propery.
705251881Speter *
706251881Speter * If REVPROP is TRUE, only check revision property names; otherwise
707251881Speter * only check node property names.
708251881Speter *
709251881Speter * Use SCRATCH_POOL for temporary allocations.
710251881Speter */
711251881Spetersvn_error_t *
712251881Spetersvn_cl__check_svn_prop_name(const char *propname,
713251881Speter                            svn_boolean_t revprop,
714251881Speter                            svn_cl__prop_use_t prop_use,
715251881Speter                            apr_pool_t *scratch_pool);
716251881Speter
717251881Speter/* If PROPNAME is one of the svn: properties with a boolean value, and
718251881Speter * PROPVAL looks like an attempt to turn the property off (i.e., it's
719251881Speter * "off", "no", "false", or ""), then print a warning to the user that
720251881Speter * setting the property to this value might not do what they expect.
721251881Speter * Perform temporary allocations in POOL.
722251881Speter */
723251881Spetervoid
724251881Spetersvn_cl__check_boolean_prop_val(const char *propname,
725251881Speter                               const char *propval,
726251881Speter                               apr_pool_t *pool);
727251881Speter
728251881Speter/* De-streamifying wrapper around svn_client_get_changelists(), which
729251881Speter   is called for each target in TARGETS to populate *PATHS (a list of
730251881Speter   paths assigned to one of the CHANGELISTS.
731251881Speter   If all targets are to be included, may set *PATHS to TARGETS without
732251881Speter   reallocating. */
733251881Spetersvn_error_t *
734251881Spetersvn_cl__changelist_paths(apr_array_header_t **paths,
735251881Speter                         const apr_array_header_t *changelists,
736251881Speter                         const apr_array_header_t *targets,
737251881Speter                         svn_depth_t depth,
738251881Speter                         svn_client_ctx_t *ctx,
739251881Speter                         apr_pool_t *result_pool,
740251881Speter                         apr_pool_t *scratch_pool);
741251881Speter
742251881Speter/* Like svn_client_args_to_target_array() but, if the only error is that some
743251881Speter * arguments are reserved file names, then print warning messages for those
744251881Speter * targets, store the rest of the targets in TARGETS_P and return success. */
745251881Spetersvn_error_t *
746251881Spetersvn_cl__args_to_target_array_print_reserved(apr_array_header_t **targets_p,
747251881Speter                                            apr_getopt_t *os,
748251881Speter                                            const apr_array_header_t *known_targets,
749251881Speter                                            svn_client_ctx_t *ctx,
750251881Speter                                            svn_boolean_t keep_dest_origpath_on_truepath_collision,
751251881Speter                                            apr_pool_t *pool);
752251881Speter
753251881Speter/* Return a string showing NODE's kind, URL and revision, to the extent that
754251881Speter * that information is available in NODE. If NODE itself is NULL, this prints
755251881Speter * just a 'none' node kind.
756251881Speter * WC_REPOS_ROOT_URL should reflect the target working copy's repository
757251881Speter * root URL. If NODE is from that same URL, the printed URL is abbreviated
758251881Speter * to caret notation (^/). WC_REPOS_ROOT_URL may be NULL, in which case
759251881Speter * this function tries to print the conflicted node's complete URL. */
760251881Speterconst char *
761251881Spetersvn_cl__node_description(const svn_wc_conflict_version_t *node,
762251881Speter                         const char *wc_repos_root_URL,
763251881Speter                         apr_pool_t *pool);
764251881Speter
765251881Speter/* Return, in @a *true_targets_p, a shallow copy of @a targets with any
766251881Speter * empty peg revision specifier snipped off the end of each element.  If any
767251881Speter * target has a non-empty peg revision specifier, throw an error.  The user
768251881Speter * may have specified a peg revision where it doesn't make sense to do so,
769251881Speter * or may have forgotten to escape an '@' character in a filename.
770251881Speter *
771251881Speter * This function is useful for subcommands for which peg revisions
772251881Speter * do not make any sense. Such subcommands still need to allow an empty
773251881Speter * peg revision to be specified on the command line so that users of
774251881Speter * the command line client can consistently escape '@' characters
775251881Speter * in filenames by appending an '@' character, regardless of the
776251881Speter * subcommand being used.
777251881Speter *
778251881Speter * It is safe to pass the address of @a targets as @a true_targets_p.
779251881Speter *
780251881Speter * Do all allocations in @a pool. */
781251881Spetersvn_error_t *
782251881Spetersvn_cl__eat_peg_revisions(apr_array_header_t **true_targets_p,
783251881Speter                          const apr_array_header_t *targets,
784251881Speter                          apr_pool_t *pool);
785251881Speter
786251881Speter/* Return an error if TARGETS contains a mixture of URLs and paths; otherwise
787251881Speter * return SVN_NO_ERROR. */
788251881Spetersvn_error_t *
789251881Spetersvn_cl__assert_homogeneous_target_type(const apr_array_header_t *targets);
790251881Speter
791251881Speter/* Return an error if TARGETS contains a URL; otherwise return SVN_NO_ERROR. */
792251881Spetersvn_error_t *
793251881Spetersvn_cl__check_targets_are_local_paths(const apr_array_header_t *targets);
794251881Speter
795251881Speter/* Return an error if TARGET is a URL; otherwise return SVN_NO_ERROR. */
796251881Spetersvn_error_t *
797251881Spetersvn_cl__check_target_is_local_path(const char *target);
798251881Speter
799251881Speter/* Return a copy of PATH, converted to the local path style, skipping
800251881Speter * PARENT_PATH if it is non-null and is a parent of or equal to PATH.
801251881Speter *
802251881Speter * This function assumes PARENT_PATH and PATH are both absolute "dirents"
803251881Speter * or both relative "dirents". */
804251881Speterconst char *
805251881Spetersvn_cl__local_style_skip_ancestor(const char *parent_path,
806251881Speter                                  const char *path,
807251881Speter                                  apr_pool_t *pool);
808251881Speter
809251881Speter/* If the user is setting a mime-type to mark one of the TARGETS as binary,
810251881Speter * as determined by property name PROPNAME and value PROPVAL, then check
811251881Speter * whether Subversion's own binary-file detection recognizes the target as
812251881Speter * a binary file. If Subversion doesn't consider the target to be a binary
813251881Speter * file, assume the user is making an error and print a warning to inform
814251881Speter * the user that some operations might fail on the file in the future. */
815251881Spetersvn_error_t *
816251881Spetersvn_cl__propset_print_binary_mime_type_warning(apr_array_header_t *targets,
817251881Speter                                               const char *propname,
818251881Speter                                               const svn_string_t *propval,
819251881Speter                                               apr_pool_t *scratch_pool);
820251881Speter
821251881Speter/* A wrapper around the deprecated svn_client_merge_reintegrate. */
822251881Spetersvn_error_t *
823251881Spetersvn_cl__deprecated_merge_reintegrate(const char *source_path_or_url,
824251881Speter                                     const svn_opt_revision_t *src_peg_revision,
825251881Speter                                     const char *target_wcpath,
826251881Speter                                     svn_boolean_t dry_run,
827251881Speter                                     const apr_array_header_t *merge_options,
828251881Speter                                     svn_client_ctx_t *ctx,
829251881Speter                                     apr_pool_t *pool);
830251881Speter
831251881Speter#ifdef __cplusplus
832251881Speter}
833251881Speter#endif /* __cplusplus */
834251881Speter
835251881Speter#endif /* SVN_CL_H */
836