]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/subversion/subversion/svn/cl.h
Add libbearssl
[FreeBSD/FreeBSD.git] / contrib / subversion / subversion / svn / cl.h
1 /*
2  * cl.h:  shared stuff in the command line program
3  *
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
12  *
13  *      http://www.apache.org/licenses/LICENSE-2.0
14  *
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
20  *    under the License.
21  * ====================================================================
22  */
23
24 /* ==================================================================== */
25
26
27 \f
28 #ifndef SVN_CL_H
29 #define SVN_CL_H
30
31 /*** Includes. ***/
32 #include <apr_tables.h>
33 #include <apr_getopt.h>
34
35 #include "svn_wc.h"
36 #include "svn_client.h"
37 #include "svn_string.h"
38 #include "svn_opt.h"
39 #include "svn_auth.h"
40 #include "svn_cmdline.h"
41
42 #ifdef __cplusplus
43 extern "C" {
44 #endif /* __cplusplus */
45
46 \f
47 /*** Option processing ***/
48
49 /* --accept actions */
50 typedef enum svn_cl__accept_t
51 {
52   /* invalid accept action */
53   svn_cl__accept_invalid = -2,
54
55   /* unspecified accept action */
56   svn_cl__accept_unspecified = -1,
57
58   /* Leave conflicts alone, for later resolution. */
59   svn_cl__accept_postpone,
60
61   /* Resolve the conflict with the pre-conflict base file. */
62   svn_cl__accept_base,
63
64   /* Resolve the conflict with the current working file. */
65   svn_cl__accept_working,
66
67   /* Resolve the conflicted hunks by choosing the corresponding text
68      from the pre-conflict working copy file. */
69   svn_cl__accept_mine_conflict,
70
71   /* Resolve the conflicted hunks by choosing the corresponding text
72      from the post-conflict base copy file. */
73   svn_cl__accept_theirs_conflict,
74
75   /* Resolve the conflict by taking the entire pre-conflict working
76      copy file. */
77   svn_cl__accept_mine_full,
78
79   /* Resolve the conflict by taking the entire post-conflict base file. */
80   svn_cl__accept_theirs_full,
81
82   /* Launch user's editor and resolve conflict with edited file. */
83   svn_cl__accept_edit,
84
85   /* Launch user's resolver and resolve conflict with edited file. */
86   svn_cl__accept_launch,
87
88   /* Use recommended resolution if available, else leave the conflict alone. */
89   svn_cl__accept_recommended
90
91 } svn_cl__accept_t;
92
93 /* --accept action user input words */
94 #define SVN_CL__ACCEPT_POSTPONE "postpone"
95 #define SVN_CL__ACCEPT_BASE "base"
96 #define SVN_CL__ACCEPT_WORKING "working"
97 #define SVN_CL__ACCEPT_MINE_CONFLICT "mine-conflict"
98 #define SVN_CL__ACCEPT_THEIRS_CONFLICT "theirs-conflict"
99 #define SVN_CL__ACCEPT_MINE_FULL "mine-full"
100 #define SVN_CL__ACCEPT_THEIRS_FULL "theirs-full"
101 #define SVN_CL__ACCEPT_EDIT "edit"
102 #define SVN_CL__ACCEPT_LAUNCH "launch"
103 #define SVN_CL__ACCEPT_RECOMMENDED "recommended"
104
105 /* Return the svn_cl__accept_t value corresponding to WORD, using exact
106  * case-sensitive string comparison. Return svn_cl__accept_invalid if WORD
107  * is empty or is not one of the known values. */
108 svn_cl__accept_t
109 svn_cl__accept_from_word(const char *word);
110
111 \f
112 /*** Mergeinfo flavors. ***/
113
114 /* --show-revs values */
115 typedef enum svn_cl__show_revs_t {
116   svn_cl__show_revs_invalid = -1,
117   svn_cl__show_revs_merged,
118   svn_cl__show_revs_eligible
119 } svn_cl__show_revs_t;
120
121 /* --show-revs user input words */
122 #define SVN_CL__SHOW_REVS_MERGED   "merged"
123 #define SVN_CL__SHOW_REVS_ELIGIBLE "eligible"
124
125 /* Return svn_cl__show_revs_t value corresponding to word. */
126 svn_cl__show_revs_t
127 svn_cl__show_revs_from_word(const char *word);
128
129 \f
130 /*** Command dispatch. ***/
131
132 /* Hold results of option processing that are shared by multiple
133    commands. */
134 typedef struct svn_cl__opt_state_t
135 {
136   /* An array of svn_opt_revision_range_t *'s representing revisions
137      ranges indicated on the command-line via the -r and -c options.
138      For each range in the list, if only one revision was provided
139      (-rN), its 'end' member remains 'svn_opt_revision_unspecified'.
140      This array always has at least one element, even if that is a
141      null range in which both ends are 'svn_opt_revision_unspecified'. */
142   apr_array_header_t *revision_ranges;
143
144   /* These are simply a copy of the range start and end values present
145      in the first item of the revision_ranges list. */
146   svn_opt_revision_t start_revision;
147   svn_opt_revision_t end_revision;
148
149   /* Flag which is only set if the '-c' option was used. */
150   svn_boolean_t used_change_arg;
151
152   /* Flag which is only set if the '-r' option was used. */
153   svn_boolean_t used_revision_arg;
154
155   /* Max number of log messages to get back from svn_client_log2. */
156   int limit;
157
158   /* After option processing is done, reflects the switch actually
159      given on the command line, or svn_depth_unknown if none. */
160   svn_depth_t depth;
161
162   /* Was --no-unlock specified? */
163   svn_boolean_t no_unlock;
164
165   const char *message;           /* log message (not converted to UTF-8) */
166   svn_boolean_t force;           /* be more forceful, as in "svn rm -f ..." */
167   svn_boolean_t force_log;       /* force validity of a suspect log msg file */
168   svn_boolean_t incremental;     /* yield output suitable for concatenation */
169   svn_boolean_t quiet;           /* sssh...avoid unnecessary output */
170   svn_boolean_t non_interactive; /* do no interactive prompting */
171   svn_boolean_t version;         /* print version information */
172   svn_boolean_t verbose;         /* be verbose */
173   svn_boolean_t update;          /* contact the server for the full story */
174   svn_stringbuf_t *filedata;     /* contents of file used as option data
175                                     (not converted to UTF-8) */
176   const char *encoding;          /* the locale/encoding of 'message' and of
177                                     'filedata' (not converted to UTF-8) */
178   svn_boolean_t help;            /* print usage message */
179   const char *auth_username;     /* auth username */
180   const char *auth_password;     /* auth password */
181   svn_boolean_t auth_password_from_stdin; /* read password from stdin */
182   const char *extensions;        /* subprocess extension args */
183   apr_array_header_t *targets;   /* target list from file */
184   svn_boolean_t xml;             /* output in xml, e.g., "svn log --xml" */
185   svn_boolean_t no_ignore;       /* disregard default ignores & svn:ignore's */
186   svn_boolean_t no_auth_cache;   /* do not cache authentication information */
187   struct
188     {
189   const char *diff_cmd;              /* the external diff command to use
190                                         (not converted to UTF-8) */
191   svn_boolean_t internal_diff;       /* override diff_cmd in config file */
192   svn_boolean_t no_diff_added;       /* do not show diffs for deleted files */
193   svn_boolean_t no_diff_deleted;     /* do not show diffs for deleted files */
194   svn_boolean_t show_copies_as_adds; /* do not diff copies with their source */
195   svn_boolean_t notice_ancestry;     /* notice ancestry for diff-y operations */
196   svn_boolean_t summarize;           /* create a summary of a diff */
197   svn_boolean_t use_git_diff_format; /* Use git's extended diff format */
198   svn_boolean_t ignore_properties;   /* ignore properties */
199   svn_boolean_t properties_only;     /* Show properties only */
200   svn_boolean_t patch_compatible;    /* Output compatible with GNU patch */
201     } diff;
202   svn_boolean_t ignore_ancestry; /* ignore ancestry for merge-y operations */
203   svn_boolean_t ignore_externals;/* ignore externals definitions */
204   svn_boolean_t stop_on_copy;    /* don't cross copies during processing */
205   svn_boolean_t dry_run;         /* try operation but make no changes */
206   svn_boolean_t revprop;         /* operate on a revision property */
207   const char *merge_cmd;         /* the external merge command to use
208                                     (not converted to UTF-8) */
209   const char *editor_cmd;        /* the external editor command to use
210                                     (not converted to UTF-8) */
211   svn_boolean_t record_only;     /* whether to record mergeinfo */
212   const char *old_target;        /* diff target */
213   const char *new_target;        /* diff target */
214   svn_boolean_t relocate;        /* rewrite urls (svn switch) */
215   const char *config_dir;        /* over-riding configuration directory */
216   apr_array_header_t *config_options; /* over-riding configuration options */
217   svn_boolean_t autoprops;       /* enable automatic properties */
218   svn_boolean_t no_autoprops;    /* disable automatic properties */
219   const char *native_eol;        /* override system standard eol marker */
220   svn_boolean_t remove;          /* deassociate a changelist */
221   apr_array_header_t *changelists; /* changelist filters */
222   svn_boolean_t keep_changelists;/* don't remove changelists after commit */
223   svn_boolean_t keep_local;      /* delete path only from repository */
224   svn_boolean_t all_revprops;    /* retrieve all revprops */
225   svn_boolean_t no_revprops;     /* retrieve no revprops */
226   apr_hash_t *revprop_table;     /* table of revision properties to get/set
227                                     (not converted to UTF-8) */
228   svn_boolean_t parents;         /* create intermediate directories */
229   svn_boolean_t use_merge_history; /* use/display extra merge information */
230   svn_cl__accept_t accept_which;   /* how to handle conflicts */
231   svn_cl__show_revs_t show_revs;   /* mergeinfo flavor */
232   svn_depth_t set_depth;           /* new sticky ambient depth value */
233   svn_boolean_t reintegrate;      /* use "reintegrate" merge-source heuristic */
234   /* trust server SSL certs that would otherwise be rejected as "untrusted" */
235   svn_boolean_t trust_server_cert_unknown_ca;
236   svn_boolean_t trust_server_cert_cn_mismatch;
237   svn_boolean_t trust_server_cert_expired;
238   svn_boolean_t trust_server_cert_not_yet_valid;
239   svn_boolean_t trust_server_cert_other_failure;
240   int strip; /* number of leading path components to strip */
241   svn_boolean_t ignore_keywords;   /* do not expand keywords */
242   svn_boolean_t reverse_diff;      /* reverse a diff (e.g. when patching) */
243   svn_boolean_t ignore_whitespace; /* don't account for whitespace when
244                                       patching */
245   svn_boolean_t show_diff;         /* produce diff output (maps to --diff) */
246   svn_boolean_t allow_mixed_rev;   /* Allow operation on mixed-revision WC */
247   svn_boolean_t include_externals; /* Recurses (in)to file & dir externals */
248   svn_boolean_t show_inherited_props;  /* get inherited properties */
249   apr_array_header_t* search_patterns; /* pattern arguments for --search */
250   svn_boolean_t mergeinfo_log;     /* show log message in mergeinfo command */
251   svn_boolean_t remove_unversioned;/* remove unversioned items */
252   svn_boolean_t remove_ignored;    /* remove ignored items */
253   svn_boolean_t no_newline;        /* do not output the trailing newline */
254   svn_boolean_t show_passwords;    /* show cached passwords */
255   svn_boolean_t pin_externals;     /* pin externals to last-changed revisions */
256   const char *show_item;           /* print only the given item */
257   svn_boolean_t adds_as_modification; /* update 'add vs add' no tree conflict */
258   svn_boolean_t vacuum_pristines; /* remove unreferenced pristines */
259   svn_boolean_t list;
260 } svn_cl__opt_state_t;
261
262 /* Conflict stats for operations such as update and merge. */
263 typedef struct svn_cl__conflict_stats_t svn_cl__conflict_stats_t;
264
265 typedef struct svn_cl__cmd_baton_t
266 {
267   svn_cl__opt_state_t *opt_state;
268   svn_cl__conflict_stats_t *conflict_stats;
269   svn_client_ctx_t *ctx;
270 } svn_cl__cmd_baton_t;
271
272
273 /* Declare all the command procedures */
274 svn_opt_subcommand_t
275   svn_cl__add,
276   svn_cl__auth,
277   svn_cl__blame,
278   svn_cl__cat,
279   svn_cl__changelist,
280   svn_cl__checkout,
281   svn_cl__cleanup,
282   svn_cl__commit,
283   svn_cl__copy,
284   svn_cl__delete,
285   svn_cl__diff,
286   svn_cl__export,
287   svn_cl__help,
288   svn_cl__import,
289   svn_cl__info,
290   svn_cl__lock,
291   svn_cl__log,
292   svn_cl__list,
293   svn_cl__merge,
294   svn_cl__mergeinfo,
295   svn_cl__mkdir,
296   svn_cl__move,
297   svn_cl__patch,
298   svn_cl__propdel,
299   svn_cl__propedit,
300   svn_cl__propget,
301   svn_cl__proplist,
302   svn_cl__propset,
303   svn_cl__relocate,
304   svn_cl__revert,
305   svn_cl__resolve,
306   svn_cl__resolved,
307   svn_cl__shelve,
308   svn_cl__unshelve,
309   svn_cl__shelves,
310   svn_cl__status,
311   svn_cl__switch,
312   svn_cl__unlock,
313   svn_cl__update,
314   svn_cl__upgrade;
315
316
317 /* See definition in svn.c for documentation. */
318 extern const svn_opt_subcommand_desc2_t svn_cl__cmd_table[];
319
320 /* See definition in svn.c for documentation. */
321 extern const int svn_cl__global_options[];
322
323 /* See definition in svn.c for documentation. */
324 extern const apr_getopt_option_t svn_cl__options[];
325
326 \f
327 /* A helper for the many subcommands that wish to merely warn when
328  * invoked on an unversioned, nonexistent, or otherwise innocuously
329  * errorful resource.  Meant to be wrapped with SVN_ERR().
330  *
331  * If ERR is null, return SVN_NO_ERROR.
332  *
333  * Else if ERR->apr_err is one of the error codes supplied in varargs,
334  * then handle ERR as a warning (unless QUIET is true), clear ERR, and
335  * return SVN_NO_ERROR, and push the value of ERR->apr_err into the
336  * ERRORS_SEEN array, if ERRORS_SEEN is not NULL.
337  *
338  * Else return ERR.
339  *
340  * Typically, error codes like SVN_ERR_UNVERSIONED_RESOURCE,
341  * SVN_ERR_ENTRY_NOT_FOUND, etc, are supplied in varargs.  Don't
342  * forget to terminate the argument list with 0 (or APR_SUCCESS).
343  */
344 svn_error_t *
345 svn_cl__try(svn_error_t *err,
346             apr_array_header_t *errors_seen,
347             svn_boolean_t quiet,
348             ...);
349
350 \f
351 /* Our cancellation callback. */
352 extern svn_cancel_func_t svn_cl__check_cancel;
353
354
355 \f
356 /* Various conflict-resolution callbacks. */
357
358 /* Opaque baton type for svn_cl__conflict_func_interactive(). */
359 typedef struct svn_cl__interactive_conflict_baton_t
360   svn_cl__interactive_conflict_baton_t;
361
362 /* Return a new, initialized, conflict stats structure, allocated in
363  * POOL. */
364 svn_cl__conflict_stats_t *
365 svn_cl__conflict_stats_create(apr_pool_t *pool);
366
367 /* Update CONFLICT_STATS to reflect that a conflict on PATH_LOCAL of kind
368  * CONFLICT_KIND is resolved.  (There is no support for updating the
369  * 'skipped paths' stats, since skips cannot be 'resolved'.) */
370 void
371 svn_cl__conflict_stats_resolved(svn_cl__conflict_stats_t *conflict_stats,
372                                 const char *path_local,
373                                 svn_wc_conflict_kind_t conflict_kind);
374
375 /* Set *CONFLICTED_PATHS to the conflicted paths contained in CONFLICT_STATS.
376  * If no conflicted path exists, set *CONFLICTED_PATHS to NULL. */
377 svn_error_t *
378 svn_cl__conflict_stats_get_paths(apr_array_header_t **conflicted_paths,
379                                  svn_cl__conflict_stats_t *conflict_stats,
380                                  apr_pool_t *result_pool,
381                                  apr_pool_t *scratch_pool);
382
383 /* Print the conflict stats accumulated in CONFLICT_STATS.
384  *
385  * Return any error encountered during printing.
386  * See also svn_cl__notifier_print_conflict_stats().
387  */
388 svn_error_t *
389 svn_cl__print_conflict_stats(svn_cl__conflict_stats_t *conflict_stats,
390                              apr_pool_t *scratch_pool);
391
392 /* 
393  * Interactively resolve the conflict a @a CONFLICT.
394  * TODO: more docs
395  */
396 svn_error_t *
397 svn_cl__resolve_conflict(svn_boolean_t *quit,
398                          svn_boolean_t *external_failed,
399                          svn_boolean_t *printed_summary,
400                          svn_client_conflict_t *conflict,
401                          svn_cl__accept_t accept_which,
402                          const char *editor_cmd,
403                          const char *path_prefix,
404                          svn_cmdline_prompt_baton_t *pb,
405                          svn_cl__conflict_stats_t *conflict_stats,
406                          svn_client_ctx_t *ctx,
407                          apr_pool_t *scratch_pool);
408
409 /* 
410  * Interactively resolve conflicts for all TARGETS.
411  * TODO: more docs
412  */
413 svn_error_t *
414 svn_cl__walk_conflicts(apr_array_header_t *targets,
415                        svn_cl__conflict_stats_t *conflict_stats,
416                        svn_cl__opt_state_t *opt_state,
417                        svn_client_ctx_t *ctx,
418                        apr_pool_t *scratch_pool);
419
420 \f
421 /*** Command-line output functions -- printing to the user. ***/
422
423 /* Print out commit information found in COMMIT_INFO to the console.
424  * POOL is used for temporay allocations.
425  * COMMIT_INFO should not be NULL.
426  *
427  * This function implements svn_commit_callback2_t.
428  */
429 svn_error_t *
430 svn_cl__print_commit_info(const svn_commit_info_t *commit_info,
431                           void *baton,
432                           apr_pool_t *pool);
433
434
435 /* Convert the date in DATA to a human-readable UTF-8-encoded string
436  * *HUMAN_CSTRING, or set the latter to "(invalid date)" if DATA is not
437  * a valid date.  DATA should be as expected by svn_time_from_cstring().
438  *
439  * Do all allocations in POOL.
440  */
441 svn_error_t *
442 svn_cl__time_cstring_to_human_cstring(const char **human_cstring,
443                                       const char *data,
444                                       apr_pool_t *pool);
445
446
447 /* Print STATUS for PATH to stdout for human consumption.  Prints in
448    abbreviated format by default, or DETAILED format if flag is set.
449
450    When SUPPRESS_EXTERNALS_PLACEHOLDERS is set, avoid printing
451    externals placeholder lines ("X lines").
452
453    When DETAILED is set, use SHOW_LAST_COMMITTED to toggle display of
454    the last-committed-revision and last-committed-author.
455
456    If SKIP_UNRECOGNIZED is TRUE, this function will not print out
457    unversioned items found in the working copy.
458
459    When DETAILED is set, and REPOS_LOCKS is set, treat missing repository locks
460    as broken WC locks.
461
462    Increment *TEXT_CONFLICTS, *PROP_CONFLICTS, or *TREE_CONFLICTS if
463    a conflict was encountered.
464
465    Use TARGET_ABSPATH and TARGET_PATH to shorten PATH into something
466    relative to the target as necessary.
467 */
468 svn_error_t *
469 svn_cl__print_status(const char *target_abspath,
470                      const char *target_path,
471                      const char *path,
472                      const svn_client_status_t *status,
473                      svn_boolean_t suppress_externals_placeholders,
474                      svn_boolean_t detailed,
475                      svn_boolean_t show_last_committed,
476                      svn_boolean_t skip_unrecognized,
477                      svn_boolean_t repos_locks,
478                      unsigned int *text_conflicts,
479                      unsigned int *prop_conflicts,
480                      unsigned int *tree_conflicts,
481                      svn_client_ctx_t *ctx,
482                      apr_pool_t *pool);
483
484
485 /* Print STATUS for PATH in XML to stdout.  Use POOL for temporary
486    allocations.
487
488    Use TARGET_ABSPATH and TARGET_PATH to shorten PATH into something
489    relative to the target as necessary.
490  */
491 svn_error_t *
492 svn_cl__print_status_xml(const char *target_abspath,
493                          const char *target_path,
494                          const char *path,
495                          const svn_client_status_t *status,
496                          svn_client_ctx_t *ctx,
497                          apr_pool_t *pool);
498
499 /* Output a commit xml element to *OUTSTR.  If *OUTSTR is NULL, allocate it
500    first from POOL, otherwise append to it.  If AUTHOR or DATE is
501    NULL, it will be omitted. */
502 void
503 svn_cl__print_xml_commit(svn_stringbuf_t **outstr,
504                          svn_revnum_t revision,
505                          const char *author,
506                          const char *date,
507                          apr_pool_t *pool);
508
509 /* Output an XML "<lock>" element describing LOCK to *OUTSTR.  If *OUTSTR is
510    NULL, allocate it first from POOL, otherwise append to it. */
511 void
512 svn_cl__print_xml_lock(svn_stringbuf_t **outstr,
513                        const svn_lock_t *lock,
514                        apr_pool_t *pool);
515
516 /* Do the following things that are commonly required before accessing revision
517    properties.  Ensure that REVISION is specified explicitly and is not
518    relative to a working-copy item.  Ensure that exactly one target is
519    specified in TARGETS.  Set *URL to the URL of the target.  Return an
520    appropriate error if any of those checks or operations fail. Use CTX for
521    accessing the working copy
522  */
523 svn_error_t *
524 svn_cl__revprop_prepare(const svn_opt_revision_t *revision,
525                         const apr_array_header_t *targets,
526                         const char **URL,
527                         svn_client_ctx_t *ctx,
528                         apr_pool_t *pool);
529
530 /* Search for a merge tool command in environment variables,
531    and use it to perform the merge of the four given files.
532    WC_PATH is the path of the file that is in conflict, relative
533    to the merge target.
534    Use POOL for all allocations.
535
536    CONFIG is a hash of svn_config_t * items keyed on a configuration
537    category (SVN_CONFIG_CATEGORY_CONFIG et al), and may be NULL.
538
539    Upon success, set *REMAINS_IN_CONFLICT to indicate whether the
540    merge result contains conflict markers.
541    */
542 svn_error_t *
543 svn_cl__merge_file_externally(const char *base_path,
544                               const char *their_path,
545                               const char *my_path,
546                               const char *merged_path,
547                               const char *wc_path,
548                               apr_hash_t *config,
549                               svn_boolean_t *remains_in_conflict,
550                               apr_pool_t *pool);
551
552 /* Like svn_cl__merge_file_externally, but using a built-in merge tool
553  * with help from an external editor specified by EDITOR_CMD. */
554 svn_error_t *
555 svn_cl__merge_file(svn_boolean_t *remains_in_conflict,
556                    const char *base_path,
557                    const char *their_path,
558                    const char *my_path,
559                    const char *merged_path,
560                    const char *wc_path,
561                    const char *path_prefix,
562                    const char *editor_cmd,
563                    apr_hash_t *config,
564                    svn_cancel_func_t cancel_func,
565                    void *cancel_baton,
566                    apr_pool_t *scratch_pool);
567
568 \f
569 /*** Notification functions to display results on the terminal. */
570
571 /* Set *NOTIFY_FUNC_P and *NOTIFY_BATON_P to a notifier/baton for all
572  * operations, allocated in POOL.
573  */
574 svn_error_t *
575 svn_cl__get_notifier(svn_wc_notify_func2_t *notify_func_p,
576                      void **notify_baton_p,
577                      svn_cl__conflict_stats_t *conflict_stats,
578                      apr_pool_t *pool);
579
580 /* Make the notifier for use with BATON print the appropriate summary
581  * line at the end of the output.
582  */
583 svn_error_t *
584 svn_cl__notifier_mark_checkout(void *baton);
585
586 /* Make the notifier for use with BATON print the appropriate summary
587  * line at the end of the output.
588  */
589 svn_error_t *
590 svn_cl__notifier_mark_export(void *baton);
591
592 /* Make the notifier for use with BATON print the appropriate notifications
593  * for a wc to repository copy
594  */
595 svn_error_t *
596 svn_cl__notifier_mark_wc_to_repos_copy(void *baton);
597
598 /* Baton for use with svn_cl__check_externals_failed_notify_wrapper(). */
599 struct svn_cl__check_externals_failed_notify_baton
600 {
601   svn_wc_notify_func2_t wrapped_func; /* The "real" notify_func2. */
602   void *wrapped_baton;                /* The "real" notify_func2 baton. */
603   svn_boolean_t had_externals_error;  /* Did something fail in an external? */
604 };
605
606 /* Notification function wrapper (implements `svn_wc_notify_func2_t').
607    Use with an svn_cl__check_externals_failed_notify_baton BATON. */
608 void
609 svn_cl__check_externals_failed_notify_wrapper(void *baton,
610                                               const svn_wc_notify_t *n,
611                                               apr_pool_t *pool);
612
613 /* Print the conflict stats accumulated in BATON, which is the
614  * notifier baton from svn_cl__get_notifier().  This is just like
615  * calling svn_cl__print_conflict_stats().
616  *
617  * Return any error encountered during printing.
618  */
619 svn_error_t *
620 svn_cl__notifier_print_conflict_stats(void *baton, apr_pool_t *scratch_pool);
621
622
623 \f/*** Log message callback stuffs. ***/
624
625 /* Allocate in POOL a baton for use with svn_cl__get_log_message().
626
627    OPT_STATE is the set of command-line options given.
628
629    BASE_DIR is a directory in which to create temporary files if an
630    external editor is used to edit the log message.  If BASE_DIR is
631    NULL, the current working directory (`.') will be used, and
632    therefore the user must have the proper permissions on that
633    directory.  ### todo: What *should* happen in the NULL case is that
634    we ask APR to tell us where a suitable tmp directory is (like, /tmp
635    on Unix and C:\Windows\Temp on Win32 or something), and use it.
636    But APR doesn't yet have that capability.
637
638    CONFIG is a client configuration hash of svn_config_t * items keyed
639    on config categories, and may be NULL.
640
641    NOTE: While the baton itself will be allocated from POOL, the items
642    add to it are added by reference, not duped into POOL!*/
643 svn_error_t *
644 svn_cl__make_log_msg_baton(void **baton,
645                            svn_cl__opt_state_t *opt_state,
646                            const char *base_dir,
647                            apr_hash_t *config,
648                            apr_pool_t *pool);
649
650 /* A function of type svn_client_get_commit_log3_t. */
651 svn_error_t *
652 svn_cl__get_log_message(const char **log_msg,
653                         const char **tmp_file,
654                         const apr_array_header_t *commit_items,
655                         void *baton,
656                         apr_pool_t *pool);
657
658 /* Handle the cleanup of a log message, using the data in the
659    LOG_MSG_BATON, in the face of COMMIT_ERR.  This may mean removing a
660    temporary file left by an external editor, or it may be a complete
661    no-op.  COMMIT_ERR may be NULL to indicate to indicate that the
662    function should act as though no commit error occurred. Use POOL
663    for temporary allocations.
664
665    All error returns from this function are guaranteed to at least
666    include COMMIT_ERR, and perhaps additional errors attached to the
667    end of COMMIT_ERR's chain.  */
668 svn_error_t *
669 svn_cl__cleanup_log_msg(void *log_msg_baton,
670                         svn_error_t *commit_err,
671                         apr_pool_t *pool);
672
673 /* Add a message about --force if appropriate */
674 svn_error_t *
675 svn_cl__may_need_force(svn_error_t *err);
676
677 /* Write the STRING to the stdio STREAM, returning an error if it fails.
678
679    This function is equal to svn_cmdline_fputs() minus the utf8->local
680    encoding translation.  */
681 svn_error_t *
682 svn_cl__error_checked_fputs(const char *string, FILE* stream);
683
684 /* If STRING is non-null, append it, wrapped in a simple XML CDATA element
685    named TAGNAME, to the string SB.  Use POOL for temporary allocations. */
686 void
687 svn_cl__xml_tagged_cdata(svn_stringbuf_t **sb,
688                          apr_pool_t *pool,
689                          const char *tagname,
690                          const char *string);
691
692 /* Print the XML prolog and document root element start-tag to stdout, using
693    TAGNAME as the root element name.  Use POOL for temporary allocations. */
694 svn_error_t *
695 svn_cl__xml_print_header(const char *tagname, apr_pool_t *pool);
696
697 /* Print the XML document root element end-tag to stdout, using TAGNAME as the
698    root element name.  Use POOL for temporary allocations. */
699 svn_error_t *
700 svn_cl__xml_print_footer(const char *tagname, apr_pool_t *pool);
701
702
703 /* For use in XML output, return a non-localised string representation
704  * of KIND, being "none" or "dir" or "file" or, in any other case,
705  * the empty string. */
706 const char *
707 svn_cl__node_kind_str_xml(svn_node_kind_t kind);
708
709 /* Return a (possibly localised) string representation of KIND, being "none" or
710    "dir" or "file" or, in any other case, the empty string. */
711 const char *
712 svn_cl__node_kind_str_human_readable(svn_node_kind_t kind);
713
714
715 /** Provides an XML name for a given OPERATION.
716  * Note: POOL is currently not used.
717  */
718 const char *
719 svn_cl__operation_str_xml(svn_wc_operation_t operation, apr_pool_t *pool);
720
721 /** Return a possibly localized human readable string for
722  * a given OPERATION.
723  * Note: POOL is currently not used.
724  */
725 const char *
726 svn_cl__operation_str_human_readable(svn_wc_operation_t operation,
727                                      apr_pool_t *pool);
728
729
730 /* What use is a property name intended for.
731    Used by svn_cl__check_svn_prop_name to customize error messages. */
732 typedef enum svn_cl__prop_use_e
733   {
734     svn_cl__prop_use_set,       /* setting the property */
735     svn_cl__prop_use_edit,      /* editing the property */
736     svn_cl__prop_use_use        /* using the property name */
737   }
738 svn_cl__prop_use_t;
739
740 /* If PROPNAME looks like but is not identical to one of the svn:
741  * poperties, raise an error and suggest a better spelling. Names that
742  * raise errors look like this:
743  *
744  *   - start with svn: but do not exactly match a known property; or,
745  *   - start with a 3-letter prefix that differs in only one letter
746  *     from "svn:", and the rest exactly matches a known propery.
747  *
748  * If REVPROP is TRUE, only check revision property names; otherwise
749  * only check node property names.
750  *
751  * Use SCRATCH_POOL for temporary allocations.
752  */
753 svn_error_t *
754 svn_cl__check_svn_prop_name(const char *propname,
755                             svn_boolean_t revprop,
756                             svn_cl__prop_use_t prop_use,
757                             apr_pool_t *scratch_pool);
758
759 /* If PROPNAME is one of the svn: properties with a boolean value, and
760  * PROPVAL looks like an attempt to turn the property off (i.e., it's
761  * "off", "no", "false", or ""), then print a warning to the user that
762  * setting the property to this value might not do what they expect.
763  * Perform temporary allocations in POOL.
764  */
765 void
766 svn_cl__check_boolean_prop_val(const char *propname,
767                                const char *propval,
768                                apr_pool_t *pool);
769
770 /* De-streamifying wrapper around svn_client_get_changelists(), which
771    is called for each target in TARGETS to populate *PATHS (a list of
772    paths assigned to one of the CHANGELISTS.
773    If all targets are to be included, may set *PATHS to TARGETS without
774    reallocating. */
775 svn_error_t *
776 svn_cl__changelist_paths(apr_array_header_t **paths,
777                          const apr_array_header_t *changelists,
778                          const apr_array_header_t *targets,
779                          svn_depth_t depth,
780                          svn_client_ctx_t *ctx,
781                          apr_pool_t *result_pool,
782                          apr_pool_t *scratch_pool);
783
784 /* Like svn_client_args_to_target_array() but, if the only error is that some
785  * arguments are reserved file names, then print warning messages for those
786  * targets, store the rest of the targets in TARGETS_P and return success. */
787 svn_error_t *
788 svn_cl__args_to_target_array_print_reserved(apr_array_header_t **targets_p,
789                                             apr_getopt_t *os,
790                                             const apr_array_header_t *known_targets,
791                                             svn_client_ctx_t *ctx,
792                                             svn_boolean_t keep_dest_origpath_on_truepath_collision,
793                                             apr_pool_t *pool);
794
795 /* Return a string showing a conflicted node's kind, URL and revision,
796  * to the extent that that information is available. If REPOS_ROOT_URL or
797  * REPOS_RELPATH are NULL, this prints just a 'none' node kind.
798  * WC_REPOS_ROOT_URL should reflect the target working copy's repository
799  * root URL. If the node is from that same URL, the printed URL is abbreviated
800  * to caret notation (^/). WC_REPOS_ROOT_URL may be NULL, in which case
801  * this function tries to print the conflicted node's complete URL. */
802 const char *
803 svn_cl__node_description(const char *repos_root_url,
804                          const char *repos_relpath,
805                          svn_revnum_t peg_rev,
806                          svn_node_kind_t node_kind,
807                          const char *wc_repos_root_URL,
808                          apr_pool_t *pool);
809
810 /* Return, in @a *true_targets_p, a shallow copy of @a targets with any
811  * empty peg revision specifier snipped off the end of each element.  If any
812  * target has a non-empty peg revision specifier, throw an error.  The user
813  * may have specified a peg revision where it doesn't make sense to do so,
814  * or may have forgotten to escape an '@' character in a filename.
815  *
816  * This function is useful for subcommands for which peg revisions
817  * do not make any sense. Such subcommands still need to allow an empty
818  * peg revision to be specified on the command line so that users of
819  * the command line client can consistently escape '@' characters
820  * in filenames by appending an '@' character, regardless of the
821  * subcommand being used.
822  *
823  * It is safe to pass the address of @a targets as @a true_targets_p.
824  *
825  * Do all allocations in @a pool. */
826 svn_error_t *
827 svn_cl__eat_peg_revisions(apr_array_header_t **true_targets_p,
828                           const apr_array_header_t *targets,
829                           apr_pool_t *pool);
830
831 /* Return an error if TARGETS contains a mixture of URLs and paths; otherwise
832  * return SVN_NO_ERROR. */
833 svn_error_t *
834 svn_cl__assert_homogeneous_target_type(const apr_array_header_t *targets);
835
836 /* Return an error if TARGETS contains a URL; otherwise return SVN_NO_ERROR. */
837 svn_error_t *
838 svn_cl__check_targets_are_local_paths(const apr_array_header_t *targets);
839
840 /* Return an error if TARGET is a URL; otherwise return SVN_NO_ERROR. */
841 svn_error_t *
842 svn_cl__check_target_is_local_path(const char *target);
843
844 /* Return a copy of PATH, converted to the local path style, skipping
845  * PARENT_PATH if it is non-null and is a parent of or equal to PATH.
846  *
847  * This function assumes PARENT_PATH and PATH are both absolute "dirents"
848  * or both relative "dirents". */
849 const char *
850 svn_cl__local_style_skip_ancestor(const char *parent_path,
851                                   const char *path,
852                                   apr_pool_t *pool);
853
854 /* If the user is setting a mime-type to mark one of the TARGETS as binary,
855  * as determined by property name PROPNAME and value PROPVAL, then check
856  * whether Subversion's own binary-file detection recognizes the target as
857  * a binary file. If Subversion doesn't consider the target to be a binary
858  * file, assume the user is making an error and print a warning to inform
859  * the user that some operations might fail on the file in the future. */
860 svn_error_t *
861 svn_cl__propset_print_binary_mime_type_warning(apr_array_header_t *targets,
862                                                const char *propname,
863                                                const svn_string_t *propval,
864                                                apr_pool_t *scratch_pool);
865
866 /* A wrapper around the deprecated svn_client_merge_reintegrate. */
867 svn_error_t *
868 svn_cl__deprecated_merge_reintegrate(const char *source_path_or_url,
869                                      const svn_opt_revision_t *src_peg_revision,
870                                      const char *target_wcpath,
871                                      svn_boolean_t dry_run,
872                                      const apr_array_header_t *merge_options,
873                                      svn_client_ctx_t *ctx,
874                                      apr_pool_t *pool);
875
876
877 /* Forward declaration of the similarity check context. */
878 typedef struct svn_cl__simcheck_context_t svn_cl__simcheck_context_t;
879
880 /* Token definition for the similarity check. */
881 typedef struct svn_cl__simcheck_t
882 {
883   /* The token we're checking for similarity. */
884   svn_string_t token;
885
886   /* User data associated with this token. */
887   const void *data;
888
889   /*
890    * The following fields are populated by svn_cl__similarity_check.
891    */
892
893   /* Similarity score [0..SVN_STRING__SIM_RANGE_MAX] */
894   apr_size_t score;
895
896   /* Number of characters of difference from the key. */
897   apr_size_t diff;
898
899   /* Similarity check context (private) */
900   svn_cl__simcheck_context_t *context;
901 } svn_cl__simcheck_t;
902
903 /* Find the entries in TOKENS that are most similar to KEY.
904  * TOKEN_COUNT is the number of entries in the (mutable) TOKENS array.
905  * Use SCRATCH_POOL for temporary allocations.
906  *
907  * On return, the TOKENS array will be sorted according to similarity
908  * to KEY, in descending order. The return value will be zero if the
909  * first token is an exact match; otherwise, it will be one more than
910  * the number of tokens that are at least two-thirds similar to KEY.
911  */
912 apr_size_t
913 svn_cl__similarity_check(const char *key,
914                          svn_cl__simcheck_t **tokens,
915                          apr_size_t token_count,
916                          apr_pool_t *scratch_pool);
917
918 #ifdef __cplusplus
919 }
920 #endif /* __cplusplus */
921
922 #endif /* SVN_CL_H */