Skip a test when run against old servers.
[svn.git] / subversion / svn / cl.h
blob016d4aee6839a7175cb40210350fe08ecccaeb05
1 /*
2 * cl.h: shared stuff in the command line program
4 * ====================================================================
5 * Copyright (c) 2000-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 /* ==================================================================== */
23 #ifndef SVN_CL_H
24 #define SVN_CL_H
26 /*** Includes. ***/
27 #include <apr_tables.h>
28 #include <apr_getopt.h>
30 #include "svn_wc.h"
31 #include "svn_client.h"
32 #include "svn_string.h"
33 #include "svn_opt.h"
34 #include "svn_auth.h"
35 #include "svn_cmdline.h"
37 #ifdef __cplusplus
38 extern "C" {
39 #endif /* __cplusplus */
42 /*** Option processing ***/
44 /* --accept actions */
45 typedef enum
47 /* invalid accept action */
48 svn_cl__accept_invalid = -2,
50 /* unspecified accept action */
51 svn_cl__accept_unspecified = -1,
53 /* Leave conflicts alone, for later resolution. */
54 svn_cl__accept_postpone,
56 /* Resolve the conflict with the pre-conflict base file. */
57 svn_cl__accept_base,
59 /* Resolve the conflict with the current working file. */
60 svn_cl__accept_working,
62 /* Resolve the conflicted hunks by choosing the corresponding text
63 from the pre-conflict working copy file.
65 Note: this is a placeholder, not actually implemented in 1.5. */
66 svn_cl__accept_mine_conflict,
68 /* Resolve the conflicted hunks by choosing the corresponding text
69 from the post-conflict base copy file.
71 Note: this is a placeholder, not actually implemented in 1.5. */
72 svn_cl__accept_theirs_conflict,
74 /* Resolve the conflict by taking the entire pre-conflict working
75 copy file. */
76 svn_cl__accept_mine_full,
78 /* Resolve the conflict by taking the entire post-conflict base file. */
79 svn_cl__accept_theirs_full,
81 /* Launch user's editor and resolve conflict with edited file. */
82 svn_cl__accept_edit,
84 /* Launch user's resolver and resolve conflict with edited file. */
85 svn_cl__accept_launch,
86 } svn_cl__accept_t;
88 /* --accept action user input words */
89 #define SVN_CL__ACCEPT_POSTPONE "postpone"
90 #define SVN_CL__ACCEPT_BASE "base"
91 #define SVN_CL__ACCEPT_WORKING "working"
92 #define SVN_CL__ACCEPT_MINE_CONFLICT "mine-conflict"
93 #define SVN_CL__ACCEPT_THEIRS_CONFLICT "theirs-conflict"
94 #define SVN_CL__ACCEPT_MINE_FULL "mine-full"
95 #define SVN_CL__ACCEPT_THEIRS_FULL "theirs-full"
96 #define SVN_CL__ACCEPT_EDIT "edit"
97 #define SVN_CL__ACCEPT_LAUNCH "launch"
99 /* Return svn_cl__accept_t value corresponding to word. */
100 svn_cl__accept_t
101 svn_cl__accept_from_word(const char *word);
104 /*** Mergeinfo flavors. ***/
106 /* --show-revs values */
107 typedef enum {
108 svn_cl__show_revs_invalid = -1,
109 svn_cl__show_revs_merged,
110 svn_cl__show_revs_eligible
111 } svn_cl__show_revs_t;
113 /* --show-revs user input words */
114 #define SVN_CL__SHOW_REVS_MERGED "merged"
115 #define SVN_CL__SHOW_REVS_ELIGIBLE "eligible"
117 /* Return svn_cl__show_revs_t value corresponding to word. */
118 svn_cl__show_revs_t
119 svn_cl__show_revs_from_word(const char *word);
122 /*** Command dispatch. ***/
124 /* Hold results of option processing that are shared by multiple
125 commands. */
126 typedef struct svn_cl__opt_state_t
128 /* An array of svn_opt_revision_range_t *'s representing revisions
129 ranges indicated on the command-line via the -r and -c options.
130 For each range in the list, if only one revision was provided
131 (-rN), its 'end' member remains `svn_opt_revision_unspecified'.
133 NOTE: This is currently used only by merge subcommand. */
134 apr_array_header_t *revision_ranges;
136 /* These are simply a copy of the range start and end values present
137 in the first item of the revision_ranges list. */
138 svn_opt_revision_t start_revision;
139 svn_opt_revision_t end_revision;
141 /* Flag which is only set if the '-c' option was used. */
142 svn_boolean_t used_change_arg;
144 /* Max number of log messages to get back from svn_client_log2. */
145 int limit;
147 /* After option processing is done, reflects the switch actually
148 given on the command line, or svn_depth_unknown if none. */
149 svn_depth_t depth;
151 /* Was --no-unlock specified? */
152 svn_boolean_t no_unlock;
154 const char *message; /* log message */
155 const char *ancestor_path; /* ### todo: who sets this? */
156 svn_boolean_t force; /* be more forceful, as in "svn rm -f ..." */
157 svn_boolean_t force_log; /* force validity of a suspect log msg file */
158 svn_boolean_t incremental; /* yield output suitable for concatenation */
159 svn_boolean_t quiet; /* sssh...avoid unnecessary output */
160 svn_boolean_t non_interactive; /* do no interactive prompting */
161 svn_boolean_t version; /* print version information */
162 svn_boolean_t verbose; /* be verbose */
163 svn_boolean_t update; /* contact the server for the full story */
164 svn_boolean_t strict; /* do strictly what was requested */
165 svn_stringbuf_t *filedata; /* contents of file used as option data */
166 const char *encoding; /* the locale/encoding of the data*/
167 svn_boolean_t help; /* print usage message */
168 const char *auth_username; /* auth username */ /* UTF-8! */
169 const char *auth_password; /* auth password */ /* UTF-8! */
170 const char *extensions; /* subprocess extension args */ /* UTF-8! */
171 apr_array_header_t *targets; /* target list from file */ /* UTF-8! */
172 svn_boolean_t xml; /* output in xml, e.g., "svn log --xml" */
173 svn_boolean_t no_ignore; /* disregard default ignores & svn:ignore's */
174 svn_boolean_t no_auth_cache; /* do not cache authentication information */
175 svn_boolean_t no_diff_deleted; /* do not show diffs for deleted files */
176 svn_boolean_t notice_ancestry; /* notice ancestry for diff-y operations */
177 svn_boolean_t ignore_ancestry; /* ignore ancestry for merge-y operations */
178 svn_boolean_t ignore_externals;/* ignore externals definitions */
179 svn_boolean_t stop_on_copy; /* don't cross copies during processing */
180 svn_boolean_t dry_run; /* try operation but make no changes */
181 svn_boolean_t revprop; /* operate on a revision property */
182 const char *diff_cmd; /* the external diff command to use */
183 const char *merge_cmd; /* the external merge command to use */
184 const char *editor_cmd; /* external editor command. */
185 svn_boolean_t record_only; /* whether to record mergeinfo */
186 const char *old_target; /* diff target */
187 const char *new_target; /* diff target */
188 svn_boolean_t relocate; /* rewrite urls (svn switch) */
189 const char *config_dir; /* over-riding configuration directory */
190 svn_boolean_t autoprops; /* enable automatic properties */
191 svn_boolean_t no_autoprops; /* disable automatic properties */
192 const char *native_eol; /* override system standard eol marker */
193 svn_boolean_t summarize; /* create a summary of a diff */
194 svn_boolean_t remove; /* deassociate a changelist */
195 apr_array_header_t *changelists; /* changelist filters */
196 const char *changelist; /* operate on this changelist
197 THIS IS TEMPORARY (LAST OF CHANGELISTS) */
198 svn_boolean_t keep_changelists;/* don't remove changelists after commit */
199 svn_boolean_t keep_local; /* delete path only from repository */
200 svn_boolean_t all_revprops; /* retrieve all props */
201 apr_hash_t *revprop_table; /* table of revision properties to get/set */
202 svn_boolean_t parents; /* create intermediate directories */
203 svn_boolean_t use_merge_history; /* use/display extra merge information */
204 svn_cl__accept_t accept_which; /* how to handle conflicts */
205 svn_cl__show_revs_t show_revs; /* mergeinfo flavor */
206 svn_depth_t set_depth; /* new sticky ambient depth value */
207 svn_boolean_t reintegrate; /* use "reintegrate" merge-source heuristic */
208 } svn_cl__opt_state_t;
211 typedef struct
213 svn_cl__opt_state_t *opt_state;
214 svn_client_ctx_t *ctx;
215 } svn_cl__cmd_baton_t;
218 /* Declare all the command procedures */
219 svn_opt_subcommand_t
220 svn_cl__add,
221 svn_cl__blame,
222 svn_cl__cat,
223 svn_cl__changelist,
224 svn_cl__checkout,
225 svn_cl__cleanup,
226 svn_cl__commit,
227 svn_cl__copy,
228 svn_cl__delete,
229 svn_cl__diff,
230 svn_cl__export,
231 svn_cl__help,
232 svn_cl__import,
233 svn_cl__info,
234 svn_cl__lock,
235 svn_cl__log,
236 svn_cl__list,
237 svn_cl__merge,
238 svn_cl__mergeinfo,
239 svn_cl__mkdir,
240 svn_cl__move,
241 svn_cl__propdel,
242 svn_cl__propedit,
243 svn_cl__propget,
244 svn_cl__proplist,
245 svn_cl__propset,
246 svn_cl__revert,
247 svn_cl__resolve,
248 svn_cl__resolved,
249 svn_cl__status,
250 svn_cl__switch,
251 svn_cl__unlock,
252 svn_cl__update;
255 /* See definition in main.c for documentation. */
256 extern const svn_opt_subcommand_desc2_t svn_cl__cmd_table[];
258 /* See definition in main.c for documentation. */
259 extern const int svn_cl__global_options[];
261 /* See definition in main.c for documentation. */
262 extern const apr_getopt_option_t svn_cl__options[];
265 /* A helper for the many subcommands that wish to merely warn when
266 * invoked on an unversioned, nonexistent, or otherwise innocuously
267 * errorful resource. Meant to be wrapped with SVN_ERR().
269 * If ERR is null, return SVN_NO_ERROR, setting *SUCCESS to TRUE
270 * if SUCCESS is not NULL.
272 * Else if ERR->apr_err is one of the error codes supplied in varargs,
273 * then handle ERR as a warning (unless QUIET is true), clear ERR, and
274 * return SVN_NO_ERROR, setting *SUCCESS to FALSE if SUCCESS is not
275 * NULL.
277 * Else return ERR, setting *SUCCESS to FALSE if SUCCESS is not NULL.
279 * Typically, error codes like SVN_ERR_UNVERSIONED_RESOURCE,
280 * SVN_ERR_ENTRY_NOT_FOUND, etc, are supplied in varargs. Don't
281 * forget to terminate the argument list with SVN_NO_ERROR.
283 svn_error_t *
284 svn_cl__try(svn_error_t *err,
285 svn_boolean_t *success,
286 svn_boolean_t quiet,
287 ...);
290 /* Our cancellation callback. */
291 svn_error_t *svn_cl__check_cancel(void *baton);
295 /* Various conflict-resolution callbacks. */
297 typedef struct {
298 svn_cl__accept_t accept_which;
299 apr_hash_t *config;
300 const char *editor_cmd;
301 svn_boolean_t external_failed;
302 svn_cmdline_prompt_baton_t *pb;
303 } svn_cl__conflict_baton_t;
305 /* Return address of newly allocated and initialized
306 svn_cl__conflict_baton_t. */
307 svn_cl__conflict_baton_t *
308 svn_cl__conflict_baton_make(svn_cl__accept_t accept_which,
309 apr_hash_t *config,
310 const char *editor_cmd,
311 svn_cmdline_prompt_baton_t *pb,
312 apr_pool_t *pool);
314 /* A conflict-resolution callback which prompts the user to choose
315 one of the 3 fulltexts, edit the merged file on the spot, or just
316 skip the conflict (to be resolved later).
317 Implements @c svn_wc_conflict_resolver_func_t. */
318 svn_error_t *
319 svn_cl__conflict_handler(svn_wc_conflict_result_t **result,
320 const svn_wc_conflict_description_t *desc,
321 void *baton,
322 apr_pool_t *pool);
326 /*** Command-line output functions -- printing to the user. ***/
328 /* Print out commit information found in COMMIT_INFO to the console.
329 * POOL is used for temporay allocations.
330 * COMMIT_INFO should not be NULL.
332 svn_error_t *svn_cl__print_commit_info(svn_commit_info_t *commit_info,
333 apr_pool_t *pool);
336 /* Print STATUS for PATH to stdout for human consumption. Prints in
337 abbreviated format by default, or DETAILED format if flag is set.
339 When DETAILED is set, use SHOW_LAST_COMMITTED to toggle display of
340 the last-committed-revision and last-committed-author.
342 If SKIP_UNRECOGNIZED is TRUE, this function will not print out
343 unversioned items found in the working copy.
345 When DETAILED is set, and REPOS_LOCKS is set, treat missing repository locks
346 as broken WC locks. */
347 svn_error_t *svn_cl__print_status(const char *path,
348 svn_wc_status2_t *status,
349 svn_boolean_t detailed,
350 svn_boolean_t show_last_committed,
351 svn_boolean_t skip_unrecognized,
352 svn_boolean_t repos_locks,
353 apr_pool_t *pool);
356 /* Print STATUS for PATH in XML to stdout. Use POOL for temporary
357 allocations. */
358 svn_error_t *
359 svn_cl__print_status_xml(const char *path,
360 svn_wc_status2_t *status,
361 apr_pool_t *pool);
364 /* Print a hash that maps property names (char *) to property values
365 (svn_string_t *). The names are assumed to be in UTF-8 format;
366 the values are either in UTF-8 (the special Subversion props) or
367 plain binary values.
369 If NAMES_ONLY is true, print just names, else print names and
370 values. */
371 svn_error_t *
372 svn_cl__print_prop_hash(apr_hash_t *prop_hash,
373 svn_boolean_t names_only,
374 apr_pool_t *pool);
376 /* Print a single xml property name-value pair to OUTSTR. If OUTSTR is NULL,
377 allocate it first from pool, otherwise append the xml to it. Escape
378 property values which are not xml safe, as determined by
379 svn_xml_is_xml_safe(). */
380 void
381 svn_cl__print_xml_prop(svn_stringbuf_t **outstr,
382 const char* propname,
383 svn_string_t *propval,
384 apr_pool_t *pool);
386 /* Same as svn_cl__print_prop_hash(), only output xml to OUTSTR. If OUTSTR is
387 NULL, allocate it first from pool, otherwise append the xml to it. */
388 svn_error_t *
389 svn_cl__print_xml_prop_hash(svn_stringbuf_t **outstr,
390 apr_hash_t *prop_hash,
391 svn_boolean_t names_only,
392 apr_pool_t *pool);
394 /* Output a commit xml element to OUTSTR. IF OUTSTR is NULL, allocate it
395 first from pool, otherwise appen the xml to it. If AUTHOR or DATE is
396 NULL, it will be omitted. */
397 void
398 svn_cl__print_xml_commit(svn_stringbuf_t **outstr,
399 svn_revnum_t revision,
400 const char *author,
401 const char *date,
402 apr_pool_t *pool);
404 /* Do the following things that are commonly required before accessing revision
405 properties. Ensure that REVISION is specified explicitly and is not
406 relative to a working-copy item. Ensure that exactly one target is
407 specified in TARGETS. Set *URL to the URL of the target. Return an
408 appropriate error if any of those checks or operations fail.
410 svn_error_t *
411 svn_cl__revprop_prepare(const svn_opt_revision_t *revision,
412 apr_array_header_t *targets,
413 const char **URL,
414 apr_pool_t *pool);
416 /* Search for a text editor command in standard environment variables,
417 and invoke it to edit CONTENTS (using a temporary file created in
418 directory BASE_DIR). Return the new contents in *EDITED_CONTENTS,
419 or set *EDITED_CONTENTS to NULL if no edit was performed.
421 If EDITOR_CMD is not NULL, it is the name of the external editor
422 command to use, overriding anything else that might determine the
423 editor.
425 If TMPFILE_LEFT is NULL, the temporary file will be destroyed.
426 Else, the file will be left on disk, and its path returned in
427 *TMPFILE_LEFT.
429 CONFIG is a hash of svn_config_t * items keyed on a configuration
430 category (SVN_CONFIG_CATEGORY_CONFIG et al), and may be NULL.
432 If AS_TEXT is TRUE, recode CONTENTS and convert to native eol-style before
433 editing and back again afterwards. In this case, ENCODING determines the
434 encoding used during editing. If non-NULL, use the named encoding, else
435 use the system encoding. If AS_TEXT is FALSE, don't do any translation.
436 In that case, ENCODING is ignored.
438 Use POOL for all allocations. Use PREFIX as the prefix for the
439 temporary file used by the editor.
441 If return error, *EDITED_CONTENTS is not touched. */
442 svn_error_t *
443 svn_cl__edit_string_externally(svn_string_t **edited_contents,
444 const char **tmpfile_left,
445 const char *editor_cmd,
446 const char *base_dir,
447 const svn_string_t *contents,
448 const char *prefix,
449 apr_hash_t *config,
450 svn_boolean_t as_text,
451 const char *encoding,
452 apr_pool_t *pool);
455 /* Search for a text editor command in standard environment variables,
456 and invoke it to edit PATH. Use POOL for all allocations.
458 If EDITOR_CMD is not NULL, it is the name of the external editor
459 command to use, overriding anything else that might determine the
460 editor.
462 CONFIG is a hash of svn_config_t * items keyed on a configuration
463 category (SVN_CONFIG_CATEGORY_CONFIG et al), and may be NULL. */
464 svn_error_t *
465 svn_cl__edit_file_externally(const char *path,
466 const char *editor_cmd,
467 apr_hash_t *config,
468 apr_pool_t *pool);
470 /* Search for a merge tool command in environment variables,
471 and use it to perform the merge of the four given files.
472 Use POOL for all allocations.
474 CONFIG is a hash of svn_config_t * items keyed on a configuration
475 category (SVN_CONFIG_CATEGORY_CONFIG et al), and may be NULL.
477 svn_error_t *
478 svn_cl__merge_file_externally(const char *base_path,
479 const char *their_path,
480 const char *my_path,
481 const char *merged_path,
482 apr_hash_t *config,
483 apr_pool_t *pool);
487 /*** Notification functions to display results on the terminal. */
489 /* Set *NOTIFY_FUNC_P and *NOTIFY_BATON_P to a notifier/baton for all
490 * operations, allocated in POOL.
492 * If this is a checkout, set IS_CHECKOUT to true, so that the
493 * notifier will print the appropriate summary line at the end of the
494 * output.
496 * If this is an export, set IS_EXPORT to true, so that the
497 * notifier will print the appropriate summary line at the end of the
498 * output.
500 * If don't want a summary line at the end of notifications, set
501 * SUPPRESS_FINAL_LINE.
503 void svn_cl__get_notifier(svn_wc_notify_func2_t *notify_func_p,
504 void **notify_baton_p,
505 svn_boolean_t is_checkout,
506 svn_boolean_t is_export,
507 svn_boolean_t suppress_final_line,
508 apr_pool_t *pool);
511 /*** Log message callback stuffs. ***/
513 /* Allocate in POOL a baton for use with svn_cl__get_log_message().
515 OPT_STATE is the set of command-line options given.
517 BASE_DIR is a directory in which to create temporary files if an
518 external editor is used to edit the log message. If BASE_DIR is
519 NULL, the current working directory (`.') will be used, and
520 therefore the user must have the proper permissions on that
521 directory. ### todo: What *should* happen in the NULL case is that
522 we ask APR to tell us where a suitable tmp directory is (like, /tmp
523 on Unix and C:\Windows\Temp on Win32 or something), and use it.
524 But APR doesn't yet have that capability.
526 CONFIG is a client configuration hash of svn_config_t * items keyed
527 on config categories, and may be NULL.
529 NOTE: While the baton itself will be allocated from POOL, the items
530 add to it are added by reference, not duped into POOL!*/
531 svn_error_t *svn_cl__make_log_msg_baton(void **baton,
532 svn_cl__opt_state_t *opt_state,
533 const char *base_dir,
534 apr_hash_t *config,
535 apr_pool_t *pool);
537 /* A function of type svn_client_get_commit_log3_t. */
538 svn_error_t *svn_cl__get_log_message(const char **log_msg,
539 const char **tmp_file,
540 const apr_array_header_t *commit_items,
541 void *baton,
542 apr_pool_t *pool);
544 /* Handle the cleanup of a log message, using the data in the
545 LOG_MSG_BATON, in the face of COMMIT_ERR. This may mean removing a
546 temporary file left by an external editor, or it may be a complete
547 no-op. COMMIT_ERR may be NULL to indicate to indicate that the
548 function should act as though no commit error occurred.
550 All error returns from this function are guaranteed to at least
551 include COMMIT_ERR, and perhaps additional errors attached to the
552 end of COMMIT_ERR's chain. */
553 svn_error_t *svn_cl__cleanup_log_msg(void *log_msg_baton,
554 svn_error_t *commit_err);
556 /* Add a message about --force if appropriate */
557 svn_error_t *svn_cl__may_need_force(svn_error_t *err);
559 /* Write the STRING to the stdio STREAM, returning an error if it fails. */
560 svn_error_t *svn_cl__error_checked_fputs(const char *string,
561 FILE* stream);
563 /* If STRING is non-null, append it, wrapped in a simple XML CDATA element
564 named TAGNAME, to the string SB. Use POOL for temporary allocations. */
565 void svn_cl__xml_tagged_cdata(svn_stringbuf_t **sb,
566 apr_pool_t *pool,
567 const char *tagname,
568 const char *string);
570 /* Print the XML prolog and document root element start-tag to stdout, using
571 TAGNAME as the root element name. Use pool for temporary allocations. */
572 svn_error_t *svn_cl__xml_print_header(const char *tagname,
573 apr_pool_t *pool);
575 /* Print the XML document root element end-tag to stdout, using TAGNAME as the
576 root element name. Use pool for temporary allocations. */
577 svn_error_t *svn_cl__xml_print_footer(const char *tagname,
578 apr_pool_t *pool);
580 /* Return a (non-localised) string representation of KIND, being "dir" or
581 "file" or, in any other case, the empty string. */
582 const char *svn_cl__node_kind_str(svn_node_kind_t kind);
585 /* If PROPNAME is one of the svn: properties with a boolean value, and
586 * PROPVAL looks like an attempt to turn the property off (i.e., it's
587 * "off", "no", "false", or ""), then print a warning to the user that
588 * setting the property to this value might not do what they expect.
589 * Perform temporary allocations in POOL.
591 void svn_cl__check_boolean_prop_val(const char *propname,
592 const char *propval,
593 apr_pool_t *pool);
595 /* De-streamifying wrapper around svn_client_get_changelists(), which
596 is called for each target in TARGETS to populate *PATHS (a list of
597 paths assigned to one of the CHANGELISTS. */
598 svn_error_t *svn_cl__changelist_paths(apr_array_header_t **paths,
599 const apr_array_header_t *changelists,
600 const apr_array_header_t *targets,
601 svn_depth_t depth,
602 svn_client_ctx_t *ctx,
603 apr_pool_t *pool);
605 svn_error_t *
606 svn_cl__args_to_target_array_print_reserved(apr_array_header_t **targets_p,
607 apr_getopt_t *os,
608 apr_array_header_t *known_targets,
609 apr_pool_t *pool);
611 #ifdef __cplusplus
613 #endif /* __cplusplus */
615 #endif /* SVN_CL_H */