2 * svn.c: Subversion command line client main file.
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
13 * http://www.apache.org/licenses/LICENSE-2.0
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
21 * ====================================================================
24 /* ==================================================================== */
33 #include <apr_strings.h>
34 #include <apr_tables.h>
35 #include <apr_general.h>
36 #include <apr_signal.h>
38 #include "svn_cmdline.h"
39 #include "svn_pools.h"
41 #include "svn_client.h"
42 #include "svn_config.h"
43 #include "svn_string.h"
44 #include "svn_dirent_uri.h"
46 #include "svn_delta.h"
48 #include "svn_error.h"
54 #include "svn_version.h"
57 #include "private/svn_opt_private.h"
58 #include "private/svn_cmdline_private.h"
59 #include "private/svn_subr_private.h"
61 #include "svn_private_config.h"
64 /*** Option Processing ***/
66 /* Add an identifier here for long options that don't have a short
67 option. Options that have both long and short options should just
68 use the short option letter as identifier. */
69 typedef enum svn_cl__longopt_t {
70 opt_auth_password = SVN_OPT_FIRST_LONGOPT_ID,
81 opt_show_copies_as_adds,
84 opt_use_git_diff_format,
85 opt_ignore_properties,
88 /* end of diff options */
106 opt_force_interactive,
121 opt_with_all_revprops,
122 opt_with_no_revprops,
127 opt_trust_server_cert,
131 opt_ignore_whitespace,
133 opt_allow_mixed_revisions,
134 opt_include_externals,
135 opt_show_inherited_props,
141 /* Option codes and descriptions for the command line client.
143 * The entire list must be terminated with an entry of nulls.
145 const apr_getopt_option_t svn_cl__options[] =
147 {"force", opt_force, 0, N_("force operation to run")},
148 {"force-log", opt_force_log, 0,
149 N_("force validity of log message source")},
150 {"help", 'h', 0, N_("show help on a subcommand")},
151 {NULL, '?', 0, N_("show help on a subcommand")},
152 {"message", 'm', 1, N_("specify log message ARG")},
153 {"quiet", 'q', 0, N_("print nothing, or only summary information")},
154 {"recursive", 'R', 0, N_("descend recursively, same as --depth=infinity")},
155 {"non-recursive", 'N', 0, N_("obsolete; try --depth=files or --depth=immediates")},
157 N_("the change made by revision ARG (like -r ARG-1:ARG)\n"
159 "If ARG is negative this is like -r ARG:ARG-1\n"
161 "If ARG is of the form ARG1-ARG2 then this is like\n"
163 "ARG1:ARG2, where ARG1 is inclusive")},
165 N_("ARG (some commands also take ARG1:ARG2 range)\n"
167 "A revision argument can be one of:\n"
169 " NUMBER revision number\n"
171 " '{' DATE '}' revision at start of the date\n"
173 " 'HEAD' latest in repository\n"
175 " 'BASE' base rev of item's working copy\n"
177 " 'COMMITTED' last commit at or before BASE\n"
179 " 'PREV' revision just before COMMITTED")},
180 {"file", 'F', 1, N_("read log message from file ARG")},
181 {"incremental", opt_incremental, 0,
182 N_("give output suitable for concatenation")},
183 {"encoding", opt_encoding, 1,
184 N_("treat value as being in charset encoding ARG")},
185 {"version", opt_version, 0, N_("show program version information")},
186 {"verbose", 'v', 0, N_("print extra information")},
187 {"show-updates", 'u', 0, N_("display update information")},
188 {"username", opt_auth_username, 1, N_("specify a username ARG")},
189 {"password", opt_auth_password, 1, N_("specify a password ARG")},
190 {"extensions", 'x', 1,
191 N_("Specify differencing options for external diff or\n"
193 "internal diff or blame. Default: '-u'. Options are\n"
195 "separated by spaces. Internal diff and blame take:\n"
197 " -u, --unified: Show 3 lines of unified context\n"
199 " -b, --ignore-space-change: Ignore changes in\n"
201 " amount of white space\n"
203 " -w, --ignore-all-space: Ignore all white space\n"
205 " --ignore-eol-style: Ignore changes in EOL style\n"
207 " -p, --show-c-function: Show C function name")},
208 {"targets", opt_targets, 1,
209 N_("pass contents of file ARG as additional args")},
210 {"depth", opt_depth, 1,
211 N_("limit operation by depth ARG ('empty', 'files',\n"
213 "'immediates', or 'infinity')")},
214 {"set-depth", opt_set_depth, 1,
215 N_("set new working copy depth to ARG ('exclude',\n"
217 "'empty', 'files', 'immediates', or 'infinity')")},
218 {"xml", opt_xml, 0, N_("output in XML")},
219 {"strict", opt_strict, 0, N_("use strict semantics")},
220 {"stop-on-copy", opt_stop_on_copy, 0,
221 N_("do not cross copies while traversing history")},
222 {"no-ignore", opt_no_ignore, 0,
223 N_("disregard default and svn:ignore and\n"
225 "svn:global-ignores property ignores")},
226 {"no-auth-cache", opt_no_auth_cache, 0,
227 N_("do not cache authentication tokens")},
228 {"trust-server-cert", opt_trust_server_cert, 0,
229 N_("accept SSL server certificates from unknown\n"
231 "certificate authorities without prompting (but only\n"
233 "with '--non-interactive')") },
234 {"non-interactive", opt_non_interactive, 0,
235 N_("do no interactive prompting (default is to prompt\n"
237 "only if standard input is a terminal device)")},
238 {"force-interactive", opt_force_interactive, 0,
239 N_("do interactive prompting even if standard input\n"
241 "is not a terminal device")},
242 {"dry-run", opt_dry_run, 0,
243 N_("try operation but make no changes")},
244 {"ignore-ancestry", opt_ignore_ancestry, 0,
245 N_("disable merge tracking; diff nodes as if related")},
246 {"ignore-externals", opt_ignore_externals, 0,
247 N_("ignore externals definitions")},
248 {"diff3-cmd", opt_merge_cmd, 1, N_("use ARG as merge command")},
249 {"editor-cmd", opt_editor_cmd, 1, N_("use ARG as external editor")},
250 {"record-only", opt_record_only, 0,
251 N_("merge only mergeinfo differences")},
252 {"old", opt_old_cmd, 1, N_("use ARG as the older target")},
253 {"new", opt_new_cmd, 1, N_("use ARG as the newer target")},
254 {"revprop", opt_revprop, 0,
255 N_("operate on a revision property (use with -r)")},
256 {"relocate", opt_relocate, 0, N_("relocate via URL-rewriting")},
257 {"config-dir", opt_config_dir, 1,
258 N_("read user configuration files from directory ARG")},
259 {"config-option", opt_config_options, 1,
260 N_("set user configuration option in the format:\n"
262 " FILE:SECTION:OPTION=[VALUE]\n"
266 " servers:global:http-library=serf")},
267 {"auto-props", opt_autoprops, 0, N_("enable automatic properties")},
268 {"no-auto-props", opt_no_autoprops, 0, N_("disable automatic properties")},
269 {"native-eol", opt_native_eol, 1,
270 N_("use a different EOL marker than the standard\n"
272 "system marker for files with the svn:eol-style\n"
274 "property set to 'native'.\n"
276 "ARG may be one of 'LF', 'CR', 'CRLF'")},
277 {"limit", 'l', 1, N_("maximum number of log entries")},
278 {"no-unlock", opt_no_unlock, 0, N_("don't unlock the targets")},
279 {"remove", opt_remove, 0, N_("remove changelist association")},
280 {"changelist", opt_changelist, 1,
281 N_("operate only on members of changelist ARG")},
282 {"keep-changelists", opt_keep_changelists, 0,
283 N_("don't delete changelists after commit")},
284 {"keep-local", opt_keep_local, 0, N_("keep path in working copy")},
285 {"with-all-revprops", opt_with_all_revprops, 0,
286 N_("retrieve all revision properties")},
287 {"with-no-revprops", opt_with_no_revprops, 0,
288 N_("retrieve no revision properties")},
289 {"with-revprop", opt_with_revprop, 1,
290 N_("set revision property ARG in new revision\n"
292 "using the name[=value] format")},
293 {"parents", opt_parents, 0, N_("make intermediate directories")},
294 {"use-merge-history", 'g', 0,
295 N_("use/display additional information from merge\n"
298 {"accept", opt_accept, 1,
299 N_("specify automatic conflict resolution action\n"
301 "('postpone', 'working', 'base', 'mine-conflict',\n"
303 "'theirs-conflict', 'mine-full', 'theirs-full',\n"
305 "'edit', 'launch')\n"
307 "(shorthand: 'p', 'mc', 'tc', 'mf', 'tf', 'e', 'l')"
309 {"show-revs", opt_show_revs, 1,
310 N_("specify which collection of revisions to display\n"
312 "('merged', 'eligible')")},
313 {"reintegrate", opt_reintegrate, 0,
315 {"strip", opt_strip, 1,
316 N_("number of leading path components to strip from\n"
318 "paths parsed from the patch file. --strip 0\n"
320 "is the default and leaves paths unmodified.\n"
322 "--strip 1 would change the path\n"
324 "'doc/fudge/crunchy.html' to 'fudge/crunchy.html'.\n"
326 "--strip 2 would leave just 'crunchy.html'\n"
328 "The expected component separator is '/' on all\n"
330 "platforms. A leading '/' counts as one component.")},
331 {"ignore-keywords", opt_ignore_keywords, 0,
332 N_("don't expand keywords")},
333 {"reverse-diff", opt_reverse_diff, 0,
334 N_("apply the unidiff in reverse")},
335 {"ignore-whitespace", opt_ignore_whitespace, 0,
336 N_("ignore whitespace during pattern matching")},
337 {"diff", opt_diff, 0, N_("produce diff output")}, /* maps to show_diff */
339 {"diff-cmd", opt_diff_cmd, 1, N_("use ARG as diff command")},
340 {"internal-diff", opt_internal_diff, 0,
341 N_("override diff-cmd specified in config file")},
342 {"no-diff-added", opt_no_diff_added, 0,
343 N_("do not print differences for added files")},
344 {"no-diff-deleted", opt_no_diff_deleted, 0,
345 N_("do not print differences for deleted files")},
346 {"show-copies-as-adds", opt_show_copies_as_adds, 0,
347 N_("don't diff copied or moved files with their source")},
348 {"notice-ancestry", opt_notice_ancestry, 0,
349 N_("diff unrelated nodes as delete and add")},
350 {"summarize", opt_summarize, 0, N_("show a summary of the results")},
351 {"git", opt_use_git_diff_format, 0,
352 N_("use git's extended diff format")},
353 {"ignore-properties", opt_ignore_properties, 0,
354 N_("ignore properties during the operation")},
355 {"properties-only", opt_properties_only, 0,
356 N_("show only properties during the operation")},
357 {"patch-compatible", opt_patch_compatible, 0,
358 N_("generate diff suitable for generic third-party\n"
360 "patch tools; currently the same as\n"
362 "--show-copies-as-adds --ignore-properties"
364 /* end of diff options */
365 {"allow-mixed-revisions", opt_allow_mixed_revisions, 0,
366 N_("Allow operation on mixed-revision working copy.\n"
368 "Use of this option is not recommended!\n"
370 "Please run 'svn update' instead.")},
371 {"include-externals", opt_include_externals, 0,
372 N_("Also commit file and dir externals reached by\n"
374 "recursion. This does not include externals with a\n"
376 "fixed revision. (See the svn:externals property)")},
377 {"show-inherited-props", opt_show_inherited_props, 0,
378 N_("retrieve target's inherited properties")},
379 {"search", opt_search, 1,
380 N_("use ARG as search pattern (glob syntax)")},
381 {"search-and", opt_search_and, 1,
382 N_("combine ARG with the previous search pattern")},
386 * These have NULL desriptions, but an option code that matches some
387 * other option (whose description should probably mention its aliases).
390 {"cl", opt_changelist, 1, NULL},
397 /*** Command dispatch. ***/
399 /* Our array of available subcommands.
401 * The entire list must be terminated with an entry of nulls.
403 * In most of the help text "PATH" is used where a working copy path is
404 * required, "URL" where a repository URL is required and "TARGET" when
405 * either a path or a url can be used. Hmm, should this be part of the
409 /* Options that apply to all commands. (While not every command may
410 currently require authentication or be interactive, allowing every
411 command to take these arguments allows scripts to just pass them
412 willy-nilly to every invocation of 'svn') . */
413 const int svn_cl__global_options[] =
414 { opt_auth_username, opt_auth_password, opt_no_auth_cache, opt_non_interactive,
415 opt_force_interactive, opt_trust_server_cert, opt_config_dir,
416 opt_config_options, 0
419 /* Options for giving a log message. (Some of these also have other uses.)
421 #define SVN_CL__LOG_MSG_OPTIONS 'm', 'F', \
427 const svn_opt_subcommand_desc2_t svn_cl__cmd_table[] =
429 { "add", svn_cl__add, {0}, N_
430 ("Put files and directories under version control, scheduling\n"
431 "them for addition to repository. They will be added in next commit.\n"
432 "usage: add PATH...\n"),
433 {opt_targets, 'N', opt_depth, 'q', opt_force, opt_no_ignore, opt_autoprops,
434 opt_no_autoprops, opt_parents },
435 {{opt_parents, N_("add intermediate parents")}} },
437 { "blame", svn_cl__blame, {"praise", "annotate", "ann"}, N_
438 ("Output the content of specified files or\n"
439 "URLs with revision and author information in-line.\n"
440 "usage: blame TARGET[@REV]...\n"
442 " If specified, REV determines in which revision the target is first\n"
444 {'r', 'v', 'g', opt_incremental, opt_xml, 'x', opt_force} },
446 { "cat", svn_cl__cat, {0}, N_
447 ("Output the content of specified files or URLs.\n"
448 "usage: cat TARGET[@REV]...\n"
450 " If specified, REV determines in which revision the target is first\n"
454 { "changelist", svn_cl__changelist, {"cl"}, N_
455 ("Associate (or dissociate) changelist CLNAME with the named files.\n"
456 "usage: 1. changelist CLNAME PATH...\n"
457 " 2. changelist --remove PATH...\n"),
458 { 'q', 'R', opt_depth, opt_remove, opt_targets, opt_changelist} },
460 { "checkout", svn_cl__checkout, {"co"}, N_
461 ("Check out a working copy from a repository.\n"
462 "usage: checkout URL[@REV]... [PATH]\n"
464 " If specified, REV determines in which revision the URL is first\n"
467 " If PATH is omitted, the basename of the URL will be used as\n"
468 " the destination. If multiple URLs are given each will be checked\n"
469 " out into a sub-directory of PATH, with the name of the sub-directory\n"
470 " being the basename of the URL.\n"
472 " If --force is used, unversioned obstructing paths in the working\n"
473 " copy destination do not automatically cause the check out to fail.\n"
474 " If the obstructing path is the same type (file or directory) as the\n"
475 " corresponding path in the repository it becomes versioned but its\n"
476 " contents are left 'as-is' in the working copy. This means that an\n"
477 " obstructing directory's unversioned children may also obstruct and\n"
478 " become versioned. For files, any content differences between the\n"
479 " obstruction and the repository are treated like a local modification\n"
480 " to the working copy. All properties from the repository are applied\n"
481 " to the obstructing path.\n"
483 " See also 'svn help update' for a list of possible characters\n"
484 " reporting the action taken.\n"),
485 {'r', 'q', 'N', opt_depth, opt_force, opt_ignore_externals} },
487 { "cleanup", svn_cl__cleanup, {0}, N_
488 ("Recursively clean up the working copy, removing write locks, resuming\n"
489 "unfinished operations, etc.\n"
490 "usage: cleanup [WCPATH...]\n"
492 " Finish any unfinished business in the working copy at WCPATH, and remove\n"
493 " write locks (shown as 'L' by the 'svn status' command) from the working\n"
494 " copy. Usually, this is only necessary if a Subversion client has crashed\n"
495 " while using the working copy, leaving it in an unusable state.\n"
497 " WARNING: There is no mechanism that will protect write locks still\n"
498 " being used by other Subversion clients. Running this command\n"
499 " while another client is using the working copy can corrupt\n"
500 " the working copy beyond repair!\n"),
503 { "commit", svn_cl__commit, {"ci"},
504 N_("Send changes from your working copy to the repository.\n"
505 "usage: commit [PATH...]\n"
507 " A log message must be provided, but it can be empty. If it is not\n"
508 " given by a --message or --file option, an editor will be started.\n"
509 " If any targets are (or contain) locked items, those will be\n"
510 " unlocked after a successful commit.\n"),
511 {'q', 'N', opt_depth, opt_targets, opt_no_unlock, SVN_CL__LOG_MSG_OPTIONS,
512 opt_changelist, opt_keep_changelists, opt_include_externals} },
514 { "copy", svn_cl__copy, {"cp"}, N_
515 ("Copy files and directories in a working copy or repository.\n"
516 "usage: copy SRC[@REV]... DST\n"
518 " SRC and DST can each be either a working copy (WC) path or URL:\n"
519 " WC -> WC: copy and schedule for addition (with history)\n"
520 " WC -> URL: immediately commit a copy of WC to URL\n"
521 " URL -> WC: check out URL into WC, schedule for addition\n"
522 " URL -> URL: complete server-side copy; used to branch and tag\n"
523 " All the SRCs must be of the same type. When copying multiple sources,\n"
524 " they will be added as children of DST, which must be a directory.\n"
526 " WARNING: For compatibility with previous versions of Subversion,\n"
527 " copies performed using two working copy paths (WC -> WC) will not\n"
528 " contact the repository. As such, they may not, by default, be able\n"
529 " to propagate merge tracking information from the source of the copy\n"
530 " to the destination.\n"),
531 {'r', 'q', opt_ignore_externals, opt_parents, SVN_CL__LOG_MSG_OPTIONS} },
533 { "delete", svn_cl__delete, {"del", "remove", "rm"}, N_
534 ("Remove files and directories from version control.\n"
535 "usage: 1. delete PATH...\n"
536 " 2. delete URL...\n"
538 " 1. Each item specified by a PATH is scheduled for deletion upon\n"
539 " the next commit. Files, and directories that have not been\n"
540 " committed, are immediately removed from the working copy\n"
541 " unless the --keep-local option is given.\n"
542 " PATHs that are, or contain, unversioned or modified items will\n"
543 " not be removed unless the --force or --keep-local option is given.\n"
545 " 2. Each item specified by a URL is deleted from the repository\n"
546 " via an immediate commit.\n"),
547 {opt_force, 'q', opt_targets, SVN_CL__LOG_MSG_OPTIONS, opt_keep_local} },
549 { "diff", svn_cl__diff, {"di"}, N_
550 ("Display local changes or differences between two revisions or paths.\n"
552 " 2. diff [-c M | -r N[:M]] [TARGET[@REV]...]\n"
553 " 3. diff [-r N[:M]] --old=OLD-TGT[@OLDREV] [--new=NEW-TGT[@NEWREV]] \\\n"
555 " 4. diff OLD-URL[@OLDREV] NEW-URL[@NEWREV]\n"
556 " 5. diff OLD-URL[@OLDREV] NEW-PATH[@NEWREV]\n"
557 " 6. diff OLD-PATH[@OLDREV] NEW-URL[@NEWREV]\n"
559 " 1. Use just 'svn diff' to display local modifications in a working copy.\n"
561 " 2. Display the changes made to TARGETs as they are seen in REV between\n"
562 " two revisions. TARGETs may be all working copy paths or all URLs.\n"
563 " If TARGETs are working copy paths, N defaults to BASE and M to the\n"
564 " working copy; if URLs, N must be specified and M defaults to HEAD.\n"
565 " The '-c M' option is equivalent to '-r N:M' where N = M-1.\n"
566 " Using '-c -M' does the reverse: '-r M:N' where N = M-1.\n"
568 " 3. Display the differences between OLD-TGT as it was seen in OLDREV and\n"
569 " NEW-TGT as it was seen in NEWREV. PATHs, if given, are relative to\n"
570 " OLD-TGT and NEW-TGT and restrict the output to differences for those\n"
571 " paths. OLD-TGT and NEW-TGT may be working copy paths or URL[@REV].\n"
572 " NEW-TGT defaults to OLD-TGT if not specified. -r N makes OLDREV default\n"
573 " to N, -r N:M makes OLDREV default to N and NEWREV default to M.\n"
574 " If OLDREV or NEWREV are not specified, they default to WORKING for\n"
575 " working copy targets and to HEAD for URL targets.\n"
577 " Either or both OLD-TGT and NEW-TGT may also be paths to unversioned\n"
578 " targets. Revisions cannot be specified for unversioned targets.\n"
579 " Both targets must be of the same node kind (file or directory).\n"
580 " Diffing unversioned targets against URL targets is not supported.\n"
582 " 4. Shorthand for 'svn diff --old=OLD-URL[@OLDREV] --new=NEW-URL[@NEWREV]'\n"
583 " 5. Shorthand for 'svn diff --old=OLD-URL[@OLDREV] --new=NEW-PATH[@NEWREV]'\n"
584 " 6. Shorthand for 'svn diff --old=OLD-PATH[@OLDREV] --new=NEW-URL[@NEWREV]'\n"),
585 {'r', 'c', opt_old_cmd, opt_new_cmd, 'N', opt_depth, opt_diff_cmd,
586 opt_internal_diff, 'x', opt_no_diff_added, opt_no_diff_deleted,
587 opt_ignore_properties, opt_properties_only,
588 opt_show_copies_as_adds, opt_notice_ancestry, opt_summarize, opt_changelist,
589 opt_force, opt_xml, opt_use_git_diff_format, opt_patch_compatible} },
590 { "export", svn_cl__export, {0}, N_
591 ("Create an unversioned copy of a tree.\n"
592 "usage: 1. export [-r REV] URL[@PEGREV] [PATH]\n"
593 " 2. export [-r REV] PATH1[@PEGREV] [PATH2]\n"
595 " 1. Exports a clean directory tree from the repository specified by\n"
596 " URL, at revision REV if it is given, otherwise at HEAD, into\n"
597 " PATH. If PATH is omitted, the last component of the URL is used\n"
598 " for the local directory name.\n"
600 " 2. Exports a clean directory tree from the working copy specified by\n"
601 " PATH1, at revision REV if it is given, otherwise at WORKING, into\n"
602 " PATH2. If PATH2 is omitted, the last component of the PATH1 is used\n"
603 " for the local directory name. If REV is not specified, all local\n"
604 " changes will be preserved. Files not under version control will\n"
607 " If specified, PEGREV determines in which revision the target is first\n"
609 {'r', 'q', 'N', opt_depth, opt_force, opt_native_eol, opt_ignore_externals,
610 opt_ignore_keywords} },
612 { "help", svn_cl__help, {"?", "h"}, N_
613 ("Describe the usage of this program or its subcommands.\n"
614 "usage: help [SUBCOMMAND...]\n"),
616 /* This command is also invoked if we see option "--help", "-h" or "-?". */
618 { "import", svn_cl__import, {0}, N_
619 ("Commit an unversioned file or tree into the repository.\n"
620 "usage: import [PATH] URL\n"
622 " Recursively commit a copy of PATH to URL.\n"
623 " If PATH is omitted '.' is assumed.\n"
624 " Parent directories are created as necessary in the repository.\n"
625 " If PATH is a directory, the contents of the directory are added\n"
626 " directly under URL.\n"
627 " Unversionable items such as device files and pipes are ignored\n"
628 " if --force is specified.\n"),
629 {'q', 'N', opt_depth, opt_autoprops, opt_force, opt_no_autoprops,
630 SVN_CL__LOG_MSG_OPTIONS, opt_no_ignore} },
632 { "info", svn_cl__info, {0}, N_
633 ("Display information about a local or remote item.\n"
634 "usage: info [TARGET[@REV]...]\n"
636 " Print information about each TARGET (default: '.').\n"
637 " TARGET may be either a working-copy path or URL. If specified, REV\n"
638 " determines in which revision the target is first looked up.\n"),
639 {'r', 'R', opt_depth, opt_targets, opt_incremental, opt_xml, opt_changelist}
642 { "list", svn_cl__list, {"ls"}, N_
643 ("List directory entries in the repository.\n"
644 "usage: list [TARGET[@REV]...]\n"
646 " List each TARGET file and the contents of each TARGET directory as\n"
647 " they exist in the repository. If TARGET is a working copy path, the\n"
648 " corresponding repository URL will be used. If specified, REV determines\n"
649 " in which revision the target is first looked up.\n"
651 " The default TARGET is '.', meaning the repository URL of the current\n"
652 " working directory.\n"
654 " With --verbose, the following fields will be shown for each item:\n"
656 " Revision number of the last commit\n"
657 " Author of the last commit\n"
658 " If locked, the letter 'O'. (Use 'svn info URL' to see details)\n"
660 " Date and time of the last commit\n"),
661 {'r', 'v', 'R', opt_depth, opt_incremental, opt_xml,
662 opt_include_externals },
663 {{opt_include_externals, N_("include externals definitions")}} },
665 { "lock", svn_cl__lock, {0}, N_
666 ("Lock working copy paths or URLs in the repository, so that\n"
667 "no other user can commit changes to them.\n"
668 "usage: lock TARGET...\n"
670 " Use --force to steal the lock from another user or working copy.\n"),
671 { opt_targets, 'm', 'F', opt_force_log, opt_encoding, opt_force },
672 {{'F', N_("read lock comment from file ARG")},
673 {'m', N_("specify lock comment ARG")},
674 {opt_force_log, N_("force validity of lock comment source")}} },
676 { "log", svn_cl__log, {0}, N_
677 ("Show the log messages for a set of revision(s) and/or path(s).\n"
678 "usage: 1. log [PATH][@REV]\n"
679 " 2. log URL[@REV] [PATH...]\n"
681 " 1. Print the log messages for the URL corresponding to PATH\n"
682 " (default: '.'). If specified, REV is the revision in which the\n"
683 " URL is first looked up, and the default revision range is REV:1.\n"
684 " If REV is not specified, the default revision range is BASE:1,\n"
685 " since the URL might not exist in the HEAD revision.\n"
687 " 2. Print the log messages for the PATHs (default: '.') under URL.\n"
688 " If specified, REV is the revision in which the URL is first\n"
689 " looked up, and the default revision range is REV:1; otherwise,\n"
690 " the URL is looked up in HEAD, and the default revision range is\n"
693 " Multiple '-c' or '-r' options may be specified (but not a\n"
694 " combination of '-c' and '-r' options), and mixing of forward and\n"
695 " reverse ranges is allowed.\n"
697 " With -v, also print all affected paths with each log message.\n"
698 " With -q, don't print the log message body itself (note that this is\n"
699 " compatible with -v).\n"
701 " Each log message is printed just once, even if more than one of the\n"
702 " affected paths for that revision were explicitly requested. Logs\n"
703 " follow copy history by default. Use --stop-on-copy to disable this\n"
704 " behavior, which can be useful for determining branchpoints.\n"
706 " The --depth option is only valid in combination with the --diff option\n"
707 " and limits the scope of the displayed diff to the specified depth.\n"
709 " If the --search option is used, log messages are displayed only if the\n"
710 " provided search pattern matches any of the author, date, log message\n"
711 " text (unless --quiet is used), or, if the --verbose option is also\n"
712 " provided, a changed path.\n"
713 " The search pattern may include \"glob syntax\" wildcards:\n"
714 " ? matches any single character\n"
715 " * matches a sequence of arbitrary characters\n"
716 " [abc] matches any of the characters listed inside the brackets\n"
717 " If multiple --search options are provided, a log message is shown if\n"
718 " it matches any of the provided search patterns. If the --search-and\n"
719 " option is used, that option's argument is combined with the pattern\n"
720 " from the previous --search or --search-and option, and a log message\n"
721 " is shown only if it matches the combined search pattern.\n"
722 " If --limit is used in combination with --search, --limit restricts the\n"
723 " number of log messages searched, rather than restricting the output\n"
724 " to a particular number of matching log messages.\n"
728 " Show the latest 5 log messages for the current working copy\n"
729 " directory and display paths changed in each commit:\n"
732 " Show the log for bar.c as of revision 42:\n"
733 " svn log bar.c@42\n"
735 " Show log messages and diffs for each commit to foo.c:\n"
736 " svn log --diff http://www.example.com/repo/project/foo.c\n"
737 " (Because the above command uses a full URL it does not require\n"
738 " a working copy.)\n"
740 " Show log messages for the children foo.c and bar.c of the directory\n"
741 " '/trunk' as it appeared in revision 50, using the ^/ URL shortcut:\n"
742 " svn log ^/trunk@50 foo.c bar.c\n"
744 " Show the log messages for any incoming changes to foo.c during the\n"
745 " next 'svn update':\n"
746 " svn log -r BASE:HEAD foo.c\n"
748 " Show the log message for the revision in which /branches/foo\n"
750 " svn log --stop-on-copy --limit 1 -r0:HEAD ^/branches/foo\n"),
751 {'r', 'q', 'v', 'g', 'c', opt_targets, opt_stop_on_copy, opt_incremental,
752 opt_xml, 'l', opt_with_all_revprops, opt_with_no_revprops, opt_with_revprop,
753 opt_depth, opt_diff, opt_diff_cmd, opt_internal_diff, 'x', opt_search,
755 {{opt_with_revprop, N_("retrieve revision property ARG")},
756 {'c', N_("the change made in revision ARG")}} },
758 { "merge", svn_cl__merge, {0}, N_
759 ( /* For this large section, let's keep it unindented for easier
760 * viewing/editing. It has been vim-treated with a textwidth=75 and 'gw'
761 * (with quotes and newlines removed). */
762 "Merge changes into a working copy.\n"
763 "usage: 1. merge SOURCE[@REV] [TARGET_WCPATH]\n"
764 " (the 'complete' merge)\n"
765 " 2. merge [-c M[,N...] | -r N:M ...] SOURCE[@REV] [TARGET_WCPATH]\n"
766 " (the 'cherry-pick' merge)\n"
767 " 3. merge SOURCE1[@REV1] SOURCE2[@REV2] [TARGET_WCPATH]\n"
768 " (the '2-URL' merge)\n"
770 " 1. This form, with one source path and no revision range, is called\n"
771 " a 'complete' merge:\n"
773 " svn merge SOURCE[@REV] [TARGET_WCPATH]\n"
775 " The complete merge is used for the 'sync' and 'reintegrate' merges\n"
776 " in the 'feature branch' pattern described below. It finds all the\n"
777 " changes on the source branch that have not already been merged to the\n"
778 " target branch, and merges them into the working copy. Merge tracking\n"
779 " is used to know which changes have already been merged.\n"
781 " SOURCE specifies the branch from where the changes will be pulled, and\n"
782 " TARGET_WCPATH specifies a working copy of the target branch to which\n"
783 " the changes will be applied. Normally SOURCE and TARGET_WCPATH should\n"
784 " each correspond to the root of a branch. (If you want to merge only a\n"
785 " subtree, then the subtree path must be included in both SOURCE and\n"
786 " TARGET_WCPATH; this is discouraged, to avoid subtree mergeinfo.)\n"
788 " SOURCE is usually a URL. The optional '@REV' specifies both the peg\n"
789 " revision of the URL and the latest revision that will be considered\n"
790 " for merging; if REV is not specified, the HEAD revision is assumed. If\n"
791 " SOURCE is a working copy path, the corresponding URL of the path is\n"
792 " used, and the default value of 'REV' is the base revision (usually the\n"
793 " revision last updated to).\n"
795 " TARGET_WCPATH is a working copy path; if omitted, '.' is generally\n"
796 " assumed. There are some special cases:\n"
798 " - If SOURCE is a URL:\n"
800 " - If the basename of the URL and the basename of '.' are the\n"
801 " same, then the differences are applied to '.'. Otherwise,\n"
802 " if a file with the same basename as that of the URL is found\n"
803 " within '.', then the differences are applied to that file.\n"
804 " In all other cases, the target defaults to '.'.\n"
806 " - If SOURCE is a working copy path:\n"
808 " - If the source is a file, then differences are applied to that\n"
809 " file (useful for reverse-merging earlier changes). Otherwise,\n"
810 " if the source is a directory, then the target defaults to '.'.\n"
812 " In normal usage the working copy should be up to date, at a single\n"
813 " revision, with no local modifications and no switched subtrees.\n"
815 " - The 'Feature Branch' Merging Pattern -\n"
817 " In this commonly used work flow, known also as the 'development\n"
818 " branch' pattern, a developer creates a branch and commits a series of\n"
819 " changes that implement a new feature. The developer periodically\n"
820 " merges all the latest changes from the parent branch so as to keep the\n"
821 " development branch up to date with those changes. When the feature is\n"
822 " complete, the developer performs a merge from the feature branch to\n"
823 " the parent branch to re-integrate the changes.\n"
825 " parent --+----------o------o-o-------------o--\n"
827 " \\ merge merge merge\n"
829 " feature +--o-o-------o----o-o----o-------\n"
831 " A merge from the parent branch to the feature branch is called a\n"
832 " 'sync' or 'catch-up' merge, and a merge from the feature branch to the\n"
833 " parent branch is called a 'reintegrate' merge.\n"
835 " - Sync Merge Example -\n"
838 " trunk --+------------L--------------R------\n"
842 " feature +------------------------o-----\n"
845 " Subversion will locate all the changes on 'trunk' that have not yet\n"
846 " been merged into the 'feature' branch. In this case that is a single\n"
847 " range, r100:200. In the diagram above, L marks the left side (trunk@100)\n"
848 " and R marks the right side (trunk@200) of the merge source. The\n"
849 " difference between L and R will be applied to the target working copy\n"
850 " path. In this case, the working copy is a clean checkout of the entire\n"
851 " 'feature' branch.\n"
853 " To perform this sync merge, have a clean working copy of the feature\n"
854 " branch and run the following command in its top-level directory:\n"
856 " svn merge ^/trunk\n"
858 " Note that the merge is now only in your local working copy and still\n"
859 " needs to be committed to the repository so that it can be seen by\n"
860 " others. You can review the changes and you may have to resolve\n"
861 " conflicts before you commit the merge.\n"
863 " - Reintegrate Merge Example -\n"
865 " The feature branch was last synced with trunk up to revision X. So the\n"
866 " difference between trunk@X and feature@HEAD contains the complete set\n"
867 " of changes that implement the feature, and no other changes. These\n"
868 " changes are applied to trunk.\n"
871 " trunk ------+--------------------L------------------o\n"
873 " \\ ............. /\n"
875 " feature +--------------------------------R\n"
877 " In the diagram above, L marks the left side (trunk@X) and R marks the\n"
878 " right side (feature@HEAD) of the merge. The difference between the\n"
879 " left and right side is merged into trunk, the target.\n"
881 " To perform the merge, have a clean working copy of trunk and run the\n"
882 " following command in its top-level directory:\n"
884 " svn merge ^/feature\n"
886 " To prevent unnecessary merge conflicts, a reintegrate merge requires\n"
887 " that TARGET_WCPATH is not a mixed-revision working copy, has no local\n"
888 " modifications, and has no switched subtrees.\n"
890 " A reintegrate merge also requires that the source branch is coherently\n"
891 " synced with the target -- in the above example, this means that all\n"
892 " revisions between the branch point W and the last merged revision X\n"
893 " are merged to the feature branch, so that there are no unmerged\n"
894 " revisions in-between.\n"
897 " 2. This form is called a 'cherry-pick' merge:\n"
899 " svn merge [-c M[,N...] | -r N:M ...] SOURCE[@REV] [TARGET_WCPATH]\n"
901 " A cherry-pick merge is used to merge specific revisions (or revision\n"
902 " ranges) from one branch to another. By default, this uses merge\n"
903 " tracking to automatically skip any revisions that have already been\n"
904 " merged to the target; you can use the --ignore-ancestry option to\n"
905 " disable such skipping.\n"
907 " SOURCE is usually a URL. The optional '@REV' specifies only the peg\n"
908 " revision of the URL and does not affect the merge range; if REV is not\n"
909 " specified, the HEAD revision is assumed. If SOURCE is a working copy\n"
910 " path, the corresponding URL of the path is used, and the default value\n"
911 " of 'REV' is the base revision (usually the revision last updated to).\n"
913 " TARGET_WCPATH is a working copy path; if omitted, '.' is generally\n"
914 " assumed. The special cases noted above in the 'complete' merge form\n"
915 " also apply here.\n"
917 " The revision ranges to be merged are specified by the '-r' and/or '-c'\n"
918 " options. '-r N:M' refers to the difference in the history of the\n"
919 " source branch between revisions N and M. You can use '-c M' to merge\n"
920 " single revisions: '-c M' is equivalent to '-r <M-1>:M'. Each such\n"
921 " difference is applied to TARGET_WCPATH.\n"
923 " If the mergeinfo in TARGET_WCPATH indicates that revisions within the\n"
924 " range were already merged, changes made in those revisions are not\n"
925 " merged again. If needed, the range is broken into multiple sub-ranges,\n"
926 " and each sub-range is merged separately.\n"
928 " A 'reverse range' can be used to undo changes. For example, when\n"
929 " source and target refer to the same branch, a previously committed\n"
930 " revision can be 'undone'. In a reverse range, N is greater than M in\n"
931 " '-r N:M', or the '-c' option is used with a negative number: '-c -M'\n"
932 " is equivalent to '-r M:<M-1>'. Undoing changes like this is also known\n"
933 " as performing a 'reverse merge'.\n"
935 " Multiple '-c' and/or '-r' options may be specified and mixing of\n"
936 " forward and reverse ranges is allowed.\n"
938 " - Cherry-pick Merge Example -\n"
940 " A bug has been fixed on trunk in revision 50. This fix needs to\n"
941 " be merged from trunk onto the release branch.\n"
943 " 1.x-release +-----------------------o-----\n"
947 " trunk ------+--------------------------LR-----\n"
950 " In the above diagram, L marks the left side (trunk@49) and R marks the\n"
951 " right side (trunk@50) of the merge. The difference between the left\n"
952 " and right side is applied to the target working copy path.\n"
954 " Note that the difference between revision 49 and 50 is exactly those\n"
955 " changes that were committed in revision 50, not including changes\n"
956 " committed in revision 49.\n"
958 " To perform the merge, have a clean working copy of the release branch\n"
959 " and run the following command in its top-level directory; remember\n"
960 " that the default target is '.':\n"
962 " svn merge -c50 ^/trunk\n"
964 " You can also cherry-pick several revisions and/or revision ranges:\n"
966 " svn merge -c50,54,60 -r65:68 ^/trunk\n"
969 " 3. This form is called a '2-URL merge':\n"
971 " svn merge SOURCE1[@REV1] SOURCE2[@REV2] [TARGET_WCPATH]\n"
973 " You should use this merge variant only if the other variants do not\n"
974 " apply to your situation, as this variant can be quite complex to\n"
977 " Two source URLs are specified, identifying two trees on the same\n"
978 " branch or on different branches. The trees are compared and the\n"
979 " difference from SOURCE1@REV1 to SOURCE2@REV2 is applied to the\n"
980 " working copy of the target branch at TARGET_WCPATH. The target\n"
981 " branch may be the same as one or both sources, or different again.\n"
982 " The three branches involved can be completely unrelated.\n"
984 " TARGET_WCPATH is a working copy path; if omitted, '.' is generally\n"
985 " assumed. The special cases noted above in the 'complete' merge form\n"
986 " also apply here.\n"
988 " SOURCE1 and/or SOURCE2 can also be specified as a working copy path,\n"
989 " in which case the merge source URL is derived from the working copy.\n"
991 " - 2-URL Merge Example -\n"
993 " Two features have been developed on separate branches called 'foo' and\n"
994 " 'bar'. It has since become clear that 'bar' should be combined with\n"
995 " the 'foo' branch for further development before reintegration.\n"
997 " Although both feature branches originate from trunk, they are not\n"
998 " directly related -- one is not a direct copy of the other. A 2-URL\n"
999 " merge is necessary.\n"
1001 " The 'bar' branch has been synced with trunk up to revision 500.\n"
1002 " (If this revision number is not known, it can be located using the\n"
1003 " 'svn log' and/or 'svn mergeinfo' commands.)\n"
1004 " The difference between trunk@500 and bar@HEAD contains the complete\n"
1005 " set of changes related to feature 'bar', and no other changes. These\n"
1006 " changes are applied to the 'foo' branch.\n"
1008 " foo +-----------------------------------o\n"
1012 " trunk ------+------+-----------------L---------> /\n"
1014 " \\ ............ /\n"
1016 " bar +-----------------------------------R\n"
1018 " In the diagram above, L marks the left side (trunk@500) and R marks\n"
1019 " the right side (bar@HEAD) of the merge. The difference between the\n"
1020 " left and right side is applied to the target working copy path, in\n"
1021 " this case a working copy of the 'foo' branch.\n"
1023 " To perform the merge, have a clean working copy of the 'foo' branch\n"
1024 " and run the following command in its top-level directory:\n"
1026 " svn merge ^/trunk@500 ^/bar\n"
1028 " The exact changes applied by a 2-URL merge can be previewed with svn's\n"
1029 " diff command, which is a good idea to verify if you do not have the\n"
1030 " luxury of a clean working copy to merge to. In this case:\n"
1032 " svn diff ^/trunk@500 ^/bar@HEAD\n"
1035 " The following applies to all types of merges:\n"
1037 " To prevent unnecessary merge conflicts, svn merge requires that\n"
1038 " TARGET_WCPATH is not a mixed-revision working copy. Running 'svn update'\n"
1039 " before starting a merge ensures that all items in the working copy are\n"
1040 " based on the same revision.\n"
1042 " If possible, you should have no local modifications in the merge's target\n"
1043 " working copy prior to the merge, to keep things simpler. It will be\n"
1044 " easier to revert the merge and to understand the branch's history.\n"
1046 " Switched sub-paths should also be avoided during merging, as they may\n"
1047 " cause incomplete merges and create subtree mergeinfo.\n"
1049 " For each merged item a line will be printed with characters reporting the\n"
1050 " action taken. These characters have the following meaning:\n"
1060 " Characters in the first column report about the item itself.\n"
1061 " Characters in the second column report about properties of the item.\n"
1062 " A 'C' in the third column indicates a tree conflict, while a 'C' in\n"
1063 " the first and second columns indicate textual conflicts in files\n"
1064 " and in property values, respectively.\n"
1066 " - Merge Tracking -\n"
1068 " Subversion uses the svn:mergeinfo property to track merge history. This\n"
1069 " property is considered at the start of a merge to determine what to merge\n"
1070 " and it is updated at the conclusion of the merge to describe the merge\n"
1071 " that took place. Mergeinfo is used only if the two sources are on the\n"
1072 " same line of history -- if the first source is an ancestor of the second,\n"
1073 " or vice-versa (i.e. if one has originally been created by copying the\n"
1074 " other). This is verified and enforced when using sync merges and\n"
1075 " reintegrate merges.\n"
1077 " The --ignore-ancestry option prevents merge tracking and thus ignores\n"
1078 " mergeinfo, neither considering it nor recording it.\n"
1080 " - Merging from foreign repositories -\n"
1082 " Subversion does support merging from foreign repositories.\n"
1083 " While all merge source URLs must point to the same repository, the merge\n"
1084 " target working copy may come from a different repository than the source.\n"
1085 " However, there are some caveats. Most notably, copies made in the\n"
1086 " merge source will be transformed into plain additions in the merge\n"
1087 " target. Also, merge-tracking is not supported for merges from foreign\n"
1088 " repositories.\n"),
1089 {'r', 'c', 'N', opt_depth, 'q', opt_force, opt_dry_run, opt_merge_cmd,
1090 opt_record_only, 'x', opt_ignore_ancestry, opt_accept, opt_reintegrate,
1091 opt_allow_mixed_revisions, 'v'} },
1093 { "mergeinfo", svn_cl__mergeinfo, {0}, N_
1094 ("Display merge-related information.\n"
1095 "usage: 1. mergeinfo SOURCE[@REV] [TARGET[@REV]]\n"
1096 " 2. mergeinfo --show-revs=WHICH SOURCE[@REV] [TARGET[@REV]]\n"
1098 " 1. Summarize the history of merging between SOURCE and TARGET. The graph\n"
1099 " shows, from left to right:\n"
1100 " the youngest common ancestor of the branches;\n"
1101 " the latest full merge in either direction, and thus the common base\n"
1102 " that will be used for the next complete merge;\n"
1103 " the repository path and revision number of the tip of each branch.\n"
1105 " 2. Print the revision numbers on SOURCE that have been merged to TARGET\n"
1106 " (with --show-revs=merged), or that have not been merged to TARGET\n"
1107 " (with --show-revs=eligible). Print only revisions in which there was\n"
1108 " at least one change in SOURCE.\n"
1110 " If --revision (-r) is provided, filter the displayed information to\n"
1111 " show only that which is associated with the revisions within the\n"
1112 " specified range. Revision numbers, dates, and the 'HEAD' keyword are\n"
1113 " valid range values.\n"
1115 " SOURCE and TARGET are the source and target branch URLs, respectively.\n"
1116 " (If a WC path is given, the corresponding base URL is used.) The default\n"
1117 " TARGET is the current working directory ('.'). REV specifies the revision\n"
1118 " to be considered the tip of the branch; the default for SOURCE is HEAD,\n"
1119 " and the default for TARGET is HEAD for a URL or BASE for a WC path.\n"
1121 " The depth can be 'empty' or 'infinity'; the default is 'empty'.\n"),
1122 {'r', 'R', opt_depth, opt_show_revs} },
1124 { "mkdir", svn_cl__mkdir, {0}, N_
1125 ("Create a new directory under version control.\n"
1126 "usage: 1. mkdir PATH...\n"
1127 " 2. mkdir URL...\n"
1129 " Create version controlled directories.\n"
1131 " 1. Each directory specified by a working copy PATH is created locally\n"
1132 " and scheduled for addition upon the next commit.\n"
1134 " 2. Each directory specified by a URL is created in the repository via\n"
1135 " an immediate commit.\n"
1137 " In both cases, all the intermediate directories must already exist,\n"
1138 " unless the --parents option is given.\n"),
1139 {'q', opt_parents, SVN_CL__LOG_MSG_OPTIONS} },
1141 { "move", svn_cl__move, {"mv", "rename", "ren"}, N_
1142 ("Move (rename) an item in a working copy or repository.\n"
1143 "usage: move SRC... DST\n"
1145 " SRC and DST can both be working copy (WC) paths or URLs:\n"
1146 " WC -> WC: move an item in a working copy, as a local change to\n"
1147 " be committed later (with or without further changes)\n"
1148 " URL -> URL: move an item in the repository directly, immediately\n"
1149 " creating a new revision in the repository\n"
1150 " All the SRCs must be of the same type. When moving multiple sources,\n"
1151 " they will be added as children of DST, which must be a directory.\n"
1153 " SRC and DST of WC -> WC moves must be committed in the same revision.\n"
1154 " Furthermore, WC -> WC moves will refuse to move a mixed-revision subtree.\n"
1155 " To avoid unnecessary conflicts, it is recommended to run 'svn update'\n"
1156 " to update the subtree to a single revision before moving it.\n"
1157 " The --allow-mixed-revisions option is provided for backward compatibility.\n"
1159 " The --revision option has no use and is deprecated.\n"),
1160 {'r', 'q', opt_force, opt_parents, opt_allow_mixed_revisions,
1161 SVN_CL__LOG_MSG_OPTIONS} },
1163 { "patch", svn_cl__patch, {0}, N_
1164 ("Apply a patch to a working copy.\n"
1165 "usage: patch PATCHFILE [WCPATH]\n"
1167 " Apply a unidiff patch in PATCHFILE to the working copy WCPATH.\n"
1168 " If WCPATH is omitted, '.' is assumed.\n"
1170 " A unidiff patch suitable for application to a working copy can be\n"
1171 " produced with the 'svn diff' command or third-party diffing tools.\n"
1172 " Any non-unidiff content of PATCHFILE is ignored, except for Subversion\n"
1173 " property diffs as produced by 'svn diff'.\n"
1175 " Changes listed in the patch will either be applied or rejected.\n"
1176 " If a change does not match at its exact line offset, it may be applied\n"
1177 " earlier or later in the file if a match is found elsewhere for the\n"
1178 " surrounding lines of context provided by the patch.\n"
1179 " A change may also be applied with fuzz, which means that one\n"
1180 " or more lines of context are ignored when matching the change.\n"
1181 " If no matching context can be found for a change, the change conflicts\n"
1182 " and will be written to a reject file with the extension .svnpatch.rej.\n"
1184 " For each patched file a line will be printed with characters reporting\n"
1185 " the action taken. These characters have the following meaning:\n"
1191 " G Merged (with local uncommitted changes)\n"
1193 " Changes applied with an offset or fuzz are reported on lines starting\n"
1194 " with the '>' symbol. You should review such changes carefully.\n"
1196 " If the patch removes all content from a file, that file is scheduled\n"
1197 " for deletion. If the patch creates a new file, that file is scheduled\n"
1198 " for addition. Use 'svn revert' to undo deletions and additions you\n"
1199 " do not agree with.\n"
1201 " Hint: If the patch file was created with Subversion, it will contain\n"
1202 " the number of a revision N the patch will cleanly apply to\n"
1203 " (look for lines like '--- foo/bar.txt (revision N)').\n"
1204 " To avoid rejects, first update to the revision N using\n"
1205 " 'svn update -r N', apply the patch, and then update back to the\n"
1206 " HEAD revision. This way, conflicts can be resolved interactively.\n"
1208 {'q', opt_dry_run, opt_strip, opt_reverse_diff,
1209 opt_ignore_whitespace} },
1211 { "propdel", svn_cl__propdel, {"pdel", "pd"}, N_
1212 ("Remove a property from files, dirs, or revisions.\n"
1213 "usage: 1. propdel PROPNAME [PATH...]\n"
1214 " 2. propdel PROPNAME --revprop -r REV [TARGET]\n"
1216 " 1. Removes versioned props in working copy.\n"
1217 " 2. Removes unversioned remote prop on repos revision.\n"
1218 " TARGET only determines which repository to access.\n"),
1219 {'q', 'R', opt_depth, 'r', opt_revprop, opt_changelist} },
1221 { "propedit", svn_cl__propedit, {"pedit", "pe"}, N_
1222 ("Edit a property with an external editor.\n"
1223 "usage: 1. propedit PROPNAME TARGET...\n"
1224 " 2. propedit PROPNAME --revprop -r REV [TARGET]\n"
1226 " 1. Edits versioned prop in working copy or repository.\n"
1227 " 2. Edits unversioned remote prop on repos revision.\n"
1228 " TARGET only determines which repository to access.\n"
1230 " See 'svn help propset' for more on setting properties.\n"),
1231 {'r', opt_revprop, SVN_CL__LOG_MSG_OPTIONS, opt_force} },
1233 { "propget", svn_cl__propget, {"pget", "pg"}, N_
1234 ("Print the value of a property on files, dirs, or revisions.\n"
1235 "usage: 1. propget PROPNAME [TARGET[@REV]...]\n"
1236 " 2. propget PROPNAME --revprop -r REV [TARGET]\n"
1238 " 1. Prints versioned props. If specified, REV determines in which\n"
1239 " revision the target is first looked up.\n"
1240 " 2. Prints unversioned remote prop on repos revision.\n"
1241 " TARGET only determines which repository to access.\n"
1243 " With --verbose, the target path and the property name are printed on\n"
1244 " separate lines before each value, like 'svn proplist --verbose'.\n"
1245 " Otherwise, if there is more than one TARGET or a depth other than\n"
1246 " 'empty', the target path is printed on the same line before each value.\n"
1248 " By default, an extra newline is printed after the property value so that\n"
1249 " the output looks pretty. With a single TARGET and depth 'empty', you can\n"
1250 " use the --strict option to disable this (useful when redirecting a binary\n"
1251 " property value to a file, for example).\n"),
1252 {'v', 'R', opt_depth, 'r', opt_revprop, opt_strict, opt_xml,
1253 opt_changelist, opt_show_inherited_props },
1254 {{'v', N_("print path, name and value on separate lines")},
1255 {opt_strict, N_("don't print an extra newline")}} },
1257 { "proplist", svn_cl__proplist, {"plist", "pl"}, N_
1258 ("List all properties on files, dirs, or revisions.\n"
1259 "usage: 1. proplist [TARGET[@REV]...]\n"
1260 " 2. proplist --revprop -r REV [TARGET]\n"
1262 " 1. Lists versioned props. If specified, REV determines in which\n"
1263 " revision the target is first looked up.\n"
1264 " 2. Lists unversioned remote props on repos revision.\n"
1265 " TARGET only determines which repository to access.\n"
1267 " With --verbose, the property values are printed as well, like 'svn propget\n"
1268 " --verbose'. With --quiet, the paths are not printed.\n"),
1269 {'v', 'R', opt_depth, 'r', 'q', opt_revprop, opt_xml, opt_changelist,
1270 opt_show_inherited_props },
1271 {{'v', N_("print path, name and value on separate lines")},
1272 {'q', N_("don't print the path")}} },
1274 { "propset", svn_cl__propset, {"pset", "ps"}, N_
1275 ("Set the value of a property on files, dirs, or revisions.\n"
1276 "usage: 1. propset PROPNAME PROPVAL PATH...\n"
1277 " 2. propset PROPNAME --revprop -r REV PROPVAL [TARGET]\n"
1279 " 1. Changes a versioned file or directory property in a working copy.\n"
1280 " 2. Changes an unversioned property on a repository revision.\n"
1281 " (TARGET only determines which repository to access.)\n"
1283 " The value may be provided with the --file option instead of PROPVAL.\n"
1285 " Property names starting with 'svn:' are reserved. Subversion recognizes\n"
1286 " the following special versioned properties on a file:\n"
1287 " svn:keywords - Keywords to be expanded. Valid keywords are:\n"
1288 " URL, HeadURL - The URL for the head version of the file.\n"
1289 " Author, LastChangedBy - The last person to modify the file.\n"
1290 " Date, LastChangedDate - The date/time the file was last modified.\n"
1291 " Rev, Revision, - The last revision the file changed.\n"
1292 " LastChangedRevision\n"
1293 " Id - A compressed summary of the previous four.\n"
1294 " Header - Similar to Id but includes the full URL.\n"
1296 " Custom keywords can be defined with a format string separated from\n"
1297 " the keyword name with '='. Valid format substitutions are:\n"
1298 " %a - The author of the revision given by %r.\n"
1299 " %b - The basename of the URL of the file.\n"
1300 " %d - Short format of the date of the revision given by %r.\n"
1301 " %D - Long format of the date of the revision given by %r.\n"
1302 " %P - The file's path, relative to the repository root.\n"
1303 " %r - The number of the revision which last changed the file.\n"
1304 " %R - The URL to the root of the repository.\n"
1305 " %u - The URL of the file.\n"
1306 " %_ - A space (keyword definitions cannot contain a literal space).\n"
1307 " %% - A literal '%'.\n"
1308 " %H - Equivalent to %P%_%r%_%d%_%a.\n"
1309 " %I - Equivalent to %b%_%r%_%d%_%a.\n"
1310 " Example custom keyword definition: MyKeyword=%r%_%a%_%P\n"
1311 " Once a custom keyword has been defined for a file, it can be used\n"
1312 " within the file like any other keyword: $MyKeyword$\n"
1314 " svn:executable - If present, make the file executable. Use\n"
1315 " 'svn propdel svn:executable PATH...' to clear.\n"
1316 " svn:eol-style - One of 'native', 'LF', 'CR', 'CRLF'.\n"
1317 " svn:mime-type - The mimetype of the file. Used to determine\n"
1318 " whether to merge the file, and how to serve it from Apache.\n"
1319 " A mimetype beginning with 'text/' (or an absent mimetype) is\n"
1320 " treated as text. Anything else is treated as binary.\n"
1321 " svn:needs-lock - If present, indicates that the file should be locked\n"
1322 " before it is modified. Makes the working copy file read-only\n"
1323 " when it is not locked. Use 'svn propdel svn:needs-lock PATH...'\n"
1326 " Subversion recognizes the following special versioned properties on a\n"
1328 " svn:ignore - A list of file glob patterns to ignore, one per line.\n"
1329 " svn:global-ignores - Like svn:ignore, but inheritable.\n"
1330 " svn:auto-props - Automatically set properties on files when they are\n"
1331 " added or imported. Contains key-value pairs, one per line, in the format:\n"
1332 " PATTERN = PROPNAME=VALUE[;PROPNAME=VALUE ...]\n"
1333 " Example (where a literal ';' is escaped by adding another ';'):\n"
1334 " *.html = svn:eol-style=native;svn:mime-type=text/html;; charset=UTF8\n"
1335 " Applies recursively to all files added or imported under the directory\n"
1336 " it is set on. See also [auto-props] in the client configuration file.\n"
1337 " svn:externals - A list of module specifiers, one per line, in the\n"
1338 " following format similar to the syntax of 'svn checkout':\n"
1339 " [-r REV] URL[@PEG] LOCALPATH\n"
1341 " http://example.com/repos/zig foo/bar\n"
1342 " The LOCALPATH is relative to the directory having this property.\n"
1343 " To pin the external to a known revision, specify the optional REV:\n"
1344 " -r25 http://example.com/repos/zig foo/bar\n"
1345 " To unambiguously identify an element at a path which may have been\n"
1346 " subsequently deleted or renamed, specify the optional PEG revision:\n"
1347 " -r25 http://example.com/repos/zig@42 foo/bar\n"
1348 " The URL may be a full URL or a relative URL starting with one of:\n"
1349 " ../ to the parent directory of the extracted external\n"
1350 " ^/ to the repository root\n"
1351 " / to the server root\n"
1352 " // to the URL scheme\n"
1353 " Use of the following format is discouraged but is supported for\n"
1354 " interoperability with Subversion 1.4 and earlier clients:\n"
1355 " LOCALPATH [-r PEG] URL\n"
1356 " The ambiguous format 'relative_path relative_path' is taken as\n"
1357 " 'relative_url relative_path' with peg revision support.\n"
1358 " Lines starting with a '#' character are ignored.\n"),
1359 {'F', opt_encoding, 'q', 'r', opt_targets, 'R', opt_depth, opt_revprop,
1360 opt_force, opt_changelist },
1361 {{'F', N_("read property value from file ARG")}} },
1363 { "relocate", svn_cl__relocate, {0}, N_
1364 ("Relocate the working copy to point to a different repository root URL.\n"
1365 "usage: 1. relocate FROM-PREFIX TO-PREFIX [PATH...]\n"
1366 " 2. relocate TO-URL [PATH]\n"
1368 " Rewrite working copy URL metadata to reflect a syntactic change only.\n"
1369 " This is used when a repository's root URL changes (such as a scheme\n"
1370 " or hostname change) but your working copy still reflects the same\n"
1371 " directory within the same repository.\n"
1373 " 1. FROM-PREFIX and TO-PREFIX are initial substrings of the working\n"
1374 " copy's current and new URLs, respectively. (You may specify the\n"
1375 " complete old and new URLs if you wish.) Use 'svn info' to determine\n"
1376 " the current working copy URL.\n"
1378 " 2. TO-URL is the (complete) new repository URL to use for PATH.\n"
1381 " svn relocate http:// svn:// project1 project2\n"
1382 " svn relocate http://www.example.com/repo/project \\\n"
1383 " svn://svn.example.com/repo/project\n"),
1384 {opt_ignore_externals} },
1386 { "resolve", svn_cl__resolve, {0}, N_
1387 ("Resolve conflicts on working copy files or directories.\n"
1388 "usage: resolve [PATH...]\n"
1390 " By default, perform interactive conflict resolution on PATH.\n"
1391 " In this mode, the command is recursive by default (depth 'infinity').\n"
1393 " The --accept=ARG option prevents interactive prompting and forces\n"
1394 " conflicts on PATH to be resolved in the manner specified by ARG.\n"
1395 " In this mode, the command is not recursive by default (depth 'empty').\n"),
1396 {opt_targets, 'R', opt_depth, 'q', opt_accept},
1397 {{opt_accept, N_("specify automatic conflict resolution source\n"
1399 "('base', 'working', 'mine-conflict',\n"
1401 "'theirs-conflict', 'mine-full', 'theirs-full')")}} },
1403 { "resolved", svn_cl__resolved, {0}, N_
1404 ("Remove 'conflicted' state on working copy files or directories.\n"
1405 "usage: resolved PATH...\n"
1407 " Note: this subcommand does not semantically resolve conflicts or\n"
1408 " remove conflict markers; it merely removes the conflict-related\n"
1409 " artifact files and allows PATH to be committed again. It has been\n"
1410 " deprecated in favor of running 'svn resolve --accept working'.\n"),
1411 {opt_targets, 'R', opt_depth, 'q'} },
1413 { "revert", svn_cl__revert, {0}, N_
1414 ("Restore pristine working copy state (undo local changes).\n"
1415 "usage: revert PATH...\n"
1417 " Revert changes in the working copy at or within PATH, and remove\n"
1418 " conflict markers as well, if any.\n"
1420 " This subcommand does not revert already committed changes.\n"
1421 " For information about undoing already committed changes, search\n"
1422 " the output of 'svn help merge' for 'undo'.\n"),
1423 {opt_targets, 'R', opt_depth, 'q', opt_changelist} },
1425 { "status", svn_cl__status, {"stat", "st"}, N_
1426 ("Print the status of working copy files and directories.\n"
1427 "usage: status [PATH...]\n"
1429 " With no args, print only locally modified items (no network access).\n"
1430 " With -q, print only summary information about locally modified items.\n"
1431 " With -u, add working revision and server out-of-date information.\n"
1432 " With -v, print full revision information on every item.\n"
1434 " The first seven columns in the output are each one character wide:\n"
1435 " First column: Says if item was added, deleted, or otherwise changed\n"
1436 " ' ' no modifications\n"
1443 " 'X' an unversioned directory created by an externals definition\n"
1444 " '?' item is not under version control\n"
1445 " '!' item is missing (removed by non-svn command) or incomplete\n"
1446 " '~' versioned item obstructed by some item of a different kind\n"
1447 " Second column: Modifications of a file's or directory's properties\n"
1448 " ' ' no modifications\n"
1451 " Third column: Whether the working copy is locked for writing by\n"
1452 " another Subversion client modifying the working copy\n"
1453 " ' ' not locked for writing\n"
1454 " 'L' locked for writing\n"
1455 " Fourth column: Scheduled commit will contain addition-with-history\n"
1456 " ' ' no history scheduled with commit\n"
1457 " '+' history scheduled with commit\n"
1458 " Fifth column: Whether the item is switched or a file external\n"
1460 " 'S' the item has a Switched URL relative to the parent\n"
1461 " 'X' a versioned file created by an eXternals definition\n"
1462 " Sixth column: Whether the item is locked in repository for exclusive commit\n"
1464 " ' ' not locked by this working copy\n"
1465 " 'K' locked by this working copy, but lock might be stolen or broken\n"
1467 " ' ' not locked in repository, not locked by this working copy\n"
1468 " 'K' locked in repository, lock owned by this working copy\n"
1469 " 'O' locked in repository, lock owned by another working copy\n"
1470 " 'T' locked in repository, lock owned by this working copy was stolen\n"
1471 " 'B' not locked in repository, lock owned by this working copy is broken\n"
1472 " Seventh column: Whether the item is the victim of a tree conflict\n"
1474 " 'C' tree-Conflicted\n"
1475 " If the item is a tree conflict victim, an additional line is printed\n"
1476 " after the item's status line, explaining the nature of the conflict.\n"
1478 " The out-of-date information appears in the ninth column (with -u):\n"
1479 " '*' a newer revision exists on the server\n"
1480 " ' ' the working copy is up to date\n"
1482 " Remaining fields are variable width and delimited by spaces:\n"
1483 " The working revision (with -u or -v; '-' if the item is copied)\n"
1484 " The last committed revision and last committed author (with -v)\n"
1485 " The working copy path is always the final field, so it can\n"
1486 " include spaces.\n"
1488 " The presence of a question mark ('?') where a working revision, last\n"
1489 " committed revision, or last committed author was expected indicates\n"
1490 " that the information is unknown or irrelevant given the state of the\n"
1491 " item (for example, when the item is the result of a copy operation).\n"
1492 " The question mark serves as a visual placeholder to facilitate parsing.\n"
1494 " Example output:\n"
1499 " svn status -u wc\n"
1503 " Status against revision: 981\n"
1505 " svn status --show-updates --verbose wc\n"
1506 " M 965 938 kfogel wc/bar.c\n"
1507 " * 965 922 sussman wc/foo.c\n"
1508 " A + - 687 joe wc/qax.c\n"
1509 " 965 687 joe wc/zig.c\n"
1510 " Status against revision: 981\n"
1515 " > local missing, incoming edit upon update\n"
1517 { 'u', 'v', 'N', opt_depth, 'q', opt_no_ignore, opt_incremental, opt_xml,
1518 opt_ignore_externals, opt_changelist},
1519 {{'q', N_("don't print unversioned items")}} },
1521 { "switch", svn_cl__switch, {"sw"}, N_
1522 ("Update the working copy to a different URL within the same repository.\n"
1523 "usage: 1. switch URL[@PEGREV] [PATH]\n"
1524 " 2. switch --relocate FROM-PREFIX TO-PREFIX [PATH...]\n"
1526 " 1. Update the working copy to mirror a new URL within the repository.\n"
1527 " This behavior is similar to 'svn update', and is the way to\n"
1528 " move a working copy to a branch or tag within the same repository.\n"
1529 " If specified, PEGREV determines in which revision the target is first\n"
1532 " If --force is used, unversioned obstructing paths in the working\n"
1533 " copy do not automatically cause a failure if the switch attempts to\n"
1534 " add the same path. If the obstructing path is the same type (file\n"
1535 " or directory) as the corresponding path in the repository it becomes\n"
1536 " versioned but its contents are left 'as-is' in the working copy.\n"
1537 " This means that an obstructing directory's unversioned children may\n"
1538 " also obstruct and become versioned. For files, any content differences\n"
1539 " between the obstruction and the repository are treated like a local\n"
1540 " modification to the working copy. All properties from the repository\n"
1541 " are applied to the obstructing path.\n"
1543 " Use the --set-depth option to set a new working copy depth on the\n"
1544 " targets of this operation.\n"
1546 " By default, Subversion will refuse to switch a working copy path to\n"
1547 " a new URL with which it shares no common version control ancestry.\n"
1548 " Use the '--ignore-ancestry' option to override this sanity check.\n"
1550 " 2. The '--relocate' option is deprecated. This syntax is equivalent to\n"
1551 " 'svn relocate FROM-PREFIX TO-PREFIX [PATH]'.\n"
1553 " See also 'svn help update' for a list of possible characters\n"
1554 " reporting the action taken.\n"
1557 " svn switch ^/branches/1.x-release\n"
1558 " svn switch --relocate http:// svn://\n"
1559 " svn switch --relocate http://www.example.com/repo/project \\\n"
1560 " svn://svn.example.com/repo/project\n"),
1561 { 'r', 'N', opt_depth, opt_set_depth, 'q', opt_merge_cmd, opt_relocate,
1562 opt_ignore_externals, opt_ignore_ancestry, opt_force, opt_accept},
1563 {{opt_ignore_ancestry,
1564 N_("allow switching to a node with no common ancestor")}}
1567 { "unlock", svn_cl__unlock, {0}, N_
1568 ("Unlock working copy paths or URLs.\n"
1569 "usage: unlock TARGET...\n"
1571 " Use --force to break the lock.\n"),
1572 { opt_targets, opt_force } },
1574 { "update", svn_cl__update, {"up"}, N_
1575 ("Bring changes from the repository into the working copy.\n"
1576 "usage: update [PATH...]\n"
1578 " If no revision is given, bring working copy up-to-date with HEAD rev.\n"
1579 " Else synchronize working copy to revision given by -r.\n"
1581 " For each updated item a line will be printed with characters reporting\n"
1582 " the action taken. These characters have the following meaning:\n"
1592 " Characters in the first column report about the item itself.\n"
1593 " Characters in the second column report about properties of the item.\n"
1594 " A 'B' in the third column signifies that the lock for the file has\n"
1595 " been broken or stolen.\n"
1596 " A 'C' in the fourth column indicates a tree conflict, while a 'C' in\n"
1597 " the first and second columns indicate textual conflicts in files\n"
1598 " and in property values, respectively.\n"
1600 " If --force is used, unversioned obstructing paths in the working\n"
1601 " copy do not automatically cause a failure if the update attempts to\n"
1602 " add the same path. If the obstructing path is the same type (file\n"
1603 " or directory) as the corresponding path in the repository it becomes\n"
1604 " versioned but its contents are left 'as-is' in the working copy.\n"
1605 " This means that an obstructing directory's unversioned children may\n"
1606 " also obstruct and become versioned. For files, any content differences\n"
1607 " between the obstruction and the repository are treated like a local\n"
1608 " modification to the working copy. All properties from the repository\n"
1609 " are applied to the obstructing path. Obstructing paths are reported\n"
1610 " in the first column with code 'E'.\n"
1612 " If the specified update target is missing from the working copy but its\n"
1613 " immediate parent directory is present, checkout the target into its\n"
1614 " parent directory at the specified depth. If --parents is specified,\n"
1615 " create any missing parent directories of the target by checking them\n"
1616 " out, too, at depth=empty.\n"
1618 " Use the --set-depth option to set a new working copy depth on the\n"
1619 " targets of this operation.\n"),
1620 {'r', 'N', opt_depth, opt_set_depth, 'q', opt_merge_cmd, opt_force,
1621 opt_ignore_externals, opt_changelist, opt_editor_cmd, opt_accept,
1624 { "upgrade", svn_cl__upgrade, {0}, N_
1625 ("Upgrade the metadata storage format for a working copy.\n"
1626 "usage: upgrade [WCPATH...]\n"
1628 " Local modifications are preserved.\n"),
1631 { NULL, NULL, {0}, NULL, {0} }
1635 /* Version compatibility check */
1636 static svn_error_t *
1637 check_lib_versions(void)
1639 static const svn_version_checklist_t checklist[] =
1641 { "svn_subr", svn_subr_version },
1642 { "svn_client", svn_client_version },
1643 { "svn_wc", svn_wc_version },
1644 { "svn_ra", svn_ra_version },
1645 { "svn_delta", svn_delta_version },
1646 { "svn_diff", svn_diff_version },
1649 SVN_VERSION_DEFINE(my_version);
1651 return svn_ver_check_list2(&my_version, checklist, svn_ver_equal);
1655 /* A flag to see if we've been cancelled by the client or not. */
1656 static volatile sig_atomic_t cancelled = FALSE;
1658 /* A signal handler to support cancellation. */
1660 signal_handler(int signum)
1662 apr_signal(signum, SIG_IGN);
1666 /* Our cancellation callback. */
1668 svn_cl__check_cancel(void *baton)
1671 return svn_error_create(SVN_ERR_CANCELLED, NULL, _("Caught signal"));
1673 return SVN_NO_ERROR;
1676 /* Add a --search argument to OPT_STATE.
1677 * These options start a new search pattern group. */
1679 add_search_pattern_group(svn_cl__opt_state_t *opt_state,
1680 const char *pattern,
1681 apr_pool_t *result_pool)
1683 apr_array_header_t *group = NULL;
1685 if (opt_state->search_patterns == NULL)
1686 opt_state->search_patterns = apr_array_make(result_pool, 1,
1687 sizeof(apr_array_header_t *));
1689 group = apr_array_make(result_pool, 1, sizeof(const char *));
1690 APR_ARRAY_PUSH(group, const char *) = pattern;
1691 APR_ARRAY_PUSH(opt_state->search_patterns, apr_array_header_t *) = group;
1694 /* Add a --search-and argument to OPT_STATE.
1695 * These patterns are added to an existing pattern group, if any. */
1697 add_search_pattern_to_latest_group(svn_cl__opt_state_t *opt_state,
1698 const char *pattern,
1699 apr_pool_t *result_pool)
1701 apr_array_header_t *group;
1703 if (opt_state->search_patterns == NULL)
1705 add_search_pattern_group(opt_state, pattern, result_pool);
1709 group = APR_ARRAY_IDX(opt_state->search_patterns,
1710 opt_state->search_patterns->nelts - 1,
1711 apr_array_header_t *);
1712 APR_ARRAY_PUSH(group, const char *) = pattern;
1718 /* Report and clear the error ERR, and return EXIT_FAILURE. Suppress the
1719 * error message if it is SVN_ERR_IO_PIPE_WRITE_ERROR. */
1720 #define EXIT_ERROR(err) \
1721 svn_cmdline_handle_exit_error(err, NULL, "svn: ")
1723 /* A redefinition of the public SVN_INT_ERR macro, that suppresses the
1724 * error message if it is SVN_ERR_IO_PIPE_WRITE_ERROR. */
1726 #define SVN_INT_ERR(expr) \
1728 svn_error_t *svn_err__temp = (expr); \
1729 if (svn_err__temp) \
1730 return EXIT_ERROR(svn_err__temp); \
1734 sub_main(int argc, const char *argv[], apr_pool_t *pool)
1739 svn_cl__opt_state_t opt_state = { 0, { 0 } };
1740 svn_client_ctx_t *ctx;
1741 apr_array_header_t *received_opts;
1743 const svn_opt_subcommand_desc2_t *subcommand = NULL;
1744 const char *dash_m_arg = NULL, *dash_F_arg = NULL;
1745 svn_cl__cmd_baton_t command_baton;
1746 svn_auth_baton_t *ab;
1747 svn_config_t *cfg_config;
1748 svn_boolean_t descend = TRUE;
1749 svn_boolean_t interactive_conflicts = FALSE;
1750 svn_boolean_t force_interactive = FALSE;
1751 svn_cl__conflict_stats_t *conflict_stats
1752 = svn_cl__conflict_stats_create(pool);
1753 svn_boolean_t use_notifier = TRUE;
1754 svn_boolean_t reading_file_from_stdin = FALSE;
1755 apr_hash_t *changelists;
1756 apr_hash_t *cfg_hash;
1758 received_opts = apr_array_make(pool, SVN_OPT_MAX_OPTIONS, sizeof(int));
1760 /* Check library versions */
1761 SVN_INT_ERR(check_lib_versions());
1763 #if defined(WIN32) || defined(__CYGWIN__)
1764 /* Set the working copy administrative directory name. */
1765 if (getenv("SVN_ASP_DOT_NET_HACK"))
1767 SVN_INT_ERR(svn_wc_set_adm_dir("_svn", pool));
1771 /* Initialize the RA library. */
1772 SVN_INT_ERR(svn_ra_initialize(pool));
1774 /* Init our changelists hash. */
1775 changelists = apr_hash_make(pool);
1777 /* Begin processing arguments. */
1778 opt_state.start_revision.kind = svn_opt_revision_unspecified;
1779 opt_state.end_revision.kind = svn_opt_revision_unspecified;
1780 opt_state.revision_ranges =
1781 apr_array_make(pool, 0, sizeof(svn_opt_revision_range_t *));
1782 opt_state.depth = svn_depth_unknown;
1783 opt_state.set_depth = svn_depth_unknown;
1784 opt_state.accept_which = svn_cl__accept_unspecified;
1785 opt_state.show_revs = svn_cl__show_revs_invalid;
1787 /* No args? Show usage. */
1790 SVN_INT_ERR(svn_cl__help(NULL, NULL, pool));
1791 return EXIT_FAILURE;
1794 /* Else, parse options. */
1795 SVN_INT_ERR(svn_cmdline__getopt_init(&os, argc, argv, pool));
1800 const char *opt_arg;
1801 const char *utf8_opt_arg;
1803 /* Parse the next option. */
1804 apr_status_t apr_err = apr_getopt_long(os, svn_cl__options, &opt_id,
1806 if (APR_STATUS_IS_EOF(apr_err))
1810 SVN_INT_ERR(svn_cl__help(NULL, NULL, pool));
1811 return EXIT_FAILURE;
1814 /* Stash the option code in an array before parsing it. */
1815 APR_ARRAY_PUSH(received_opts, int) = opt_id;
1820 err = svn_cstring_atoi(&opt_state.limit, opt_arg);
1823 err = svn_error_create(SVN_ERR_CL_ARG_PARSING_ERROR, err,
1824 _("Non-numeric limit argument given"));
1825 return EXIT_ERROR(err);
1827 if (opt_state.limit <= 0)
1829 err = svn_error_create(SVN_ERR_INCORRECT_PARAMS, NULL,
1830 _("Argument to --limit must be positive"));
1831 return EXIT_ERROR(err);
1836 /* Note that there's no way here to detect if the log message
1837 contains a zero byte -- if it does, then opt_arg will just
1838 be shorter than the user intended. Oh well. */
1839 opt_state.message = apr_pstrdup(pool, opt_arg);
1840 dash_m_arg = opt_arg;
1844 apr_array_header_t *change_revs =
1845 svn_cstring_split(opt_arg, ", \n\r\t\v", TRUE, pool);
1847 if (opt_state.old_target)
1849 err = svn_error_create
1850 (SVN_ERR_CL_ARG_PARSING_ERROR, NULL,
1851 _("Can't specify -c with --old"));
1852 return EXIT_ERROR(err);
1855 for (i = 0; i < change_revs->nelts; i++)
1858 svn_revnum_t changeno, changeno_end;
1859 const char *change_str =
1860 APR_ARRAY_IDX(change_revs, i, const char *);
1861 const char *s = change_str;
1862 svn_boolean_t is_negative;
1864 /* Check for a leading minus to allow "-c -r42".
1865 * The is_negative flag is used to handle "-c -42" and "-c -r42".
1866 * The "-c r-42" case is handled by strtol() returning a
1867 * negative number. */
1868 is_negative = (*s == '-');
1872 /* Allow any number of 'r's to prefix a revision number. */
1875 changeno = changeno_end = strtol(s, &end, 10);
1876 if (end != s && *end == '-')
1878 if (changeno < 0 || is_negative)
1880 err = svn_error_createf(SVN_ERR_CL_ARG_PARSING_ERROR,
1882 _("Negative number in range (%s)"
1883 " not supported with -c"),
1885 return EXIT_ERROR(err);
1890 changeno_end = strtol(s, &end, 10);
1892 if (end == change_str || *end != '\0')
1894 err = svn_error_createf(SVN_ERR_CL_ARG_PARSING_ERROR, NULL,
1895 _("Non-numeric change argument (%s) "
1896 "given to -c"), change_str);
1897 return EXIT_ERROR(err);
1902 err = svn_error_create(SVN_ERR_CL_ARG_PARSING_ERROR, NULL,
1903 _("There is no change 0"));
1904 return EXIT_ERROR(err);
1908 changeno = -changeno;
1910 /* Figure out the range:
1913 -c M-N -> -r M-1:N for M < N
1914 -c M-N -> -r M:N-1 for M > N
1915 -c -M-N -> error (too confusing/no valid use case)
1919 if (changeno <= changeno_end)
1926 changeno = -changeno;
1927 changeno_end = changeno - 1;
1930 opt_state.used_change_arg = TRUE;
1931 APR_ARRAY_PUSH(opt_state.revision_ranges,
1932 svn_opt_revision_range_t *)
1933 = svn_opt__revision_range_from_revnums(changeno, changeno_end,
1939 opt_state.used_revision_arg = TRUE;
1940 if (svn_opt_parse_revision_to_range(opt_state.revision_ranges,
1941 opt_arg, pool) != 0)
1943 SVN_INT_ERR(svn_utf_cstring_to_utf8(&utf8_opt_arg, opt_arg, pool));
1944 err = svn_error_createf
1945 (SVN_ERR_CL_ARG_PARSING_ERROR, NULL,
1946 _("Syntax error in revision argument '%s'"),
1948 return EXIT_ERROR(err);
1952 opt_state.verbose = TRUE;
1955 opt_state.update = TRUE;
1959 opt_state.help = TRUE;
1962 opt_state.quiet = TRUE;
1964 case opt_incremental:
1965 opt_state.incremental = TRUE;
1968 SVN_INT_ERR(svn_utf_cstring_to_utf8(&utf8_opt_arg, opt_arg, pool));
1969 SVN_INT_ERR(svn_stringbuf_from_file2(&(opt_state.filedata),
1970 utf8_opt_arg, pool));
1971 reading_file_from_stdin = (strcmp(utf8_opt_arg, "-") == 0);
1972 dash_F_arg = opt_arg;
1976 svn_stringbuf_t *buffer, *buffer_utf8;
1978 /* We need to convert to UTF-8 now, even before we divide
1979 the targets into an array, because otherwise we wouldn't
1980 know what delimiter to use for svn_cstring_split(). */
1982 SVN_INT_ERR(svn_utf_cstring_to_utf8(&utf8_opt_arg, opt_arg, pool));
1983 SVN_INT_ERR(svn_stringbuf_from_file2(&buffer, utf8_opt_arg, pool));
1984 SVN_INT_ERR(svn_utf_stringbuf_to_utf8(&buffer_utf8, buffer, pool));
1985 opt_state.targets = svn_cstring_split(buffer_utf8->data, "\n\r",
1990 opt_state.force = TRUE;
1993 opt_state.force_log = TRUE;
1996 opt_state.dry_run = TRUE;
1999 opt_state.revprop = TRUE;
2002 opt_state.depth = svn_depth_infinity;
2008 err = svn_utf_cstring_to_utf8(&utf8_opt_arg, opt_arg, pool);
2011 (svn_error_createf(SVN_ERR_CL_ARG_PARSING_ERROR, err,
2012 _("Error converting depth "
2013 "from locale to UTF-8")));
2014 opt_state.depth = svn_depth_from_word(utf8_opt_arg);
2015 if (opt_state.depth == svn_depth_unknown
2016 || opt_state.depth == svn_depth_exclude)
2019 (svn_error_createf(SVN_ERR_CL_ARG_PARSING_ERROR, NULL,
2020 _("'%s' is not a valid depth; try "
2021 "'empty', 'files', 'immediates', "
2027 err = svn_utf_cstring_to_utf8(&utf8_opt_arg, opt_arg, pool);
2030 (svn_error_createf(SVN_ERR_CL_ARG_PARSING_ERROR, err,
2031 _("Error converting depth "
2032 "from locale to UTF-8")));
2033 opt_state.set_depth = svn_depth_from_word(utf8_opt_arg);
2034 /* svn_depth_exclude is okay for --set-depth. */
2035 if (opt_state.set_depth == svn_depth_unknown)
2038 (svn_error_createf(SVN_ERR_CL_ARG_PARSING_ERROR, NULL,
2039 _("'%s' is not a valid depth; try "
2040 "'exclude', 'empty', 'files', "
2041 "'immediates', or 'infinity'"),
2046 opt_state.version = TRUE;
2048 case opt_auth_username:
2049 SVN_INT_ERR(svn_utf_cstring_to_utf8(&opt_state.auth_username,
2052 case opt_auth_password:
2053 SVN_INT_ERR(svn_utf_cstring_to_utf8(&opt_state.auth_password,
2057 opt_state.encoding = apr_pstrdup(pool, opt_arg);
2060 opt_state.xml = TRUE;
2062 case opt_stop_on_copy:
2063 opt_state.stop_on_copy = TRUE;
2066 opt_state.strict = TRUE;
2069 opt_state.no_ignore = TRUE;
2071 case opt_no_auth_cache:
2072 opt_state.no_auth_cache = TRUE;
2074 case opt_non_interactive:
2075 opt_state.non_interactive = TRUE;
2077 case opt_force_interactive:
2078 force_interactive = TRUE;
2080 case opt_trust_server_cert:
2081 opt_state.trust_server_cert = TRUE;
2083 case opt_no_diff_added:
2084 opt_state.diff.no_diff_added = TRUE;
2086 case opt_no_diff_deleted:
2087 opt_state.diff.no_diff_deleted = TRUE;
2089 case opt_ignore_properties:
2090 opt_state.diff.ignore_properties = TRUE;
2092 case opt_show_copies_as_adds:
2093 opt_state.diff.show_copies_as_adds = TRUE;
2095 case opt_notice_ancestry:
2096 opt_state.diff.notice_ancestry = TRUE;
2098 case opt_ignore_ancestry:
2099 opt_state.ignore_ancestry = TRUE;
2101 case opt_ignore_externals:
2102 opt_state.ignore_externals = TRUE;
2105 opt_state.relocate = TRUE;
2108 SVN_INT_ERR(svn_utf_cstring_to_utf8(&opt_state.extensions,
2112 opt_state.diff.diff_cmd = apr_pstrdup(pool, opt_arg);
2115 opt_state.merge_cmd = apr_pstrdup(pool, opt_arg);
2117 case opt_record_only:
2118 opt_state.record_only = TRUE;
2120 case opt_editor_cmd:
2121 opt_state.editor_cmd = apr_pstrdup(pool, opt_arg);
2124 if (opt_state.used_change_arg)
2126 err = svn_error_create
2127 (SVN_ERR_CL_ARG_PARSING_ERROR, NULL,
2128 _("Can't specify -c with --old"));
2129 return EXIT_ERROR(err);
2131 opt_state.old_target = apr_pstrdup(pool, opt_arg);
2134 opt_state.new_target = apr_pstrdup(pool, opt_arg);
2136 case opt_config_dir:
2138 const char *path_utf8;
2139 SVN_INT_ERR(svn_utf_cstring_to_utf8(&path_utf8, opt_arg, pool));
2140 opt_state.config_dir = svn_dirent_internal_style(path_utf8, pool);
2143 case opt_config_options:
2144 if (!opt_state.config_options)
2145 opt_state.config_options =
2146 apr_array_make(pool, 1,
2147 sizeof(svn_cmdline__config_argument_t*));
2149 SVN_INT_ERR(svn_utf_cstring_to_utf8(&opt_arg, opt_arg, pool));
2150 SVN_INT_ERR(svn_cmdline__parse_config_option(opt_state.config_options,
2154 opt_state.autoprops = TRUE;
2156 case opt_no_autoprops:
2157 opt_state.no_autoprops = TRUE;
2159 case opt_native_eol:
2160 if ( !strcmp("LF", opt_arg) || !strcmp("CR", opt_arg) ||
2161 !strcmp("CRLF", opt_arg))
2162 opt_state.native_eol = apr_pstrdup(pool, opt_arg);
2165 SVN_INT_ERR(svn_utf_cstring_to_utf8(&utf8_opt_arg, opt_arg, pool));
2166 err = svn_error_createf
2167 (SVN_ERR_CL_ARG_PARSING_ERROR, NULL,
2168 _("Syntax error in native-eol argument '%s'"),
2170 return EXIT_ERROR(err);
2174 opt_state.no_unlock = TRUE;
2177 opt_state.diff.summarize = TRUE;
2180 opt_state.remove = TRUE;
2182 case opt_changelist:
2183 SVN_INT_ERR(svn_utf_cstring_to_utf8(&utf8_opt_arg, opt_arg, pool));
2184 opt_state.changelist = utf8_opt_arg;
2185 if (opt_state.changelist[0] == '\0')
2187 err = svn_error_create(SVN_ERR_CL_ARG_PARSING_ERROR, NULL,
2188 _("Changelist names must not be empty"));
2189 return EXIT_ERROR(err);
2191 svn_hash_sets(changelists, opt_state.changelist, (void *)1);
2193 case opt_keep_changelists:
2194 opt_state.keep_changelists = TRUE;
2196 case opt_keep_local:
2197 opt_state.keep_local = TRUE;
2199 case opt_with_all_revprops:
2200 /* If --with-all-revprops is specified along with one or more
2201 * --with-revprops options, --with-all-revprops takes precedence. */
2202 opt_state.all_revprops = TRUE;
2204 case opt_with_no_revprops:
2205 opt_state.no_revprops = TRUE;
2207 case opt_with_revprop:
2208 SVN_INT_ERR(svn_opt_parse_revprop(&opt_state.revprop_table,
2212 opt_state.parents = TRUE;
2215 opt_state.use_merge_history = TRUE;
2218 opt_state.accept_which = svn_cl__accept_from_word(opt_arg);
2219 if (opt_state.accept_which == svn_cl__accept_invalid)
2221 (svn_error_createf(SVN_ERR_CL_ARG_PARSING_ERROR, NULL,
2222 _("'%s' is not a valid --accept value"),
2226 opt_state.show_revs = svn_cl__show_revs_from_word(opt_arg);
2227 if (opt_state.show_revs == svn_cl__show_revs_invalid)
2229 (svn_error_createf(SVN_ERR_CL_ARG_PARSING_ERROR, NULL,
2230 _("'%s' is not a valid --show-revs value"),
2233 case opt_reintegrate:
2234 opt_state.reintegrate = TRUE;
2238 err = svn_cstring_atoi(&opt_state.strip, opt_arg);
2241 err = svn_error_createf(SVN_ERR_CL_ARG_PARSING_ERROR, err,
2242 _("Invalid strip count '%s'"), opt_arg);
2243 return EXIT_ERROR(err);
2245 if (opt_state.strip < 0)
2247 err = svn_error_create(SVN_ERR_INCORRECT_PARAMS, NULL,
2248 _("Argument to --strip must be positive"));
2249 return EXIT_ERROR(err);
2253 case opt_ignore_keywords:
2254 opt_state.ignore_keywords = TRUE;
2256 case opt_reverse_diff:
2257 opt_state.reverse_diff = TRUE;
2259 case opt_ignore_whitespace:
2260 opt_state.ignore_whitespace = TRUE;
2263 opt_state.show_diff = TRUE;
2265 case opt_internal_diff:
2266 opt_state.diff.internal_diff = TRUE;
2268 case opt_patch_compatible:
2269 opt_state.diff.patch_compatible = TRUE;
2271 case opt_use_git_diff_format:
2272 opt_state.diff.use_git_diff_format = TRUE;
2274 case opt_allow_mixed_revisions:
2275 opt_state.allow_mixed_rev = TRUE;
2277 case opt_include_externals:
2278 opt_state.include_externals = TRUE;
2280 case opt_show_inherited_props:
2281 opt_state.show_inherited_props = TRUE;
2283 case opt_properties_only:
2284 opt_state.diff.properties_only = TRUE;
2287 add_search_pattern_group(&opt_state, opt_arg, pool);
2289 case opt_search_and:
2290 add_search_pattern_to_latest_group(&opt_state, opt_arg, pool);
2292 /* Hmmm. Perhaps this would be a good place to squirrel away
2293 opts that commands like svn diff might need. Hmmm indeed. */
2298 /* The --non-interactive and --force-interactive options are mutually
2300 if (opt_state.non_interactive && force_interactive)
2302 err = svn_error_create(SVN_ERR_CL_ARG_PARSING_ERROR, NULL,
2303 _("--non-interactive and --force-interactive "
2304 "are mutually exclusive"));
2305 return EXIT_ERROR(err);
2308 opt_state.non_interactive = !svn_cmdline__be_interactive(
2309 opt_state.non_interactive,
2312 /* Turn our hash of changelists into an array of unique ones. */
2313 SVN_INT_ERR(svn_hash_keys(&(opt_state.changelists), changelists, pool));
2315 /* ### This really belongs in libsvn_client. The trouble is,
2316 there's no one place there to run it from, no
2317 svn_client_init(). We'd have to add it to all the public
2318 functions that a client might call. It's unmaintainable to do
2319 initialization from within libsvn_client itself, but it seems
2320 burdensome to demand that all clients call svn_client_init()
2321 before calling any other libsvn_client function... On the other
2322 hand, the alternative is effectively to demand that they call
2323 svn_config_ensure() instead, so maybe we should have a generic
2324 init function anyway. Thoughts? */
2325 SVN_INT_ERR(svn_config_ensure(opt_state.config_dir, pool));
2327 /* If the user asked for help, then the rest of the arguments are
2328 the names of subcommands to get help on (if any), or else they're
2329 just typos/mistakes. Whatever the case, the subcommand to
2330 actually run is svn_cl__help(). */
2332 subcommand = svn_opt_get_canonical_subcommand2(svn_cl__cmd_table, "help");
2334 /* If we're not running the `help' subcommand, then look for a
2335 subcommand in the first argument. */
2336 if (subcommand == NULL)
2338 if (os->ind >= os->argc)
2340 if (opt_state.version)
2342 /* Use the "help" subcommand to handle the "--version" option. */
2343 static const svn_opt_subcommand_desc2_t pseudo_cmd =
2344 { "--version", svn_cl__help, {0}, "",
2345 {opt_version, /* must accept its own option */
2346 'q', /* brief output */
2347 'v', /* verbose output */
2348 opt_config_dir /* all commands accept this */
2351 subcommand = &pseudo_cmd;
2356 (svn_cmdline_fprintf(stderr, pool,
2357 _("Subcommand argument required\n")));
2358 svn_error_clear(svn_cl__help(NULL, NULL, pool));
2359 return EXIT_FAILURE;
2364 const char *first_arg = os->argv[os->ind++];
2365 subcommand = svn_opt_get_canonical_subcommand2(svn_cl__cmd_table,
2367 if (subcommand == NULL)
2369 const char *first_arg_utf8;
2370 SVN_INT_ERR(svn_utf_cstring_to_utf8(&first_arg_utf8,
2373 (svn_cmdline_fprintf(stderr, pool,
2374 _("Unknown subcommand: '%s'\n"),
2376 svn_error_clear(svn_cl__help(NULL, NULL, pool));
2378 /* Be kind to people who try 'svn undo'. */
2379 if (strcmp(first_arg_utf8, "undo") == 0)
2382 (svn_cmdline_fprintf(stderr, pool,
2383 _("Undo is done using either the "
2384 "'svn revert' or the 'svn merge' "
2388 return EXIT_FAILURE;
2393 /* Check that the subcommand wasn't passed any inappropriate options. */
2394 for (i = 0; i < received_opts->nelts; i++)
2396 opt_id = APR_ARRAY_IDX(received_opts, i, int);
2398 /* All commands implicitly accept --help, so just skip over this
2399 when we see it. Note that we don't want to include this option
2400 in their "accepted options" list because it would be awfully
2401 redundant to display it in every commands' help text. */
2402 if (opt_id == 'h' || opt_id == '?')
2405 if (! svn_opt_subcommand_takes_option3(subcommand, opt_id,
2406 svn_cl__global_options))
2409 const apr_getopt_option_t *badopt =
2410 svn_opt_get_option_from_code2(opt_id, svn_cl__options,
2412 svn_opt_format_option(&optstr, badopt, FALSE, pool);
2413 if (subcommand->name[0] == '-')
2414 svn_error_clear(svn_cl__help(NULL, NULL, pool));
2417 (svn_cmdline_fprintf
2418 (stderr, pool, _("Subcommand '%s' doesn't accept option '%s'\n"
2419 "Type 'svn help %s' for usage.\n"),
2420 subcommand->name, optstr, subcommand->name));
2421 return EXIT_FAILURE;
2425 /* Only merge and log support multiple revisions/revision ranges. */
2426 if (subcommand->cmd_func != svn_cl__merge
2427 && subcommand->cmd_func != svn_cl__log)
2429 if (opt_state.revision_ranges->nelts > 1)
2431 err = svn_error_create(SVN_ERR_CL_ARG_PARSING_ERROR, NULL,
2432 _("Multiple revision arguments "
2433 "encountered; can't specify -c twice, "
2434 "or both -c and -r"));
2435 return EXIT_ERROR(err);
2439 /* Disallow simultaneous use of both --depth and --set-depth. */
2440 if ((opt_state.depth != svn_depth_unknown)
2441 && (opt_state.set_depth != svn_depth_unknown))
2443 err = svn_error_create(SVN_ERR_CL_ARG_PARSING_ERROR, NULL,
2444 _("--depth and --set-depth are mutually "
2446 return EXIT_ERROR(err);
2449 /* Disallow simultaneous use of both --with-all-revprops and
2450 --with-no-revprops. */
2451 if (opt_state.all_revprops && opt_state.no_revprops)
2453 err = svn_error_create(SVN_ERR_CL_ARG_PARSING_ERROR, NULL,
2454 _("--with-all-revprops and --with-no-revprops "
2455 "are mutually exclusive"));
2456 return EXIT_ERROR(err);
2459 /* Disallow simultaneous use of both --with-revprop and
2460 --with-no-revprops. */
2461 if (opt_state.revprop_table && opt_state.no_revprops)
2463 err = svn_error_create(SVN_ERR_CL_ARG_PARSING_ERROR, NULL,
2464 _("--with-revprop and --with-no-revprops "
2465 "are mutually exclusive"));
2466 return EXIT_ERROR(err);
2469 /* Disallow simultaneous use of both -m and -F, when they are
2470 both used to pass a commit message or lock comment. ('propset'
2471 takes the property value, not a commit message, from -F.)
2473 if (opt_state.filedata && opt_state.message
2474 && subcommand->cmd_func != svn_cl__propset)
2476 err = svn_error_create(SVN_ERR_CL_ARG_PARSING_ERROR, NULL,
2477 _("--message (-m) and --file (-F) "
2478 "are mutually exclusive"));
2479 return EXIT_ERROR(err);
2482 /* --trust-server-cert can only be used with --non-interactive */
2483 if (opt_state.trust_server_cert && !opt_state.non_interactive)
2485 err = svn_error_create(SVN_ERR_CL_ARG_PARSING_ERROR, NULL,
2486 _("--trust-server-cert requires "
2487 "--non-interactive"));
2488 return EXIT_ERROR(err);
2491 /* Disallow simultaneous use of both --diff-cmd and
2493 if (opt_state.diff.diff_cmd && opt_state.diff.internal_diff)
2495 err = svn_error_create(SVN_ERR_CL_ARG_PARSING_ERROR, NULL,
2496 _("--diff-cmd and --internal-diff "
2497 "are mutually exclusive"));
2498 return EXIT_ERROR(err);
2501 /* Ensure that 'revision_ranges' has at least one item, and make
2502 'start_revision' and 'end_revision' match that item. */
2503 if (opt_state.revision_ranges->nelts == 0)
2505 svn_opt_revision_range_t *range = apr_palloc(pool, sizeof(*range));
2506 range->start.kind = svn_opt_revision_unspecified;
2507 range->end.kind = svn_opt_revision_unspecified;
2508 APR_ARRAY_PUSH(opt_state.revision_ranges,
2509 svn_opt_revision_range_t *) = range;
2511 opt_state.start_revision = APR_ARRAY_IDX(opt_state.revision_ranges, 0,
2512 svn_opt_revision_range_t *)->start;
2513 opt_state.end_revision = APR_ARRAY_IDX(opt_state.revision_ranges, 0,
2514 svn_opt_revision_range_t *)->end;
2516 err = svn_config_get_config(&cfg_hash, opt_state.config_dir, pool);
2519 /* Fallback to default config if the config directory isn't readable
2520 or is not a directory. */
2521 if (APR_STATUS_IS_EACCES(err->apr_err)
2522 || SVN__APR_STATUS_IS_ENOTDIR(err->apr_err))
2524 svn_config_t *empty_cfg;
2526 svn_handle_warning2(stderr, err, "svn: ");
2527 svn_error_clear(err);
2528 cfg_hash = apr_hash_make(pool);
2529 SVN_INT_ERR(svn_config_create2(&empty_cfg, FALSE, FALSE, pool));
2530 svn_hash_sets(cfg_hash, SVN_CONFIG_CATEGORY_CONFIG, empty_cfg);
2531 SVN_INT_ERR(svn_config_create2(&empty_cfg, FALSE, FALSE, pool));
2532 svn_hash_sets(cfg_hash, SVN_CONFIG_CATEGORY_SERVERS, empty_cfg);
2535 return EXIT_ERROR(err);
2538 /* Relocation is infinite-depth only. */
2539 if (opt_state.relocate)
2541 if (opt_state.depth != svn_depth_unknown)
2543 err = svn_error_create(SVN_ERR_CL_MUTUALLY_EXCLUSIVE_ARGS, NULL,
2544 _("--relocate and --depth are mutually "
2546 return EXIT_ERROR(err);
2550 err = svn_error_create(
2551 SVN_ERR_CL_MUTUALLY_EXCLUSIVE_ARGS, NULL,
2552 _("--relocate and --non-recursive (-N) are mutually "
2554 return EXIT_ERROR(err);
2558 /* Only a few commands can accept a revision range; the rest can take at
2559 most one revision number. */
2560 if (subcommand->cmd_func != svn_cl__blame
2561 && subcommand->cmd_func != svn_cl__diff
2562 && subcommand->cmd_func != svn_cl__log
2563 && subcommand->cmd_func != svn_cl__mergeinfo
2564 && subcommand->cmd_func != svn_cl__merge)
2566 if (opt_state.end_revision.kind != svn_opt_revision_unspecified)
2568 err = svn_error_create(SVN_ERR_CLIENT_REVISION_RANGE, NULL, NULL);
2569 return EXIT_ERROR(err);
2573 /* -N has a different meaning depending on the command */
2576 if (subcommand->cmd_func == svn_cl__status)
2578 opt_state.depth = svn_depth_immediates;
2580 else if (subcommand->cmd_func == svn_cl__revert
2581 || subcommand->cmd_func == svn_cl__add
2582 || subcommand->cmd_func == svn_cl__commit)
2584 /* In pre-1.5 Subversion, some commands treated -N like
2585 --depth=empty, so force that mapping here. Anyway, with
2586 revert it makes sense to be especially conservative,
2587 since revert can lose data. */
2588 opt_state.depth = svn_depth_empty;
2592 opt_state.depth = svn_depth_files;
2596 cfg_config = svn_hash_gets(cfg_hash, SVN_CONFIG_CATEGORY_CONFIG);
2598 /* Update the options in the config */
2599 if (opt_state.config_options)
2602 svn_cmdline__apply_config_options(cfg_hash,
2603 opt_state.config_options,
2604 "svn: ", "--config-option"));
2607 #if !defined(SVN_CL_NO_EXCLUSIVE_LOCK)
2609 const char *exclusive_clients_option;
2610 apr_array_header_t *exclusive_clients;
2612 svn_config_get(cfg_config, &exclusive_clients_option,
2613 SVN_CONFIG_SECTION_WORKING_COPY,
2614 SVN_CONFIG_OPTION_SQLITE_EXCLUSIVE_CLIENTS,
2616 exclusive_clients = svn_cstring_split(exclusive_clients_option,
2618 for (i = 0; i < exclusive_clients->nelts; ++i)
2620 const char *exclusive_client = APR_ARRAY_IDX(exclusive_clients, i,
2623 /* This blocks other clients from accessing the wc.db so it must
2624 be explicitly enabled.*/
2625 if (!strcmp(exclusive_client, "svn"))
2626 svn_config_set(cfg_config,
2627 SVN_CONFIG_SECTION_WORKING_COPY,
2628 SVN_CONFIG_OPTION_SQLITE_EXCLUSIVE,
2634 /* Create a client context object. */
2635 command_baton.opt_state = &opt_state;
2636 SVN_INT_ERR(svn_client_create_context2(&ctx, cfg_hash, pool));
2637 command_baton.ctx = ctx;
2639 /* If we're running a command that could result in a commit, verify
2640 that any log message we were given on the command line makes
2641 sense (unless we've also been instructed not to care). This may
2642 access the working copy so do it after setting the locking mode. */
2643 if ((! opt_state.force_log)
2644 && (subcommand->cmd_func == svn_cl__commit
2645 || subcommand->cmd_func == svn_cl__copy
2646 || subcommand->cmd_func == svn_cl__delete
2647 || subcommand->cmd_func == svn_cl__import
2648 || subcommand->cmd_func == svn_cl__mkdir
2649 || subcommand->cmd_func == svn_cl__move
2650 || subcommand->cmd_func == svn_cl__lock
2651 || subcommand->cmd_func == svn_cl__propedit))
2653 /* If the -F argument is a file that's under revision control,
2654 that's probably not what the user intended. */
2657 svn_node_kind_t kind;
2658 const char *local_abspath;
2659 const char *fname_utf8 = svn_dirent_internal_style(dash_F_arg, pool);
2661 err = svn_dirent_get_absolute(&local_abspath, fname_utf8, pool);
2665 err = svn_wc_read_kind2(&kind, ctx->wc_ctx, local_abspath, TRUE,
2668 if (!err && kind != svn_node_none && kind != svn_node_unknown)
2670 if (subcommand->cmd_func != svn_cl__lock)
2672 err = svn_error_create(
2673 SVN_ERR_CL_LOG_MESSAGE_IS_VERSIONED_FILE, NULL,
2674 _("Log message file is a versioned file; "
2675 "use '--force-log' to override"));
2679 err = svn_error_create(
2680 SVN_ERR_CL_LOG_MESSAGE_IS_VERSIONED_FILE, NULL,
2681 _("Lock comment file is a versioned file; "
2682 "use '--force-log' to override"));
2684 return EXIT_ERROR(err);
2687 svn_error_clear(err);
2690 /* If the -m argument is a file at all, that's probably not what
2691 the user intended. */
2695 if (apr_stat(&finfo, dash_m_arg,
2696 APR_FINFO_MIN, pool) == APR_SUCCESS)
2698 if (subcommand->cmd_func != svn_cl__lock)
2700 err = svn_error_create
2701 (SVN_ERR_CL_LOG_MESSAGE_IS_PATHNAME, NULL,
2702 _("The log message is a pathname "
2703 "(was -F intended?); use '--force-log' to override"));
2707 err = svn_error_create
2708 (SVN_ERR_CL_LOG_MESSAGE_IS_PATHNAME, NULL,
2709 _("The lock comment is a pathname "
2710 "(was -F intended?); use '--force-log' to override"));
2712 return EXIT_ERROR(err);
2717 /* XXX: Only diff_cmd for now, overlay rest later and stop passing
2718 opt_state altogether? */
2719 if (opt_state.diff.diff_cmd)
2720 svn_config_set(cfg_config, SVN_CONFIG_SECTION_HELPERS,
2721 SVN_CONFIG_OPTION_DIFF_CMD, opt_state.diff.diff_cmd);
2722 if (opt_state.merge_cmd)
2723 svn_config_set(cfg_config, SVN_CONFIG_SECTION_HELPERS,
2724 SVN_CONFIG_OPTION_DIFF3_CMD, opt_state.merge_cmd);
2725 if (opt_state.diff.internal_diff)
2726 svn_config_set(cfg_config, SVN_CONFIG_SECTION_HELPERS,
2727 SVN_CONFIG_OPTION_DIFF_CMD, NULL);
2729 /* Check for mutually exclusive args --auto-props and --no-auto-props */
2730 if (opt_state.autoprops && opt_state.no_autoprops)
2732 err = svn_error_create(SVN_ERR_CL_MUTUALLY_EXCLUSIVE_ARGS, NULL,
2733 _("--auto-props and --no-auto-props are "
2734 "mutually exclusive"));
2735 return EXIT_ERROR(err);
2738 /* Update auto-props-enable option, and populate the MIME types map,
2739 for add/import commands */
2740 if (subcommand->cmd_func == svn_cl__add
2741 || subcommand->cmd_func == svn_cl__import)
2743 const char *mimetypes_file;
2744 svn_config_get(cfg_config, &mimetypes_file,
2745 SVN_CONFIG_SECTION_MISCELLANY,
2746 SVN_CONFIG_OPTION_MIMETYPES_FILE, FALSE);
2747 if (mimetypes_file && *mimetypes_file)
2749 SVN_INT_ERR(svn_io_parse_mimetypes_file(&(ctx->mimetypes_map),
2750 mimetypes_file, pool));
2753 if (opt_state.autoprops)
2755 svn_config_set_bool(cfg_config, SVN_CONFIG_SECTION_MISCELLANY,
2756 SVN_CONFIG_OPTION_ENABLE_AUTO_PROPS, TRUE);
2758 if (opt_state.no_autoprops)
2760 svn_config_set_bool(cfg_config, SVN_CONFIG_SECTION_MISCELLANY,
2761 SVN_CONFIG_OPTION_ENABLE_AUTO_PROPS, FALSE);
2765 /* Update the 'keep-locks' runtime option */
2766 if (opt_state.no_unlock)
2767 svn_config_set_bool(cfg_config, SVN_CONFIG_SECTION_MISCELLANY,
2768 SVN_CONFIG_OPTION_NO_UNLOCK, TRUE);
2770 /* Set the log message callback function. Note that individual
2771 subcommands will populate the ctx->log_msg_baton3. */
2772 ctx->log_msg_func3 = svn_cl__get_log_message;
2774 /* Set up the notifier.
2776 In general, we use it any time we aren't in --quiet mode. 'svn
2777 status' is unique, though, in that we don't want it in --quiet mode
2778 unless we're also in --verbose mode. When in --xml mode,
2779 though, we never want it. */
2780 if (opt_state.quiet)
2781 use_notifier = FALSE;
2782 if ((subcommand->cmd_func == svn_cl__status) && opt_state.verbose)
2783 use_notifier = TRUE;
2785 use_notifier = FALSE;
2788 SVN_INT_ERR(svn_cl__get_notifier(&ctx->notify_func2, &ctx->notify_baton2,
2789 conflict_stats, pool));
2792 /* Set up our cancellation support. */
2793 ctx->cancel_func = svn_cl__check_cancel;
2794 apr_signal(SIGINT, signal_handler);
2796 /* SIGBREAK is a Win32 specific signal generated by ctrl-break. */
2797 apr_signal(SIGBREAK, signal_handler);
2800 apr_signal(SIGHUP, signal_handler);
2803 apr_signal(SIGTERM, signal_handler);
2807 /* Disable SIGPIPE generation for the platforms that have it. */
2808 apr_signal(SIGPIPE, SIG_IGN);
2812 /* Disable SIGXFSZ generation for the platforms that have it, otherwise
2813 * working with large files when compiled against an APR that doesn't have
2814 * large file support will crash the program, which is uncool. */
2815 apr_signal(SIGXFSZ, SIG_IGN);
2818 /* Set up Authentication stuff. */
2819 SVN_INT_ERR(svn_cmdline_create_auth_baton(&ab,
2820 opt_state.non_interactive,
2821 opt_state.auth_username,
2822 opt_state.auth_password,
2823 opt_state.config_dir,
2824 opt_state.no_auth_cache,
2825 opt_state.trust_server_cert,
2831 ctx->auth_baton = ab;
2833 if (opt_state.non_interactive)
2835 if (opt_state.accept_which == svn_cl__accept_edit)
2837 svn_error_createf(SVN_ERR_CL_ARG_PARSING_ERROR, NULL,
2838 _("--accept=%s incompatible with"
2839 " --non-interactive"),
2840 SVN_CL__ACCEPT_EDIT));
2842 if (opt_state.accept_which == svn_cl__accept_launch)
2844 svn_error_createf(SVN_ERR_CL_ARG_PARSING_ERROR, NULL,
2845 _("--accept=%s incompatible with"
2846 " --non-interactive"),
2847 SVN_CL__ACCEPT_LAUNCH));
2849 /* The default action when we're non-interactive is to postpone
2850 * conflict resolution. */
2851 if (opt_state.accept_which == svn_cl__accept_unspecified)
2852 opt_state.accept_which = svn_cl__accept_postpone;
2855 /* Check whether interactive conflict resolution is disabled by
2856 * the configuration file. If no --accept option was specified
2857 * we postpone all conflicts in this case. */
2858 SVN_INT_ERR(svn_config_get_bool(cfg_config, &interactive_conflicts,
2859 SVN_CONFIG_SECTION_MISCELLANY,
2860 SVN_CONFIG_OPTION_INTERACTIVE_CONFLICTS,
2862 if (!interactive_conflicts)
2864 /* Make 'svn resolve' non-interactive. */
2865 if (subcommand->cmd_func == svn_cl__resolve)
2866 opt_state.non_interactive = TRUE;
2868 /* We're not resolving conflicts interactively. If no --accept option
2869 * was provided the default behaviour is to postpone all conflicts. */
2870 if (opt_state.accept_which == svn_cl__accept_unspecified)
2871 opt_state.accept_which = svn_cl__accept_postpone;
2874 /* Install the default conflict handler. */
2876 svn_cl__interactive_conflict_baton_t *b;
2878 ctx->conflict_func = NULL;
2879 ctx->conflict_baton = NULL;
2881 ctx->conflict_func2 = svn_cl__conflict_func_interactive;
2882 SVN_INT_ERR(svn_cl__get_conflict_func_interactive_baton(
2884 opt_state.accept_which,
2885 ctx->config, opt_state.editor_cmd, conflict_stats,
2886 ctx->cancel_func, ctx->cancel_baton, pool));
2887 ctx->conflict_baton2 = b;
2890 /* And now we finally run the subcommand. */
2891 err = (*subcommand->cmd_func)(os, &command_baton, pool);
2894 /* For argument-related problems, suggest using the 'help'
2896 if (err->apr_err == SVN_ERR_CL_INSUFFICIENT_ARGS
2897 || err->apr_err == SVN_ERR_CL_ARG_PARSING_ERROR)
2899 err = svn_error_quick_wrap(
2900 err, apr_psprintf(pool,
2901 _("Try 'svn help %s' for more information"),
2904 if (err->apr_err == SVN_ERR_WC_UPGRADE_REQUIRED)
2906 err = svn_error_quick_wrap(err,
2907 _("Please see the 'svn upgrade' command"));
2910 if (err->apr_err == SVN_ERR_AUTHN_FAILED && opt_state.non_interactive)
2912 err = svn_error_quick_wrap(err,
2913 _("Authentication failed and interactive"
2914 " prompting is disabled; see the"
2915 " --force-interactive option"));
2916 if (reading_file_from_stdin)
2917 err = svn_error_quick_wrap(err,
2918 _("Reading file from standard input "
2919 "because of -F option; this can "
2920 "interfere with interactive "
2924 /* Tell the user about 'svn cleanup' if any error on the stack
2925 was about locked working copies. */
2926 if (svn_error_find_cause(err, SVN_ERR_WC_LOCKED))
2928 err = svn_error_quick_wrap(
2929 err, _("Run 'svn cleanup' to remove locks "
2930 "(type 'svn help cleanup' for details)"));
2933 if (err->apr_err == SVN_ERR_SQLITE_BUSY)
2935 err = svn_error_quick_wrap(err,
2936 _("Another process is blocking the "
2937 "working copy database, or the "
2938 "underlying filesystem does not "
2939 "support file locking; if the working "
2940 "copy is on a network filesystem, make "
2941 "sure file locking has been enabled "
2942 "on the file server"));
2945 if (svn_error_find_cause(err, SVN_ERR_RA_CANNOT_CREATE_TUNNEL) &&
2946 (opt_state.auth_username || opt_state.auth_password))
2948 err = svn_error_quick_wrap(
2949 err, _("When using svn+ssh:// URLs, keep in mind that the "
2950 "--username and --password options are ignored "
2951 "because authentication is performed by SSH, not "
2955 /* Ensure that stdout is flushed, so the user will see any write errors.
2956 This makes sure that output is not silently lost. */
2957 err = svn_error_compose_create(err, svn_cmdline_fflush(stdout));
2959 return EXIT_ERROR(err);
2963 /* Ensure that stdout is flushed, so the user will see any write errors.
2964 This makes sure that output is not silently lost. */
2965 SVN_INT_ERR(svn_cmdline_fflush(stdout));
2967 return EXIT_SUCCESS;
2972 main(int argc, const char *argv[])
2977 /* Initialize the app. */
2978 if (svn_cmdline_init("svn", stderr) != EXIT_SUCCESS)
2979 return EXIT_FAILURE;
2981 /* Create our top-level pool. Use a separate mutexless allocator,
2982 * given this application is single threaded.
2984 pool = apr_allocator_owner_get(svn_pool_create_allocator(FALSE));
2986 exit_code = sub_main(argc, argv, pool);
2988 svn_pool_destroy(pool);