1/*
2 * svn.c:  Subversion command line client main file.
3 *
4 * ====================================================================
5 *    Licensed to the Apache Software Foundation (ASF) under one
6 *    or more contributor license agreements.  See the NOTICE file
7 *    distributed with this work for additional information
8 *    regarding copyright ownership.  The ASF licenses this file
9 *    to you under the Apache License, Version 2.0 (the
10 *    "License"); you may not use this file except in compliance
11 *    with the License.  You may obtain a copy of the License at
12 *
13 *      http://www.apache.org/licenses/LICENSE-2.0
14 *
15 *    Unless required by applicable law or agreed to in writing,
16 *    software distributed under the License is distributed on an
17 *    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
18 *    KIND, either express or implied.  See the License for the
19 *    specific language governing permissions and limitations
20 *    under the License.
21 * ====================================================================
22 */
23
24/* ==================================================================== */
25
26
27
28/*** Includes. ***/
29
30#include <string.h>
31#include <assert.h>
32
33#include <apr_strings.h>
34#include <apr_tables.h>
35#include <apr_general.h>
36#include <apr_signal.h>
37
38#include "svn_cmdline.h"
39#include "svn_pools.h"
40#include "svn_wc.h"
41#include "svn_client.h"
42#include "svn_config.h"
43#include "svn_string.h"
44#include "svn_dirent_uri.h"
45#include "svn_path.h"
46#include "svn_delta.h"
47#include "svn_diff.h"
48#include "svn_error.h"
49#include "svn_io.h"
50#include "svn_opt.h"
51#include "svn_utf.h"
52#include "svn_auth.h"
53#include "svn_hash.h"
54#include "svn_version.h"
55#include "cl.h"
56
57#include "private/svn_opt_private.h"
58#include "private/svn_cmdline_private.h"
59
60#include "svn_private_config.h"
61
62
63/*** Option Processing ***/
64
65/* Add an identifier here for long options that don't have a short
66   option. Options that have both long and short options should just
67   use the short option letter as identifier.  */
68typedef enum svn_cl__longopt_t {
69  opt_auth_password = SVN_OPT_FIRST_LONGOPT_ID,
70  opt_auth_username,
71  opt_autoprops,
72  opt_changelist,
73  opt_config_dir,
74  opt_config_options,
75  /* diff options */
76  opt_diff_cmd,
77  opt_internal_diff,
78  opt_no_diff_added,
79  opt_no_diff_deleted,
80  opt_show_copies_as_adds,
81  opt_notice_ancestry,
82  opt_summarize,
83  opt_use_git_diff_format,
84  opt_ignore_properties,
85  opt_properties_only,
86  opt_patch_compatible,
87  /* end of diff options */
88  opt_dry_run,
89  opt_editor_cmd,
90  opt_encoding,
91  opt_force_log,
92  opt_force,
93  opt_keep_changelists,
94  opt_ignore_ancestry,
95  opt_ignore_externals,
96  opt_incremental,
97  opt_merge_cmd,
98  opt_native_eol,
99  opt_new_cmd,
100  opt_no_auth_cache,
101  opt_no_autoprops,
102  opt_no_ignore,
103  opt_no_unlock,
104  opt_non_interactive,
105  opt_force_interactive,
106  opt_old_cmd,
107  opt_record_only,
108  opt_relocate,
109  opt_remove,
110  opt_revprop,
111  opt_stop_on_copy,
112  opt_strict,
113  opt_targets,
114  opt_depth,
115  opt_set_depth,
116  opt_version,
117  opt_xml,
118  opt_keep_local,
119  opt_with_revprop,
120  opt_with_all_revprops,
121  opt_with_no_revprops,
122  opt_parents,
123  opt_accept,
124  opt_show_revs,
125  opt_reintegrate,
126  opt_trust_server_cert,
127  opt_strip,
128  opt_ignore_keywords,
129  opt_reverse_diff,
130  opt_ignore_whitespace,
131  opt_diff,
132  opt_allow_mixed_revisions,
133  opt_include_externals,
134  opt_show_inherited_props,
135  opt_search,
136  opt_search_and
137} svn_cl__longopt_t;
138
139
140/* Option codes and descriptions for the command line client.
141 *
142 * The entire list must be terminated with an entry of nulls.
143 */
144const apr_getopt_option_t svn_cl__options[] =
145{
146  {"force",         opt_force, 0, N_("force operation to run")},
147  {"force-log",     opt_force_log, 0,
148                    N_("force validity of log message source")},
149  {"help",          'h', 0, N_("show help on a subcommand")},
150  {NULL,            '?', 0, N_("show help on a subcommand")},
151  {"message",       'm', 1, N_("specify log message ARG")},
152  {"quiet",         'q', 0, N_("print nothing, or only summary information")},
153  {"recursive",     'R', 0, N_("descend recursively, same as --depth=infinity")},
154  {"non-recursive", 'N', 0, N_("obsolete; try --depth=files or --depth=immediates")},
155  {"change",        'c', 1,
156                    N_("the change made by revision ARG (like -r ARG-1:ARG)\n"
157                       "                             "
158                       "If ARG is negative this is like -r ARG:ARG-1\n"
159                       "                             "
160                       "If ARG is of the form ARG1-ARG2 then this is like\n"
161                       "                             "
162                       "ARG1:ARG2, where ARG1 is inclusive")},
163  {"revision",      'r', 1,
164                    N_("ARG (some commands also take ARG1:ARG2 range)\n"
165                       "                             "
166                       "A revision argument can be one of:\n"
167                       "                             "
168                       "   NUMBER       revision number\n"
169                       "                             "
170                       "   '{' DATE '}' revision at start of the date\n"
171                       "                             "
172                       "   'HEAD'       latest in repository\n"
173                       "                             "
174                       "   'BASE'       base rev of item's working copy\n"
175                       "                             "
176                       "   'COMMITTED'  last commit at or before BASE\n"
177                       "                             "
178                       "   'PREV'       revision just before COMMITTED")},
179  {"file",          'F', 1, N_("read log message from file ARG")},
180  {"incremental",   opt_incremental, 0,
181                    N_("give output suitable for concatenation")},
182  {"encoding",      opt_encoding, 1,
183                    N_("treat value as being in charset encoding ARG")},
184  {"version",       opt_version, 0, N_("show program version information")},
185  {"verbose",       'v', 0, N_("print extra information")},
186  {"show-updates",  'u', 0, N_("display update information")},
187  {"username",      opt_auth_username, 1, N_("specify a username ARG")},
188  {"password",      opt_auth_password, 1, N_("specify a password ARG")},
189  {"extensions",    'x', 1,
190                    N_("Specify differencing options for external diff or\n"
191                       "                             "
192                       "internal diff or blame. Default: '-u'. Options are\n"
193                       "                             "
194                       "separated by spaces. Internal diff and blame take:\n"
195                       "                             "
196                       "  -u, --unified: Show 3 lines of unified context\n"
197                       "                             "
198                       "  -b, --ignore-space-change: Ignore changes in\n"
199                       "                             "
200                       "    amount of white space\n"
201                       "                             "
202                       "  -w, --ignore-all-space: Ignore all white space\n"
203                       "                             "
204                       "  --ignore-eol-style: Ignore changes in EOL style\n"
205                       "                             "
206                       "  -p, --show-c-function: Show C function name")},
207  {"targets",       opt_targets, 1,
208                    N_("pass contents of file ARG as additional args")},
209  {"depth",         opt_depth, 1,
210                    N_("limit operation by depth ARG ('empty', 'files',\n"
211                       "                             "
212                       "'immediates', or 'infinity')")},
213  {"set-depth",     opt_set_depth, 1,
214                    N_("set new working copy depth to ARG ('exclude',\n"
215                       "                             "
216                       "'empty', 'files', 'immediates', or 'infinity')")},
217  {"xml",           opt_xml, 0, N_("output in XML")},
218  {"strict",        opt_strict, 0, N_("use strict semantics")},
219  {"stop-on-copy",  opt_stop_on_copy, 0,
220                    N_("do not cross copies while traversing history")},
221  {"no-ignore",     opt_no_ignore, 0,
222                    N_("disregard default and svn:ignore and\n"
223                       "                             "
224                       "svn:global-ignores property ignores")},
225  {"no-auth-cache", opt_no_auth_cache, 0,
226                    N_("do not cache authentication tokens")},
227  {"trust-server-cert", opt_trust_server_cert, 0,
228                    N_("accept SSL server certificates from unknown\n"
229                       "                             "
230                       "certificate authorities without prompting (but only\n"
231                       "                             "
232                       "with '--non-interactive')") },
233  {"non-interactive", opt_non_interactive, 0,
234                    N_("do no interactive prompting (default is to prompt\n"
235                       "                             "
236                       "only if standard input is a terminal device)")},
237  {"force-interactive", opt_force_interactive, 0,
238                    N_("do interactive prompting even if standard input\n"
239                       "                             "
240                       "is not a terminal device")},
241  {"dry-run",       opt_dry_run, 0,
242                    N_("try operation but make no changes")},
243  {"ignore-ancestry", opt_ignore_ancestry, 0,
244                    N_("disable merge tracking; diff nodes as if related")},
245  {"ignore-externals", opt_ignore_externals, 0,
246                    N_("ignore externals definitions")},
247  {"diff3-cmd",     opt_merge_cmd, 1, N_("use ARG as merge command")},
248  {"editor-cmd",    opt_editor_cmd, 1, N_("use ARG as external editor")},
249  {"record-only",   opt_record_only, 0,
250                    N_("merge only mergeinfo differences")},
251  {"old",           opt_old_cmd, 1, N_("use ARG as the older target")},
252  {"new",           opt_new_cmd, 1, N_("use ARG as the newer target")},
253  {"revprop",       opt_revprop, 0,
254                    N_("operate on a revision property (use with -r)")},
255  {"relocate",      opt_relocate, 0, N_("relocate via URL-rewriting")},
256  {"config-dir",    opt_config_dir, 1,
257                    N_("read user configuration files from directory ARG")},
258  {"config-option", opt_config_options, 1,
259                    N_("set user configuration option in the format:\n"
260                       "                             "
261                       "    FILE:SECTION:OPTION=[VALUE]\n"
262                       "                             "
263                       "For example:\n"
264                       "                             "
265                       "    servers:global:http-library=serf")},
266  {"auto-props",    opt_autoprops, 0, N_("enable automatic properties")},
267  {"no-auto-props", opt_no_autoprops, 0, N_("disable automatic properties")},
268  {"native-eol",    opt_native_eol, 1,
269                    N_("use a different EOL marker than the standard\n"
270                       "                             "
271                       "system marker for files with the svn:eol-style\n"
272                       "                             "
273                       "property set to 'native'.\n"
274                       "                             "
275                       "ARG may be one of 'LF', 'CR', 'CRLF'")},
276  {"limit",         'l', 1, N_("maximum number of log entries")},
277  {"no-unlock",     opt_no_unlock, 0, N_("don't unlock the targets")},
278  {"remove",         opt_remove, 0, N_("remove changelist association")},
279  {"changelist",    opt_changelist, 1,
280                    N_("operate only on members of changelist ARG")},
281  {"keep-changelists", opt_keep_changelists, 0,
282                    N_("don't delete changelists after commit")},
283  {"keep-local",    opt_keep_local, 0, N_("keep path in working copy")},
284  {"with-all-revprops",  opt_with_all_revprops, 0,
285                    N_("retrieve all revision properties")},
286  {"with-no-revprops",  opt_with_no_revprops, 0,
287                    N_("retrieve no revision properties")},
288  {"with-revprop",  opt_with_revprop, 1,
289                    N_("set revision property ARG in new revision\n"
290                       "                             "
291                       "using the name[=value] format")},
292  {"parents",       opt_parents, 0, N_("make intermediate directories")},
293  {"use-merge-history", 'g', 0,
294                    N_("use/display additional information from merge\n"
295                       "                             "
296                       "history")},
297  {"accept",        opt_accept, 1,
298                    N_("specify automatic conflict resolution action\n"
299                       "                             "
300                       "('postpone', 'working', 'base', 'mine-conflict',\n"
301                       "                             "
302                       "'theirs-conflict', 'mine-full', 'theirs-full',\n"
303                       "                             "
304                       "'edit', 'launch')\n"
305                       "                             "
306                       "(shorthand: 'p', 'mc', 'tc', 'mf', 'tf', 'e', 'l')"
307                       )},
308  {"show-revs",     opt_show_revs, 1,
309                    N_("specify which collection of revisions to display\n"
310                       "                             "
311                       "('merged', 'eligible')")},
312  {"reintegrate",   opt_reintegrate, 0,
313                    N_("deprecated")},
314  {"strip",         opt_strip, 1,
315                    N_("number of leading path components to strip from\n"
316                       "                             "
317                       "paths parsed from the patch file. --strip 0\n"
318                       "                             "
319                       "is the default and leaves paths unmodified.\n"
320                       "                             "
321                       "--strip 1 would change the path\n"
322                       "                             "
323                       "'doc/fudge/crunchy.html' to 'fudge/crunchy.html'.\n"
324                       "                             "
325                       "--strip 2 would leave just 'crunchy.html'\n"
326                       "                             "
327                       "The expected component separator is '/' on all\n"
328                       "                             "
329                       "platforms. A leading '/' counts as one component.")},
330  {"ignore-keywords", opt_ignore_keywords, 0,
331                    N_("don't expand keywords")},
332  {"reverse-diff", opt_reverse_diff, 0,
333                    N_("apply the unidiff in reverse")},
334  {"ignore-whitespace", opt_ignore_whitespace, 0,
335                       N_("ignore whitespace during pattern matching")},
336  {"diff", opt_diff, 0, N_("produce diff output")}, /* maps to show_diff */
337  /* diff options */
338  {"diff-cmd",      opt_diff_cmd, 1, N_("use ARG as diff command")},
339  {"internal-diff", opt_internal_diff, 0,
340                       N_("override diff-cmd specified in config file")},
341  {"no-diff-added", opt_no_diff_added, 0,
342                    N_("do not print differences for added files")},
343  {"no-diff-deleted", opt_no_diff_deleted, 0,
344                    N_("do not print differences for deleted files")},
345  {"show-copies-as-adds", opt_show_copies_as_adds, 0,
346                    N_("don't diff copied or moved files with their source")},
347  {"notice-ancestry", opt_notice_ancestry, 0,
348                    N_("diff unrelated nodes as delete and add")},
349  {"summarize",     opt_summarize, 0, N_("show a summary of the results")},
350  {"git", opt_use_git_diff_format, 0,
351                       N_("use git's extended diff format")},
352  {"ignore-properties", opt_ignore_properties, 0,
353                    N_("ignore properties during the operation")},
354  {"properties-only", opt_properties_only, 0,
355                       N_("show only properties during the operation")},
356  {"patch-compatible", opt_patch_compatible, 0,
357                       N_("generate diff suitable for generic third-party\n"
358                       "                             "
359                       "patch tools; currently the same as\n"
360                       "                             "
361                       "--show-copies-as-adds --ignore-properties"
362                       )},
363  /* end of diff options */
364  {"allow-mixed-revisions", opt_allow_mixed_revisions, 0,
365                       N_("Allow operation on mixed-revision working copy.\n"
366                       "                             "
367                       "Use of this option is not recommended!\n"
368                       "                             "
369                       "Please run 'svn update' instead.")},
370  {"include-externals", opt_include_externals, 0,
371                       N_("Also commit file and dir externals reached by\n"
372                       "                             "
373                       "recursion. This does not include externals with a\n"
374                       "                             "
375                       "fixed revision. (See the svn:externals property)")},
376  {"show-inherited-props", opt_show_inherited_props, 0,
377                       N_("retrieve target's inherited properties")},
378  {"search", opt_search, 1,
379                       N_("use ARG as search pattern (glob syntax)")},
380  {"search-and", opt_search_and, 1,
381                       N_("combine ARG with the previous search pattern")},
382
383  /* Long-opt Aliases
384   *
385   * These have NULL desriptions, but an option code that matches some
386   * other option (whose description should probably mention its aliases).
387  */
388
389  {"cl",            opt_changelist, 1, NULL},
390
391  {0,               0, 0, 0},
392};
393
394
395
396/*** Command dispatch. ***/
397
398/* Our array of available subcommands.
399 *
400 * The entire list must be terminated with an entry of nulls.
401 *
402 * In most of the help text "PATH" is used where a working copy path is
403 * required, "URL" where a repository URL is required and "TARGET" when
404 * either a path or a url can be used.  Hmm, should this be part of the
405 * help text?
406 */
407
408/* Options that apply to all commands.  (While not every command may
409   currently require authentication or be interactive, allowing every
410   command to take these arguments allows scripts to just pass them
411   willy-nilly to every invocation of 'svn') . */
412const int svn_cl__global_options[] =
413{ opt_auth_username, opt_auth_password, opt_no_auth_cache, opt_non_interactive,
414  opt_force_interactive, opt_trust_server_cert, opt_config_dir,
415  opt_config_options, 0
416};
417
418/* Options for giving a log message.  (Some of these also have other uses.)
419 */
420#define SVN_CL__LOG_MSG_OPTIONS 'm', 'F', \
421                                opt_force_log, \
422                                opt_editor_cmd, \
423                                opt_encoding, \
424                                opt_with_revprop
425
426const svn_opt_subcommand_desc2_t svn_cl__cmd_table[] =
427{
428  { "add", svn_cl__add, {0}, N_
429    ("Put files and directories under version control, scheduling\n"
430     "them for addition to repository.  They will be added in next commit.\n"
431     "usage: add PATH...\n"),
432    {opt_targets, 'N', opt_depth, 'q', opt_force, opt_no_ignore, opt_autoprops,
433     opt_no_autoprops, opt_parents },
434     {{opt_parents, N_("add intermediate parents")}} },
435
436  { "blame", svn_cl__blame, {"praise", "annotate", "ann"}, N_
437    ("Output the content of specified files or\n"
438     "URLs with revision and author information in-line.\n"
439     "usage: blame TARGET[@REV]...\n"
440     "\n"
441     "  If specified, REV determines in which revision the target is first\n"
442     "  looked up.\n"),
443    {'r', 'v', 'g', opt_incremental, opt_xml, 'x', opt_force} },
444
445  { "cat", svn_cl__cat, {0}, N_
446    ("Output the content of specified files or URLs.\n"
447     "usage: cat TARGET[@REV]...\n"
448     "\n"
449     "  If specified, REV determines in which revision the target is first\n"
450     "  looked up.\n"),
451    {'r'} },
452
453  { "changelist", svn_cl__changelist, {"cl"}, N_
454    ("Associate (or dissociate) changelist CLNAME with the named files.\n"
455     "usage: 1. changelist CLNAME PATH...\n"
456     "       2. changelist --remove PATH...\n"),
457    { 'q', 'R', opt_depth, opt_remove, opt_targets, opt_changelist} },
458
459  { "checkout", svn_cl__checkout, {"co"}, N_
460    ("Check out a working copy from a repository.\n"
461     "usage: checkout URL[@REV]... [PATH]\n"
462     "\n"
463     "  If specified, REV determines in which revision the URL is first\n"
464     "  looked up.\n"
465     "\n"
466     "  If PATH is omitted, the basename of the URL will be used as\n"
467     "  the destination. If multiple URLs are given each will be checked\n"
468     "  out into a sub-directory of PATH, with the name of the sub-directory\n"
469     "  being the basename of the URL.\n"
470     "\n"
471     "  If --force is used, unversioned obstructing paths in the working\n"
472     "  copy destination do not automatically cause the check out to fail.\n"
473     "  If the obstructing path is the same type (file or directory) as the\n"
474     "  corresponding path in the repository it becomes versioned but its\n"
475     "  contents are left 'as-is' in the working copy.  This means that an\n"
476     "  obstructing directory's unversioned children may also obstruct and\n"
477     "  become versioned.  For files, any content differences between the\n"
478     "  obstruction and the repository are treated like a local modification\n"
479     "  to the working copy.  All properties from the repository are applied\n"
480     "  to the obstructing path.\n"
481     "\n"
482     "  See also 'svn help update' for a list of possible characters\n"
483     "  reporting the action taken.\n"),
484    {'r', 'q', 'N', opt_depth, opt_force, opt_ignore_externals} },
485
486  { "cleanup", svn_cl__cleanup, {0}, N_
487    ("Recursively clean up the working copy, removing write locks, resuming\n"
488     "unfinished operations, etc.\n"
489     "usage: cleanup [WCPATH...]\n"
490     "\n"
491     "  Finish any unfinished business in the working copy at WCPATH, and remove\n"
492     "  write locks (shown as 'L' by the 'svn status' command) from the working\n"
493     "  copy. Usually, this is only necessary if a Subversion client has crashed\n"
494     "  while using the working copy, leaving it in an unusable state.\n"
495     "\n"
496     "  WARNING: There is no mechanism that will protect write locks still\n"
497     "           being used by other Subversion clients. Running this command\n"
498     "           while another client is using the working copy can corrupt\n"
499     "           the working copy beyond repair!\n"),
500    {opt_merge_cmd} },
501
502  { "commit", svn_cl__commit, {"ci"},
503    N_("Send changes from your working copy to the repository.\n"
504       "usage: commit [PATH...]\n"
505       "\n"
506       "  A log message must be provided, but it can be empty.  If it is not\n"
507       "  given by a --message or --file option, an editor will be started.\n"
508       "  If any targets are (or contain) locked items, those will be\n"
509       "  unlocked after a successful commit.\n"),
510    {'q', 'N', opt_depth, opt_targets, opt_no_unlock, SVN_CL__LOG_MSG_OPTIONS,
511     opt_changelist, opt_keep_changelists, opt_include_externals} },
512
513  { "copy", svn_cl__copy, {"cp"}, N_
514    ("Copy files and directories in a working copy or repository.\n"
515     "usage: copy SRC[@REV]... DST\n"
516     "\n"
517     "  SRC and DST can each be either a working copy (WC) path or URL:\n"
518     "    WC  -> WC:   copy and schedule for addition (with history)\n"
519     "    WC  -> URL:  immediately commit a copy of WC to URL\n"
520     "    URL -> WC:   check out URL into WC, schedule for addition\n"
521     "    URL -> URL:  complete server-side copy;  used to branch and tag\n"
522     "  All the SRCs must be of the same type. When copying multiple sources,\n"
523     "  they will be added as children of DST, which must be a directory.\n"
524     "\n"
525     "  WARNING: For compatibility with previous versions of Subversion,\n"
526     "  copies performed using two working copy paths (WC -> WC) will not\n"
527     "  contact the repository.  As such, they may not, by default, be able\n"
528     "  to propagate merge tracking information from the source of the copy\n"
529     "  to the destination.\n"),
530    {'r', 'q', opt_ignore_externals, opt_parents, SVN_CL__LOG_MSG_OPTIONS} },
531
532  { "delete", svn_cl__delete, {"del", "remove", "rm"}, N_
533    ("Remove files and directories from version control.\n"
534     "usage: 1. delete PATH...\n"
535     "       2. delete URL...\n"
536     "\n"
537     "  1. Each item specified by a PATH is scheduled for deletion upon\n"
538     "    the next commit.  Files, and directories that have not been\n"
539     "    committed, are immediately removed from the working copy\n"
540     "    unless the --keep-local option is given.\n"
541     "    PATHs that are, or contain, unversioned or modified items will\n"
542     "    not be removed unless the --force or --keep-local option is given.\n"
543     "\n"
544     "  2. Each item specified by a URL is deleted from the repository\n"
545     "    via an immediate commit.\n"),
546    {opt_force, 'q', opt_targets, SVN_CL__LOG_MSG_OPTIONS, opt_keep_local} },
547
548  { "diff", svn_cl__diff, {"di"}, N_
549    ("Display local changes or differences between two revisions or paths.\n"
550     "usage: 1. diff\n"
551     "       2. diff [-c M | -r N[:M]] [TARGET[@REV]...]\n"
552     "       3. diff [-r N[:M]] --old=OLD-TGT[@OLDREV] [--new=NEW-TGT[@NEWREV]] \\\n"
553     "               [PATH...]\n"
554     "       4. diff OLD-URL[@OLDREV] NEW-URL[@NEWREV]\n"
555     "       5. diff OLD-URL[@OLDREV] NEW-PATH[@NEWREV]\n"
556     "       6. diff OLD-PATH[@OLDREV] NEW-URL[@NEWREV]\n"
557     "\n"
558     "  1. Use just 'svn diff' to display local modifications in a working copy.\n"
559     "\n"
560     "  2. Display the changes made to TARGETs as they are seen in REV between\n"
561     "     two revisions.  TARGETs may be all working copy paths or all URLs.\n"
562     "     If TARGETs are working copy paths, N defaults to BASE and M to the\n"
563     "     working copy; if URLs, N must be specified and M defaults to HEAD.\n"
564     "     The '-c M' option is equivalent to '-r N:M' where N = M-1.\n"
565     "     Using '-c -M' does the reverse: '-r M:N' where N = M-1.\n"
566     "\n"
567     "  3. Display the differences between OLD-TGT as it was seen in OLDREV and\n"
568     "     NEW-TGT as it was seen in NEWREV.  PATHs, if given, are relative to\n"
569     "     OLD-TGT and NEW-TGT and restrict the output to differences for those\n"
570     "     paths.  OLD-TGT and NEW-TGT may be working copy paths or URL[@REV].\n"
571     "     NEW-TGT defaults to OLD-TGT if not specified.  -r N makes OLDREV default\n"
572     "     to N, -r N:M makes OLDREV default to N and NEWREV default to M.\n"
573     "     If OLDREV or NEWREV are not specified, they default to WORKING for\n"
574     "     working copy targets and to HEAD for URL targets.\n"
575     "\n"
576     "     Either or both OLD-TGT and NEW-TGT may also be paths to unversioned\n"
577     "     targets. Revisions cannot be specified for unversioned targets.\n"
578     "     Both targets must be of the same node kind (file or directory).\n"
579     "     Diffing unversioned targets against URL targets is not supported.\n"
580     "\n"
581     "  4. Shorthand for 'svn diff --old=OLD-URL[@OLDREV] --new=NEW-URL[@NEWREV]'\n"
582     "  5. Shorthand for 'svn diff --old=OLD-URL[@OLDREV] --new=NEW-PATH[@NEWREV]'\n"
583     "  6. Shorthand for 'svn diff --old=OLD-PATH[@OLDREV] --new=NEW-URL[@NEWREV]'\n"),
584    {'r', 'c', opt_old_cmd, opt_new_cmd, 'N', opt_depth, opt_diff_cmd,
585     opt_internal_diff, 'x', opt_no_diff_added, opt_no_diff_deleted,
586     opt_ignore_properties, opt_properties_only,
587     opt_show_copies_as_adds, opt_notice_ancestry, opt_summarize, opt_changelist,
588     opt_force, opt_xml, opt_use_git_diff_format, opt_patch_compatible} },
589  { "export", svn_cl__export, {0}, N_
590    ("Create an unversioned copy of a tree.\n"
591     "usage: 1. export [-r REV] URL[@PEGREV] [PATH]\n"
592     "       2. export [-r REV] PATH1[@PEGREV] [PATH2]\n"
593     "\n"
594     "  1. Exports a clean directory tree from the repository specified by\n"
595     "     URL, at revision REV if it is given, otherwise at HEAD, into\n"
596     "     PATH. If PATH is omitted, the last component of the URL is used\n"
597     "     for the local directory name.\n"
598     "\n"
599     "  2. Exports a clean directory tree from the working copy specified by\n"
600     "     PATH1, at revision REV if it is given, otherwise at WORKING, into\n"
601     "     PATH2.  If PATH2 is omitted, the last component of the PATH1 is used\n"
602     "     for the local directory name. If REV is not specified, all local\n"
603     "     changes will be preserved.  Files not under version control will\n"
604     "     not be copied.\n"
605     "\n"
606     "  If specified, PEGREV determines in which revision the target is first\n"
607     "  looked up.\n"),
608    {'r', 'q', 'N', opt_depth, opt_force, opt_native_eol, opt_ignore_externals,
609     opt_ignore_keywords} },
610
611  { "help", svn_cl__help, {"?", "h"}, N_
612    ("Describe the usage of this program or its subcommands.\n"
613     "usage: help [SUBCOMMAND...]\n"),
614    {0} },
615  /* This command is also invoked if we see option "--help", "-h" or "-?". */
616
617  { "import", svn_cl__import, {0}, N_
618    ("Commit an unversioned file or tree into the repository.\n"
619     "usage: import [PATH] URL\n"
620     "\n"
621     "  Recursively commit a copy of PATH to URL.\n"
622     "  If PATH is omitted '.' is assumed.\n"
623     "  Parent directories are created as necessary in the repository.\n"
624     "  If PATH is a directory, the contents of the directory are added\n"
625     "  directly under URL.\n"
626     "  Unversionable items such as device files and pipes are ignored\n"
627     "  if --force is specified.\n"),
628    {'q', 'N', opt_depth, opt_autoprops, opt_force, opt_no_autoprops,
629     SVN_CL__LOG_MSG_OPTIONS, opt_no_ignore} },
630
631  { "info", svn_cl__info, {0}, N_
632    ("Display information about a local or remote item.\n"
633     "usage: info [TARGET[@REV]...]\n"
634     "\n"
635     "  Print information about each TARGET (default: '.').\n"
636     "  TARGET may be either a working-copy path or URL.  If specified, REV\n"
637     "  determines in which revision the target is first looked up.\n"),
638    {'r', 'R', opt_depth, opt_targets, opt_incremental, opt_xml, opt_changelist}
639  },
640
641  { "list", svn_cl__list, {"ls"}, N_
642    ("List directory entries in the repository.\n"
643     "usage: list [TARGET[@REV]...]\n"
644     "\n"
645     "  List each TARGET file and the contents of each TARGET directory as\n"
646     "  they exist in the repository.  If TARGET is a working copy path, the\n"
647     "  corresponding repository URL will be used. If specified, REV determines\n"
648     "  in which revision the target is first looked up.\n"
649     "\n"
650     "  The default TARGET is '.', meaning the repository URL of the current\n"
651     "  working directory.\n"
652     "\n"
653     "  With --verbose, the following fields will be shown for each item:\n"
654     "\n"
655     "    Revision number of the last commit\n"
656     "    Author of the last commit\n"
657     "    If locked, the letter 'O'.  (Use 'svn info URL' to see details)\n"
658     "    Size (in bytes)\n"
659     "    Date and time of the last commit\n"),
660    {'r', 'v', 'R', opt_depth, opt_incremental, opt_xml,
661     opt_include_externals },
662    {{opt_include_externals, N_("include externals definitions")}} },
663
664  { "lock", svn_cl__lock, {0}, N_
665    ("Lock working copy paths or URLs in the repository, so that\n"
666     "no other user can commit changes to them.\n"
667     "usage: lock TARGET...\n"
668     "\n"
669     "  Use --force to steal the lock from another user or working copy.\n"),
670    { opt_targets, 'm', 'F', opt_force_log, opt_encoding, opt_force },
671    {{'F', N_("read lock comment from file ARG")},
672     {'m', N_("specify lock comment ARG")},
673     {opt_force_log, N_("force validity of lock comment source")}} },
674
675  { "log", svn_cl__log, {0}, N_
676    ("Show the log messages for a set of revision(s) and/or path(s).\n"
677     "usage: 1. log [PATH][@REV]\n"
678     "       2. log URL[@REV] [PATH...]\n"
679     "\n"
680     "  1. Print the log messages for the URL corresponding to PATH\n"
681     "     (default: '.'). If specified, REV is the revision in which the\n"
682     "     URL is first looked up, and the default revision range is REV:1.\n"
683     "     If REV is not specified, the default revision range is BASE:1,\n"
684     "     since the URL might not exist in the HEAD revision.\n"
685     "\n"
686     "  2. Print the log messages for the PATHs (default: '.') under URL.\n"
687     "     If specified, REV is the revision in which the URL is first\n"
688     "     looked up, and the default revision range is REV:1; otherwise,\n"
689     "     the URL is looked up in HEAD, and the default revision range is\n"
690     "     HEAD:1.\n"
691     "\n"
692     "  Multiple '-c' or '-r' options may be specified (but not a\n"
693     "  combination of '-c' and '-r' options), and mixing of forward and\n"
694     "  reverse ranges is allowed.\n"
695     "\n"
696     "  With -v, also print all affected paths with each log message.\n"
697     "  With -q, don't print the log message body itself (note that this is\n"
698     "  compatible with -v).\n"
699     "\n"
700     "  Each log message is printed just once, even if more than one of the\n"
701     "  affected paths for that revision were explicitly requested.  Logs\n"
702     "  follow copy history by default.  Use --stop-on-copy to disable this\n"
703     "  behavior, which can be useful for determining branchpoints.\n"
704     "\n"
705     "  The --depth option is only valid in combination with the --diff option\n"
706     "  and limits the scope of the displayed diff to the specified depth.\n"
707     "\n"
708     "  If the --search option is used, log messages are displayed only if the\n"
709     "  provided search pattern matches any of the author, date, log message\n"
710     "  text (unless --quiet is used), or, if the --verbose option is also\n"
711     "  provided, a changed path.\n"
712     "  The search pattern may include \"glob syntax\" wildcards:\n"
713     "      ?      matches any single character\n"
714     "      *      matches a sequence of arbitrary characters\n"
715     "      [abc]  matches any of the characters listed inside the brackets\n"
716     "  If multiple --search options are provided, a log message is shown if\n"
717     "  it matches any of the provided search patterns. If the --search-and\n"
718     "  option is used, that option's argument is combined with the pattern\n"
719     "  from the previous --search or --search-and option, and a log message\n"
720     "  is shown only if it matches the combined search pattern.\n"
721     "  If --limit is used in combination with --search, --limit restricts the\n"
722     "  number of log messages searched, rather than restricting the output\n"
723     "  to a particular number of matching log messages.\n"
724     "\n"
725     "  Examples:\n"
726     "\n"
727     "    Show the latest 5 log messages for the current working copy\n"
728     "    directory and display paths changed in each commit:\n"
729     "      svn log -l 5 -v\n"
730     "\n"
731     "    Show the log for bar.c as of revision 42:\n"
732     "      svn log bar.c@42\n"
733     "\n"
734     "    Show log messages and diffs for each commit to foo.c:\n"
735     "      svn log --diff http://www.example.com/repo/project/foo.c\n"
736     "    (Because the above command uses a full URL it does not require\n"
737     "     a working copy.)\n"
738     "\n"
739     "    Show log messages for the children foo.c and bar.c of the directory\n"
740     "    '/trunk' as it appeared in revision 50, using the ^/ URL shortcut:\n"
741     "      svn log ^/trunk@50 foo.c bar.c\n"
742     "\n"
743     "    Show the log messages for any incoming changes to foo.c during the\n"
744     "    next 'svn update':\n"
745     "      svn log -r BASE:HEAD foo.c\n"
746     "\n"
747     "    Show the log message for the revision in which /branches/foo\n"
748     "    was created:\n"
749     "      svn log --stop-on-copy --limit 1 -r0:HEAD ^/branches/foo\n"),
750    {'r', 'q', 'v', 'g', 'c', opt_targets, opt_stop_on_copy, opt_incremental,
751     opt_xml, 'l', opt_with_all_revprops, opt_with_no_revprops, opt_with_revprop,
752     opt_depth, opt_diff, opt_diff_cmd, opt_internal_diff, 'x', opt_search,
753     opt_search_and, },
754    {{opt_with_revprop, N_("retrieve revision property ARG")},
755     {'c', N_("the change made in revision ARG")}} },
756
757  { "merge", svn_cl__merge, {0}, N_
758    ( /* For this large section, let's keep it unindented for easier
759       * viewing/editing. It has been vim-treated with a textwidth=75 and 'gw'
760       * (with quotes and newlines removed). */
761"Merge changes into a working copy.\n"
762"usage: 1. merge SOURCE[@REV] [TARGET_WCPATH]\n"
763"          (the 'complete' merge)\n"
764"       2. merge [-c M[,N...] | -r N:M ...] SOURCE[@REV] [TARGET_WCPATH]\n"
765"          (the 'cherry-pick' merge)\n"
766"       3. merge SOURCE1[@REV1] SOURCE2[@REV2] [TARGET_WCPATH]\n"
767"          (the '2-URL' merge)\n"
768"\n"
769"  1. This form, with one source path and no revision range, is called\n"
770"     a 'complete' merge:\n"
771"\n"
772"       svn merge SOURCE[@REV] [TARGET_WCPATH]\n"
773"\n"
774"     The complete merge is used for the 'sync' and 'reintegrate' merges\n"
775"     in the 'feature branch' pattern described below. It finds all the\n"
776"     changes on the source branch that have not already been merged to the\n"
777"     target branch, and merges them into the working copy. Merge tracking\n"
778"     is used to know which changes have already been merged.\n"
779"\n"
780"     SOURCE specifies the branch from where the changes will be pulled, and\n"
781"     TARGET_WCPATH specifies a working copy of the target branch to which\n"
782"     the changes will be applied. Normally SOURCE and TARGET_WCPATH should\n"
783"     each correspond to the root of a branch. (If you want to merge only a\n"
784"     subtree, then the subtree path must be included in both SOURCE and\n"
785"     TARGET_WCPATH; this is discouraged, to avoid subtree mergeinfo.)\n"
786"\n"
787"     SOURCE is usually a URL. The optional '@REV' specifies both the peg\n"
788"     revision of the URL and the latest revision that will be considered\n"
789"     for merging; if REV is not specified, the HEAD revision is assumed. If\n"
790"     SOURCE is a working copy path, the corresponding URL of the path is\n"
791"     used, and the default value of 'REV' is the base revision (usually the\n"
792"     revision last updated to).\n"
793"\n"
794"     TARGET_WCPATH is a working copy path; if omitted, '.' is generally\n"
795"     assumed. There are some special cases:\n"
796"\n"
797"       - If SOURCE is a URL:\n"
798"\n"
799"           - If the basename of the URL and the basename of '.' are the\n"
800"             same, then the differences are applied to '.'. Otherwise,\n"
801"             if a file with the same basename as that of the URL is found\n"
802"             within '.', then the differences are applied to that file.\n"
803"             In all other cases, the target defaults to '.'.\n"
804"\n"
805"       - If SOURCE is a working copy path:\n"
806"\n"
807"           - If the source is a file, then differences are applied to that\n"
808"             file (useful for reverse-merging earlier changes). Otherwise,\n"
809"             if the source is a directory, then the target defaults to '.'.\n"
810"\n"
811"     In normal usage the working copy should be up to date, at a single\n"
812"     revision, with no local modifications and no switched subtrees.\n"
813"\n"
814"       - The 'Feature Branch' Merging Pattern -\n"
815"\n"
816"     In this commonly used work flow, known also as the 'development\n"
817"     branch' pattern, a developer creates a branch and commits a series of\n"
818"     changes that implement a new feature. The developer periodically\n"
819"     merges all the latest changes from the parent branch so as to keep the\n"
820"     development branch up to date with those changes. When the feature is\n"
821"     complete, the developer performs a merge from the feature branch to\n"
822"     the parent branch to re-integrate the changes.\n"
823"\n"
824"         parent --+----------o------o-o-------------o--\n"
825"                   \\            \\           \\      /\n"
826"                    \\          merge      merge  merge\n"
827"                     \\            \\           \\  /\n"
828"         feature      +--o-o-------o----o-o----o-------\n"
829"\n"
830"     A merge from the parent branch to the feature branch is called a\n"
831"     'sync' or 'catch-up' merge, and a merge from the feature branch to the\n"
832"     parent branch is called a 'reintegrate' merge.\n"
833"\n"
834"       - Sync Merge Example -\n"
835"                                 ............\n"
836"                                .            .\n"
837"         trunk  --+------------L--------------R------\n"
838"                   \\                           \\\n"
839"                    \\                          |\n"
840"                     \\                         v\n"
841"         feature      +------------------------o-----\n"
842"                             r100            r200\n"
843"\n"
844"     Subversion will locate all the changes on 'trunk' that have not yet\n"
845"     been merged into the 'feature' branch. In this case that is a single\n"
846"     range, r100:200. In the diagram above, L marks the left side (trunk@100)\n"
847"     and R marks the right side (trunk@200) of the merge source. The\n"
848"     difference between L and R will be applied to the target working copy\n"
849"     path. In this case, the working copy is a clean checkout of the entire\n"
850"     'feature' branch.\n"
851"\n"
852"     To perform this sync merge, have a clean working copy of the feature\n"
853"     branch and run the following command in its top-level directory:\n"
854"\n"
855"         svn merge ^/trunk\n"
856"\n"
857"     Note that the merge is now only in your local working copy and still\n"
858"     needs to be committed to the repository so that it can be seen by\n"
859"     others. You can review the changes and you may have to resolve\n"
860"     conflicts before you commit the merge.\n"
861"\n"
862"       - Reintegrate Merge Example -\n"
863"\n"
864"     The feature branch was last synced with trunk up to revision X. So the\n"
865"     difference between trunk@X and feature@HEAD contains the complete set\n"
866"     of changes that implement the feature, and no other changes. These\n"
867"     changes are applied to trunk.\n"
868"\n"
869"                    rW                   rX\n"
870"         trunk ------+--------------------L------------------o\n"
871"                      \\                    .                 ^\n"
872"                       \\                    .............   /\n"
873"                        \\                                . /\n"
874"         feature         +--------------------------------R\n"
875"\n"
876"     In the diagram above, L marks the left side (trunk@X) and R marks the\n"
877"     right side (feature@HEAD) of the merge. The difference between the\n"
878"     left and right side is merged into trunk, the target.\n"
879"\n"
880"     To perform the merge, have a clean working copy of trunk and run the\n"
881"     following command in its top-level directory:\n"
882"\n"
883"         svn merge ^/feature\n"
884"\n"
885"     To prevent unnecessary merge conflicts, a reintegrate merge requires\n"
886"     that TARGET_WCPATH is not a mixed-revision working copy, has no local\n"
887"     modifications, and has no switched subtrees.\n"
888"\n"
889"     A reintegrate merge also requires that the source branch is coherently\n"
890"     synced with the target -- in the above example, this means that all\n"
891"     revisions between the branch point W and the last merged revision X\n"
892"     are merged to the feature branch, so that there are no unmerged\n"
893"     revisions in-between.\n"
894"\n"
895"\n"
896"  2. This form is called a 'cherry-pick' merge:\n"
897"\n"
898"       svn merge [-c M[,N...] | -r N:M ...] SOURCE[@REV] [TARGET_WCPATH]\n"
899"\n"
900"     A cherry-pick merge is used to merge specific revisions (or revision\n"
901"     ranges) from one branch to another. By default, this uses merge\n"
902"     tracking to automatically skip any revisions that have already been\n"
903"     merged to the target; you can use the --ignore-ancestry option to\n"
904"     disable such skipping.\n"
905"\n"
906"     SOURCE is usually a URL. The optional '@REV' specifies only the peg\n"
907"     revision of the URL and does not affect the merge range; if REV is not\n"
908"     specified, the HEAD revision is assumed. If SOURCE is a working copy\n"
909"     path, the corresponding URL of the path is used, and the default value\n"
910"     of 'REV' is the base revision (usually the revision last updated to).\n"
911"\n"
912"     TARGET_WCPATH is a working copy path; if omitted, '.' is generally\n"
913"     assumed. The special cases noted above in the 'complete' merge form\n"
914"     also apply here.\n"
915"\n"
916"     The revision ranges to be merged are specified by the '-r' and/or '-c'\n"
917"     options. '-r N:M' refers to the difference in the history of the\n"
918"     source branch between revisions N and M. You can use '-c M' to merge\n"
919"     single revisions: '-c M' is equivalent to '-r <M-1>:M'. Each such\n"
920"     difference is applied to TARGET_WCPATH.\n"
921"\n"
922"     If the mergeinfo in TARGET_WCPATH indicates that revisions within the\n"
923"     range were already merged, changes made in those revisions are not\n"
924"     merged again. If needed, the range is broken into multiple sub-ranges,\n"
925"     and each sub-range is merged separately.\n"
926"\n"
927"     A 'reverse range' can be used to undo changes. For example, when\n"
928"     source and target refer to the same branch, a previously committed\n"
929"     revision can be 'undone'. In a reverse range, N is greater than M in\n"
930"     '-r N:M', or the '-c' option is used with a negative number: '-c -M'\n"
931"     is equivalent to '-r M:<M-1>'. Undoing changes like this is also known\n"
932"     as performing a 'reverse merge'.\n"
933"\n"
934"     Multiple '-c' and/or '-r' options may be specified and mixing of\n"
935"     forward and reverse ranges is allowed.\n"
936"\n"
937"       - Cherry-pick Merge Example -\n"
938"\n"
939"     A bug has been fixed on trunk in revision 50. This fix needs to\n"
940"     be merged from trunk onto the release branch.\n"
941"\n"
942"            1.x-release  +-----------------------o-----\n"
943"                        /                        ^\n"
944"                       /                         |\n"
945"                      /                          |\n"
946"         trunk ------+--------------------------LR-----\n"
947"                                                r50\n"
948"\n"
949"     In the above diagram, L marks the left side (trunk@49) and R marks the\n"
950"     right side (trunk@50) of the merge. The difference between the left\n"
951"     and right side is applied to the target working copy path.\n"
952"\n"
953"     Note that the difference between revision 49 and 50 is exactly those\n"
954"     changes that were committed in revision 50, not including changes\n"
955"     committed in revision 49.\n"
956"\n"
957"     To perform the merge, have a clean working copy of the release branch\n"
958"     and run the following command in its top-level directory; remember\n"
959"     that the default target is '.':\n"
960"\n"
961"         svn merge -c50 ^/trunk\n"
962"\n"
963"     You can also cherry-pick several revisions and/or revision ranges:\n"
964"\n"
965"         svn merge -c50,54,60 -r65:68 ^/trunk\n"
966"\n"
967"\n"
968"  3. This form is called a '2-URL merge':\n"
969"\n"
970"       svn merge SOURCE1[@REV1] SOURCE2[@REV2] [TARGET_WCPATH]\n"
971"\n"
972"     You should use this merge variant only if the other variants do not\n"
973"     apply to your situation, as this variant can be quite complex to\n"
974"     master.\n"
975"\n"
976"     Two source URLs are specified, identifying two trees on the same\n"
977"     branch or on different branches. The trees are compared and the\n"
978"     difference from SOURCE1@REV1 to SOURCE2@REV2 is applied to the\n"
979"     working copy of the target branch at TARGET_WCPATH. The target\n"
980"     branch may be the same as one or both sources, or different again.\n"
981"     The three branches involved can be completely unrelated.\n"
982"\n"
983"     TARGET_WCPATH is a working copy path; if omitted, '.' is generally\n"
984"     assumed. The special cases noted above in the 'complete' merge form\n"
985"     also apply here.\n"
986"\n"
987"     SOURCE1 and/or SOURCE2 can also be specified as a working copy path,\n"
988"     in which case the merge source URL is derived from the working copy.\n"
989"\n"
990"       - 2-URL Merge Example -\n"
991"\n"
992"     Two features have been developed on separate branches called 'foo' and\n"
993"     'bar'. It has since become clear that 'bar' should be combined with\n"
994"     the 'foo' branch for further development before reintegration.\n"
995"\n"
996"     Although both feature branches originate from trunk, they are not\n"
997"     directly related -- one is not a direct copy of the other. A 2-URL\n"
998"     merge is necessary.\n"
999"\n"
1000"     The 'bar' branch has been synced with trunk up to revision 500.\n"
1001"     (If this revision number is not known, it can be located using the\n"
1002"     'svn log' and/or 'svn mergeinfo' commands.)\n"
1003"     The difference between trunk@500 and bar@HEAD contains the complete\n"
1004"     set of changes related to feature 'bar', and no other changes. These\n"
1005"     changes are applied to the 'foo' branch.\n"
1006"\n"
1007"                           foo  +-----------------------------------o\n"
1008"                               /                                    ^\n"
1009"                              /                                    /\n"
1010"                             /              r500                  /\n"
1011"         trunk ------+------+-----------------L--------->        /\n"
1012"                      \\                        .                /\n"
1013"                       \\                        ............   /\n"
1014"                        \\                                   . /\n"
1015"                    bar  +-----------------------------------R\n"
1016"\n"
1017"     In the diagram above, L marks the left side (trunk@500) and R marks\n"
1018"     the right side (bar@HEAD) of the merge. The difference between the\n"
1019"     left and right side is applied to the target working copy path, in\n"
1020"     this case a working copy of the 'foo' branch.\n"
1021"\n"
1022"     To perform the merge, have a clean working copy of the 'foo' branch\n"
1023"     and run the following command in its top-level directory:\n"
1024"\n"
1025"         svn merge ^/trunk@500 ^/bar\n"
1026"\n"
1027"     The exact changes applied by a 2-URL merge can be previewed with svn's\n"
1028"     diff command, which is a good idea to verify if you do not have the\n"
1029"     luxury of a clean working copy to merge to. In this case:\n"
1030"\n"
1031"         svn diff ^/trunk@500 ^/bar@HEAD\n"
1032"\n"
1033"\n"
1034"  The following applies to all types of merges:\n"
1035"\n"
1036"  To prevent unnecessary merge conflicts, svn merge requires that\n"
1037"  TARGET_WCPATH is not a mixed-revision working copy. Running 'svn update'\n"
1038"  before starting a merge ensures that all items in the working copy are\n"
1039"  based on the same revision.\n"
1040"\n"
1041"  If possible, you should have no local modifications in the merge's target\n"
1042"  working copy prior to the merge, to keep things simpler. It will be\n"
1043"  easier to revert the merge and to understand the branch's history.\n"
1044"\n"
1045"  Switched sub-paths should also be avoided during merging, as they may\n"
1046"  cause incomplete merges and create subtree mergeinfo.\n"
1047"\n"
1048"  For each merged item a line will be printed with characters reporting the\n"
1049"  action taken. These characters have the following meaning:\n"
1050"\n"
1051"    A  Added\n"
1052"    D  Deleted\n"
1053"    U  Updated\n"
1054"    C  Conflict\n"
1055"    G  Merged\n"
1056"    E  Existed\n"
1057"    R  Replaced\n"
1058"\n"
1059"  Characters in the first column report about the item itself.\n"
1060"  Characters in the second column report about properties of the item.\n"
1061"  A 'C' in the third column indicates a tree conflict, while a 'C' in\n"
1062"  the first and second columns indicate textual conflicts in files\n"
1063"  and in property values, respectively.\n"
1064"\n"
1065"    - Merge Tracking -\n"
1066"\n"
1067"  Subversion uses the svn:mergeinfo property to track merge history. This\n"
1068"  property is considered at the start of a merge to determine what to merge\n"
1069"  and it is updated at the conclusion of the merge to describe the merge\n"
1070"  that took place. Mergeinfo is used only if the two sources are on the\n"
1071"  same line of history -- if the first source is an ancestor of the second,\n"
1072"  or vice-versa (i.e. if one has originally been created by copying the\n"
1073"  other). This is verified and enforced when using sync merges and\n"
1074"  reintegrate merges.\n"
1075"\n"
1076"  The --ignore-ancestry option prevents merge tracking and thus ignores\n"
1077"  mergeinfo, neither considering it nor recording it.\n"
1078"\n"
1079"    - Merging from foreign repositories -\n"
1080"\n"
1081"  Subversion does support merging from foreign repositories.\n"
1082"  While all merge source URLs must point to the same repository, the merge\n"
1083"  target working copy may come from a different repository than the source.\n"
1084"  However, there are some caveats. Most notably, copies made in the\n"
1085"  merge source will be transformed into plain additions in the merge\n"
1086"  target. Also, merge-tracking is not supported for merges from foreign\n"
1087"  repositories.\n"),
1088    {'r', 'c', 'N', opt_depth, 'q', opt_force, opt_dry_run, opt_merge_cmd,
1089     opt_record_only, 'x', opt_ignore_ancestry, opt_accept, opt_reintegrate,
1090     opt_allow_mixed_revisions, 'v'} },
1091
1092  { "mergeinfo", svn_cl__mergeinfo, {0}, N_
1093    ("Display merge-related information.\n"
1094     "usage: 1. mergeinfo SOURCE[@REV] [TARGET[@REV]]\n"
1095     "       2. mergeinfo --show-revs=WHICH SOURCE[@REV] [TARGET[@REV]]\n"
1096     "\n"
1097     "  1. Summarize the history of merging between SOURCE and TARGET. The graph\n"
1098     "     shows, from left to right:\n"
1099     "       the youngest common ancestor of the branches;\n"
1100     "       the latest full merge in either direction, and thus the common base\n"
1101     "         that will be used for the next complete merge;\n"
1102     "       the repository path and revision number of the tip of each branch.\n"
1103     "\n"
1104     "  2. Print the revision numbers on SOURCE that have been merged to TARGET\n"
1105     "     (with --show-revs=merged), or that have not been merged to TARGET\n"
1106     "     (with --show-revs=eligible). Print only revisions in which there was\n"
1107     "     at least one change in SOURCE.\n"
1108     "\n"
1109     "     If --revision (-r) is provided, filter the displayed information to\n"
1110     "     show only that which is associated with the revisions within the\n"
1111     "     specified range.  Revision numbers, dates, and the 'HEAD' keyword are\n"
1112     "     valid range values.\n"
1113     "\n"
1114     "  SOURCE and TARGET are the source and target branch URLs, respectively.\n"
1115     "  (If a WC path is given, the corresponding base URL is used.) The default\n"
1116     "  TARGET is the current working directory ('.'). REV specifies the revision\n"
1117     "  to be considered the tip of the branch; the default for SOURCE is HEAD,\n"
1118     "  and the default for TARGET is HEAD for a URL or BASE for a WC path.\n"
1119     "\n"
1120     "  The depth can be 'empty' or 'infinity'; the default is 'empty'.\n"),
1121    {'r', 'R', opt_depth, opt_show_revs} },
1122
1123  { "mkdir", svn_cl__mkdir, {0}, N_
1124    ("Create a new directory under version control.\n"
1125     "usage: 1. mkdir PATH...\n"
1126     "       2. mkdir URL...\n"
1127     "\n"
1128     "  Create version controlled directories.\n"
1129     "\n"
1130     "  1. Each directory specified by a working copy PATH is created locally\n"
1131     "    and scheduled for addition upon the next commit.\n"
1132     "\n"
1133     "  2. Each directory specified by a URL is created in the repository via\n"
1134     "    an immediate commit.\n"
1135     "\n"
1136     "  In both cases, all the intermediate directories must already exist,\n"
1137     "  unless the --parents option is given.\n"),
1138    {'q', opt_parents, SVN_CL__LOG_MSG_OPTIONS} },
1139
1140  { "move", svn_cl__move, {"mv", "rename", "ren"}, N_
1141    ("Move (rename) an item in a working copy or repository.\n"
1142     "usage: move SRC... DST\n"
1143     "\n"
1144     "  SRC and DST can both be working copy (WC) paths or URLs:\n"
1145     "    WC  -> WC:  move an item in a working copy, as a local change to\n"
1146     "                be committed later (with or without further changes)\n"
1147     "    URL -> URL: move an item in the repository directly, immediately\n"
1148     "                creating a new revision in the repository\n"
1149     "  All the SRCs must be of the same type. When moving multiple sources,\n"
1150     "  they will be added as children of DST, which must be a directory.\n"
1151     "\n"
1152     "  SRC and DST of WC -> WC moves must be committed in the same revision.\n"
1153     "  Furthermore, WC -> WC moves will refuse to move a mixed-revision subtree.\n"
1154     "  To avoid unnecessary conflicts, it is recommended to run 'svn update'\n"
1155     "  to update the subtree to a single revision before moving it.\n"
1156     "  The --allow-mixed-revisions option is provided for backward compatibility.\n"
1157     "\n"
1158     "  The --revision option has no use and is deprecated.\n"),
1159    {'r', 'q', opt_force, opt_parents, opt_allow_mixed_revisions,
1160     SVN_CL__LOG_MSG_OPTIONS} },
1161
1162  { "patch", svn_cl__patch, {0}, N_
1163    ("Apply a patch to a working copy.\n"
1164     "usage: patch PATCHFILE [WCPATH]\n"
1165     "\n"
1166     "  Apply a unidiff patch in PATCHFILE to the working copy WCPATH.\n"
1167     "  If WCPATH is omitted, '.' is assumed.\n"
1168     "\n"
1169     "  A unidiff patch suitable for application to a working copy can be\n"
1170     "  produced with the 'svn diff' command or third-party diffing tools.\n"
1171     "  Any non-unidiff content of PATCHFILE is ignored, except for Subversion\n"
1172     "  property diffs as produced by 'svn diff'.\n"
1173     "\n"
1174     "  Changes listed in the patch will either be applied or rejected.\n"
1175     "  If a change does not match at its exact line offset, it may be applied\n"
1176     "  earlier or later in the file if a match is found elsewhere for the\n"
1177     "  surrounding lines of context provided by the patch.\n"
1178     "  A change may also be applied with fuzz, which means that one\n"
1179     "  or more lines of context are ignored when matching the change.\n"
1180     "  If no matching context can be found for a change, the change conflicts\n"
1181     "  and will be written to a reject file with the extension .svnpatch.rej.\n"
1182     "\n"
1183     "  For each patched file a line will be printed with characters reporting\n"
1184     "  the action taken. These characters have the following meaning:\n"
1185     "\n"
1186     "    A  Added\n"
1187     "    D  Deleted\n"
1188     "    U  Updated\n"
1189     "    C  Conflict\n"
1190     "    G  Merged (with local uncommitted changes)\n"
1191     "\n"
1192     "  Changes applied with an offset or fuzz are reported on lines starting\n"
1193     "  with the '>' symbol. You should review such changes carefully.\n"
1194     "\n"
1195     "  If the patch removes all content from a file, that file is scheduled\n"
1196     "  for deletion. If the patch creates a new file, that file is scheduled\n"
1197     "  for addition. Use 'svn revert' to undo deletions and additions you\n"
1198     "  do not agree with.\n"
1199     "\n"
1200     "  Hint: If the patch file was created with Subversion, it will contain\n"
1201     "        the number of a revision N the patch will cleanly apply to\n"
1202     "        (look for lines like '--- foo/bar.txt        (revision N)').\n"
1203     "        To avoid rejects, first update to the revision N using\n"
1204     "        'svn update -r N', apply the patch, and then update back to the\n"
1205     "        HEAD revision. This way, conflicts can be resolved interactively.\n"
1206     ),
1207    {'q', opt_dry_run, opt_strip, opt_reverse_diff,
1208     opt_ignore_whitespace} },
1209
1210  { "propdel", svn_cl__propdel, {"pdel", "pd"}, N_
1211    ("Remove a property from files, dirs, or revisions.\n"
1212     "usage: 1. propdel PROPNAME [PATH...]\n"
1213     "       2. propdel PROPNAME --revprop -r REV [TARGET]\n"
1214     "\n"
1215     "  1. Removes versioned props in working copy.\n"
1216     "  2. Removes unversioned remote prop on repos revision.\n"
1217     "     TARGET only determines which repository to access.\n"),
1218    {'q', 'R', opt_depth, 'r', opt_revprop, opt_changelist} },
1219
1220  { "propedit", svn_cl__propedit, {"pedit", "pe"}, N_
1221    ("Edit a property with an external editor.\n"
1222     "usage: 1. propedit PROPNAME TARGET...\n"
1223     "       2. propedit PROPNAME --revprop -r REV [TARGET]\n"
1224     "\n"
1225     "  1. Edits versioned prop in working copy or repository.\n"
1226     "  2. Edits unversioned remote prop on repos revision.\n"
1227     "     TARGET only determines which repository to access.\n"
1228     "\n"
1229     "  See 'svn help propset' for more on setting properties.\n"),
1230    {'r', opt_revprop, SVN_CL__LOG_MSG_OPTIONS, opt_force} },
1231
1232  { "propget", svn_cl__propget, {"pget", "pg"}, N_
1233    ("Print the value of a property on files, dirs, or revisions.\n"
1234     "usage: 1. propget PROPNAME [TARGET[@REV]...]\n"
1235     "       2. propget PROPNAME --revprop -r REV [TARGET]\n"
1236     "\n"
1237     "  1. Prints versioned props. If specified, REV determines in which\n"
1238     "     revision the target is first looked up.\n"
1239     "  2. Prints unversioned remote prop on repos revision.\n"
1240     "     TARGET only determines which repository to access.\n"
1241     "\n"
1242     "  With --verbose, the target path and the property name are printed on\n"
1243     "  separate lines before each value, like 'svn proplist --verbose'.\n"
1244     "  Otherwise, if there is more than one TARGET or a depth other than\n"
1245     "  'empty', the target path is printed on the same line before each value.\n"
1246     "\n"
1247     "  By default, an extra newline is printed after the property value so that\n"
1248     "  the output looks pretty.  With a single TARGET and depth 'empty', you can\n"
1249     "  use the --strict option to disable this (useful when redirecting a binary\n"
1250     "  property value to a file, for example).\n"),
1251    {'v', 'R', opt_depth, 'r', opt_revprop, opt_strict, opt_xml,
1252     opt_changelist, opt_show_inherited_props },
1253    {{'v', N_("print path, name and value on separate lines")},
1254     {opt_strict, N_("don't print an extra newline")}} },
1255
1256  { "proplist", svn_cl__proplist, {"plist", "pl"}, N_
1257    ("List all properties on files, dirs, or revisions.\n"
1258     "usage: 1. proplist [TARGET[@REV]...]\n"
1259     "       2. proplist --revprop -r REV [TARGET]\n"
1260     "\n"
1261     "  1. Lists versioned props. If specified, REV determines in which\n"
1262     "     revision the target is first looked up.\n"
1263     "  2. Lists unversioned remote props on repos revision.\n"
1264     "     TARGET only determines which repository to access.\n"
1265     "\n"
1266     "  With --verbose, the property values are printed as well, like 'svn propget\n"
1267     "  --verbose'.  With --quiet, the paths are not printed.\n"),
1268    {'v', 'R', opt_depth, 'r', 'q', opt_revprop, opt_xml, opt_changelist,
1269     opt_show_inherited_props },
1270    {{'v', N_("print path, name and value on separate lines")},
1271     {'q', N_("don't print the path")}} },
1272
1273  { "propset", svn_cl__propset, {"pset", "ps"}, N_
1274    ("Set the value of a property on files, dirs, or revisions.\n"
1275     "usage: 1. propset PROPNAME PROPVAL PATH...\n"
1276     "       2. propset PROPNAME --revprop -r REV PROPVAL [TARGET]\n"
1277     "\n"
1278     "  1. Changes a versioned file or directory property in a working copy.\n"
1279     "  2. Changes an unversioned property on a repository revision.\n"
1280     "     (TARGET only determines which repository to access.)\n"
1281     "\n"
1282     "  The value may be provided with the --file option instead of PROPVAL.\n"
1283     "\n"
1284     "  Property names starting with 'svn:' are reserved.  Subversion recognizes\n"
1285     "  the following special versioned properties on a file:\n"
1286     "    svn:keywords   - Keywords to be expanded.  Valid keywords are:\n"
1287     "      URL, HeadURL             - The URL for the head version of the file.\n"
1288     "      Author, LastChangedBy    - The last person to modify the file.\n"
1289     "      Date, LastChangedDate    - The date/time the file was last modified.\n"
1290     "      Rev, Revision,           - The last revision the file changed.\n"
1291     "        LastChangedRevision\n"
1292     "      Id                       - A compressed summary of the previous four.\n"
1293     "      Header                   - Similar to Id but includes the full URL.\n"
1294     "\n"
1295     "      Custom keywords can be defined with a format string separated from\n"
1296     "      the keyword name with '='. Valid format substitutions are:\n"
1297     "        %a   - The author of the revision given by %r.\n"
1298     "        %b   - The basename of the URL of the file.\n"
1299     "        %d   - Short format of the date of the revision given by %r.\n"
1300     "        %D   - Long format of the date of the revision given by %r.\n"
1301     "        %P   - The file's path, relative to the repository root.\n"
1302     "        %r   - The number of the revision which last changed the file.\n"
1303     "        %R   - The URL to the root of the repository.\n"
1304     "        %u   - The URL of the file.\n"
1305     "        %_   - A space (keyword definitions cannot contain a literal space).\n"
1306     "        %%   - A literal '%'.\n"
1307     "        %H   - Equivalent to %P%_%r%_%d%_%a.\n"
1308     "        %I   - Equivalent to %b%_%r%_%d%_%a.\n"
1309     "      Example custom keyword definition: MyKeyword=%r%_%a%_%P\n"
1310     "      Once a custom keyword has been defined for a file, it can be used\n"
1311     "      within the file like any other keyword: $MyKeyword$\n"
1312     "\n"
1313     "    svn:executable - If present, make the file executable.  Use\n"
1314     "      'svn propdel svn:executable PATH...' to clear.\n"
1315     "    svn:eol-style  - One of 'native', 'LF', 'CR', 'CRLF'.\n"
1316     "    svn:mime-type  - The mimetype of the file.  Used to determine\n"
1317     "      whether to merge the file, and how to serve it from Apache.\n"
1318     "      A mimetype beginning with 'text/' (or an absent mimetype) is\n"
1319     "      treated as text.  Anything else is treated as binary.\n"
1320     "    svn:needs-lock - If present, indicates that the file should be locked\n"
1321     "      before it is modified.  Makes the working copy file read-only\n"
1322     "      when it is not locked.  Use 'svn propdel svn:needs-lock PATH...'\n"
1323     "      to clear.\n"
1324     "\n"
1325     "  Subversion recognizes the following special versioned properties on a\n"
1326     "  directory:\n"
1327     "    svn:ignore         - A list of file glob patterns to ignore, one per line.\n"
1328     "    svn:global-ignores - Like svn:ignore, but inheritable.\n"
1329     "    svn:externals      - A list of module specifiers, one per line, in the\n"
1330     "      following format similar to the syntax of 'svn checkout':\n"
1331     "        [-r REV] URL[@PEG] LOCALPATH\n"
1332     "      Example:\n"
1333     "        http://example.com/repos/zig foo/bar\n"
1334     "      The LOCALPATH is relative to the directory having this property.\n"
1335     "      To pin the external to a known revision, specify the optional REV:\n"
1336     "        -r25 http://example.com/repos/zig foo/bar\n"
1337     "      To unambiguously identify an element at a path which may have been\n"
1338     "      subsequently deleted or renamed, specify the optional PEG revision:\n"
1339     "        -r25 http://example.com/repos/zig@42 foo/bar\n"
1340     "      The URL may be a full URL or a relative URL starting with one of:\n"
1341     "        ../  to the parent directory of the extracted external\n"
1342     "        ^/   to the repository root\n"
1343     "        /    to the server root\n"
1344     "        //   to the URL scheme\n"
1345     "      Use of the following format is discouraged but is supported for\n"
1346     "      interoperability with Subversion 1.4 and earlier clients:\n"
1347     "        LOCALPATH [-r PEG] URL\n"
1348     "      The ambiguous format 'relative_path relative_path' is taken as\n"
1349     "      'relative_url relative_path' with peg revision support.\n"
1350     "      Lines starting with a '#' character are ignored.\n"),
1351    {'F', opt_encoding, 'q', 'r', opt_targets, 'R', opt_depth, opt_revprop,
1352     opt_force, opt_changelist },
1353    {{'F', N_("read property value from file ARG")}} },
1354
1355  { "relocate", svn_cl__relocate, {0}, N_
1356    ("Relocate the working copy to point to a different repository root URL.\n"
1357     "usage: 1. relocate FROM-PREFIX TO-PREFIX [PATH...]\n"
1358     "       2. relocate TO-URL [PATH]\n"
1359     "\n"
1360     "  Rewrite working copy URL metadata to reflect a syntactic change only.\n"
1361     "  This is used when a repository's root URL changes (such as a scheme\n"
1362     "  or hostname change) but your working copy still reflects the same\n"
1363     "  directory within the same repository.\n"
1364     "\n"
1365     "  1. FROM-PREFIX and TO-PREFIX are initial substrings of the working\n"
1366     "     copy's current and new URLs, respectively.  (You may specify the\n"
1367     "     complete old and new URLs if you wish.)  Use 'svn info' to determine\n"
1368     "     the current working copy URL.\n"
1369     "\n"
1370     "  2. TO-URL is the (complete) new repository URL to use for PATH.\n"
1371     "\n"
1372     "  Examples:\n"
1373     "    svn relocate http:// svn:// project1 project2\n"
1374     "    svn relocate http://www.example.com/repo/project \\\n"
1375     "                 svn://svn.example.com/repo/project\n"),
1376    {opt_ignore_externals} },
1377
1378  { "resolve", svn_cl__resolve, {0}, N_
1379    ("Resolve conflicts on working copy files or directories.\n"
1380     "usage: resolve [PATH...]\n"
1381     "\n"
1382     "  By default, perform interactive conflict resolution on PATH.\n"
1383     "  In this mode, the command is recursive by default (depth 'infinity').\n"
1384     "\n"
1385     "  The --accept=ARG option prevents interactive prompting and forces\n"
1386     "  conflicts on PATH to be resolved in the manner specified by ARG.\n"
1387     "  In this mode, the command is not recursive by default (depth 'empty').\n"),
1388    {opt_targets, 'R', opt_depth, 'q', opt_accept},
1389    {{opt_accept, N_("specify automatic conflict resolution source\n"
1390                     "                             "
1391                     "('base', 'working', 'mine-conflict',\n"
1392                     "                             "
1393                     "'theirs-conflict', 'mine-full', 'theirs-full')")}} },
1394
1395  { "resolved", svn_cl__resolved, {0}, N_
1396    ("Remove 'conflicted' state on working copy files or directories.\n"
1397     "usage: resolved PATH...\n"
1398     "\n"
1399     "  Note:  this subcommand does not semantically resolve conflicts or\n"
1400     "  remove conflict markers; it merely removes the conflict-related\n"
1401     "  artifact files and allows PATH to be committed again.  It has been\n"
1402     "  deprecated in favor of running 'svn resolve --accept working'.\n"),
1403    {opt_targets, 'R', opt_depth, 'q'} },
1404
1405  { "revert", svn_cl__revert, {0}, N_
1406    ("Restore pristine working copy state (undo local changes).\n"
1407     "usage: revert PATH...\n"
1408     "\n"
1409     "  Revert changes in the working copy at or within PATH, and remove\n"
1410     "  conflict markers as well, if any.\n"
1411     "\n"
1412     "  This subcommand does not revert already committed changes.\n"
1413     "  For information about undoing already committed changes, search\n"
1414     "  the output of 'svn help merge' for 'undo'.\n"),
1415    {opt_targets, 'R', opt_depth, 'q', opt_changelist} },
1416
1417  { "status", svn_cl__status, {"stat", "st"}, N_
1418    ("Print the status of working copy files and directories.\n"
1419     "usage: status [PATH...]\n"
1420     "\n"
1421     "  With no args, print only locally modified items (no network access).\n"
1422     "  With -q, print only summary information about locally modified items.\n"
1423     "  With -u, add working revision and server out-of-date information.\n"
1424     "  With -v, print full revision information on every item.\n"
1425     "\n"
1426     "  The first seven columns in the output are each one character wide:\n"
1427     "    First column: Says if item was added, deleted, or otherwise changed\n"
1428     "      ' ' no modifications\n"
1429     "      'A' Added\n"
1430     "      'C' Conflicted\n"
1431     "      'D' Deleted\n"
1432     "      'I' Ignored\n"
1433     "      'M' Modified\n"
1434     "      'R' Replaced\n"
1435     "      'X' an unversioned directory created by an externals definition\n"
1436     "      '?' item is not under version control\n"
1437     "      '!' item is missing (removed by non-svn command) or incomplete\n"
1438     "      '~' versioned item obstructed by some item of a different kind\n"
1439     "    Second column: Modifications of a file's or directory's properties\n"
1440     "      ' ' no modifications\n"
1441     "      'C' Conflicted\n"
1442     "      'M' Modified\n"
1443     "    Third column: Whether the working copy is locked for writing by\n"
1444     "                  another Subversion client modifying the working copy\n"
1445     "      ' ' not locked for writing\n"
1446     "      'L' locked for writing\n"
1447     "    Fourth column: Scheduled commit will contain addition-with-history\n"
1448     "      ' ' no history scheduled with commit\n"
1449     "      '+' history scheduled with commit\n"
1450     "    Fifth column: Whether the item is switched or a file external\n"
1451     "      ' ' normal\n"
1452     "      'S' the item has a Switched URL relative to the parent\n"
1453     "      'X' a versioned file created by an eXternals definition\n"
1454     "    Sixth column: Whether the item is locked in repository for exclusive commit\n"
1455     "      (without -u)\n"
1456     "      ' ' not locked by this working copy\n"
1457     "      'K' locked by this working copy, but lock might be stolen or broken\n"
1458     "      (with -u)\n"
1459     "      ' ' not locked in repository, not locked by this working copy\n"
1460     "      'K' locked in repository, lock owned by this working copy\n"
1461     "      'O' locked in repository, lock owned by another working copy\n"
1462     "      'T' locked in repository, lock owned by this working copy was stolen\n"
1463     "      'B' not locked in repository, lock owned by this working copy is broken\n"
1464     "    Seventh column: Whether the item is the victim of a tree conflict\n"
1465     "      ' ' normal\n"
1466     "      'C' tree-Conflicted\n"
1467     "    If the item is a tree conflict victim, an additional line is printed\n"
1468     "    after the item's status line, explaining the nature of the conflict.\n"
1469     "\n"
1470     "  The out-of-date information appears in the ninth column (with -u):\n"
1471     "      '*' a newer revision exists on the server\n"
1472     "      ' ' the working copy is up to date\n"
1473     "\n"
1474     "  Remaining fields are variable width and delimited by spaces:\n"
1475     "    The working revision (with -u or -v; '-' if the item is copied)\n"
1476     "    The last committed revision and last committed author (with -v)\n"
1477     "    The working copy path is always the final field, so it can\n"
1478     "      include spaces.\n"
1479     "\n"
1480     "  The presence of a question mark ('?') where a working revision, last\n"
1481     "  committed revision, or last committed author was expected indicates\n"
1482     "  that the information is unknown or irrelevant given the state of the\n"
1483     "  item (for example, when the item is the result of a copy operation).\n"
1484     "  The question mark serves as a visual placeholder to facilitate parsing.\n"
1485     "\n"
1486     "  Example output:\n"
1487     "    svn status wc\n"
1488     "     M      wc/bar.c\n"
1489     "    A  +    wc/qax.c\n"
1490     "\n"
1491     "    svn status -u wc\n"
1492     "     M             965   wc/bar.c\n"
1493     "            *      965   wc/foo.c\n"
1494     "    A  +             -   wc/qax.c\n"
1495     "    Status against revision:   981\n"
1496     "\n"
1497     "    svn status --show-updates --verbose wc\n"
1498     "     M             965      938 kfogel       wc/bar.c\n"
1499     "            *      965      922 sussman      wc/foo.c\n"
1500     "    A  +             -      687 joe          wc/qax.c\n"
1501     "                   965      687 joe          wc/zig.c\n"
1502     "    Status against revision:   981\n"
1503     "\n"
1504     "    svn status\n"
1505     "     M      wc/bar.c\n"
1506     "    !     C wc/qaz.c\n"
1507     "          >   local missing, incoming edit upon update\n"
1508     "    D       wc/qax.c\n"),
1509    { 'u', 'v', 'N', opt_depth, 'q', opt_no_ignore, opt_incremental, opt_xml,
1510      opt_ignore_externals, opt_changelist},
1511    {{'q', N_("don't print unversioned items")}} },
1512
1513  { "switch", svn_cl__switch, {"sw"}, N_
1514    ("Update the working copy to a different URL within the same repository.\n"
1515     "usage: 1. switch URL[@PEGREV] [PATH]\n"
1516     "       2. switch --relocate FROM-PREFIX TO-PREFIX [PATH...]\n"
1517     "\n"
1518     "  1. Update the working copy to mirror a new URL within the repository.\n"
1519     "     This behavior is similar to 'svn update', and is the way to\n"
1520     "     move a working copy to a branch or tag within the same repository.\n"
1521     "     If specified, PEGREV determines in which revision the target is first\n"
1522     "     looked up.\n"
1523     "\n"
1524     "     If --force is used, unversioned obstructing paths in the working\n"
1525     "     copy do not automatically cause a failure if the switch attempts to\n"
1526     "     add the same path.  If the obstructing path is the same type (file\n"
1527     "     or directory) as the corresponding path in the repository it becomes\n"
1528     "     versioned but its contents are left 'as-is' in the working copy.\n"
1529     "     This means that an obstructing directory's unversioned children may\n"
1530     "     also obstruct and become versioned.  For files, any content differences\n"
1531     "     between the obstruction and the repository are treated like a local\n"
1532     "     modification to the working copy.  All properties from the repository\n"
1533     "     are applied to the obstructing path.\n"
1534     "\n"
1535     "     Use the --set-depth option to set a new working copy depth on the\n"
1536     "     targets of this operation.\n"
1537     "\n"
1538     "     By default, Subversion will refuse to switch a working copy path to\n"
1539     "     a new URL with which it shares no common version control ancestry.\n"
1540     "     Use the '--ignore-ancestry' option to override this sanity check.\n"
1541     "\n"
1542     "  2. The '--relocate' option is deprecated. This syntax is equivalent to\n"
1543     "     'svn relocate FROM-PREFIX TO-PREFIX [PATH]'.\n"
1544     "\n"
1545     "  See also 'svn help update' for a list of possible characters\n"
1546     "  reporting the action taken.\n"
1547     "\n"
1548     "  Examples:\n"
1549     "    svn switch ^/branches/1.x-release\n"
1550     "    svn switch --relocate http:// svn://\n"
1551     "    svn switch --relocate http://www.example.com/repo/project \\\n"
1552     "                          svn://svn.example.com/repo/project\n"),
1553    { 'r', 'N', opt_depth, opt_set_depth, 'q', opt_merge_cmd, opt_relocate,
1554      opt_ignore_externals, opt_ignore_ancestry, opt_force, opt_accept},
1555    {{opt_ignore_ancestry,
1556      N_("allow switching to a node with no common ancestor")}}
1557  },
1558
1559  { "unlock", svn_cl__unlock, {0}, N_
1560    ("Unlock working copy paths or URLs.\n"
1561     "usage: unlock TARGET...\n"
1562     "\n"
1563     "  Use --force to break the lock.\n"),
1564    { opt_targets, opt_force } },
1565
1566  { "update", svn_cl__update, {"up"},  N_
1567    ("Bring changes from the repository into the working copy.\n"
1568     "usage: update [PATH...]\n"
1569     "\n"
1570     "  If no revision is given, bring working copy up-to-date with HEAD rev.\n"
1571     "  Else synchronize working copy to revision given by -r.\n"
1572     "\n"
1573     "  For each updated item a line will be printed with characters reporting\n"
1574     "  the action taken. These characters have the following meaning:\n"
1575     "\n"
1576     "    A  Added\n"
1577     "    D  Deleted\n"
1578     "    U  Updated\n"
1579     "    C  Conflict\n"
1580     "    G  Merged\n"
1581     "    E  Existed\n"
1582     "    R  Replaced\n"
1583     "\n"
1584     "  Characters in the first column report about the item itself.\n"
1585     "  Characters in the second column report about properties of the item.\n"
1586     "  A 'B' in the third column signifies that the lock for the file has\n"
1587     "  been broken or stolen.\n"
1588     "  A 'C' in the fourth column indicates a tree conflict, while a 'C' in\n"
1589     "  the first and second columns indicate textual conflicts in files\n"
1590     "  and in property values, respectively.\n"
1591     "\n"
1592     "  If --force is used, unversioned obstructing paths in the working\n"
1593     "  copy do not automatically cause a failure if the update attempts to\n"
1594     "  add the same path.  If the obstructing path is the same type (file\n"
1595     "  or directory) as the corresponding path in the repository it becomes\n"
1596     "  versioned but its contents are left 'as-is' in the working copy.\n"
1597     "  This means that an obstructing directory's unversioned children may\n"
1598     "  also obstruct and become versioned.  For files, any content differences\n"
1599     "  between the obstruction and the repository are treated like a local\n"
1600     "  modification to the working copy.  All properties from the repository\n"
1601     "  are applied to the obstructing path.  Obstructing paths are reported\n"
1602     "  in the first column with code 'E'.\n"
1603     "\n"
1604     "  If the specified update target is missing from the working copy but its\n"
1605     "  immediate parent directory is present, checkout the target into its\n"
1606     "  parent directory at the specified depth.  If --parents is specified,\n"
1607     "  create any missing parent directories of the target by checking them\n"
1608     "  out, too, at depth=empty.\n"
1609     "\n"
1610     "  Use the --set-depth option to set a new working copy depth on the\n"
1611     "  targets of this operation.\n"),
1612    {'r', 'N', opt_depth, opt_set_depth, 'q', opt_merge_cmd, opt_force,
1613     opt_ignore_externals, opt_changelist, opt_editor_cmd, opt_accept,
1614     opt_parents} },
1615
1616  { "upgrade", svn_cl__upgrade, {0}, N_
1617    ("Upgrade the metadata storage format for a working copy.\n"
1618     "usage: upgrade [WCPATH...]\n"
1619     "\n"
1620     "  Local modifications are preserved.\n"),
1621    { 'q' } },
1622
1623  { NULL, NULL, {0}, NULL, {0} }
1624};
1625
1626
1627/* Version compatibility check */
1628static svn_error_t *
1629check_lib_versions(void)
1630{
1631  static const svn_version_checklist_t checklist[] =
1632    {
1633      { "svn_subr",   svn_subr_version },
1634      { "svn_client", svn_client_version },
1635      { "svn_wc",     svn_wc_version },
1636      { "svn_ra",     svn_ra_version },
1637      { "svn_delta",  svn_delta_version },
1638      { "svn_diff",   svn_diff_version },
1639      { NULL, NULL }
1640    };
1641  SVN_VERSION_DEFINE(my_version);
1642
1643  return svn_ver_check_list(&my_version, checklist);
1644}
1645
1646
1647/* A flag to see if we've been cancelled by the client or not. */
1648static volatile sig_atomic_t cancelled = FALSE;
1649
1650/* A signal handler to support cancellation. */
1651static void
1652signal_handler(int signum)
1653{
1654  apr_signal(signum, SIG_IGN);
1655  cancelled = TRUE;
1656}
1657
1658/* Our cancellation callback. */
1659svn_error_t *
1660svn_cl__check_cancel(void *baton)
1661{
1662  if (cancelled)
1663    return svn_error_create(SVN_ERR_CANCELLED, NULL, _("Caught signal"));
1664  else
1665    return SVN_NO_ERROR;
1666}
1667
1668/* Add a --search argument to OPT_STATE.
1669 * These options start a new search pattern group. */
1670static void
1671add_search_pattern_group(svn_cl__opt_state_t *opt_state,
1672                         const char *pattern,
1673                         apr_pool_t *result_pool)
1674{
1675  apr_array_header_t *group = NULL;
1676
1677  if (opt_state->search_patterns == NULL)
1678    opt_state->search_patterns = apr_array_make(result_pool, 1,
1679                                                sizeof(apr_array_header_t *));
1680
1681  group = apr_array_make(result_pool, 1, sizeof(const char *));
1682  APR_ARRAY_PUSH(group, const char *) = pattern;
1683  APR_ARRAY_PUSH(opt_state->search_patterns, apr_array_header_t *) = group;
1684}
1685
1686/* Add a --search-and argument to OPT_STATE.
1687 * These patterns are added to an existing pattern group, if any. */
1688static void
1689add_search_pattern_to_latest_group(svn_cl__opt_state_t *opt_state,
1690                                   const char *pattern,
1691                                   apr_pool_t *result_pool)
1692{
1693  apr_array_header_t *group;
1694
1695  if (opt_state->search_patterns == NULL)
1696    {
1697      add_search_pattern_group(opt_state, pattern, result_pool);
1698      return;
1699    }
1700
1701  group = APR_ARRAY_IDX(opt_state->search_patterns,
1702                        opt_state->search_patterns->nelts - 1,
1703                        apr_array_header_t *);
1704  APR_ARRAY_PUSH(group, const char *) = pattern;
1705}
1706
1707
1708/*** Main. ***/
1709
1710/* Report and clear the error ERR, and return EXIT_FAILURE. Suppress the
1711 * error message if it is SVN_ERR_IO_PIPE_WRITE_ERROR. */
1712#define EXIT_ERROR(err)                                                 \
1713  svn_cmdline_handle_exit_error(err, NULL, "svn: ")
1714
1715/* A redefinition of the public SVN_INT_ERR macro, that suppresses the
1716 * error message if it is SVN_ERR_IO_PIPE_WRITE_ERROR. */
1717#undef SVN_INT_ERR
1718#define SVN_INT_ERR(expr)                                        \
1719  do {                                                           \
1720    svn_error_t *svn_err__temp = (expr);                         \
1721    if (svn_err__temp)                                           \
1722      return EXIT_ERROR(svn_err__temp);                          \
1723  } while (0)
1724
1725static int
1726sub_main(int argc, const char *argv[], apr_pool_t *pool)
1727{
1728  svn_error_t *err;
1729  int opt_id;
1730  apr_getopt_t *os;
1731  svn_cl__opt_state_t opt_state = { 0, { 0 } };
1732  svn_client_ctx_t *ctx;
1733  apr_array_header_t *received_opts;
1734  int i;
1735  const svn_opt_subcommand_desc2_t *subcommand = NULL;
1736  const char *dash_m_arg = NULL, *dash_F_arg = NULL;
1737  svn_cl__cmd_baton_t command_baton;
1738  svn_auth_baton_t *ab;
1739  svn_config_t *cfg_config;
1740  svn_boolean_t descend = TRUE;
1741  svn_boolean_t interactive_conflicts = FALSE;
1742  svn_boolean_t force_interactive = FALSE;
1743  svn_cl__conflict_stats_t *conflict_stats
1744    = svn_cl__conflict_stats_create(pool);
1745  svn_boolean_t use_notifier = TRUE;
1746  svn_boolean_t reading_file_from_stdin = FALSE;
1747  apr_hash_t *changelists;
1748  apr_hash_t *cfg_hash;
1749
1750  received_opts = apr_array_make(pool, SVN_OPT_MAX_OPTIONS, sizeof(int));
1751
1752  /* Check library versions */
1753  SVN_INT_ERR(check_lib_versions());
1754
1755#if defined(WIN32) || defined(__CYGWIN__)
1756  /* Set the working copy administrative directory name. */
1757  if (getenv("SVN_ASP_DOT_NET_HACK"))
1758    {
1759      SVN_INT_ERR(svn_wc_set_adm_dir("_svn", pool));
1760    }
1761#endif
1762
1763  /* Initialize the RA library. */
1764  SVN_INT_ERR(svn_ra_initialize(pool));
1765
1766  /* Init our changelists hash. */
1767  changelists = apr_hash_make(pool);
1768
1769  /* Begin processing arguments. */
1770  opt_state.start_revision.kind = svn_opt_revision_unspecified;
1771  opt_state.end_revision.kind = svn_opt_revision_unspecified;
1772  opt_state.revision_ranges =
1773    apr_array_make(pool, 0, sizeof(svn_opt_revision_range_t *));
1774  opt_state.depth = svn_depth_unknown;
1775  opt_state.set_depth = svn_depth_unknown;
1776  opt_state.accept_which = svn_cl__accept_unspecified;
1777  opt_state.show_revs = svn_cl__show_revs_invalid;
1778
1779  /* No args?  Show usage. */
1780  if (argc <= 1)
1781    {
1782      SVN_INT_ERR(svn_cl__help(NULL, NULL, pool));
1783      return EXIT_FAILURE;
1784    }
1785
1786  /* Else, parse options. */
1787  SVN_INT_ERR(svn_cmdline__getopt_init(&os, argc, argv, pool));
1788
1789  os->interleave = 1;
1790  while (1)
1791    {
1792      const char *opt_arg;
1793      const char *utf8_opt_arg;
1794
1795      /* Parse the next option. */
1796      apr_status_t apr_err = apr_getopt_long(os, svn_cl__options, &opt_id,
1797                                             &opt_arg);
1798      if (APR_STATUS_IS_EOF(apr_err))
1799        break;
1800      else if (apr_err)
1801        {
1802          SVN_INT_ERR(svn_cl__help(NULL, NULL, pool));
1803          return EXIT_FAILURE;
1804        }
1805
1806      /* Stash the option code in an array before parsing it. */
1807      APR_ARRAY_PUSH(received_opts, int) = opt_id;
1808
1809      switch (opt_id) {
1810      case 'l':
1811        {
1812          err = svn_cstring_atoi(&opt_state.limit, opt_arg);
1813          if (err)
1814            {
1815              err = svn_error_create(SVN_ERR_CL_ARG_PARSING_ERROR, err,
1816                                     _("Non-numeric limit argument given"));
1817              return EXIT_ERROR(err);
1818            }
1819          if (opt_state.limit <= 0)
1820            {
1821              err = svn_error_create(SVN_ERR_INCORRECT_PARAMS, NULL,
1822                                    _("Argument to --limit must be positive"));
1823              return EXIT_ERROR(err);
1824            }
1825        }
1826        break;
1827      case 'm':
1828        /* Note that there's no way here to detect if the log message
1829           contains a zero byte -- if it does, then opt_arg will just
1830           be shorter than the user intended.  Oh well. */
1831        opt_state.message = apr_pstrdup(pool, opt_arg);
1832        dash_m_arg = opt_arg;
1833        break;
1834      case 'c':
1835        {
1836          apr_array_header_t *change_revs =
1837            svn_cstring_split(opt_arg, ", \n\r\t\v", TRUE, pool);
1838
1839          if (opt_state.old_target)
1840            {
1841              err = svn_error_create
1842                (SVN_ERR_CL_ARG_PARSING_ERROR, NULL,
1843                 _("Can't specify -c with --old"));
1844              return EXIT_ERROR(err);
1845            }
1846
1847          for (i = 0; i < change_revs->nelts; i++)
1848            {
1849              char *end;
1850              svn_revnum_t changeno, changeno_end;
1851              const char *change_str =
1852                APR_ARRAY_IDX(change_revs, i, const char *);
1853              const char *s = change_str;
1854              svn_boolean_t is_negative;
1855
1856              /* Check for a leading minus to allow "-c -r42".
1857               * The is_negative flag is used to handle "-c -42" and "-c -r42".
1858               * The "-c r-42" case is handled by strtol() returning a
1859               * negative number. */
1860              is_negative = (*s == '-');
1861              if (is_negative)
1862                s++;
1863
1864              /* Allow any number of 'r's to prefix a revision number. */
1865              while (*s == 'r')
1866                s++;
1867              changeno = changeno_end = strtol(s, &end, 10);
1868              if (end != s && *end == '-')
1869                {
1870                  if (changeno < 0 || is_negative)
1871                    {
1872                      err = svn_error_createf(SVN_ERR_CL_ARG_PARSING_ERROR,
1873                                              NULL,
1874                                              _("Negative number in range (%s)"
1875                                                " not supported with -c"),
1876                                              change_str);
1877                      return EXIT_ERROR(err);
1878                    }
1879                  s = end + 1;
1880                  while (*s == 'r')
1881                    s++;
1882                  changeno_end = strtol(s, &end, 10);
1883                }
1884              if (end == change_str || *end != '\0')
1885                {
1886                  err = svn_error_createf(SVN_ERR_CL_ARG_PARSING_ERROR, NULL,
1887                                          _("Non-numeric change argument (%s) "
1888                                            "given to -c"), change_str);
1889                  return EXIT_ERROR(err);
1890                }
1891
1892              if (changeno == 0)
1893                {
1894                  err = svn_error_create(SVN_ERR_CL_ARG_PARSING_ERROR, NULL,
1895                                         _("There is no change 0"));
1896                  return EXIT_ERROR(err);
1897                }
1898
1899              if (is_negative)
1900                changeno = -changeno;
1901
1902              /* Figure out the range:
1903                    -c N  -> -r N-1:N
1904                    -c -N -> -r N:N-1
1905                    -c M-N -> -r M-1:N for M < N
1906                    -c M-N -> -r M:N-1 for M > N
1907                    -c -M-N -> error (too confusing/no valid use case)
1908              */
1909              if (changeno > 0)
1910                {
1911                  if (changeno <= changeno_end)
1912                    changeno--;
1913                  else
1914                    changeno_end--;
1915                }
1916              else
1917                {
1918                  changeno = -changeno;
1919                  changeno_end = changeno - 1;
1920                }
1921
1922              opt_state.used_change_arg = TRUE;
1923              APR_ARRAY_PUSH(opt_state.revision_ranges,
1924                             svn_opt_revision_range_t *)
1925                = svn_opt__revision_range_from_revnums(changeno, changeno_end,
1926                                                       pool);
1927            }
1928        }
1929        break;
1930      case 'r':
1931        opt_state.used_revision_arg = TRUE;
1932        if (svn_opt_parse_revision_to_range(opt_state.revision_ranges,
1933                                            opt_arg, pool) != 0)
1934          {
1935            SVN_INT_ERR(svn_utf_cstring_to_utf8(&utf8_opt_arg, opt_arg, pool));
1936            err = svn_error_createf
1937                (SVN_ERR_CL_ARG_PARSING_ERROR, NULL,
1938                 _("Syntax error in revision argument '%s'"),
1939                 utf8_opt_arg);
1940            return EXIT_ERROR(err);
1941          }
1942        break;
1943      case 'v':
1944        opt_state.verbose = TRUE;
1945        break;
1946      case 'u':
1947        opt_state.update = TRUE;
1948        break;
1949      case 'h':
1950      case '?':
1951        opt_state.help = TRUE;
1952        break;
1953      case 'q':
1954        opt_state.quiet = TRUE;
1955        break;
1956      case opt_incremental:
1957        opt_state.incremental = TRUE;
1958        break;
1959      case 'F':
1960        SVN_INT_ERR(svn_utf_cstring_to_utf8(&utf8_opt_arg, opt_arg, pool));
1961        SVN_INT_ERR(svn_stringbuf_from_file2(&(opt_state.filedata),
1962                                             utf8_opt_arg, pool));
1963        reading_file_from_stdin = (strcmp(utf8_opt_arg, "-") == 0);
1964        dash_F_arg = opt_arg;
1965        break;
1966      case opt_targets:
1967        {
1968          svn_stringbuf_t *buffer, *buffer_utf8;
1969
1970          /* We need to convert to UTF-8 now, even before we divide
1971             the targets into an array, because otherwise we wouldn't
1972             know what delimiter to use for svn_cstring_split().  */
1973
1974          SVN_INT_ERR(svn_utf_cstring_to_utf8(&utf8_opt_arg, opt_arg, pool));
1975          SVN_INT_ERR(svn_stringbuf_from_file2(&buffer, utf8_opt_arg, pool));
1976          SVN_INT_ERR(svn_utf_stringbuf_to_utf8(&buffer_utf8, buffer, pool));
1977          opt_state.targets = svn_cstring_split(buffer_utf8->data, "\n\r",
1978                                                TRUE, pool);
1979        }
1980        break;
1981      case opt_force:
1982        opt_state.force = TRUE;
1983        break;
1984      case opt_force_log:
1985        opt_state.force_log = TRUE;
1986        break;
1987      case opt_dry_run:
1988        opt_state.dry_run = TRUE;
1989        break;
1990      case opt_revprop:
1991        opt_state.revprop = TRUE;
1992        break;
1993      case 'R':
1994        opt_state.depth = svn_depth_infinity;
1995        break;
1996      case 'N':
1997        descend = FALSE;
1998        break;
1999      case opt_depth:
2000        err = svn_utf_cstring_to_utf8(&utf8_opt_arg, opt_arg, pool);
2001        if (err)
2002          return EXIT_ERROR
2003            (svn_error_createf(SVN_ERR_CL_ARG_PARSING_ERROR, err,
2004                               _("Error converting depth "
2005                                 "from locale to UTF-8")));
2006        opt_state.depth = svn_depth_from_word(utf8_opt_arg);
2007        if (opt_state.depth == svn_depth_unknown
2008            || opt_state.depth == svn_depth_exclude)
2009          {
2010            return EXIT_ERROR
2011              (svn_error_createf(SVN_ERR_CL_ARG_PARSING_ERROR, NULL,
2012                                 _("'%s' is not a valid depth; try "
2013                                   "'empty', 'files', 'immediates', "
2014                                   "or 'infinity'"),
2015                                 utf8_opt_arg));
2016          }
2017        break;
2018      case opt_set_depth:
2019        err = svn_utf_cstring_to_utf8(&utf8_opt_arg, opt_arg, pool);
2020        if (err)
2021          return EXIT_ERROR
2022            (svn_error_createf(SVN_ERR_CL_ARG_PARSING_ERROR, err,
2023                               _("Error converting depth "
2024                                 "from locale to UTF-8")));
2025        opt_state.set_depth = svn_depth_from_word(utf8_opt_arg);
2026        /* svn_depth_exclude is okay for --set-depth. */
2027        if (opt_state.set_depth == svn_depth_unknown)
2028          {
2029            return EXIT_ERROR
2030              (svn_error_createf(SVN_ERR_CL_ARG_PARSING_ERROR, NULL,
2031                                 _("'%s' is not a valid depth; try "
2032                                   "'exclude', 'empty', 'files', "
2033                                   "'immediates', or 'infinity'"),
2034                                 utf8_opt_arg));
2035          }
2036        break;
2037      case opt_version:
2038        opt_state.version = TRUE;
2039        break;
2040      case opt_auth_username:
2041        SVN_INT_ERR(svn_utf_cstring_to_utf8(&opt_state.auth_username,
2042                                            opt_arg, pool));
2043        break;
2044      case opt_auth_password:
2045        SVN_INT_ERR(svn_utf_cstring_to_utf8(&opt_state.auth_password,
2046                                            opt_arg, pool));
2047        break;
2048      case opt_encoding:
2049        opt_state.encoding = apr_pstrdup(pool, opt_arg);
2050        break;
2051      case opt_xml:
2052        opt_state.xml = TRUE;
2053        break;
2054      case opt_stop_on_copy:
2055        opt_state.stop_on_copy = TRUE;
2056        break;
2057      case opt_strict:
2058        opt_state.strict = TRUE;
2059        break;
2060      case opt_no_ignore:
2061        opt_state.no_ignore = TRUE;
2062        break;
2063      case opt_no_auth_cache:
2064        opt_state.no_auth_cache = TRUE;
2065        break;
2066      case opt_non_interactive:
2067        opt_state.non_interactive = TRUE;
2068        break;
2069      case opt_force_interactive:
2070        force_interactive = TRUE;
2071        break;
2072      case opt_trust_server_cert:
2073        opt_state.trust_server_cert = TRUE;
2074        break;
2075      case opt_no_diff_added:
2076        opt_state.diff.no_diff_added = TRUE;
2077        break;
2078      case opt_no_diff_deleted:
2079        opt_state.diff.no_diff_deleted = TRUE;
2080        break;
2081      case opt_ignore_properties:
2082        opt_state.diff.ignore_properties = TRUE;
2083        break;
2084      case opt_show_copies_as_adds:
2085        opt_state.diff.show_copies_as_adds = TRUE;
2086        break;
2087      case opt_notice_ancestry:
2088        opt_state.diff.notice_ancestry = TRUE;
2089        break;
2090      case opt_ignore_ancestry:
2091        opt_state.ignore_ancestry = TRUE;
2092        break;
2093      case opt_ignore_externals:
2094        opt_state.ignore_externals = TRUE;
2095        break;
2096      case opt_relocate:
2097        opt_state.relocate = TRUE;
2098        break;
2099      case 'x':
2100        SVN_INT_ERR(svn_utf_cstring_to_utf8(&opt_state.extensions,
2101                                            opt_arg, pool));
2102        break;
2103      case opt_diff_cmd:
2104        opt_state.diff.diff_cmd = apr_pstrdup(pool, opt_arg);
2105        break;
2106      case opt_merge_cmd:
2107        opt_state.merge_cmd = apr_pstrdup(pool, opt_arg);
2108        break;
2109      case opt_record_only:
2110        opt_state.record_only = TRUE;
2111        break;
2112      case opt_editor_cmd:
2113        opt_state.editor_cmd = apr_pstrdup(pool, opt_arg);
2114        break;
2115      case opt_old_cmd:
2116        if (opt_state.used_change_arg)
2117          {
2118            err = svn_error_create
2119              (SVN_ERR_CL_ARG_PARSING_ERROR, NULL,
2120               _("Can't specify -c with --old"));
2121            return EXIT_ERROR(err);
2122          }
2123        opt_state.old_target = apr_pstrdup(pool, opt_arg);
2124        break;
2125      case opt_new_cmd:
2126        opt_state.new_target = apr_pstrdup(pool, opt_arg);
2127        break;
2128      case opt_config_dir:
2129        {
2130          const char *path_utf8;
2131          SVN_INT_ERR(svn_utf_cstring_to_utf8(&path_utf8, opt_arg, pool));
2132          opt_state.config_dir = svn_dirent_internal_style(path_utf8, pool);
2133        }
2134        break;
2135      case opt_config_options:
2136        if (!opt_state.config_options)
2137          opt_state.config_options =
2138                   apr_array_make(pool, 1,
2139                                  sizeof(svn_cmdline__config_argument_t*));
2140
2141        SVN_INT_ERR(svn_utf_cstring_to_utf8(&opt_arg, opt_arg, pool));
2142        SVN_INT_ERR(svn_cmdline__parse_config_option(opt_state.config_options,
2143                                                     opt_arg, pool));
2144        break;
2145      case opt_autoprops:
2146        opt_state.autoprops = TRUE;
2147        break;
2148      case opt_no_autoprops:
2149        opt_state.no_autoprops = TRUE;
2150        break;
2151      case opt_native_eol:
2152        if ( !strcmp("LF", opt_arg) || !strcmp("CR", opt_arg) ||
2153             !strcmp("CRLF", opt_arg))
2154          opt_state.native_eol = apr_pstrdup(pool, opt_arg);
2155        else
2156          {
2157            SVN_INT_ERR(svn_utf_cstring_to_utf8(&utf8_opt_arg, opt_arg, pool));
2158            err = svn_error_createf
2159                (SVN_ERR_CL_ARG_PARSING_ERROR, NULL,
2160                 _("Syntax error in native-eol argument '%s'"),
2161                 utf8_opt_arg);
2162            return EXIT_ERROR(err);
2163          }
2164        break;
2165      case opt_no_unlock:
2166        opt_state.no_unlock = TRUE;
2167        break;
2168      case opt_summarize:
2169        opt_state.diff.summarize = TRUE;
2170        break;
2171      case opt_remove:
2172        opt_state.remove = TRUE;
2173        break;
2174      case opt_changelist:
2175        SVN_INT_ERR(svn_utf_cstring_to_utf8(&utf8_opt_arg, opt_arg, pool));
2176        opt_state.changelist = utf8_opt_arg;
2177        if (opt_state.changelist[0] == '\0')
2178          {
2179            err = svn_error_create(SVN_ERR_CL_ARG_PARSING_ERROR, NULL,
2180                                   _("Changelist names must not be empty"));
2181            return EXIT_ERROR(err);
2182          }
2183        svn_hash_sets(changelists, opt_state.changelist, (void *)1);
2184        break;
2185      case opt_keep_changelists:
2186        opt_state.keep_changelists = TRUE;
2187        break;
2188      case opt_keep_local:
2189        opt_state.keep_local = TRUE;
2190        break;
2191      case opt_with_all_revprops:
2192        /* If --with-all-revprops is specified along with one or more
2193         * --with-revprops options, --with-all-revprops takes precedence. */
2194        opt_state.all_revprops = TRUE;
2195        break;
2196      case opt_with_no_revprops:
2197        opt_state.no_revprops = TRUE;
2198        break;
2199      case opt_with_revprop:
2200        SVN_INT_ERR(svn_opt_parse_revprop(&opt_state.revprop_table,
2201                                          opt_arg, pool));
2202        break;
2203      case opt_parents:
2204        opt_state.parents = TRUE;
2205        break;
2206      case 'g':
2207        opt_state.use_merge_history = TRUE;
2208        break;
2209      case opt_accept:
2210        opt_state.accept_which = svn_cl__accept_from_word(opt_arg);
2211        if (opt_state.accept_which == svn_cl__accept_invalid)
2212          return EXIT_ERROR
2213            (svn_error_createf(SVN_ERR_CL_ARG_PARSING_ERROR, NULL,
2214                               _("'%s' is not a valid --accept value"),
2215                               opt_arg));
2216        break;
2217      case opt_show_revs:
2218        opt_state.show_revs = svn_cl__show_revs_from_word(opt_arg);
2219        if (opt_state.show_revs == svn_cl__show_revs_invalid)
2220          return EXIT_ERROR
2221            (svn_error_createf(SVN_ERR_CL_ARG_PARSING_ERROR, NULL,
2222                               _("'%s' is not a valid --show-revs value"),
2223                               opt_arg));
2224        break;
2225      case opt_reintegrate:
2226        opt_state.reintegrate = TRUE;
2227        break;
2228      case opt_strip:
2229        {
2230          err = svn_cstring_atoi(&opt_state.strip, opt_arg);
2231          if (err)
2232            {
2233              err = svn_error_createf(SVN_ERR_CL_ARG_PARSING_ERROR, err,
2234                                      _("Invalid strip count '%s'"), opt_arg);
2235              return EXIT_ERROR(err);
2236            }
2237          if (opt_state.strip < 0)
2238            {
2239              err = svn_error_create(SVN_ERR_INCORRECT_PARAMS, NULL,
2240                                     _("Argument to --strip must be positive"));
2241              return EXIT_ERROR(err);
2242            }
2243        }
2244        break;
2245      case opt_ignore_keywords:
2246        opt_state.ignore_keywords = TRUE;
2247        break;
2248      case opt_reverse_diff:
2249        opt_state.reverse_diff = TRUE;
2250        break;
2251      case opt_ignore_whitespace:
2252          opt_state.ignore_whitespace = TRUE;
2253          break;
2254      case opt_diff:
2255          opt_state.show_diff = TRUE;
2256          break;
2257      case opt_internal_diff:
2258        opt_state.diff.internal_diff = TRUE;
2259        break;
2260      case opt_patch_compatible:
2261        opt_state.diff.patch_compatible = TRUE;
2262        break;
2263      case opt_use_git_diff_format:
2264        opt_state.diff.use_git_diff_format = TRUE;
2265        break;
2266      case opt_allow_mixed_revisions:
2267        opt_state.allow_mixed_rev = TRUE;
2268        break;
2269      case opt_include_externals:
2270        opt_state.include_externals = TRUE;
2271        break;
2272      case opt_show_inherited_props:
2273        opt_state.show_inherited_props = TRUE;
2274        break;
2275      case opt_properties_only:
2276        opt_state.diff.properties_only = TRUE;
2277        break;
2278      case opt_search:
2279        add_search_pattern_group(&opt_state, opt_arg, pool);
2280        break;
2281      case opt_search_and:
2282        add_search_pattern_to_latest_group(&opt_state, opt_arg, pool);
2283      default:
2284        /* Hmmm. Perhaps this would be a good place to squirrel away
2285           opts that commands like svn diff might need. Hmmm indeed. */
2286        break;
2287      }
2288    }
2289
2290  /* The --non-interactive and --force-interactive options are mutually
2291   * exclusive. */
2292  if (opt_state.non_interactive && force_interactive)
2293    {
2294      err = svn_error_create(SVN_ERR_CL_ARG_PARSING_ERROR, NULL,
2295                             _("--non-interactive and --force-interactive "
2296                               "are mutually exclusive"));
2297      return EXIT_ERROR(err);
2298    }
2299  else
2300    opt_state.non_interactive = !svn_cmdline__be_interactive(
2301                                  opt_state.non_interactive,
2302                                  force_interactive);
2303
2304  /* Turn our hash of changelists into an array of unique ones. */
2305  SVN_INT_ERR(svn_hash_keys(&(opt_state.changelists), changelists, pool));
2306
2307  /* ### This really belongs in libsvn_client.  The trouble is,
2308     there's no one place there to run it from, no
2309     svn_client_init().  We'd have to add it to all the public
2310     functions that a client might call.  It's unmaintainable to do
2311     initialization from within libsvn_client itself, but it seems
2312     burdensome to demand that all clients call svn_client_init()
2313     before calling any other libsvn_client function... On the other
2314     hand, the alternative is effectively to demand that they call
2315     svn_config_ensure() instead, so maybe we should have a generic
2316     init function anyway.  Thoughts?  */
2317  SVN_INT_ERR(svn_config_ensure(opt_state.config_dir, pool));
2318
2319  /* If the user asked for help, then the rest of the arguments are
2320     the names of subcommands to get help on (if any), or else they're
2321     just typos/mistakes.  Whatever the case, the subcommand to
2322     actually run is svn_cl__help(). */
2323  if (opt_state.help)
2324    subcommand = svn_opt_get_canonical_subcommand2(svn_cl__cmd_table, "help");
2325
2326  /* If we're not running the `help' subcommand, then look for a
2327     subcommand in the first argument. */
2328  if (subcommand == NULL)
2329    {
2330      if (os->ind >= os->argc)
2331        {
2332          if (opt_state.version)
2333            {
2334              /* Use the "help" subcommand to handle the "--version" option. */
2335              static const svn_opt_subcommand_desc2_t pseudo_cmd =
2336                { "--version", svn_cl__help, {0}, "",
2337                  {opt_version,    /* must accept its own option */
2338                   'q',            /* brief output */
2339                   'v',            /* verbose output */
2340                   opt_config_dir  /* all commands accept this */
2341                  } };
2342
2343              subcommand = &pseudo_cmd;
2344            }
2345          else
2346            {
2347              svn_error_clear
2348                (svn_cmdline_fprintf(stderr, pool,
2349                                     _("Subcommand argument required\n")));
2350              svn_error_clear(svn_cl__help(NULL, NULL, pool));
2351              return EXIT_FAILURE;
2352            }
2353        }
2354      else
2355        {
2356          const char *first_arg = os->argv[os->ind++];
2357          subcommand = svn_opt_get_canonical_subcommand2(svn_cl__cmd_table,
2358                                                         first_arg);
2359          if (subcommand == NULL)
2360            {
2361              const char *first_arg_utf8;
2362              SVN_INT_ERR(svn_utf_cstring_to_utf8(&first_arg_utf8,
2363                                                  first_arg, pool));
2364              svn_error_clear
2365                (svn_cmdline_fprintf(stderr, pool,
2366                                     _("Unknown subcommand: '%s'\n"),
2367                                     first_arg_utf8));
2368              svn_error_clear(svn_cl__help(NULL, NULL, pool));
2369
2370              /* Be kind to people who try 'svn undo'. */
2371              if (strcmp(first_arg_utf8, "undo") == 0)
2372                {
2373                  svn_error_clear
2374                    (svn_cmdline_fprintf(stderr, pool,
2375                                         _("Undo is done using either the "
2376                                           "'svn revert' or the 'svn merge' "
2377                                           "command.\n")));
2378                }
2379
2380              return EXIT_FAILURE;
2381            }
2382        }
2383    }
2384
2385  /* Check that the subcommand wasn't passed any inappropriate options. */
2386  for (i = 0; i < received_opts->nelts; i++)
2387    {
2388      opt_id = APR_ARRAY_IDX(received_opts, i, int);
2389
2390      /* All commands implicitly accept --help, so just skip over this
2391         when we see it. Note that we don't want to include this option
2392         in their "accepted options" list because it would be awfully
2393         redundant to display it in every commands' help text. */
2394      if (opt_id == 'h' || opt_id == '?')
2395        continue;
2396
2397      if (! svn_opt_subcommand_takes_option3(subcommand, opt_id,
2398                                             svn_cl__global_options))
2399        {
2400          const char *optstr;
2401          const apr_getopt_option_t *badopt =
2402            svn_opt_get_option_from_code2(opt_id, svn_cl__options,
2403                                          subcommand, pool);
2404          svn_opt_format_option(&optstr, badopt, FALSE, pool);
2405          if (subcommand->name[0] == '-')
2406            svn_error_clear(svn_cl__help(NULL, NULL, pool));
2407          else
2408            svn_error_clear
2409              (svn_cmdline_fprintf
2410               (stderr, pool, _("Subcommand '%s' doesn't accept option '%s'\n"
2411                                "Type 'svn help %s' for usage.\n"),
2412                subcommand->name, optstr, subcommand->name));
2413          return EXIT_FAILURE;
2414        }
2415    }
2416
2417  /* Only merge and log support multiple revisions/revision ranges. */
2418  if (subcommand->cmd_func != svn_cl__merge
2419      && subcommand->cmd_func != svn_cl__log)
2420    {
2421      if (opt_state.revision_ranges->nelts > 1)
2422        {
2423          err = svn_error_create(SVN_ERR_CL_ARG_PARSING_ERROR, NULL,
2424                                 _("Multiple revision arguments "
2425                                   "encountered; can't specify -c twice, "
2426                                   "or both -c and -r"));
2427          return EXIT_ERROR(err);
2428        }
2429    }
2430
2431  /* Disallow simultaneous use of both --depth and --set-depth. */
2432  if ((opt_state.depth != svn_depth_unknown)
2433      && (opt_state.set_depth != svn_depth_unknown))
2434    {
2435      err = svn_error_create(SVN_ERR_CL_ARG_PARSING_ERROR, NULL,
2436                             _("--depth and --set-depth are mutually "
2437                               "exclusive"));
2438      return EXIT_ERROR(err);
2439    }
2440
2441  /* Disallow simultaneous use of both --with-all-revprops and
2442     --with-no-revprops.  */
2443  if (opt_state.all_revprops && opt_state.no_revprops)
2444    {
2445      err = svn_error_create(SVN_ERR_CL_ARG_PARSING_ERROR, NULL,
2446                             _("--with-all-revprops and --with-no-revprops "
2447                               "are mutually exclusive"));
2448      return EXIT_ERROR(err);
2449    }
2450
2451  /* Disallow simultaneous use of both --with-revprop and
2452     --with-no-revprops.  */
2453  if (opt_state.revprop_table && opt_state.no_revprops)
2454    {
2455      err = svn_error_create(SVN_ERR_CL_ARG_PARSING_ERROR, NULL,
2456                             _("--with-revprop and --with-no-revprops "
2457                               "are mutually exclusive"));
2458      return EXIT_ERROR(err);
2459    }
2460
2461  /* Disallow simultaneous use of both -m and -F, when they are
2462     both used to pass a commit message or lock comment.  ('propset'
2463     takes the property value, not a commit message, from -F.)
2464   */
2465  if (opt_state.filedata && opt_state.message
2466      && subcommand->cmd_func != svn_cl__propset)
2467    {
2468      err = svn_error_create(SVN_ERR_CL_ARG_PARSING_ERROR, NULL,
2469                             _("--message (-m) and --file (-F) "
2470                               "are mutually exclusive"));
2471      return EXIT_ERROR(err);
2472    }
2473
2474  /* --trust-server-cert can only be used with --non-interactive */
2475  if (opt_state.trust_server_cert && !opt_state.non_interactive)
2476    {
2477      err = svn_error_create(SVN_ERR_CL_ARG_PARSING_ERROR, NULL,
2478                             _("--trust-server-cert requires "
2479                               "--non-interactive"));
2480      return EXIT_ERROR(err);
2481    }
2482
2483  /* Disallow simultaneous use of both --diff-cmd and
2484     --internal-diff.  */
2485  if (opt_state.diff.diff_cmd && opt_state.diff.internal_diff)
2486    {
2487      err = svn_error_create(SVN_ERR_CL_ARG_PARSING_ERROR, NULL,
2488                             _("--diff-cmd and --internal-diff "
2489                               "are mutually exclusive"));
2490      return EXIT_ERROR(err);
2491    }
2492
2493  /* Ensure that 'revision_ranges' has at least one item, and make
2494     'start_revision' and 'end_revision' match that item. */
2495  if (opt_state.revision_ranges->nelts == 0)
2496    {
2497      svn_opt_revision_range_t *range = apr_palloc(pool, sizeof(*range));
2498      range->start.kind = svn_opt_revision_unspecified;
2499      range->end.kind = svn_opt_revision_unspecified;
2500      APR_ARRAY_PUSH(opt_state.revision_ranges,
2501                     svn_opt_revision_range_t *) = range;
2502    }
2503  opt_state.start_revision = APR_ARRAY_IDX(opt_state.revision_ranges, 0,
2504                                           svn_opt_revision_range_t *)->start;
2505  opt_state.end_revision = APR_ARRAY_IDX(opt_state.revision_ranges, 0,
2506                                         svn_opt_revision_range_t *)->end;
2507
2508  err = svn_config_get_config(&cfg_hash, opt_state.config_dir, pool);
2509  if (err)
2510    {
2511      /* Fallback to default config if the config directory isn't readable
2512         or is not a directory. */
2513      if (APR_STATUS_IS_EACCES(err->apr_err)
2514          || SVN__APR_STATUS_IS_ENOTDIR(err->apr_err))
2515        {
2516          svn_handle_warning2(stderr, err, "svn: ");
2517          svn_error_clear(err);
2518          cfg_hash = NULL;
2519        }
2520      else
2521        return EXIT_ERROR(err);
2522    }
2523
2524  /* Relocation is infinite-depth only. */
2525  if (opt_state.relocate)
2526    {
2527      if (opt_state.depth != svn_depth_unknown)
2528        {
2529          err = svn_error_create(SVN_ERR_CL_MUTUALLY_EXCLUSIVE_ARGS, NULL,
2530                                 _("--relocate and --depth are mutually "
2531                                   "exclusive"));
2532          return EXIT_ERROR(err);
2533        }
2534      if (! descend)
2535        {
2536          err = svn_error_create(
2537                    SVN_ERR_CL_MUTUALLY_EXCLUSIVE_ARGS, NULL,
2538                    _("--relocate and --non-recursive (-N) are mutually "
2539                      "exclusive"));
2540          return EXIT_ERROR(err);
2541        }
2542    }
2543
2544  /* Only a few commands can accept a revision range; the rest can take at
2545     most one revision number. */
2546  if (subcommand->cmd_func != svn_cl__blame
2547      && subcommand->cmd_func != svn_cl__diff
2548      && subcommand->cmd_func != svn_cl__log
2549      && subcommand->cmd_func != svn_cl__mergeinfo
2550      && subcommand->cmd_func != svn_cl__merge)
2551    {
2552      if (opt_state.end_revision.kind != svn_opt_revision_unspecified)
2553        {
2554          err = svn_error_create(SVN_ERR_CLIENT_REVISION_RANGE, NULL, NULL);
2555          return EXIT_ERROR(err);
2556        }
2557    }
2558
2559  /* -N has a different meaning depending on the command */
2560  if (!descend)
2561    {
2562      if (subcommand->cmd_func == svn_cl__status)
2563        {
2564          opt_state.depth = svn_depth_immediates;
2565        }
2566      else if (subcommand->cmd_func == svn_cl__revert
2567               || subcommand->cmd_func == svn_cl__add
2568               || subcommand->cmd_func == svn_cl__commit)
2569        {
2570          /* In pre-1.5 Subversion, some commands treated -N like
2571             --depth=empty, so force that mapping here.  Anyway, with
2572             revert it makes sense to be especially conservative,
2573             since revert can lose data. */
2574          opt_state.depth = svn_depth_empty;
2575        }
2576      else
2577        {
2578          opt_state.depth = svn_depth_files;
2579        }
2580    }
2581
2582  cfg_config = svn_hash_gets(cfg_hash, SVN_CONFIG_CATEGORY_CONFIG);
2583
2584  /* Update the options in the config */
2585  if (opt_state.config_options)
2586    {
2587      svn_error_clear(
2588          svn_cmdline__apply_config_options(cfg_hash,
2589                                            opt_state.config_options,
2590                                            "svn: ", "--config-option"));
2591    }
2592
2593#if !defined(SVN_CL_NO_EXCLUSIVE_LOCK)
2594  {
2595    const char *exclusive_clients_option;
2596    apr_array_header_t *exclusive_clients;
2597
2598    svn_config_get(cfg_config, &exclusive_clients_option,
2599                   SVN_CONFIG_SECTION_WORKING_COPY,
2600                   SVN_CONFIG_OPTION_SQLITE_EXCLUSIVE_CLIENTS,
2601                   NULL);
2602    exclusive_clients = svn_cstring_split(exclusive_clients_option,
2603                                          " ,", TRUE, pool);
2604    for (i = 0; i < exclusive_clients->nelts; ++i)
2605      {
2606        const char *exclusive_client = APR_ARRAY_IDX(exclusive_clients, i,
2607                                                     const char *);
2608
2609        /* This blocks other clients from accessing the wc.db so it must
2610           be explicitly enabled.*/
2611        if (!strcmp(exclusive_client, "svn"))
2612          svn_config_set(cfg_config,
2613                         SVN_CONFIG_SECTION_WORKING_COPY,
2614                         SVN_CONFIG_OPTION_SQLITE_EXCLUSIVE,
2615                         "true");
2616      }
2617  }
2618#endif
2619
2620  /* Create a client context object. */
2621  command_baton.opt_state = &opt_state;
2622  SVN_INT_ERR(svn_client_create_context2(&ctx, cfg_hash, pool));
2623  command_baton.ctx = ctx;
2624
2625  /* If we're running a command that could result in a commit, verify
2626     that any log message we were given on the command line makes
2627     sense (unless we've also been instructed not to care).  This may
2628     access the working copy so do it after setting the locking mode. */
2629  if ((! opt_state.force_log)
2630      && (subcommand->cmd_func == svn_cl__commit
2631          || subcommand->cmd_func == svn_cl__copy
2632          || subcommand->cmd_func == svn_cl__delete
2633          || subcommand->cmd_func == svn_cl__import
2634          || subcommand->cmd_func == svn_cl__mkdir
2635          || subcommand->cmd_func == svn_cl__move
2636          || subcommand->cmd_func == svn_cl__lock
2637          || subcommand->cmd_func == svn_cl__propedit))
2638    {
2639      /* If the -F argument is a file that's under revision control,
2640         that's probably not what the user intended. */
2641      if (dash_F_arg)
2642        {
2643          svn_node_kind_t kind;
2644          const char *local_abspath;
2645          const char *fname_utf8 = svn_dirent_internal_style(dash_F_arg, pool);
2646
2647          err = svn_dirent_get_absolute(&local_abspath, fname_utf8, pool);
2648
2649          if (!err)
2650            {
2651              err = svn_wc_read_kind2(&kind, ctx->wc_ctx, local_abspath, TRUE,
2652                                      FALSE, pool);
2653
2654              if (!err && kind != svn_node_none && kind != svn_node_unknown)
2655                {
2656                  if (subcommand->cmd_func != svn_cl__lock)
2657                    {
2658                      err = svn_error_create(
2659                         SVN_ERR_CL_LOG_MESSAGE_IS_VERSIONED_FILE, NULL,
2660                         _("Log message file is a versioned file; "
2661                           "use '--force-log' to override"));
2662                    }
2663                  else
2664                    {
2665                      err = svn_error_create(
2666                         SVN_ERR_CL_LOG_MESSAGE_IS_VERSIONED_FILE, NULL,
2667                         _("Lock comment file is a versioned file; "
2668                           "use '--force-log' to override"));
2669                    }
2670                  return EXIT_ERROR(err);
2671                }
2672            }
2673          svn_error_clear(err);
2674        }
2675
2676      /* If the -m argument is a file at all, that's probably not what
2677         the user intended. */
2678      if (dash_m_arg)
2679        {
2680          apr_finfo_t finfo;
2681          if (apr_stat(&finfo, dash_m_arg,
2682                       APR_FINFO_MIN, pool) == APR_SUCCESS)
2683            {
2684              if (subcommand->cmd_func != svn_cl__lock)
2685                {
2686                  err = svn_error_create
2687                    (SVN_ERR_CL_LOG_MESSAGE_IS_PATHNAME, NULL,
2688                     _("The log message is a pathname "
2689                       "(was -F intended?); use '--force-log' to override"));
2690                }
2691              else
2692                {
2693                  err = svn_error_create
2694                    (SVN_ERR_CL_LOG_MESSAGE_IS_PATHNAME, NULL,
2695                     _("The lock comment is a pathname "
2696                       "(was -F intended?); use '--force-log' to override"));
2697                }
2698              return EXIT_ERROR(err);
2699            }
2700        }
2701    }
2702
2703  /* XXX: Only diff_cmd for now, overlay rest later and stop passing
2704     opt_state altogether? */
2705  if (opt_state.diff.diff_cmd)
2706    svn_config_set(cfg_config, SVN_CONFIG_SECTION_HELPERS,
2707                   SVN_CONFIG_OPTION_DIFF_CMD, opt_state.diff.diff_cmd);
2708  if (opt_state.merge_cmd)
2709    svn_config_set(cfg_config, SVN_CONFIG_SECTION_HELPERS,
2710                   SVN_CONFIG_OPTION_DIFF3_CMD, opt_state.merge_cmd);
2711  if (opt_state.diff.internal_diff)
2712    svn_config_set(cfg_config, SVN_CONFIG_SECTION_HELPERS,
2713                   SVN_CONFIG_OPTION_DIFF_CMD, NULL);
2714
2715  /* Check for mutually exclusive args --auto-props and --no-auto-props */
2716  if (opt_state.autoprops && opt_state.no_autoprops)
2717    {
2718      err = svn_error_create(SVN_ERR_CL_MUTUALLY_EXCLUSIVE_ARGS, NULL,
2719                             _("--auto-props and --no-auto-props are "
2720                               "mutually exclusive"));
2721      return EXIT_ERROR(err);
2722    }
2723
2724  /* Update auto-props-enable option, and populate the MIME types map,
2725     for add/import commands */
2726  if (subcommand->cmd_func == svn_cl__add
2727      || subcommand->cmd_func == svn_cl__import)
2728    {
2729      const char *mimetypes_file;
2730      svn_config_get(cfg_config, &mimetypes_file,
2731                     SVN_CONFIG_SECTION_MISCELLANY,
2732                     SVN_CONFIG_OPTION_MIMETYPES_FILE, FALSE);
2733      if (mimetypes_file && *mimetypes_file)
2734        {
2735          SVN_INT_ERR(svn_io_parse_mimetypes_file(&(ctx->mimetypes_map),
2736                                                  mimetypes_file, pool));
2737        }
2738
2739      if (opt_state.autoprops)
2740        {
2741          svn_config_set_bool(cfg_config, SVN_CONFIG_SECTION_MISCELLANY,
2742                              SVN_CONFIG_OPTION_ENABLE_AUTO_PROPS, TRUE);
2743        }
2744      if (opt_state.no_autoprops)
2745        {
2746          svn_config_set_bool(cfg_config, SVN_CONFIG_SECTION_MISCELLANY,
2747                              SVN_CONFIG_OPTION_ENABLE_AUTO_PROPS, FALSE);
2748        }
2749    }
2750
2751  /* Update the 'keep-locks' runtime option */
2752  if (opt_state.no_unlock)
2753    svn_config_set_bool(cfg_config, SVN_CONFIG_SECTION_MISCELLANY,
2754                        SVN_CONFIG_OPTION_NO_UNLOCK, TRUE);
2755
2756  /* Set the log message callback function.  Note that individual
2757     subcommands will populate the ctx->log_msg_baton3. */
2758  ctx->log_msg_func3 = svn_cl__get_log_message;
2759
2760  /* Set up the notifier.
2761
2762     In general, we use it any time we aren't in --quiet mode.  'svn
2763     status' is unique, though, in that we don't want it in --quiet mode
2764     unless we're also in --verbose mode.  When in --xml mode,
2765     though, we never want it.  */
2766  if (opt_state.quiet)
2767    use_notifier = FALSE;
2768  if ((subcommand->cmd_func == svn_cl__status) && opt_state.verbose)
2769    use_notifier = TRUE;
2770  if (opt_state.xml)
2771    use_notifier = FALSE;
2772  if (use_notifier)
2773    {
2774      SVN_INT_ERR(svn_cl__get_notifier(&ctx->notify_func2, &ctx->notify_baton2,
2775                                       conflict_stats, pool));
2776    }
2777
2778  /* Set up our cancellation support. */
2779  ctx->cancel_func = svn_cl__check_cancel;
2780  apr_signal(SIGINT, signal_handler);
2781#ifdef SIGBREAK
2782  /* SIGBREAK is a Win32 specific signal generated by ctrl-break. */
2783  apr_signal(SIGBREAK, signal_handler);
2784#endif
2785#ifdef SIGHUP
2786  apr_signal(SIGHUP, signal_handler);
2787#endif
2788#ifdef SIGTERM
2789  apr_signal(SIGTERM, signal_handler);
2790#endif
2791
2792#ifdef SIGPIPE
2793  /* Disable SIGPIPE generation for the platforms that have it. */
2794  apr_signal(SIGPIPE, SIG_IGN);
2795#endif
2796
2797#ifdef SIGXFSZ
2798  /* Disable SIGXFSZ generation for the platforms that have it, otherwise
2799   * working with large files when compiled against an APR that doesn't have
2800   * large file support will crash the program, which is uncool. */
2801  apr_signal(SIGXFSZ, SIG_IGN);
2802#endif
2803
2804  /* Set up Authentication stuff. */
2805  SVN_INT_ERR(svn_cmdline_create_auth_baton(&ab,
2806                                            opt_state.non_interactive,
2807                                            opt_state.auth_username,
2808                                            opt_state.auth_password,
2809                                            opt_state.config_dir,
2810                                            opt_state.no_auth_cache,
2811                                            opt_state.trust_server_cert,
2812                                            cfg_config,
2813                                            ctx->cancel_func,
2814                                            ctx->cancel_baton,
2815                                            pool));
2816
2817  ctx->auth_baton = ab;
2818
2819  if (opt_state.non_interactive)
2820    {
2821      if (opt_state.accept_which == svn_cl__accept_edit)
2822        return EXIT_ERROR(
2823                 svn_error_createf(SVN_ERR_CL_ARG_PARSING_ERROR, NULL,
2824                                   _("--accept=%s incompatible with"
2825                                     " --non-interactive"),
2826                                   SVN_CL__ACCEPT_EDIT));
2827
2828      if (opt_state.accept_which == svn_cl__accept_launch)
2829        return EXIT_ERROR(
2830                 svn_error_createf(SVN_ERR_CL_ARG_PARSING_ERROR, NULL,
2831                                   _("--accept=%s incompatible with"
2832                                     " --non-interactive"),
2833                                   SVN_CL__ACCEPT_LAUNCH));
2834
2835      /* The default action when we're non-interactive is to postpone
2836       * conflict resolution. */
2837      if (opt_state.accept_which == svn_cl__accept_unspecified)
2838        opt_state.accept_which = svn_cl__accept_postpone;
2839    }
2840
2841  /* Check whether interactive conflict resolution is disabled by
2842   * the configuration file. If no --accept option was specified
2843   * we postpone all conflicts in this case. */
2844  SVN_INT_ERR(svn_config_get_bool(cfg_config, &interactive_conflicts,
2845                                  SVN_CONFIG_SECTION_MISCELLANY,
2846                                  SVN_CONFIG_OPTION_INTERACTIVE_CONFLICTS,
2847                                  TRUE));
2848  if (!interactive_conflicts)
2849    {
2850      /* Make 'svn resolve' non-interactive. */
2851      if (subcommand->cmd_func == svn_cl__resolve)
2852        opt_state.non_interactive = TRUE;
2853
2854      /* We're not resolving conflicts interactively. If no --accept option
2855       * was provided the default behaviour is to postpone all conflicts. */
2856      if (opt_state.accept_which == svn_cl__accept_unspecified)
2857        opt_state.accept_which = svn_cl__accept_postpone;
2858    }
2859
2860  /* Install the default conflict handler. */
2861  {
2862    svn_cl__interactive_conflict_baton_t *b;
2863
2864    ctx->conflict_func = NULL;
2865    ctx->conflict_baton = NULL;
2866
2867    ctx->conflict_func2 = svn_cl__conflict_func_interactive;
2868    SVN_INT_ERR(svn_cl__get_conflict_func_interactive_baton(
2869                &b,
2870                opt_state.accept_which,
2871                ctx->config, opt_state.editor_cmd, conflict_stats,
2872                ctx->cancel_func, ctx->cancel_baton, pool));
2873    ctx->conflict_baton2 = b;
2874  }
2875
2876  /* And now we finally run the subcommand. */
2877  err = (*subcommand->cmd_func)(os, &command_baton, pool);
2878  if (err)
2879    {
2880      /* For argument-related problems, suggest using the 'help'
2881         subcommand. */
2882      if (err->apr_err == SVN_ERR_CL_INSUFFICIENT_ARGS
2883          || err->apr_err == SVN_ERR_CL_ARG_PARSING_ERROR)
2884        {
2885          err = svn_error_quick_wrap(
2886                  err, apr_psprintf(pool,
2887                                    _("Try 'svn help %s' for more information"),
2888                                    subcommand->name));
2889        }
2890      if (err->apr_err == SVN_ERR_WC_UPGRADE_REQUIRED)
2891        {
2892          err = svn_error_quick_wrap(err,
2893                                     _("Please see the 'svn upgrade' command"));
2894        }
2895
2896      if (err->apr_err == SVN_ERR_AUTHN_FAILED && opt_state.non_interactive)
2897        {
2898          err = svn_error_quick_wrap(err,
2899                                     _("Authentication failed and interactive"
2900                                       " prompting is disabled; see the"
2901                                       " --force-interactive option"));
2902          if (reading_file_from_stdin)
2903            err = svn_error_quick_wrap(err,
2904                                       _("Reading file from standard input "
2905                                         "because of -F option; this can "
2906                                         "interfere with interactive "
2907                                         "prompting"));
2908        }
2909
2910      /* Tell the user about 'svn cleanup' if any error on the stack
2911         was about locked working copies. */
2912      if (svn_error_find_cause(err, SVN_ERR_WC_LOCKED))
2913        {
2914          err = svn_error_quick_wrap(
2915                  err, _("Run 'svn cleanup' to remove locks "
2916                         "(type 'svn help cleanup' for details)"));
2917        }
2918
2919      if (err->apr_err == SVN_ERR_SQLITE_BUSY)
2920        {
2921          err = svn_error_quick_wrap(err,
2922                                     _("Another process is blocking the "
2923                                       "working copy database, or the "
2924                                       "underlying filesystem does not "
2925                                       "support file locking; if the working "
2926                                       "copy is on a network filesystem, make "
2927                                       "sure file locking has been enabled "
2928                                       "on the file server"));
2929        }
2930
2931      if (svn_error_find_cause(err, SVN_ERR_RA_CANNOT_CREATE_TUNNEL) &&
2932          (opt_state.auth_username || opt_state.auth_password))
2933        {
2934          err = svn_error_quick_wrap(
2935                  err, _("When using svn+ssh:// URLs, keep in mind that the "
2936                         "--username and --password options are ignored "
2937                         "because authentication is performed by SSH, not "
2938                         "Subversion"));
2939        }
2940
2941      return EXIT_ERROR(err);
2942    }
2943  else
2944    {
2945      /* Ensure that stdout is flushed, so the user will see any write errors.
2946         This makes sure that output is not silently lost. */
2947      SVN_INT_ERR(svn_cmdline_fflush(stdout));
2948
2949      return EXIT_SUCCESS;
2950    }
2951}
2952
2953int
2954main(int argc, const char *argv[])
2955{
2956  apr_pool_t *pool;
2957  int exit_code;
2958
2959  /* Initialize the app. */
2960  if (svn_cmdline_init("svn", stderr) != EXIT_SUCCESS)
2961    return EXIT_FAILURE;
2962
2963  /* Create our top-level pool.  Use a separate mutexless allocator,
2964   * given this application is single threaded.
2965   */
2966  pool = apr_allocator_owner_get(svn_pool_create_allocator(FALSE));
2967
2968  exit_code = sub_main(argc, argv, pool);
2969
2970  svn_pool_destroy(pool);
2971  return exit_code;
2972}
2973