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