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