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