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