1251881Speter/*
2251881Speter * svn.c:  Subversion command line client main file.
3251881Speter *
4251881Speter * ====================================================================
5251881Speter *    Licensed to the Apache Software Foundation (ASF) under one
6251881Speter *    or more contributor license agreements.  See the NOTICE file
7251881Speter *    distributed with this work for additional information
8251881Speter *    regarding copyright ownership.  The ASF licenses this file
9251881Speter *    to you under the Apache License, Version 2.0 (the
10251881Speter *    "License"); you may not use this file except in compliance
11251881Speter *    with the License.  You may obtain a copy of the License at
12251881Speter *
13251881Speter *      http://www.apache.org/licenses/LICENSE-2.0
14251881Speter *
15251881Speter *    Unless required by applicable law or agreed to in writing,
16251881Speter *    software distributed under the License is distributed on an
17251881Speter *    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
18251881Speter *    KIND, either express or implied.  See the License for the
19251881Speter *    specific language governing permissions and limitations
20251881Speter *    under the License.
21251881Speter * ====================================================================
22251881Speter */
23251881Speter
24251881Speter/* ==================================================================== */
25251881Speter
26251881Speter
27251881Speter
28251881Speter/*** Includes. ***/
29251881Speter
30251881Speter#include <string.h>
31251881Speter#include <assert.h>
32251881Speter
33251881Speter#include <apr_strings.h>
34251881Speter#include <apr_tables.h>
35251881Speter#include <apr_general.h>
36251881Speter#include <apr_signal.h>
37251881Speter
38251881Speter#include "svn_cmdline.h"
39251881Speter#include "svn_pools.h"
40251881Speter#include "svn_wc.h"
41251881Speter#include "svn_client.h"
42251881Speter#include "svn_config.h"
43251881Speter#include "svn_string.h"
44251881Speter#include "svn_dirent_uri.h"
45251881Speter#include "svn_path.h"
46251881Speter#include "svn_delta.h"
47251881Speter#include "svn_diff.h"
48251881Speter#include "svn_error.h"
49251881Speter#include "svn_io.h"
50251881Speter#include "svn_opt.h"
51251881Speter#include "svn_utf.h"
52251881Speter#include "svn_auth.h"
53251881Speter#include "svn_hash.h"
54251881Speter#include "svn_version.h"
55251881Speter#include "cl.h"
56251881Speter
57251881Speter#include "private/svn_opt_private.h"
58251881Speter#include "private/svn_cmdline_private.h"
59262253Speter#include "private/svn_subr_private.h"
60251881Speter
61251881Speter#include "svn_private_config.h"
62251881Speter
63251881Speter
64251881Speter/*** Option Processing ***/
65251881Speter
66251881Speter/* Add an identifier here for long options that don't have a short
67251881Speter   option. Options that have both long and short options should just
68251881Speter   use the short option letter as identifier.  */
69251881Spetertypedef enum svn_cl__longopt_t {
70251881Speter  opt_auth_password = SVN_OPT_FIRST_LONGOPT_ID,
71251881Speter  opt_auth_username,
72251881Speter  opt_autoprops,
73251881Speter  opt_changelist,
74251881Speter  opt_config_dir,
75251881Speter  opt_config_options,
76251881Speter  /* diff options */
77251881Speter  opt_diff_cmd,
78251881Speter  opt_internal_diff,
79251881Speter  opt_no_diff_added,
80251881Speter  opt_no_diff_deleted,
81251881Speter  opt_show_copies_as_adds,
82251881Speter  opt_notice_ancestry,
83251881Speter  opt_summarize,
84251881Speter  opt_use_git_diff_format,
85251881Speter  opt_ignore_properties,
86251881Speter  opt_properties_only,
87251881Speter  opt_patch_compatible,
88251881Speter  /* end of diff options */
89251881Speter  opt_dry_run,
90251881Speter  opt_editor_cmd,
91251881Speter  opt_encoding,
92251881Speter  opt_force_log,
93251881Speter  opt_force,
94251881Speter  opt_keep_changelists,
95251881Speter  opt_ignore_ancestry,
96251881Speter  opt_ignore_externals,
97251881Speter  opt_incremental,
98251881Speter  opt_merge_cmd,
99251881Speter  opt_native_eol,
100251881Speter  opt_new_cmd,
101251881Speter  opt_no_auth_cache,
102251881Speter  opt_no_autoprops,
103251881Speter  opt_no_ignore,
104251881Speter  opt_no_unlock,
105251881Speter  opt_non_interactive,
106251881Speter  opt_force_interactive,
107251881Speter  opt_old_cmd,
108251881Speter  opt_record_only,
109251881Speter  opt_relocate,
110251881Speter  opt_remove,
111251881Speter  opt_revprop,
112251881Speter  opt_stop_on_copy,
113299742Sdim  opt_strict,                   /* ### DEPRECATED */
114251881Speter  opt_targets,
115251881Speter  opt_depth,
116251881Speter  opt_set_depth,
117251881Speter  opt_version,
118251881Speter  opt_xml,
119251881Speter  opt_keep_local,
120251881Speter  opt_with_revprop,
121251881Speter  opt_with_all_revprops,
122251881Speter  opt_with_no_revprops,
123251881Speter  opt_parents,
124251881Speter  opt_accept,
125251881Speter  opt_show_revs,
126251881Speter  opt_reintegrate,
127251881Speter  opt_trust_server_cert,
128299742Sdim  opt_trust_server_cert_failures,
129251881Speter  opt_strip,
130251881Speter  opt_ignore_keywords,
131251881Speter  opt_reverse_diff,
132251881Speter  opt_ignore_whitespace,
133251881Speter  opt_diff,
134251881Speter  opt_allow_mixed_revisions,
135251881Speter  opt_include_externals,
136251881Speter  opt_show_inherited_props,
137251881Speter  opt_search,
138299742Sdim  opt_search_and,
139299742Sdim  opt_mergeinfo_log,
140299742Sdim  opt_remove_unversioned,
141299742Sdim  opt_remove_ignored,
142299742Sdim  opt_no_newline,
143299742Sdim  opt_show_passwords,
144299742Sdim  opt_pin_externals,
145299742Sdim  opt_show_item,
146251881Speter} svn_cl__longopt_t;
147251881Speter
148251881Speter
149251881Speter/* Option codes and descriptions for the command line client.
150251881Speter *
151251881Speter * The entire list must be terminated with an entry of nulls.
152251881Speter */
153251881Speterconst apr_getopt_option_t svn_cl__options[] =
154251881Speter{
155251881Speter  {"force",         opt_force, 0, N_("force operation to run")},
156251881Speter  {"force-log",     opt_force_log, 0,
157251881Speter                    N_("force validity of log message source")},
158251881Speter  {"help",          'h', 0, N_("show help on a subcommand")},
159251881Speter  {NULL,            '?', 0, N_("show help on a subcommand")},
160251881Speter  {"message",       'm', 1, N_("specify log message ARG")},
161251881Speter  {"quiet",         'q', 0, N_("print nothing, or only summary information")},
162251881Speter  {"recursive",     'R', 0, N_("descend recursively, same as --depth=infinity")},
163251881Speter  {"non-recursive", 'N', 0, N_("obsolete; try --depth=files or --depth=immediates")},
164251881Speter  {"change",        'c', 1,
165251881Speter                    N_("the change made by revision ARG (like -r ARG-1:ARG)\n"
166251881Speter                       "                             "
167251881Speter                       "If ARG is negative this is like -r ARG:ARG-1\n"
168251881Speter                       "                             "
169251881Speter                       "If ARG is of the form ARG1-ARG2 then this is like\n"
170251881Speter                       "                             "
171251881Speter                       "ARG1:ARG2, where ARG1 is inclusive")},
172251881Speter  {"revision",      'r', 1,
173251881Speter                    N_("ARG (some commands also take ARG1:ARG2 range)\n"
174251881Speter                       "                             "
175251881Speter                       "A revision argument can be one of:\n"
176251881Speter                       "                             "
177251881Speter                       "   NUMBER       revision number\n"
178251881Speter                       "                             "
179251881Speter                       "   '{' DATE '}' revision at start of the date\n"
180251881Speter                       "                             "
181251881Speter                       "   'HEAD'       latest in repository\n"
182251881Speter                       "                             "
183251881Speter                       "   'BASE'       base rev of item's working copy\n"
184251881Speter                       "                             "
185251881Speter                       "   'COMMITTED'  last commit at or before BASE\n"
186251881Speter                       "                             "
187251881Speter                       "   'PREV'       revision just before COMMITTED")},
188251881Speter  {"file",          'F', 1, N_("read log message from file ARG")},
189251881Speter  {"incremental",   opt_incremental, 0,
190251881Speter                    N_("give output suitable for concatenation")},
191251881Speter  {"encoding",      opt_encoding, 1,
192251881Speter                    N_("treat value as being in charset encoding ARG")},
193251881Speter  {"version",       opt_version, 0, N_("show program version information")},
194251881Speter  {"verbose",       'v', 0, N_("print extra information")},
195251881Speter  {"show-updates",  'u', 0, N_("display update information")},
196251881Speter  {"username",      opt_auth_username, 1, N_("specify a username ARG")},
197299742Sdim  {"password",      opt_auth_password, 1,
198299742Sdim                    N_("specify a password ARG (caution: on many operating\n"
199299742Sdim                       "                             "
200299742Sdim                       "systems, other users will be able to see this)")},
201251881Speter  {"extensions",    'x', 1,
202251881Speter                    N_("Specify differencing options for external diff or\n"
203251881Speter                       "                             "
204251881Speter                       "internal diff or blame. Default: '-u'. Options are\n"
205251881Speter                       "                             "
206251881Speter                       "separated by spaces. Internal diff and blame take:\n"
207251881Speter                       "                             "
208251881Speter                       "  -u, --unified: Show 3 lines of unified context\n"
209251881Speter                       "                             "
210251881Speter                       "  -b, --ignore-space-change: Ignore changes in\n"
211251881Speter                       "                             "
212251881Speter                       "    amount of white space\n"
213251881Speter                       "                             "
214251881Speter                       "  -w, --ignore-all-space: Ignore all white space\n"
215251881Speter                       "                             "
216251881Speter                       "  --ignore-eol-style: Ignore changes in EOL style\n"
217251881Speter                       "                             "
218299742Sdim                       "  -U ARG, --context ARG: Show ARG lines of context\n"
219299742Sdim                       "                             "
220251881Speter                       "  -p, --show-c-function: Show C function name")},
221251881Speter  {"targets",       opt_targets, 1,
222251881Speter                    N_("pass contents of file ARG as additional args")},
223251881Speter  {"depth",         opt_depth, 1,
224251881Speter                    N_("limit operation by depth ARG ('empty', 'files',\n"
225251881Speter                       "                             "
226251881Speter                       "'immediates', or 'infinity')")},
227251881Speter  {"set-depth",     opt_set_depth, 1,
228251881Speter                    N_("set new working copy depth to ARG ('exclude',\n"
229251881Speter                       "                             "
230251881Speter                       "'empty', 'files', 'immediates', or 'infinity')")},
231251881Speter  {"xml",           opt_xml, 0, N_("output in XML")},
232299742Sdim  {"strict",        opt_strict, 0, N_("DEPRECATED")},
233251881Speter  {"stop-on-copy",  opt_stop_on_copy, 0,
234251881Speter                    N_("do not cross copies while traversing history")},
235251881Speter  {"no-ignore",     opt_no_ignore, 0,
236251881Speter                    N_("disregard default and svn:ignore and\n"
237251881Speter                       "                             "
238251881Speter                       "svn:global-ignores property ignores")},
239251881Speter  {"no-auth-cache", opt_no_auth_cache, 0,
240251881Speter                    N_("do not cache authentication tokens")},
241251881Speter  {"trust-server-cert", opt_trust_server_cert, 0,
242299742Sdim                    N_("deprecated; same as\n"
243251881Speter                       "                             "
244299742Sdim                       "--trust-server-cert-failures=unknown-ca")},
245299742Sdim  {"trust-server-cert-failures", opt_trust_server_cert_failures, 1,
246299742Sdim                    N_("with --non-interactive, accept SSL server\n"
247251881Speter                       "                             "
248299742Sdim                       "certificates with failures; ARG is comma-separated\n"
249299742Sdim                       "                             "
250299742Sdim                       "list of 'unknown-ca' (Unknown Authority),\n"
251299742Sdim                       "                             "
252299742Sdim                       "'cn-mismatch' (Hostname mismatch), 'expired'\n"
253299742Sdim                       "                             "
254299742Sdim                       "(Expired certificate), 'not-yet-valid' (Not yet\n"
255299742Sdim                       "                             "
256299742Sdim                       "valid certificate) and 'other' (all other not\n"
257299742Sdim                       "                             "
258299742Sdim                       "separately classified certificate errors).")},
259251881Speter  {"non-interactive", opt_non_interactive, 0,
260251881Speter                    N_("do no interactive prompting (default is to prompt\n"
261251881Speter                       "                             "
262251881Speter                       "only if standard input is a terminal device)")},
263251881Speter  {"force-interactive", opt_force_interactive, 0,
264251881Speter                    N_("do interactive prompting even if standard input\n"
265251881Speter                       "                             "
266251881Speter                       "is not a terminal device")},
267251881Speter  {"dry-run",       opt_dry_run, 0,
268251881Speter                    N_("try operation but make no changes")},
269251881Speter  {"ignore-ancestry", opt_ignore_ancestry, 0,
270251881Speter                    N_("disable merge tracking; diff nodes as if related")},
271251881Speter  {"ignore-externals", opt_ignore_externals, 0,
272251881Speter                    N_("ignore externals definitions")},
273251881Speter  {"diff3-cmd",     opt_merge_cmd, 1, N_("use ARG as merge command")},
274251881Speter  {"editor-cmd",    opt_editor_cmd, 1, N_("use ARG as external editor")},
275251881Speter  {"record-only",   opt_record_only, 0,
276251881Speter                    N_("merge only mergeinfo differences")},
277251881Speter  {"old",           opt_old_cmd, 1, N_("use ARG as the older target")},
278251881Speter  {"new",           opt_new_cmd, 1, N_("use ARG as the newer target")},
279251881Speter  {"revprop",       opt_revprop, 0,
280251881Speter                    N_("operate on a revision property (use with -r)")},
281251881Speter  {"relocate",      opt_relocate, 0, N_("relocate via URL-rewriting")},
282251881Speter  {"config-dir",    opt_config_dir, 1,
283251881Speter                    N_("read user configuration files from directory ARG")},
284251881Speter  {"config-option", opt_config_options, 1,
285251881Speter                    N_("set user configuration option in the format:\n"
286251881Speter                       "                             "
287251881Speter                       "    FILE:SECTION:OPTION=[VALUE]\n"
288251881Speter                       "                             "
289251881Speter                       "For example:\n"
290251881Speter                       "                             "
291251881Speter                       "    servers:global:http-library=serf")},
292251881Speter  {"auto-props",    opt_autoprops, 0, N_("enable automatic properties")},
293251881Speter  {"no-auto-props", opt_no_autoprops, 0, N_("disable automatic properties")},
294251881Speter  {"native-eol",    opt_native_eol, 1,
295251881Speter                    N_("use a different EOL marker than the standard\n"
296251881Speter                       "                             "
297251881Speter                       "system marker for files with the svn:eol-style\n"
298251881Speter                       "                             "
299251881Speter                       "property set to 'native'.\n"
300251881Speter                       "                             "
301251881Speter                       "ARG may be one of 'LF', 'CR', 'CRLF'")},
302251881Speter  {"limit",         'l', 1, N_("maximum number of log entries")},
303251881Speter  {"no-unlock",     opt_no_unlock, 0, N_("don't unlock the targets")},
304251881Speter  {"remove",         opt_remove, 0, N_("remove changelist association")},
305251881Speter  {"changelist",    opt_changelist, 1,
306251881Speter                    N_("operate only on members of changelist ARG")},
307251881Speter  {"keep-changelists", opt_keep_changelists, 0,
308251881Speter                    N_("don't delete changelists after commit")},
309251881Speter  {"keep-local",    opt_keep_local, 0, N_("keep path in working copy")},
310251881Speter  {"with-all-revprops",  opt_with_all_revprops, 0,
311251881Speter                    N_("retrieve all revision properties")},
312251881Speter  {"with-no-revprops",  opt_with_no_revprops, 0,
313251881Speter                    N_("retrieve no revision properties")},
314251881Speter  {"with-revprop",  opt_with_revprop, 1,
315251881Speter                    N_("set revision property ARG in new revision\n"
316251881Speter                       "                             "
317251881Speter                       "using the name[=value] format")},
318251881Speter  {"parents",       opt_parents, 0, N_("make intermediate directories")},
319251881Speter  {"use-merge-history", 'g', 0,
320251881Speter                    N_("use/display additional information from merge\n"
321251881Speter                       "                             "
322251881Speter                       "history")},
323251881Speter  {"accept",        opt_accept, 1,
324251881Speter                    N_("specify automatic conflict resolution action\n"
325251881Speter                       "                             "
326251881Speter                       "('postpone', 'working', 'base', 'mine-conflict',\n"
327251881Speter                       "                             "
328251881Speter                       "'theirs-conflict', 'mine-full', 'theirs-full',\n"
329251881Speter                       "                             "
330251881Speter                       "'edit', 'launch')\n"
331251881Speter                       "                             "
332251881Speter                       "(shorthand: 'p', 'mc', 'tc', 'mf', 'tf', 'e', 'l')"
333251881Speter                       )},
334251881Speter  {"show-revs",     opt_show_revs, 1,
335251881Speter                    N_("specify which collection of revisions to display\n"
336251881Speter                       "                             "
337251881Speter                       "('merged', 'eligible')")},
338251881Speter  {"reintegrate",   opt_reintegrate, 0,
339251881Speter                    N_("deprecated")},
340251881Speter  {"strip",         opt_strip, 1,
341251881Speter                    N_("number of leading path components to strip from\n"
342251881Speter                       "                             "
343251881Speter                       "paths parsed from the patch file. --strip 0\n"
344251881Speter                       "                             "
345251881Speter                       "is the default and leaves paths unmodified.\n"
346251881Speter                       "                             "
347251881Speter                       "--strip 1 would change the path\n"
348251881Speter                       "                             "
349251881Speter                       "'doc/fudge/crunchy.html' to 'fudge/crunchy.html'.\n"
350251881Speter                       "                             "
351251881Speter                       "--strip 2 would leave just 'crunchy.html'\n"
352251881Speter                       "                             "
353251881Speter                       "The expected component separator is '/' on all\n"
354251881Speter                       "                             "
355251881Speter                       "platforms. A leading '/' counts as one component.")},
356251881Speter  {"ignore-keywords", opt_ignore_keywords, 0,
357251881Speter                    N_("don't expand keywords")},
358251881Speter  {"reverse-diff", opt_reverse_diff, 0,
359251881Speter                    N_("apply the unidiff in reverse")},
360251881Speter  {"ignore-whitespace", opt_ignore_whitespace, 0,
361251881Speter                       N_("ignore whitespace during pattern matching")},
362251881Speter  {"diff", opt_diff, 0, N_("produce diff output")}, /* maps to show_diff */
363251881Speter  /* diff options */
364251881Speter  {"diff-cmd",      opt_diff_cmd, 1, N_("use ARG as diff command")},
365251881Speter  {"internal-diff", opt_internal_diff, 0,
366251881Speter                       N_("override diff-cmd specified in config file")},
367251881Speter  {"no-diff-added", opt_no_diff_added, 0,
368251881Speter                    N_("do not print differences for added files")},
369251881Speter  {"no-diff-deleted", opt_no_diff_deleted, 0,
370251881Speter                    N_("do not print differences for deleted files")},
371251881Speter  {"show-copies-as-adds", opt_show_copies_as_adds, 0,
372251881Speter                    N_("don't diff copied or moved files with their source")},
373251881Speter  {"notice-ancestry", opt_notice_ancestry, 0,
374251881Speter                    N_("diff unrelated nodes as delete and add")},
375251881Speter  {"summarize",     opt_summarize, 0, N_("show a summary of the results")},
376251881Speter  {"git", opt_use_git_diff_format, 0,
377251881Speter                       N_("use git's extended diff format")},
378251881Speter  {"ignore-properties", opt_ignore_properties, 0,
379251881Speter                    N_("ignore properties during the operation")},
380251881Speter  {"properties-only", opt_properties_only, 0,
381251881Speter                       N_("show only properties during the operation")},
382251881Speter  {"patch-compatible", opt_patch_compatible, 0,
383251881Speter                       N_("generate diff suitable for generic third-party\n"
384251881Speter                       "                             "
385251881Speter                       "patch tools; currently the same as\n"
386251881Speter                       "                             "
387251881Speter                       "--show-copies-as-adds --ignore-properties"
388251881Speter                       )},
389251881Speter  /* end of diff options */
390251881Speter  {"allow-mixed-revisions", opt_allow_mixed_revisions, 0,
391251881Speter                       N_("Allow operation on mixed-revision working copy.\n"
392251881Speter                       "                             "
393251881Speter                       "Use of this option is not recommended!\n"
394251881Speter                       "                             "
395251881Speter                       "Please run 'svn update' instead.")},
396251881Speter  {"include-externals", opt_include_externals, 0,
397299742Sdim                       N_("also operate on externals defined by\n"
398251881Speter                       "                             "
399299742Sdim                       "svn:externals properties")},
400251881Speter  {"show-inherited-props", opt_show_inherited_props, 0,
401299742Sdim                       N_("retrieve properties set on parents of the target")},
402251881Speter  {"search", opt_search, 1,
403251881Speter                       N_("use ARG as search pattern (glob syntax)")},
404251881Speter  {"search-and", opt_search_and, 1,
405251881Speter                       N_("combine ARG with the previous search pattern")},
406299742Sdim  {"log", opt_mergeinfo_log, 0,
407299742Sdim                       N_("show revision log message, author and date")},
408299742Sdim  {"remove-unversioned", opt_remove_unversioned, 0,
409299742Sdim                       N_("remove unversioned items")},
410299742Sdim  {"remove-ignored", opt_remove_ignored, 0, N_("remove ignored items")},
411299742Sdim  {"no-newline", opt_no_newline, 0, N_("do not output the trailing newline")},
412299742Sdim  {"show-passwords", opt_show_passwords, 0, N_("show cached passwords")},
413299742Sdim  {"pin-externals", opt_pin_externals, 0,
414299742Sdim                       N_("pin externals with no explicit revision to their\n"
415299742Sdim                          "                             "
416299742Sdim                          "current revision (recommended when tagging)")},
417299742Sdim  {"show-item", opt_show_item, 1,
418299742Sdim                       N_("print only the item identified by ARG ('kind',\n"
419299742Sdim                       "                             "
420299742Sdim                       "'url', 'relative-url', 'repos-root-url',\n"
421299742Sdim                       "                             "
422299742Sdim                       "'repos-uuid', 'revision', 'last-changed-revision',\n"
423299742Sdim                       "                             "
424299742Sdim                       "'last-changed-date', 'last-changed-author',\n"
425299742Sdim                       "                             "
426299742Sdim                       "'wc-root')")},
427251881Speter
428251881Speter  /* Long-opt Aliases
429251881Speter   *
430251881Speter   * These have NULL desriptions, but an option code that matches some
431251881Speter   * other option (whose description should probably mention its aliases).
432251881Speter  */
433251881Speter
434251881Speter  {"cl",            opt_changelist, 1, NULL},
435251881Speter
436251881Speter  {0,               0, 0, 0},
437251881Speter};
438251881Speter
439251881Speter
440251881Speter
441251881Speter/*** Command dispatch. ***/
442251881Speter
443251881Speter/* Our array of available subcommands.
444251881Speter *
445251881Speter * The entire list must be terminated with an entry of nulls.
446251881Speter *
447251881Speter * In most of the help text "PATH" is used where a working copy path is
448251881Speter * required, "URL" where a repository URL is required and "TARGET" when
449251881Speter * either a path or a url can be used.  Hmm, should this be part of the
450251881Speter * help text?
451251881Speter */
452251881Speter
453251881Speter/* Options that apply to all commands.  (While not every command may
454251881Speter   currently require authentication or be interactive, allowing every
455251881Speter   command to take these arguments allows scripts to just pass them
456251881Speter   willy-nilly to every invocation of 'svn') . */
457251881Speterconst int svn_cl__global_options[] =
458251881Speter{ opt_auth_username, opt_auth_password, opt_no_auth_cache, opt_non_interactive,
459299742Sdim  opt_force_interactive, opt_trust_server_cert,
460299742Sdim  opt_trust_server_cert_failures,
461299742Sdim  opt_config_dir, opt_config_options, 0
462251881Speter};
463251881Speter
464251881Speter/* Options for giving a log message.  (Some of these also have other uses.)
465251881Speter */
466251881Speter#define SVN_CL__LOG_MSG_OPTIONS 'm', 'F', \
467251881Speter                                opt_force_log, \
468251881Speter                                opt_editor_cmd, \
469251881Speter                                opt_encoding, \
470251881Speter                                opt_with_revprop
471251881Speter
472251881Speterconst svn_opt_subcommand_desc2_t svn_cl__cmd_table[] =
473251881Speter{
474251881Speter  { "add", svn_cl__add, {0}, N_
475251881Speter    ("Put files and directories under version control, scheduling\n"
476251881Speter     "them for addition to repository.  They will be added in next commit.\n"
477251881Speter     "usage: add PATH...\n"),
478251881Speter    {opt_targets, 'N', opt_depth, 'q', opt_force, opt_no_ignore, opt_autoprops,
479251881Speter     opt_no_autoprops, opt_parents },
480251881Speter     {{opt_parents, N_("add intermediate parents")}} },
481251881Speter
482299742Sdim  { "auth", svn_cl__auth, {0}, N_
483299742Sdim   ("Manage cached authentication credentials.\n"
484299742Sdim    "usage: 1. svn auth [PATTERN ...]\n"
485299742Sdim    "usage: 2. svn auth --remove PATTERN [PATTERN ...]\n"
486299742Sdim    "\n"
487299742Sdim    "  With no arguments, list all cached authentication credentials.\n"
488299742Sdim    "  Authentication credentials include usernames, passwords,\n"
489299742Sdim    "  SSL certificates, and SSL client-certificate passphrases.\n"
490299742Sdim    "  If PATTERN is specified, only list credentials with attributes matching one\n"
491299742Sdim    "  or more patterns. With the --remove option, remove cached authentication\n"
492299742Sdim    "  credentials matching one or more patterns.\n"
493299742Sdim    "\n"
494299742Sdim    "  If more than one pattern is specified credentials are considered only they\n"
495299742Sdim    "  match all specified patterns. Patterns are matched case-sensitively and may\n"
496299742Sdim    "  contain glob wildcards:\n"
497299742Sdim    "    ?      matches any single character\n"
498299742Sdim    "    *      matches a sequence of arbitrary characters\n"
499299742Sdim    "    [abc]  matches any of the characters listed inside the brackets\n"
500299742Sdim    "  Note that wildcards will usually need to be quoted or escaped on the\n"
501299742Sdim    "  command line because many command shells will interfere by trying to\n"
502299742Sdim    "  expand them.\n"),
503299742Sdim    { opt_remove, opt_show_passwords },
504299742Sdim    { {opt_remove, N_("remove matching authentication credentials")} }
505299742Sdim
506299742Sdim    },
507299742Sdim
508251881Speter  { "blame", svn_cl__blame, {"praise", "annotate", "ann"}, N_
509299742Sdim    ("Show when each line of a file was last (or\n"
510299742Sdim     "next) changed.\n"
511299742Sdim     "usage: blame [-rM:N] TARGET[@REV]...\n"
512251881Speter     "\n"
513299742Sdim     "  Annotate each line of a file with the revision number and author of the\n"
514299742Sdim     "  last change (or optionally the next change) to that line.\n"
515299742Sdim     "\n"
516299742Sdim     "  With no revision range (same as -r0:REV), or with '-r M:N' where M < N,\n"
517299742Sdim     "  annotate each line that is present in revision N of the file, with\n"
518299742Sdim     "  the last revision at or before rN that changed or added the line,\n"
519299742Sdim     "  looking back no further than rM.\n"
520299742Sdim     "\n"
521299742Sdim     "  With a reverse revision range '-r M:N' where M > N,\n"
522299742Sdim     "  annotate each line that is present in revision N of the file, with\n"
523299742Sdim     "  the next revision after rN that changed or deleted the line,\n"
524299742Sdim     "  looking forward no further than rM.\n"
525299742Sdim     "\n"
526251881Speter     "  If specified, REV determines in which revision the target is first\n"
527299742Sdim     "  looked up.\n"
528299742Sdim     "\n"
529299742Sdim     "  Write the annotated result to standard output.\n"),
530251881Speter    {'r', 'v', 'g', opt_incremental, opt_xml, 'x', opt_force} },
531251881Speter
532251881Speter  { "cat", svn_cl__cat, {0}, N_
533251881Speter    ("Output the content of specified files or URLs.\n"
534251881Speter     "usage: cat TARGET[@REV]...\n"
535251881Speter     "\n"
536251881Speter     "  If specified, REV determines in which revision the target is first\n"
537251881Speter     "  looked up.\n"),
538299742Sdim    {'r', opt_ignore_keywords} },
539251881Speter
540251881Speter  { "changelist", svn_cl__changelist, {"cl"}, N_
541251881Speter    ("Associate (or dissociate) changelist CLNAME with the named files.\n"
542251881Speter     "usage: 1. changelist CLNAME PATH...\n"
543251881Speter     "       2. changelist --remove PATH...\n"),
544251881Speter    { 'q', 'R', opt_depth, opt_remove, opt_targets, opt_changelist} },
545251881Speter
546251881Speter  { "checkout", svn_cl__checkout, {"co"}, N_
547251881Speter    ("Check out a working copy from a repository.\n"
548251881Speter     "usage: checkout URL[@REV]... [PATH]\n"
549251881Speter     "\n"
550251881Speter     "  If specified, REV determines in which revision the URL is first\n"
551251881Speter     "  looked up.\n"
552251881Speter     "\n"
553251881Speter     "  If PATH is omitted, the basename of the URL will be used as\n"
554251881Speter     "  the destination. If multiple URLs are given each will be checked\n"
555251881Speter     "  out into a sub-directory of PATH, with the name of the sub-directory\n"
556251881Speter     "  being the basename of the URL.\n"
557251881Speter     "\n"
558251881Speter     "  If --force is used, unversioned obstructing paths in the working\n"
559251881Speter     "  copy destination do not automatically cause the check out to fail.\n"
560251881Speter     "  If the obstructing path is the same type (file or directory) as the\n"
561251881Speter     "  corresponding path in the repository it becomes versioned but its\n"
562251881Speter     "  contents are left 'as-is' in the working copy.  This means that an\n"
563251881Speter     "  obstructing directory's unversioned children may also obstruct and\n"
564251881Speter     "  become versioned.  For files, any content differences between the\n"
565251881Speter     "  obstruction and the repository are treated like a local modification\n"
566251881Speter     "  to the working copy.  All properties from the repository are applied\n"
567251881Speter     "  to the obstructing path.\n"
568251881Speter     "\n"
569251881Speter     "  See also 'svn help update' for a list of possible characters\n"
570251881Speter     "  reporting the action taken.\n"),
571251881Speter    {'r', 'q', 'N', opt_depth, opt_force, opt_ignore_externals} },
572251881Speter
573251881Speter  { "cleanup", svn_cl__cleanup, {0}, N_
574253734Speter    ("Recursively clean up the working copy, removing write locks, resuming\n"
575251881Speter     "unfinished operations, etc.\n"
576253734Speter     "usage: cleanup [WCPATH...]\n"
577253734Speter     "\n"
578299742Sdim     "  By default, finish any unfinished business in the working copy at WCPATH,\n"
579299742Sdim     "  and remove write locks (shown as 'L' by the 'svn status' command) from\n"
580299742Sdim     "  the working copy. Usually, this is only necessary if a Subversion client\n"
581299742Sdim     "  has crashed while using the working copy, leaving it in an unusable state.\n"
582253734Speter     "\n"
583253734Speter     "  WARNING: There is no mechanism that will protect write locks still\n"
584253734Speter     "           being used by other Subversion clients. Running this command\n"
585253734Speter     "           while another client is using the working copy can corrupt\n"
586299742Sdim     "           the working copy beyond repair!\n"
587299742Sdim     "\n"
588299742Sdim     "  If the --remove-unversioned option or the --remove-ignored option\n"
589299742Sdim     "  is given, remove any unversioned or ignored items within WCPATH.\n"
590299742Sdim     "  To prevent accidental working copy corruption, unversioned or ignored\n"
591299742Sdim     "  items can only be removed if the working copy is not already locked\n"
592299742Sdim     "  for writing by another Subversion client.\n"
593299742Sdim     "  Note that the 'svn status' command shows unversioned items as '?',\n"
594299742Sdim     "  and ignored items as 'I' if the --no-ignore option is given to it.\n"),
595299742Sdim    {opt_merge_cmd, opt_remove_unversioned, opt_remove_ignored,
596299742Sdim     opt_include_externals, 'q'} },
597251881Speter
598251881Speter  { "commit", svn_cl__commit, {"ci"},
599251881Speter    N_("Send changes from your working copy to the repository.\n"
600251881Speter       "usage: commit [PATH...]\n"
601251881Speter       "\n"
602251881Speter       "  A log message must be provided, but it can be empty.  If it is not\n"
603251881Speter       "  given by a --message or --file option, an editor will be started.\n"
604251881Speter       "  If any targets are (or contain) locked items, those will be\n"
605299742Sdim       "  unlocked after a successful commit.\n"
606299742Sdim       "\n"
607299742Sdim       "  If --include-externals is given, also commit file and directory\n"
608299742Sdim       "  externals reached by recursion. Do not commit externals with a\n"
609299742Sdim       "  fixed revision.\n"),
610251881Speter    {'q', 'N', opt_depth, opt_targets, opt_no_unlock, SVN_CL__LOG_MSG_OPTIONS,
611251881Speter     opt_changelist, opt_keep_changelists, opt_include_externals} },
612251881Speter
613251881Speter  { "copy", svn_cl__copy, {"cp"}, N_
614251881Speter    ("Copy files and directories in a working copy or repository.\n"
615251881Speter     "usage: copy SRC[@REV]... DST\n"
616251881Speter     "\n"
617251881Speter     "  SRC and DST can each be either a working copy (WC) path or URL:\n"
618251881Speter     "    WC  -> WC:   copy and schedule for addition (with history)\n"
619251881Speter     "    WC  -> URL:  immediately commit a copy of WC to URL\n"
620251881Speter     "    URL -> WC:   check out URL into WC, schedule for addition\n"
621251881Speter     "    URL -> URL:  complete server-side copy;  used to branch and tag\n"
622251881Speter     "  All the SRCs must be of the same type. When copying multiple sources,\n"
623251881Speter     "  they will be added as children of DST, which must be a directory.\n"
624251881Speter     "\n"
625251881Speter     "  WARNING: For compatibility with previous versions of Subversion,\n"
626251881Speter     "  copies performed using two working copy paths (WC -> WC) will not\n"
627251881Speter     "  contact the repository.  As such, they may not, by default, be able\n"
628251881Speter     "  to propagate merge tracking information from the source of the copy\n"
629251881Speter     "  to the destination.\n"),
630299742Sdim    {'r', 'q', opt_ignore_externals, opt_parents, SVN_CL__LOG_MSG_OPTIONS,
631299742Sdim     opt_pin_externals} },
632251881Speter
633251881Speter  { "delete", svn_cl__delete, {"del", "remove", "rm"}, N_
634251881Speter    ("Remove files and directories from version control.\n"
635251881Speter     "usage: 1. delete PATH...\n"
636251881Speter     "       2. delete URL...\n"
637251881Speter     "\n"
638251881Speter     "  1. Each item specified by a PATH is scheduled for deletion upon\n"
639251881Speter     "    the next commit.  Files, and directories that have not been\n"
640251881Speter     "    committed, are immediately removed from the working copy\n"
641251881Speter     "    unless the --keep-local option is given.\n"
642251881Speter     "    PATHs that are, or contain, unversioned or modified items will\n"
643251881Speter     "    not be removed unless the --force or --keep-local option is given.\n"
644251881Speter     "\n"
645251881Speter     "  2. Each item specified by a URL is deleted from the repository\n"
646251881Speter     "    via an immediate commit.\n"),
647251881Speter    {opt_force, 'q', opt_targets, SVN_CL__LOG_MSG_OPTIONS, opt_keep_local} },
648251881Speter
649251881Speter  { "diff", svn_cl__diff, {"di"}, N_
650251881Speter    ("Display local changes or differences between two revisions or paths.\n"
651251881Speter     "usage: 1. diff\n"
652251881Speter     "       2. diff [-c M | -r N[:M]] [TARGET[@REV]...]\n"
653251881Speter     "       3. diff [-r N[:M]] --old=OLD-TGT[@OLDREV] [--new=NEW-TGT[@NEWREV]] \\\n"
654251881Speter     "               [PATH...]\n"
655251881Speter     "       4. diff OLD-URL[@OLDREV] NEW-URL[@NEWREV]\n"
656251881Speter     "       5. diff OLD-URL[@OLDREV] NEW-PATH[@NEWREV]\n"
657251881Speter     "       6. diff OLD-PATH[@OLDREV] NEW-URL[@NEWREV]\n"
658251881Speter     "\n"
659251881Speter     "  1. Use just 'svn diff' to display local modifications in a working copy.\n"
660251881Speter     "\n"
661251881Speter     "  2. Display the changes made to TARGETs as they are seen in REV between\n"
662251881Speter     "     two revisions.  TARGETs may be all working copy paths or all URLs.\n"
663251881Speter     "     If TARGETs are working copy paths, N defaults to BASE and M to the\n"
664251881Speter     "     working copy; if URLs, N must be specified and M defaults to HEAD.\n"
665251881Speter     "     The '-c M' option is equivalent to '-r N:M' where N = M-1.\n"
666251881Speter     "     Using '-c -M' does the reverse: '-r M:N' where N = M-1.\n"
667251881Speter     "\n"
668251881Speter     "  3. Display the differences between OLD-TGT as it was seen in OLDREV and\n"
669251881Speter     "     NEW-TGT as it was seen in NEWREV.  PATHs, if given, are relative to\n"
670251881Speter     "     OLD-TGT and NEW-TGT and restrict the output to differences for those\n"
671251881Speter     "     paths.  OLD-TGT and NEW-TGT may be working copy paths or URL[@REV].\n"
672251881Speter     "     NEW-TGT defaults to OLD-TGT if not specified.  -r N makes OLDREV default\n"
673251881Speter     "     to N, -r N:M makes OLDREV default to N and NEWREV default to M.\n"
674251881Speter     "     If OLDREV or NEWREV are not specified, they default to WORKING for\n"
675251881Speter     "     working copy targets and to HEAD for URL targets.\n"
676251881Speter     "\n"
677251881Speter     "     Either or both OLD-TGT and NEW-TGT may also be paths to unversioned\n"
678251881Speter     "     targets. Revisions cannot be specified for unversioned targets.\n"
679251881Speter     "     Both targets must be of the same node kind (file or directory).\n"
680251881Speter     "     Diffing unversioned targets against URL targets is not supported.\n"
681251881Speter     "\n"
682251881Speter     "  4. Shorthand for 'svn diff --old=OLD-URL[@OLDREV] --new=NEW-URL[@NEWREV]'\n"
683251881Speter     "  5. Shorthand for 'svn diff --old=OLD-URL[@OLDREV] --new=NEW-PATH[@NEWREV]'\n"
684251881Speter     "  6. Shorthand for 'svn diff --old=OLD-PATH[@OLDREV] --new=NEW-URL[@NEWREV]'\n"),
685251881Speter    {'r', 'c', opt_old_cmd, opt_new_cmd, 'N', opt_depth, opt_diff_cmd,
686251881Speter     opt_internal_diff, 'x', opt_no_diff_added, opt_no_diff_deleted,
687251881Speter     opt_ignore_properties, opt_properties_only,
688251881Speter     opt_show_copies_as_adds, opt_notice_ancestry, opt_summarize, opt_changelist,
689251881Speter     opt_force, opt_xml, opt_use_git_diff_format, opt_patch_compatible} },
690251881Speter  { "export", svn_cl__export, {0}, N_
691251881Speter    ("Create an unversioned copy of a tree.\n"
692251881Speter     "usage: 1. export [-r REV] URL[@PEGREV] [PATH]\n"
693251881Speter     "       2. export [-r REV] PATH1[@PEGREV] [PATH2]\n"
694251881Speter     "\n"
695251881Speter     "  1. Exports a clean directory tree from the repository specified by\n"
696251881Speter     "     URL, at revision REV if it is given, otherwise at HEAD, into\n"
697251881Speter     "     PATH. If PATH is omitted, the last component of the URL is used\n"
698251881Speter     "     for the local directory name.\n"
699251881Speter     "\n"
700251881Speter     "  2. Exports a clean directory tree from the working copy specified by\n"
701251881Speter     "     PATH1, at revision REV if it is given, otherwise at WORKING, into\n"
702251881Speter     "     PATH2.  If PATH2 is omitted, the last component of the PATH1 is used\n"
703251881Speter     "     for the local directory name. If REV is not specified, all local\n"
704251881Speter     "     changes will be preserved.  Files not under version control will\n"
705251881Speter     "     not be copied.\n"
706251881Speter     "\n"
707251881Speter     "  If specified, PEGREV determines in which revision the target is first\n"
708251881Speter     "  looked up.\n"),
709251881Speter    {'r', 'q', 'N', opt_depth, opt_force, opt_native_eol, opt_ignore_externals,
710251881Speter     opt_ignore_keywords} },
711251881Speter
712251881Speter  { "help", svn_cl__help, {"?", "h"}, N_
713251881Speter    ("Describe the usage of this program or its subcommands.\n"
714251881Speter     "usage: help [SUBCOMMAND...]\n"),
715251881Speter    {0} },
716251881Speter  /* This command is also invoked if we see option "--help", "-h" or "-?". */
717251881Speter
718251881Speter  { "import", svn_cl__import, {0}, N_
719251881Speter    ("Commit an unversioned file or tree into the repository.\n"
720251881Speter     "usage: import [PATH] URL\n"
721251881Speter     "\n"
722251881Speter     "  Recursively commit a copy of PATH to URL.\n"
723251881Speter     "  If PATH is omitted '.' is assumed.\n"
724251881Speter     "  Parent directories are created as necessary in the repository.\n"
725251881Speter     "  If PATH is a directory, the contents of the directory are added\n"
726251881Speter     "  directly under URL.\n"
727251881Speter     "  Unversionable items such as device files and pipes are ignored\n"
728251881Speter     "  if --force is specified.\n"),
729251881Speter    {'q', 'N', opt_depth, opt_autoprops, opt_force, opt_no_autoprops,
730251881Speter     SVN_CL__LOG_MSG_OPTIONS, opt_no_ignore} },
731251881Speter
732251881Speter  { "info", svn_cl__info, {0}, N_
733251881Speter    ("Display information about a local or remote item.\n"
734251881Speter     "usage: info [TARGET[@REV]...]\n"
735251881Speter     "\n"
736251881Speter     "  Print information about each TARGET (default: '.').\n"
737251881Speter     "  TARGET may be either a working-copy path or URL.  If specified, REV\n"
738299742Sdim     "  determines in which revision the target is first looked up.\n"
739299742Sdim     "\n"
740299742Sdim     "  With --show-item, print only the value of one item of information\n"
741299742Sdim     "  about TARGET. One of the following items can be selected:\n"
742299742Sdim     "     kind                  the kind of TARGET\n"
743299742Sdim     "     url                   the URL of TARGET in the repository\n"
744299742Sdim     "     relative-url          the repository-relative URL\n"
745299742Sdim     "     repos-root-url        the repository root URL\n"
746299742Sdim     "     repos-uuid            the repository UUID\n"
747299742Sdim     "     revision              the revision of TARGET (defaults to BASE\n"
748299742Sdim     "                           for working copy paths and HEAD for URLs)\n"
749299742Sdim     "     last-changed-revision the most recent revision in which TARGET\n"
750299742Sdim     "                           was changed\n"
751299742Sdim     "     last-changed-date     the date of the last-changed revision\n"
752299742Sdim     "     last-changed-author   the author of the last-changed revision\n"
753299742Sdim     "     wc-root               the root of TARGET's working copy\n"),
754299742Sdim    {'r', 'R', opt_depth, opt_targets, opt_incremental, opt_xml,
755299742Sdim     opt_changelist, opt_include_externals, opt_show_item, opt_no_newline}
756251881Speter  },
757251881Speter
758251881Speter  { "list", svn_cl__list, {"ls"}, N_
759251881Speter    ("List directory entries in the repository.\n"
760251881Speter     "usage: list [TARGET[@REV]...]\n"
761251881Speter     "\n"
762251881Speter     "  List each TARGET file and the contents of each TARGET directory as\n"
763251881Speter     "  they exist in the repository.  If TARGET is a working copy path, the\n"
764251881Speter     "  corresponding repository URL will be used. If specified, REV determines\n"
765251881Speter     "  in which revision the target is first looked up.\n"
766251881Speter     "\n"
767251881Speter     "  The default TARGET is '.', meaning the repository URL of the current\n"
768251881Speter     "  working directory.\n"
769251881Speter     "\n"
770251881Speter     "  With --verbose, the following fields will be shown for each item:\n"
771251881Speter     "\n"
772251881Speter     "    Revision number of the last commit\n"
773251881Speter     "    Author of the last commit\n"
774251881Speter     "    If locked, the letter 'O'.  (Use 'svn info URL' to see details)\n"
775251881Speter     "    Size (in bytes)\n"
776251881Speter     "    Date and time of the last commit\n"),
777251881Speter    {'r', 'v', 'R', opt_depth, opt_incremental, opt_xml,
778299742Sdim     opt_include_externals}, },
779251881Speter
780251881Speter  { "lock", svn_cl__lock, {0}, N_
781251881Speter    ("Lock working copy paths or URLs in the repository, so that\n"
782251881Speter     "no other user can commit changes to them.\n"
783251881Speter     "usage: lock TARGET...\n"
784251881Speter     "\n"
785251881Speter     "  Use --force to steal the lock from another user or working copy.\n"),
786251881Speter    { opt_targets, 'm', 'F', opt_force_log, opt_encoding, opt_force },
787251881Speter    {{'F', N_("read lock comment from file ARG")},
788251881Speter     {'m', N_("specify lock comment ARG")},
789251881Speter     {opt_force_log, N_("force validity of lock comment source")}} },
790251881Speter
791251881Speter  { "log", svn_cl__log, {0}, N_
792251881Speter    ("Show the log messages for a set of revision(s) and/or path(s).\n"
793251881Speter     "usage: 1. log [PATH][@REV]\n"
794251881Speter     "       2. log URL[@REV] [PATH...]\n"
795251881Speter     "\n"
796251881Speter     "  1. Print the log messages for the URL corresponding to PATH\n"
797251881Speter     "     (default: '.'). If specified, REV is the revision in which the\n"
798251881Speter     "     URL is first looked up, and the default revision range is REV:1.\n"
799251881Speter     "     If REV is not specified, the default revision range is BASE:1,\n"
800251881Speter     "     since the URL might not exist in the HEAD revision.\n"
801251881Speter     "\n"
802251881Speter     "  2. Print the log messages for the PATHs (default: '.') under URL.\n"
803251881Speter     "     If specified, REV is the revision in which the URL is first\n"
804251881Speter     "     looked up, and the default revision range is REV:1; otherwise,\n"
805251881Speter     "     the URL is looked up in HEAD, and the default revision range is\n"
806251881Speter     "     HEAD:1.\n"
807251881Speter     "\n"
808251881Speter     "  Multiple '-c' or '-r' options may be specified (but not a\n"
809251881Speter     "  combination of '-c' and '-r' options), and mixing of forward and\n"
810251881Speter     "  reverse ranges is allowed.\n"
811251881Speter     "\n"
812251881Speter     "  With -v, also print all affected paths with each log message.\n"
813251881Speter     "  With -q, don't print the log message body itself (note that this is\n"
814251881Speter     "  compatible with -v).\n"
815251881Speter     "\n"
816251881Speter     "  Each log message is printed just once, even if more than one of the\n"
817251881Speter     "  affected paths for that revision were explicitly requested.  Logs\n"
818251881Speter     "  follow copy history by default.  Use --stop-on-copy to disable this\n"
819251881Speter     "  behavior, which can be useful for determining branchpoints.\n"
820251881Speter     "\n"
821251881Speter     "  The --depth option is only valid in combination with the --diff option\n"
822251881Speter     "  and limits the scope of the displayed diff to the specified depth.\n"
823251881Speter     "\n"
824251881Speter     "  If the --search option is used, log messages are displayed only if the\n"
825251881Speter     "  provided search pattern matches any of the author, date, log message\n"
826251881Speter     "  text (unless --quiet is used), or, if the --verbose option is also\n"
827251881Speter     "  provided, a changed path.\n"
828251881Speter     "  The search pattern may include \"glob syntax\" wildcards:\n"
829251881Speter     "      ?      matches any single character\n"
830251881Speter     "      *      matches a sequence of arbitrary characters\n"
831251881Speter     "      [abc]  matches any of the characters listed inside the brackets\n"
832251881Speter     "  If multiple --search options are provided, a log message is shown if\n"
833251881Speter     "  it matches any of the provided search patterns. If the --search-and\n"
834251881Speter     "  option is used, that option's argument is combined with the pattern\n"
835251881Speter     "  from the previous --search or --search-and option, and a log message\n"
836251881Speter     "  is shown only if it matches the combined search pattern.\n"
837251881Speter     "  If --limit is used in combination with --search, --limit restricts the\n"
838251881Speter     "  number of log messages searched, rather than restricting the output\n"
839251881Speter     "  to a particular number of matching log messages.\n"
840251881Speter     "\n"
841251881Speter     "  Examples:\n"
842251881Speter     "\n"
843251881Speter     "    Show the latest 5 log messages for the current working copy\n"
844251881Speter     "    directory and display paths changed in each commit:\n"
845251881Speter     "      svn log -l 5 -v\n"
846251881Speter     "\n"
847251881Speter     "    Show the log for bar.c as of revision 42:\n"
848251881Speter     "      svn log bar.c@42\n"
849251881Speter     "\n"
850251881Speter     "    Show log messages and diffs for each commit to foo.c:\n"
851251881Speter     "      svn log --diff http://www.example.com/repo/project/foo.c\n"
852251881Speter     "    (Because the above command uses a full URL it does not require\n"
853251881Speter     "     a working copy.)\n"
854251881Speter     "\n"
855251881Speter     "    Show log messages for the children foo.c and bar.c of the directory\n"
856251881Speter     "    '/trunk' as it appeared in revision 50, using the ^/ URL shortcut:\n"
857251881Speter     "      svn log ^/trunk@50 foo.c bar.c\n"
858251881Speter     "\n"
859251881Speter     "    Show the log messages for any incoming changes to foo.c during the\n"
860251881Speter     "    next 'svn update':\n"
861251881Speter     "      svn log -r BASE:HEAD foo.c\n"
862251881Speter     "\n"
863251881Speter     "    Show the log message for the revision in which /branches/foo\n"
864251881Speter     "    was created:\n"
865251881Speter     "      svn log --stop-on-copy --limit 1 -r0:HEAD ^/branches/foo\n"),
866299742Sdim    {'r', 'c', 'q', 'v', 'g', opt_targets, opt_stop_on_copy, opt_incremental,
867299742Sdim     opt_xml, 'l', opt_with_all_revprops, opt_with_no_revprops,
868299742Sdim     opt_with_revprop, opt_depth, opt_diff, opt_diff_cmd,
869299742Sdim     opt_internal_diff, 'x', opt_search, opt_search_and },
870251881Speter    {{opt_with_revprop, N_("retrieve revision property ARG")},
871299742Sdim     {'c', N_("the change made in revision ARG")},
872299742Sdim     {'v', N_("also print all affected paths")},
873299742Sdim     {'q', N_("do not print the log message")}} },
874251881Speter
875251881Speter  { "merge", svn_cl__merge, {0}, N_
876251881Speter    ( /* For this large section, let's keep it unindented for easier
877251881Speter       * viewing/editing. It has been vim-treated with a textwidth=75 and 'gw'
878251881Speter       * (with quotes and newlines removed). */
879251881Speter"Merge changes into a working copy.\n"
880251881Speter"usage: 1. merge SOURCE[@REV] [TARGET_WCPATH]\n"
881253734Speter"          (the 'complete' merge)\n"
882251881Speter"       2. merge [-c M[,N...] | -r N:M ...] SOURCE[@REV] [TARGET_WCPATH]\n"
883251881Speter"          (the 'cherry-pick' merge)\n"
884251881Speter"       3. merge SOURCE1[@REV1] SOURCE2[@REV2] [TARGET_WCPATH]\n"
885251881Speter"          (the '2-URL' merge)\n"
886251881Speter"\n"
887251881Speter"  1. This form, with one source path and no revision range, is called\n"
888253734Speter"     a 'complete' merge:\n"
889251881Speter"\n"
890251881Speter"       svn merge SOURCE[@REV] [TARGET_WCPATH]\n"
891251881Speter"\n"
892253734Speter"     The complete merge is used for the 'sync' and 'reintegrate' merges\n"
893251881Speter"     in the 'feature branch' pattern described below. It finds all the\n"
894251881Speter"     changes on the source branch that have not already been merged to the\n"
895251881Speter"     target branch, and merges them into the working copy. Merge tracking\n"
896251881Speter"     is used to know which changes have already been merged.\n"
897251881Speter"\n"
898251881Speter"     SOURCE specifies the branch from where the changes will be pulled, and\n"
899251881Speter"     TARGET_WCPATH specifies a working copy of the target branch to which\n"
900251881Speter"     the changes will be applied. Normally SOURCE and TARGET_WCPATH should\n"
901251881Speter"     each correspond to the root of a branch. (If you want to merge only a\n"
902251881Speter"     subtree, then the subtree path must be included in both SOURCE and\n"
903251881Speter"     TARGET_WCPATH; this is discouraged, to avoid subtree mergeinfo.)\n"
904251881Speter"\n"
905251881Speter"     SOURCE is usually a URL. The optional '@REV' specifies both the peg\n"
906251881Speter"     revision of the URL and the latest revision that will be considered\n"
907251881Speter"     for merging; if REV is not specified, the HEAD revision is assumed. If\n"
908251881Speter"     SOURCE is a working copy path, the corresponding URL of the path is\n"
909251881Speter"     used, and the default value of 'REV' is the base revision (usually the\n"
910251881Speter"     revision last updated to).\n"
911251881Speter"\n"
912251881Speter"     TARGET_WCPATH is a working copy path; if omitted, '.' is generally\n"
913251881Speter"     assumed. There are some special cases:\n"
914251881Speter"\n"
915251881Speter"       - If SOURCE is a URL:\n"
916251881Speter"\n"
917251881Speter"           - If the basename of the URL and the basename of '.' are the\n"
918251881Speter"             same, then the differences are applied to '.'. Otherwise,\n"
919251881Speter"             if a file with the same basename as that of the URL is found\n"
920251881Speter"             within '.', then the differences are applied to that file.\n"
921251881Speter"             In all other cases, the target defaults to '.'.\n"
922251881Speter"\n"
923251881Speter"       - If SOURCE is a working copy path:\n"
924251881Speter"\n"
925251881Speter"           - If the source is a file, then differences are applied to that\n"
926251881Speter"             file (useful for reverse-merging earlier changes). Otherwise,\n"
927251881Speter"             if the source is a directory, then the target defaults to '.'.\n"
928251881Speter"\n"
929251881Speter"     In normal usage the working copy should be up to date, at a single\n"
930251881Speter"     revision, with no local modifications and no switched subtrees.\n"
931251881Speter"\n"
932251881Speter"       - The 'Feature Branch' Merging Pattern -\n"
933251881Speter"\n"
934251881Speter"     In this commonly used work flow, known also as the 'development\n"
935251881Speter"     branch' pattern, a developer creates a branch and commits a series of\n"
936251881Speter"     changes that implement a new feature. The developer periodically\n"
937251881Speter"     merges all the latest changes from the parent branch so as to keep the\n"
938251881Speter"     development branch up to date with those changes. When the feature is\n"
939251881Speter"     complete, the developer performs a merge from the feature branch to\n"
940251881Speter"     the parent branch to re-integrate the changes.\n"
941251881Speter"\n"
942251881Speter"         parent --+----------o------o-o-------------o--\n"
943251881Speter"                   \\            \\           \\      /\n"
944251881Speter"                    \\          merge      merge  merge\n"
945251881Speter"                     \\            \\           \\  /\n"
946251881Speter"         feature      +--o-o-------o----o-o----o-------\n"
947251881Speter"\n"
948251881Speter"     A merge from the parent branch to the feature branch is called a\n"
949251881Speter"     'sync' or 'catch-up' merge, and a merge from the feature branch to the\n"
950251881Speter"     parent branch is called a 'reintegrate' merge.\n"
951251881Speter"\n"
952251881Speter"       - Sync Merge Example -\n"
953251881Speter"                                 ............\n"
954251881Speter"                                .            .\n"
955251881Speter"         trunk  --+------------L--------------R------\n"
956251881Speter"                   \\                           \\\n"
957251881Speter"                    \\                          |\n"
958251881Speter"                     \\                         v\n"
959251881Speter"         feature      +------------------------o-----\n"
960251881Speter"                             r100            r200\n"
961251881Speter"\n"
962251881Speter"     Subversion will locate all the changes on 'trunk' that have not yet\n"
963251881Speter"     been merged into the 'feature' branch. In this case that is a single\n"
964251881Speter"     range, r100:200. In the diagram above, L marks the left side (trunk@100)\n"
965251881Speter"     and R marks the right side (trunk@200) of the merge source. The\n"
966251881Speter"     difference between L and R will be applied to the target working copy\n"
967251881Speter"     path. In this case, the working copy is a clean checkout of the entire\n"
968251881Speter"     'feature' branch.\n"
969251881Speter"\n"
970251881Speter"     To perform this sync merge, have a clean working copy of the feature\n"
971251881Speter"     branch and run the following command in its top-level directory:\n"
972251881Speter"\n"
973251881Speter"         svn merge ^/trunk\n"
974251881Speter"\n"
975251881Speter"     Note that the merge is now only in your local working copy and still\n"
976251881Speter"     needs to be committed to the repository so that it can be seen by\n"
977251881Speter"     others. You can review the changes and you may have to resolve\n"
978251881Speter"     conflicts before you commit the merge.\n"
979251881Speter"\n"
980251881Speter"       - Reintegrate Merge Example -\n"
981251881Speter"\n"
982251881Speter"     The feature branch was last synced with trunk up to revision X. So the\n"
983251881Speter"     difference between trunk@X and feature@HEAD contains the complete set\n"
984251881Speter"     of changes that implement the feature, and no other changes. These\n"
985251881Speter"     changes are applied to trunk.\n"
986251881Speter"\n"
987251881Speter"                    rW                   rX\n"
988251881Speter"         trunk ------+--------------------L------------------o\n"
989251881Speter"                      \\                    .                 ^\n"
990251881Speter"                       \\                    .............   /\n"
991251881Speter"                        \\                                . /\n"
992251881Speter"         feature         +--------------------------------R\n"
993251881Speter"\n"
994251881Speter"     In the diagram above, L marks the left side (trunk@X) and R marks the\n"
995251881Speter"     right side (feature@HEAD) of the merge. The difference between the\n"
996251881Speter"     left and right side is merged into trunk, the target.\n"
997251881Speter"\n"
998251881Speter"     To perform the merge, have a clean working copy of trunk and run the\n"
999251881Speter"     following command in its top-level directory:\n"
1000251881Speter"\n"
1001251881Speter"         svn merge ^/feature\n"
1002251881Speter"\n"
1003251881Speter"     To prevent unnecessary merge conflicts, a reintegrate merge requires\n"
1004251881Speter"     that TARGET_WCPATH is not a mixed-revision working copy, has no local\n"
1005251881Speter"     modifications, and has no switched subtrees.\n"
1006251881Speter"\n"
1007251881Speter"     A reintegrate merge also requires that the source branch is coherently\n"
1008251881Speter"     synced with the target -- in the above example, this means that all\n"
1009251881Speter"     revisions between the branch point W and the last merged revision X\n"
1010251881Speter"     are merged to the feature branch, so that there are no unmerged\n"
1011251881Speter"     revisions in-between.\n"
1012251881Speter"\n"
1013251881Speter"\n"
1014251881Speter"  2. This form is called a 'cherry-pick' merge:\n"
1015251881Speter"\n"
1016251881Speter"       svn merge [-c M[,N...] | -r N:M ...] SOURCE[@REV] [TARGET_WCPATH]\n"
1017251881Speter"\n"
1018251881Speter"     A cherry-pick merge is used to merge specific revisions (or revision\n"
1019251881Speter"     ranges) from one branch to another. By default, this uses merge\n"
1020251881Speter"     tracking to automatically skip any revisions that have already been\n"
1021251881Speter"     merged to the target; you can use the --ignore-ancestry option to\n"
1022251881Speter"     disable such skipping.\n"
1023251881Speter"\n"
1024251881Speter"     SOURCE is usually a URL. The optional '@REV' specifies only the peg\n"
1025251881Speter"     revision of the URL and does not affect the merge range; if REV is not\n"
1026251881Speter"     specified, the HEAD revision is assumed. If SOURCE is a working copy\n"
1027251881Speter"     path, the corresponding URL of the path is used, and the default value\n"
1028251881Speter"     of 'REV' is the base revision (usually the revision last updated to).\n"
1029251881Speter"\n"
1030251881Speter"     TARGET_WCPATH is a working copy path; if omitted, '.' is generally\n"
1031253734Speter"     assumed. The special cases noted above in the 'complete' merge form\n"
1032251881Speter"     also apply here.\n"
1033251881Speter"\n"
1034251881Speter"     The revision ranges to be merged are specified by the '-r' and/or '-c'\n"
1035251881Speter"     options. '-r N:M' refers to the difference in the history of the\n"
1036251881Speter"     source branch between revisions N and M. You can use '-c M' to merge\n"
1037251881Speter"     single revisions: '-c M' is equivalent to '-r <M-1>:M'. Each such\n"
1038251881Speter"     difference is applied to TARGET_WCPATH.\n"
1039251881Speter"\n"
1040251881Speter"     If the mergeinfo in TARGET_WCPATH indicates that revisions within the\n"
1041251881Speter"     range were already merged, changes made in those revisions are not\n"
1042251881Speter"     merged again. If needed, the range is broken into multiple sub-ranges,\n"
1043251881Speter"     and each sub-range is merged separately.\n"
1044251881Speter"\n"
1045251881Speter"     A 'reverse range' can be used to undo changes. For example, when\n"
1046251881Speter"     source and target refer to the same branch, a previously committed\n"
1047251881Speter"     revision can be 'undone'. In a reverse range, N is greater than M in\n"
1048251881Speter"     '-r N:M', or the '-c' option is used with a negative number: '-c -M'\n"
1049251881Speter"     is equivalent to '-r M:<M-1>'. Undoing changes like this is also known\n"
1050251881Speter"     as performing a 'reverse merge'.\n"
1051251881Speter"\n"
1052251881Speter"     Multiple '-c' and/or '-r' options may be specified and mixing of\n"
1053251881Speter"     forward and reverse ranges is allowed.\n"
1054251881Speter"\n"
1055251881Speter"       - Cherry-pick Merge Example -\n"
1056251881Speter"\n"
1057251881Speter"     A bug has been fixed on trunk in revision 50. This fix needs to\n"
1058251881Speter"     be merged from trunk onto the release branch.\n"
1059251881Speter"\n"
1060251881Speter"            1.x-release  +-----------------------o-----\n"
1061251881Speter"                        /                        ^\n"
1062251881Speter"                       /                         |\n"
1063251881Speter"                      /                          |\n"
1064251881Speter"         trunk ------+--------------------------LR-----\n"
1065251881Speter"                                                r50\n"
1066251881Speter"\n"
1067251881Speter"     In the above diagram, L marks the left side (trunk@49) and R marks the\n"
1068251881Speter"     right side (trunk@50) of the merge. The difference between the left\n"
1069251881Speter"     and right side is applied to the target working copy path.\n"
1070251881Speter"\n"
1071251881Speter"     Note that the difference between revision 49 and 50 is exactly those\n"
1072251881Speter"     changes that were committed in revision 50, not including changes\n"
1073251881Speter"     committed in revision 49.\n"
1074251881Speter"\n"
1075251881Speter"     To perform the merge, have a clean working copy of the release branch\n"
1076251881Speter"     and run the following command in its top-level directory; remember\n"
1077251881Speter"     that the default target is '.':\n"
1078251881Speter"\n"
1079251881Speter"         svn merge -c50 ^/trunk\n"
1080251881Speter"\n"
1081251881Speter"     You can also cherry-pick several revisions and/or revision ranges:\n"
1082251881Speter"\n"
1083251881Speter"         svn merge -c50,54,60 -r65:68 ^/trunk\n"
1084251881Speter"\n"
1085251881Speter"\n"
1086251881Speter"  3. This form is called a '2-URL merge':\n"
1087251881Speter"\n"
1088251881Speter"       svn merge SOURCE1[@REV1] SOURCE2[@REV2] [TARGET_WCPATH]\n"
1089251881Speter"\n"
1090251881Speter"     You should use this merge variant only if the other variants do not\n"
1091251881Speter"     apply to your situation, as this variant can be quite complex to\n"
1092251881Speter"     master.\n"
1093251881Speter"\n"
1094251881Speter"     Two source URLs are specified, identifying two trees on the same\n"
1095251881Speter"     branch or on different branches. The trees are compared and the\n"
1096251881Speter"     difference from SOURCE1@REV1 to SOURCE2@REV2 is applied to the\n"
1097251881Speter"     working copy of the target branch at TARGET_WCPATH. The target\n"
1098251881Speter"     branch may be the same as one or both sources, or different again.\n"
1099251881Speter"     The three branches involved can be completely unrelated.\n"
1100251881Speter"\n"
1101251881Speter"     TARGET_WCPATH is a working copy path; if omitted, '.' is generally\n"
1102253734Speter"     assumed. The special cases noted above in the 'complete' merge form\n"
1103251881Speter"     also apply here.\n"
1104251881Speter"\n"
1105251881Speter"     SOURCE1 and/or SOURCE2 can also be specified as a working copy path,\n"
1106251881Speter"     in which case the merge source URL is derived from the working copy.\n"
1107251881Speter"\n"
1108251881Speter"       - 2-URL Merge Example -\n"
1109251881Speter"\n"
1110251881Speter"     Two features have been developed on separate branches called 'foo' and\n"
1111251881Speter"     'bar'. It has since become clear that 'bar' should be combined with\n"
1112251881Speter"     the 'foo' branch for further development before reintegration.\n"
1113251881Speter"\n"
1114251881Speter"     Although both feature branches originate from trunk, they are not\n"
1115251881Speter"     directly related -- one is not a direct copy of the other. A 2-URL\n"
1116251881Speter"     merge is necessary.\n"
1117251881Speter"\n"
1118251881Speter"     The 'bar' branch has been synced with trunk up to revision 500.\n"
1119251881Speter"     (If this revision number is not known, it can be located using the\n"
1120251881Speter"     'svn log' and/or 'svn mergeinfo' commands.)\n"
1121251881Speter"     The difference between trunk@500 and bar@HEAD contains the complete\n"
1122251881Speter"     set of changes related to feature 'bar', and no other changes. These\n"
1123251881Speter"     changes are applied to the 'foo' branch.\n"
1124251881Speter"\n"
1125251881Speter"                           foo  +-----------------------------------o\n"
1126251881Speter"                               /                                    ^\n"
1127251881Speter"                              /                                    /\n"
1128251881Speter"                             /              r500                  /\n"
1129251881Speter"         trunk ------+------+-----------------L--------->        /\n"
1130251881Speter"                      \\                        .                /\n"
1131251881Speter"                       \\                        ............   /\n"
1132251881Speter"                        \\                                   . /\n"
1133251881Speter"                    bar  +-----------------------------------R\n"
1134251881Speter"\n"
1135251881Speter"     In the diagram above, L marks the left side (trunk@500) and R marks\n"
1136251881Speter"     the right side (bar@HEAD) of the merge. The difference between the\n"
1137251881Speter"     left and right side is applied to the target working copy path, in\n"
1138251881Speter"     this case a working copy of the 'foo' branch.\n"
1139251881Speter"\n"
1140251881Speter"     To perform the merge, have a clean working copy of the 'foo' branch\n"
1141251881Speter"     and run the following command in its top-level directory:\n"
1142251881Speter"\n"
1143251881Speter"         svn merge ^/trunk@500 ^/bar\n"
1144251881Speter"\n"
1145251881Speter"     The exact changes applied by a 2-URL merge can be previewed with svn's\n"
1146251881Speter"     diff command, which is a good idea to verify if you do not have the\n"
1147251881Speter"     luxury of a clean working copy to merge to. In this case:\n"
1148251881Speter"\n"
1149251881Speter"         svn diff ^/trunk@500 ^/bar@HEAD\n"
1150251881Speter"\n"
1151251881Speter"\n"
1152251881Speter"  The following applies to all types of merges:\n"
1153251881Speter"\n"
1154251881Speter"  To prevent unnecessary merge conflicts, svn merge requires that\n"
1155251881Speter"  TARGET_WCPATH is not a mixed-revision working copy. Running 'svn update'\n"
1156251881Speter"  before starting a merge ensures that all items in the working copy are\n"
1157251881Speter"  based on the same revision.\n"
1158251881Speter"\n"
1159251881Speter"  If possible, you should have no local modifications in the merge's target\n"
1160251881Speter"  working copy prior to the merge, to keep things simpler. It will be\n"
1161251881Speter"  easier to revert the merge and to understand the branch's history.\n"
1162251881Speter"\n"
1163251881Speter"  Switched sub-paths should also be avoided during merging, as they may\n"
1164251881Speter"  cause incomplete merges and create subtree mergeinfo.\n"
1165251881Speter"\n"
1166251881Speter"  For each merged item a line will be printed with characters reporting the\n"
1167251881Speter"  action taken. These characters have the following meaning:\n"
1168251881Speter"\n"
1169251881Speter"    A  Added\n"
1170251881Speter"    D  Deleted\n"
1171251881Speter"    U  Updated\n"
1172251881Speter"    C  Conflict\n"
1173251881Speter"    G  Merged\n"
1174251881Speter"    E  Existed\n"
1175251881Speter"    R  Replaced\n"
1176251881Speter"\n"
1177251881Speter"  Characters in the first column report about the item itself.\n"
1178251881Speter"  Characters in the second column report about properties of the item.\n"
1179251881Speter"  A 'C' in the third column indicates a tree conflict, while a 'C' in\n"
1180251881Speter"  the first and second columns indicate textual conflicts in files\n"
1181251881Speter"  and in property values, respectively.\n"
1182251881Speter"\n"
1183251881Speter"    - Merge Tracking -\n"
1184251881Speter"\n"
1185251881Speter"  Subversion uses the svn:mergeinfo property to track merge history. This\n"
1186251881Speter"  property is considered at the start of a merge to determine what to merge\n"
1187251881Speter"  and it is updated at the conclusion of the merge to describe the merge\n"
1188251881Speter"  that took place. Mergeinfo is used only if the two sources are on the\n"
1189251881Speter"  same line of history -- if the first source is an ancestor of the second,\n"
1190251881Speter"  or vice-versa (i.e. if one has originally been created by copying the\n"
1191251881Speter"  other). This is verified and enforced when using sync merges and\n"
1192251881Speter"  reintegrate merges.\n"
1193251881Speter"\n"
1194251881Speter"  The --ignore-ancestry option prevents merge tracking and thus ignores\n"
1195251881Speter"  mergeinfo, neither considering it nor recording it.\n"
1196251881Speter"\n"
1197251881Speter"    - Merging from foreign repositories -\n"
1198251881Speter"\n"
1199251881Speter"  Subversion does support merging from foreign repositories.\n"
1200251881Speter"  While all merge source URLs must point to the same repository, the merge\n"
1201251881Speter"  target working copy may come from a different repository than the source.\n"
1202251881Speter"  However, there are some caveats. Most notably, copies made in the\n"
1203251881Speter"  merge source will be transformed into plain additions in the merge\n"
1204251881Speter"  target. Also, merge-tracking is not supported for merges from foreign\n"
1205251881Speter"  repositories.\n"),
1206251881Speter    {'r', 'c', 'N', opt_depth, 'q', opt_force, opt_dry_run, opt_merge_cmd,
1207251881Speter     opt_record_only, 'x', opt_ignore_ancestry, opt_accept, opt_reintegrate,
1208299742Sdim     opt_allow_mixed_revisions, 'v'},
1209299742Sdim    { { opt_force, N_("force deletions even if deleted contents don't match") } }
1210299742Sdim  },
1211251881Speter
1212251881Speter  { "mergeinfo", svn_cl__mergeinfo, {0}, N_
1213251881Speter    ("Display merge-related information.\n"
1214251881Speter     "usage: 1. mergeinfo SOURCE[@REV] [TARGET[@REV]]\n"
1215251881Speter     "       2. mergeinfo --show-revs=WHICH SOURCE[@REV] [TARGET[@REV]]\n"
1216251881Speter     "\n"
1217251881Speter     "  1. Summarize the history of merging between SOURCE and TARGET. The graph\n"
1218251881Speter     "     shows, from left to right:\n"
1219251881Speter     "       the youngest common ancestor of the branches;\n"
1220251881Speter     "       the latest full merge in either direction, and thus the common base\n"
1221253734Speter     "         that will be used for the next complete merge;\n"
1222251881Speter     "       the repository path and revision number of the tip of each branch.\n"
1223251881Speter     "\n"
1224251881Speter     "  2. Print the revision numbers on SOURCE that have been merged to TARGET\n"
1225251881Speter     "     (with --show-revs=merged), or that have not been merged to TARGET\n"
1226251881Speter     "     (with --show-revs=eligible). Print only revisions in which there was\n"
1227251881Speter     "     at least one change in SOURCE.\n"
1228251881Speter     "\n"
1229251881Speter     "     If --revision (-r) is provided, filter the displayed information to\n"
1230251881Speter     "     show only that which is associated with the revisions within the\n"
1231251881Speter     "     specified range.  Revision numbers, dates, and the 'HEAD' keyword are\n"
1232251881Speter     "     valid range values.\n"
1233251881Speter     "\n"
1234251881Speter     "  SOURCE and TARGET are the source and target branch URLs, respectively.\n"
1235251881Speter     "  (If a WC path is given, the corresponding base URL is used.) The default\n"
1236251881Speter     "  TARGET is the current working directory ('.'). REV specifies the revision\n"
1237251881Speter     "  to be considered the tip of the branch; the default for SOURCE is HEAD,\n"
1238251881Speter     "  and the default for TARGET is HEAD for a URL or BASE for a WC path.\n"
1239251881Speter     "\n"
1240251881Speter     "  The depth can be 'empty' or 'infinity'; the default is 'empty'.\n"),
1241299742Sdim    {'r', 'R', 'q', 'v', opt_depth, opt_show_revs, opt_mergeinfo_log,
1242299742Sdim      opt_incremental } },
1243251881Speter
1244251881Speter  { "mkdir", svn_cl__mkdir, {0}, N_
1245251881Speter    ("Create a new directory under version control.\n"
1246251881Speter     "usage: 1. mkdir PATH...\n"
1247251881Speter     "       2. mkdir URL...\n"
1248251881Speter     "\n"
1249251881Speter     "  Create version controlled directories.\n"
1250251881Speter     "\n"
1251251881Speter     "  1. Each directory specified by a working copy PATH is created locally\n"
1252251881Speter     "    and scheduled for addition upon the next commit.\n"
1253251881Speter     "\n"
1254251881Speter     "  2. Each directory specified by a URL is created in the repository via\n"
1255251881Speter     "    an immediate commit.\n"
1256251881Speter     "\n"
1257251881Speter     "  In both cases, all the intermediate directories must already exist,\n"
1258251881Speter     "  unless the --parents option is given.\n"),
1259251881Speter    {'q', opt_parents, SVN_CL__LOG_MSG_OPTIONS} },
1260251881Speter
1261251881Speter  { "move", svn_cl__move, {"mv", "rename", "ren"}, N_
1262251881Speter    ("Move (rename) an item in a working copy or repository.\n"
1263251881Speter     "usage: move SRC... DST\n"
1264251881Speter     "\n"
1265251881Speter     "  SRC and DST can both be working copy (WC) paths or URLs:\n"
1266251881Speter     "    WC  -> WC:  move an item in a working copy, as a local change to\n"
1267251881Speter     "                be committed later (with or without further changes)\n"
1268251881Speter     "    URL -> URL: move an item in the repository directly, immediately\n"
1269251881Speter     "                creating a new revision in the repository\n"
1270251881Speter     "  All the SRCs must be of the same type. When moving multiple sources,\n"
1271251881Speter     "  they will be added as children of DST, which must be a directory.\n"
1272251881Speter     "\n"
1273251881Speter     "  SRC and DST of WC -> WC moves must be committed in the same revision.\n"
1274251881Speter     "  Furthermore, WC -> WC moves will refuse to move a mixed-revision subtree.\n"
1275251881Speter     "  To avoid unnecessary conflicts, it is recommended to run 'svn update'\n"
1276251881Speter     "  to update the subtree to a single revision before moving it.\n"
1277251881Speter     "  The --allow-mixed-revisions option is provided for backward compatibility.\n"
1278251881Speter     "\n"
1279251881Speter     "  The --revision option has no use and is deprecated.\n"),
1280251881Speter    {'r', 'q', opt_force, opt_parents, opt_allow_mixed_revisions,
1281251881Speter     SVN_CL__LOG_MSG_OPTIONS} },
1282251881Speter
1283251881Speter  { "patch", svn_cl__patch, {0}, N_
1284251881Speter    ("Apply a patch to a working copy.\n"
1285251881Speter     "usage: patch PATCHFILE [WCPATH]\n"
1286251881Speter     "\n"
1287251881Speter     "  Apply a unidiff patch in PATCHFILE to the working copy WCPATH.\n"
1288251881Speter     "  If WCPATH is omitted, '.' is assumed.\n"
1289251881Speter     "\n"
1290251881Speter     "  A unidiff patch suitable for application to a working copy can be\n"
1291251881Speter     "  produced with the 'svn diff' command or third-party diffing tools.\n"
1292251881Speter     "  Any non-unidiff content of PATCHFILE is ignored, except for Subversion\n"
1293251881Speter     "  property diffs as produced by 'svn diff'.\n"
1294251881Speter     "\n"
1295251881Speter     "  Changes listed in the patch will either be applied or rejected.\n"
1296251881Speter     "  If a change does not match at its exact line offset, it may be applied\n"
1297251881Speter     "  earlier or later in the file if a match is found elsewhere for the\n"
1298251881Speter     "  surrounding lines of context provided by the patch.\n"
1299251881Speter     "  A change may also be applied with fuzz, which means that one\n"
1300251881Speter     "  or more lines of context are ignored when matching the change.\n"
1301251881Speter     "  If no matching context can be found for a change, the change conflicts\n"
1302251881Speter     "  and will be written to a reject file with the extension .svnpatch.rej.\n"
1303251881Speter     "\n"
1304251881Speter     "  For each patched file a line will be printed with characters reporting\n"
1305251881Speter     "  the action taken. These characters have the following meaning:\n"
1306251881Speter     "\n"
1307251881Speter     "    A  Added\n"
1308251881Speter     "    D  Deleted\n"
1309251881Speter     "    U  Updated\n"
1310251881Speter     "    C  Conflict\n"
1311251881Speter     "    G  Merged (with local uncommitted changes)\n"
1312251881Speter     "\n"
1313251881Speter     "  Changes applied with an offset or fuzz are reported on lines starting\n"
1314251881Speter     "  with the '>' symbol. You should review such changes carefully.\n"
1315251881Speter     "\n"
1316251881Speter     "  If the patch removes all content from a file, that file is scheduled\n"
1317251881Speter     "  for deletion. If the patch creates a new file, that file is scheduled\n"
1318251881Speter     "  for addition. Use 'svn revert' to undo deletions and additions you\n"
1319251881Speter     "  do not agree with.\n"
1320251881Speter     "\n"
1321251881Speter     "  Hint: If the patch file was created with Subversion, it will contain\n"
1322251881Speter     "        the number of a revision N the patch will cleanly apply to\n"
1323251881Speter     "        (look for lines like '--- foo/bar.txt        (revision N)').\n"
1324251881Speter     "        To avoid rejects, first update to the revision N using\n"
1325251881Speter     "        'svn update -r N', apply the patch, and then update back to the\n"
1326251881Speter     "        HEAD revision. This way, conflicts can be resolved interactively.\n"
1327251881Speter     ),
1328251881Speter    {'q', opt_dry_run, opt_strip, opt_reverse_diff,
1329251881Speter     opt_ignore_whitespace} },
1330251881Speter
1331251881Speter  { "propdel", svn_cl__propdel, {"pdel", "pd"}, N_
1332251881Speter    ("Remove a property from files, dirs, or revisions.\n"
1333251881Speter     "usage: 1. propdel PROPNAME [PATH...]\n"
1334251881Speter     "       2. propdel PROPNAME --revprop -r REV [TARGET]\n"
1335251881Speter     "\n"
1336251881Speter     "  1. Removes versioned props in working copy.\n"
1337251881Speter     "  2. Removes unversioned remote prop on repos revision.\n"
1338299742Sdim     "     TARGET only determines which repository to access.\n"
1339299742Sdim     "\n"
1340299742Sdim     "  See 'svn help propset' for descriptions of the svn:* special properties.\n"),
1341251881Speter    {'q', 'R', opt_depth, 'r', opt_revprop, opt_changelist} },
1342251881Speter
1343251881Speter  { "propedit", svn_cl__propedit, {"pedit", "pe"}, N_
1344251881Speter    ("Edit a property with an external editor.\n"
1345251881Speter     "usage: 1. propedit PROPNAME TARGET...\n"
1346251881Speter     "       2. propedit PROPNAME --revprop -r REV [TARGET]\n"
1347251881Speter     "\n"
1348251881Speter     "  1. Edits versioned prop in working copy or repository.\n"
1349251881Speter     "  2. Edits unversioned remote prop on repos revision.\n"
1350251881Speter     "     TARGET only determines which repository to access.\n"
1351251881Speter     "\n"
1352299742Sdim     "  See 'svn help propset' for descriptions of the svn:* special properties.\n"),
1353251881Speter    {'r', opt_revprop, SVN_CL__LOG_MSG_OPTIONS, opt_force} },
1354251881Speter
1355251881Speter  { "propget", svn_cl__propget, {"pget", "pg"}, N_
1356251881Speter    ("Print the value of a property on files, dirs, or revisions.\n"
1357251881Speter     "usage: 1. propget PROPNAME [TARGET[@REV]...]\n"
1358251881Speter     "       2. propget PROPNAME --revprop -r REV [TARGET]\n"
1359251881Speter     "\n"
1360251881Speter     "  1. Prints versioned props. If specified, REV determines in which\n"
1361251881Speter     "     revision the target is first looked up.\n"
1362251881Speter     "  2. Prints unversioned remote prop on repos revision.\n"
1363251881Speter     "     TARGET only determines which repository to access.\n"
1364251881Speter     "\n"
1365251881Speter     "  With --verbose, the target path and the property name are printed on\n"
1366251881Speter     "  separate lines before each value, like 'svn proplist --verbose'.\n"
1367251881Speter     "  Otherwise, if there is more than one TARGET or a depth other than\n"
1368251881Speter     "  'empty', the target path is printed on the same line before each value.\n"
1369251881Speter     "\n"
1370251881Speter     "  By default, an extra newline is printed after the property value so that\n"
1371299742Sdim     "  the output looks pretty.  With a single TARGET, depth 'empty' and without\n"
1372299742Sdim     "  --show-inherited-props, you can use the --no-newline option to disable this\n"
1373299742Sdim     "  (useful when redirecting a binary property value to a file, for example).\n"
1374299742Sdim     "\n"
1375299742Sdim     "  See 'svn help propset' for descriptions of the svn:* special properties.\n"),
1376299742Sdim    {'v', 'R', opt_depth, 'r', opt_revprop, opt_strict, opt_no_newline, opt_xml,
1377251881Speter     opt_changelist, opt_show_inherited_props },
1378251881Speter    {{'v', N_("print path, name and value on separate lines")},
1379299742Sdim     {opt_strict, N_("(deprecated; use --no-newline)")}} },
1380251881Speter
1381251881Speter  { "proplist", svn_cl__proplist, {"plist", "pl"}, N_
1382251881Speter    ("List all properties on files, dirs, or revisions.\n"
1383251881Speter     "usage: 1. proplist [TARGET[@REV]...]\n"
1384251881Speter     "       2. proplist --revprop -r REV [TARGET]\n"
1385251881Speter     "\n"
1386251881Speter     "  1. Lists versioned props. If specified, REV determines in which\n"
1387251881Speter     "     revision the target is first looked up.\n"
1388251881Speter     "  2. Lists unversioned remote props on repos revision.\n"
1389251881Speter     "     TARGET only determines which repository to access.\n"
1390251881Speter     "\n"
1391251881Speter     "  With --verbose, the property values are printed as well, like 'svn propget\n"
1392299742Sdim     "  --verbose'.  With --quiet, the paths are not printed.\n"
1393299742Sdim     "\n"
1394299742Sdim     "  See 'svn help propset' for descriptions of the svn:* special properties.\n"),
1395251881Speter    {'v', 'R', opt_depth, 'r', 'q', opt_revprop, opt_xml, opt_changelist,
1396251881Speter     opt_show_inherited_props },
1397251881Speter    {{'v', N_("print path, name and value on separate lines")},
1398251881Speter     {'q', N_("don't print the path")}} },
1399251881Speter
1400251881Speter  { "propset", svn_cl__propset, {"pset", "ps"}, N_
1401251881Speter    ("Set the value of a property on files, dirs, or revisions.\n"
1402251881Speter     "usage: 1. propset PROPNAME PROPVAL PATH...\n"
1403251881Speter     "       2. propset PROPNAME --revprop -r REV PROPVAL [TARGET]\n"
1404251881Speter     "\n"
1405251881Speter     "  1. Changes a versioned file or directory property in a working copy.\n"
1406251881Speter     "  2. Changes an unversioned property on a repository revision.\n"
1407251881Speter     "     (TARGET only determines which repository to access.)\n"
1408251881Speter     "\n"
1409251881Speter     "  The value may be provided with the --file option instead of PROPVAL.\n"
1410251881Speter     "\n"
1411251881Speter     "  Property names starting with 'svn:' are reserved.  Subversion recognizes\n"
1412251881Speter     "  the following special versioned properties on a file:\n"
1413251881Speter     "    svn:keywords   - Keywords to be expanded.  Valid keywords are:\n"
1414251881Speter     "      URL, HeadURL             - The URL for the head version of the file.\n"
1415251881Speter     "      Author, LastChangedBy    - The last person to modify the file.\n"
1416251881Speter     "      Date, LastChangedDate    - The date/time the file was last modified.\n"
1417251881Speter     "      Rev, Revision,           - The last revision the file changed.\n"
1418251881Speter     "        LastChangedRevision\n"
1419251881Speter     "      Id                       - A compressed summary of the previous four.\n"
1420251881Speter     "      Header                   - Similar to Id but includes the full URL.\n"
1421251881Speter     "\n"
1422251881Speter     "      Custom keywords can be defined with a format string separated from\n"
1423251881Speter     "      the keyword name with '='. Valid format substitutions are:\n"
1424251881Speter     "        %a   - The author of the revision given by %r.\n"
1425251881Speter     "        %b   - The basename of the URL of the file.\n"
1426251881Speter     "        %d   - Short format of the date of the revision given by %r.\n"
1427251881Speter     "        %D   - Long format of the date of the revision given by %r.\n"
1428251881Speter     "        %P   - The file's path, relative to the repository root.\n"
1429251881Speter     "        %r   - The number of the revision which last changed the file.\n"
1430251881Speter     "        %R   - The URL to the root of the repository.\n"
1431251881Speter     "        %u   - The URL of the file.\n"
1432251881Speter     "        %_   - A space (keyword definitions cannot contain a literal space).\n"
1433251881Speter     "        %%   - A literal '%'.\n"
1434251881Speter     "        %H   - Equivalent to %P%_%r%_%d%_%a.\n"
1435251881Speter     "        %I   - Equivalent to %b%_%r%_%d%_%a.\n"
1436251881Speter     "      Example custom keyword definition: MyKeyword=%r%_%a%_%P\n"
1437251881Speter     "      Once a custom keyword has been defined for a file, it can be used\n"
1438251881Speter     "      within the file like any other keyword: $MyKeyword$\n"
1439251881Speter     "\n"
1440251881Speter     "    svn:executable - If present, make the file executable.  Use\n"
1441251881Speter     "      'svn propdel svn:executable PATH...' to clear.\n"
1442251881Speter     "    svn:eol-style  - One of 'native', 'LF', 'CR', 'CRLF'.\n"
1443251881Speter     "    svn:mime-type  - The mimetype of the file.  Used to determine\n"
1444251881Speter     "      whether to merge the file, and how to serve it from Apache.\n"
1445251881Speter     "      A mimetype beginning with 'text/' (or an absent mimetype) is\n"
1446251881Speter     "      treated as text.  Anything else is treated as binary.\n"
1447251881Speter     "    svn:needs-lock - If present, indicates that the file should be locked\n"
1448251881Speter     "      before it is modified.  Makes the working copy file read-only\n"
1449251881Speter     "      when it is not locked.  Use 'svn propdel svn:needs-lock PATH...'\n"
1450251881Speter     "      to clear.\n"
1451251881Speter     "\n"
1452251881Speter     "  Subversion recognizes the following special versioned properties on a\n"
1453251881Speter     "  directory:\n"
1454251881Speter     "    svn:ignore         - A list of file glob patterns to ignore, one per line.\n"
1455251881Speter     "    svn:global-ignores - Like svn:ignore, but inheritable.\n"
1456289166Speter     "    svn:auto-props     - Automatically set properties on files when they are\n"
1457289166Speter     "      added or imported. Contains key-value pairs, one per line, in the format:\n"
1458289166Speter     "        PATTERN = PROPNAME=VALUE[;PROPNAME=VALUE ...]\n"
1459289166Speter     "      Example (where a literal ';' is escaped by adding another ';'):\n"
1460289166Speter     "        *.html = svn:eol-style=native;svn:mime-type=text/html;; charset=UTF8\n"
1461289166Speter     "      Applies recursively to all files added or imported under the directory\n"
1462289166Speter     "      it is set on.  See also [auto-props] in the client configuration file.\n"
1463251881Speter     "    svn:externals      - A list of module specifiers, one per line, in the\n"
1464251881Speter     "      following format similar to the syntax of 'svn checkout':\n"
1465251881Speter     "        [-r REV] URL[@PEG] LOCALPATH\n"
1466251881Speter     "      Example:\n"
1467251881Speter     "        http://example.com/repos/zig foo/bar\n"
1468251881Speter     "      The LOCALPATH is relative to the directory having this property.\n"
1469251881Speter     "      To pin the external to a known revision, specify the optional REV:\n"
1470251881Speter     "        -r25 http://example.com/repos/zig foo/bar\n"
1471251881Speter     "      To unambiguously identify an element at a path which may have been\n"
1472251881Speter     "      subsequently deleted or renamed, specify the optional PEG revision:\n"
1473251881Speter     "        -r25 http://example.com/repos/zig@42 foo/bar\n"
1474251881Speter     "      The URL may be a full URL or a relative URL starting with one of:\n"
1475251881Speter     "        ../  to the parent directory of the extracted external\n"
1476251881Speter     "        ^/   to the repository root\n"
1477251881Speter     "        /    to the server root\n"
1478251881Speter     "        //   to the URL scheme\n"
1479299742Sdim     "      ^/../  to a sibling repository beneath the same SVNParentPath location\n"
1480251881Speter     "      Use of the following format is discouraged but is supported for\n"
1481251881Speter     "      interoperability with Subversion 1.4 and earlier clients:\n"
1482251881Speter     "        LOCALPATH [-r PEG] URL\n"
1483251881Speter     "      The ambiguous format 'relative_path relative_path' is taken as\n"
1484251881Speter     "      'relative_url relative_path' with peg revision support.\n"
1485251881Speter     "      Lines starting with a '#' character are ignored.\n"),
1486251881Speter    {'F', opt_encoding, 'q', 'r', opt_targets, 'R', opt_depth, opt_revprop,
1487251881Speter     opt_force, opt_changelist },
1488251881Speter    {{'F', N_("read property value from file ARG")}} },
1489251881Speter
1490251881Speter  { "relocate", svn_cl__relocate, {0}, N_
1491251881Speter    ("Relocate the working copy to point to a different repository root URL.\n"
1492251881Speter     "usage: 1. relocate FROM-PREFIX TO-PREFIX [PATH...]\n"
1493251881Speter     "       2. relocate TO-URL [PATH]\n"
1494251881Speter     "\n"
1495251881Speter     "  Rewrite working copy URL metadata to reflect a syntactic change only.\n"
1496251881Speter     "  This is used when a repository's root URL changes (such as a scheme\n"
1497251881Speter     "  or hostname change) but your working copy still reflects the same\n"
1498251881Speter     "  directory within the same repository.\n"
1499251881Speter     "\n"
1500251881Speter     "  1. FROM-PREFIX and TO-PREFIX are initial substrings of the working\n"
1501251881Speter     "     copy's current and new URLs, respectively.  (You may specify the\n"
1502251881Speter     "     complete old and new URLs if you wish.)  Use 'svn info' to determine\n"
1503251881Speter     "     the current working copy URL.\n"
1504251881Speter     "\n"
1505251881Speter     "  2. TO-URL is the (complete) new repository URL to use for PATH.\n"
1506251881Speter     "\n"
1507251881Speter     "  Examples:\n"
1508251881Speter     "    svn relocate http:// svn:// project1 project2\n"
1509251881Speter     "    svn relocate http://www.example.com/repo/project \\\n"
1510251881Speter     "                 svn://svn.example.com/repo/project\n"),
1511251881Speter    {opt_ignore_externals} },
1512251881Speter
1513251881Speter  { "resolve", svn_cl__resolve, {0}, N_
1514251881Speter    ("Resolve conflicts on working copy files or directories.\n"
1515251881Speter     "usage: resolve [PATH...]\n"
1516251881Speter     "\n"
1517251881Speter     "  By default, perform interactive conflict resolution on PATH.\n"
1518251881Speter     "  In this mode, the command is recursive by default (depth 'infinity').\n"
1519251881Speter     "\n"
1520251881Speter     "  The --accept=ARG option prevents interactive prompting and forces\n"
1521251881Speter     "  conflicts on PATH to be resolved in the manner specified by ARG.\n"
1522251881Speter     "  In this mode, the command is not recursive by default (depth 'empty').\n"),
1523251881Speter    {opt_targets, 'R', opt_depth, 'q', opt_accept},
1524251881Speter    {{opt_accept, N_("specify automatic conflict resolution source\n"
1525251881Speter                     "                             "
1526251881Speter                     "('base', 'working', 'mine-conflict',\n"
1527251881Speter                     "                             "
1528251881Speter                     "'theirs-conflict', 'mine-full', 'theirs-full')")}} },
1529251881Speter
1530251881Speter  { "resolved", svn_cl__resolved, {0}, N_
1531251881Speter    ("Remove 'conflicted' state on working copy files or directories.\n"
1532251881Speter     "usage: resolved PATH...\n"
1533251881Speter     "\n"
1534251881Speter     "  Note:  this subcommand does not semantically resolve conflicts or\n"
1535251881Speter     "  remove conflict markers; it merely removes the conflict-related\n"
1536251881Speter     "  artifact files and allows PATH to be committed again.  It has been\n"
1537251881Speter     "  deprecated in favor of running 'svn resolve --accept working'.\n"),
1538251881Speter    {opt_targets, 'R', opt_depth, 'q'} },
1539251881Speter
1540251881Speter  { "revert", svn_cl__revert, {0}, N_
1541251881Speter    ("Restore pristine working copy state (undo local changes).\n"
1542251881Speter     "usage: revert PATH...\n"
1543251881Speter     "\n"
1544251881Speter     "  Revert changes in the working copy at or within PATH, and remove\n"
1545251881Speter     "  conflict markers as well, if any.\n"
1546251881Speter     "\n"
1547251881Speter     "  This subcommand does not revert already committed changes.\n"
1548251881Speter     "  For information about undoing already committed changes, search\n"
1549251881Speter     "  the output of 'svn help merge' for 'undo'.\n"),
1550251881Speter    {opt_targets, 'R', opt_depth, 'q', opt_changelist} },
1551251881Speter
1552251881Speter  { "status", svn_cl__status, {"stat", "st"}, N_
1553251881Speter    ("Print the status of working copy files and directories.\n"
1554251881Speter     "usage: status [PATH...]\n"
1555251881Speter     "\n"
1556251881Speter     "  With no args, print only locally modified items (no network access).\n"
1557251881Speter     "  With -q, print only summary information about locally modified items.\n"
1558251881Speter     "  With -u, add working revision and server out-of-date information.\n"
1559251881Speter     "  With -v, print full revision information on every item.\n"
1560251881Speter     "\n"
1561251881Speter     "  The first seven columns in the output are each one character wide:\n"
1562251881Speter     "    First column: Says if item was added, deleted, or otherwise changed\n"
1563251881Speter     "      ' ' no modifications\n"
1564251881Speter     "      'A' Added\n"
1565251881Speter     "      'C' Conflicted\n"
1566251881Speter     "      'D' Deleted\n"
1567251881Speter     "      'I' Ignored\n"
1568251881Speter     "      'M' Modified\n"
1569251881Speter     "      'R' Replaced\n"
1570251881Speter     "      'X' an unversioned directory created by an externals definition\n"
1571251881Speter     "      '?' item is not under version control\n"
1572251881Speter     "      '!' item is missing (removed by non-svn command) or incomplete\n"
1573251881Speter     "      '~' versioned item obstructed by some item of a different kind\n"
1574251881Speter     "    Second column: Modifications of a file's or directory's properties\n"
1575251881Speter     "      ' ' no modifications\n"
1576251881Speter     "      'C' Conflicted\n"
1577251881Speter     "      'M' Modified\n"
1578253734Speter     "    Third column: Whether the working copy is locked for writing by\n"
1579253734Speter     "                  another Subversion client modifying the working copy\n"
1580253734Speter     "      ' ' not locked for writing\n"
1581253734Speter     "      'L' locked for writing\n"
1582299742Sdim     "    Fourth column: Scheduled commit will create a copy (addition-with-history)\n"
1583299742Sdim     "      ' ' no history scheduled with commit (item was newly added)\n"
1584299742Sdim     "      '+' history scheduled with commit (item was copied)\n"
1585251881Speter     "    Fifth column: Whether the item is switched or a file external\n"
1586251881Speter     "      ' ' normal\n"
1587251881Speter     "      'S' the item has a Switched URL relative to the parent\n"
1588251881Speter     "      'X' a versioned file created by an eXternals definition\n"
1589253734Speter     "    Sixth column: Whether the item is locked in repository for exclusive commit\n"
1590251881Speter     "      (without -u)\n"
1591253734Speter     "      ' ' not locked by this working copy\n"
1592253734Speter     "      'K' locked by this working copy, but lock might be stolen or broken\n"
1593251881Speter     "      (with -u)\n"
1594253734Speter     "      ' ' not locked in repository, not locked by this working copy\n"
1595253734Speter     "      'K' locked in repository, lock owned by this working copy\n"
1596253734Speter     "      'O' locked in repository, lock owned by another working copy\n"
1597253734Speter     "      'T' locked in repository, lock owned by this working copy was stolen\n"
1598253734Speter     "      'B' not locked in repository, lock owned by this working copy is broken\n"
1599251881Speter     "    Seventh column: Whether the item is the victim of a tree conflict\n"
1600251881Speter     "      ' ' normal\n"
1601251881Speter     "      'C' tree-Conflicted\n"
1602251881Speter     "    If the item is a tree conflict victim, an additional line is printed\n"
1603251881Speter     "    after the item's status line, explaining the nature of the conflict.\n"
1604251881Speter     "\n"
1605251881Speter     "  The out-of-date information appears in the ninth column (with -u):\n"
1606251881Speter     "      '*' a newer revision exists on the server\n"
1607251881Speter     "      ' ' the working copy is up to date\n"
1608251881Speter     "\n"
1609251881Speter     "  Remaining fields are variable width and delimited by spaces:\n"
1610251881Speter     "    The working revision (with -u or -v; '-' if the item is copied)\n"
1611251881Speter     "    The last committed revision and last committed author (with -v)\n"
1612251881Speter     "    The working copy path is always the final field, so it can\n"
1613251881Speter     "      include spaces.\n"
1614251881Speter     "\n"
1615251881Speter     "  The presence of a question mark ('?') where a working revision, last\n"
1616251881Speter     "  committed revision, or last committed author was expected indicates\n"
1617251881Speter     "  that the information is unknown or irrelevant given the state of the\n"
1618251881Speter     "  item (for example, when the item is the result of a copy operation).\n"
1619251881Speter     "  The question mark serves as a visual placeholder to facilitate parsing.\n"
1620251881Speter     "\n"
1621251881Speter     "  Example output:\n"
1622251881Speter     "    svn status wc\n"
1623251881Speter     "     M      wc/bar.c\n"
1624251881Speter     "    A  +    wc/qax.c\n"
1625251881Speter     "\n"
1626251881Speter     "    svn status -u wc\n"
1627251881Speter     "     M             965   wc/bar.c\n"
1628251881Speter     "            *      965   wc/foo.c\n"
1629251881Speter     "    A  +             -   wc/qax.c\n"
1630251881Speter     "    Status against revision:   981\n"
1631251881Speter     "\n"
1632251881Speter     "    svn status --show-updates --verbose wc\n"
1633251881Speter     "     M             965      938 kfogel       wc/bar.c\n"
1634251881Speter     "            *      965      922 sussman      wc/foo.c\n"
1635251881Speter     "    A  +             -      687 joe          wc/qax.c\n"
1636251881Speter     "                   965      687 joe          wc/zig.c\n"
1637251881Speter     "    Status against revision:   981\n"
1638251881Speter     "\n"
1639251881Speter     "    svn status\n"
1640251881Speter     "     M      wc/bar.c\n"
1641251881Speter     "    !     C wc/qaz.c\n"
1642251881Speter     "          >   local missing, incoming edit upon update\n"
1643251881Speter     "    D       wc/qax.c\n"),
1644299742Sdim    { 'u', 'v', 'N', opt_depth, 'r', 'q', opt_no_ignore, opt_incremental,
1645299742Sdim      opt_xml, opt_ignore_externals, opt_changelist},
1646251881Speter    {{'q', N_("don't print unversioned items")}} },
1647251881Speter
1648251881Speter  { "switch", svn_cl__switch, {"sw"}, N_
1649251881Speter    ("Update the working copy to a different URL within the same repository.\n"
1650251881Speter     "usage: 1. switch URL[@PEGREV] [PATH]\n"
1651251881Speter     "       2. switch --relocate FROM-PREFIX TO-PREFIX [PATH...]\n"
1652251881Speter     "\n"
1653251881Speter     "  1. Update the working copy to mirror a new URL within the repository.\n"
1654251881Speter     "     This behavior is similar to 'svn update', and is the way to\n"
1655251881Speter     "     move a working copy to a branch or tag within the same repository.\n"
1656251881Speter     "     If specified, PEGREV determines in which revision the target is first\n"
1657251881Speter     "     looked up.\n"
1658251881Speter     "\n"
1659251881Speter     "     If --force is used, unversioned obstructing paths in the working\n"
1660251881Speter     "     copy do not automatically cause a failure if the switch attempts to\n"
1661251881Speter     "     add the same path.  If the obstructing path is the same type (file\n"
1662251881Speter     "     or directory) as the corresponding path in the repository it becomes\n"
1663251881Speter     "     versioned but its contents are left 'as-is' in the working copy.\n"
1664251881Speter     "     This means that an obstructing directory's unversioned children may\n"
1665251881Speter     "     also obstruct and become versioned.  For files, any content differences\n"
1666251881Speter     "     between the obstruction and the repository are treated like a local\n"
1667251881Speter     "     modification to the working copy.  All properties from the repository\n"
1668251881Speter     "     are applied to the obstructing path.\n"
1669251881Speter     "\n"
1670251881Speter     "     Use the --set-depth option to set a new working copy depth on the\n"
1671251881Speter     "     targets of this operation.\n"
1672251881Speter     "\n"
1673251881Speter     "     By default, Subversion will refuse to switch a working copy path to\n"
1674251881Speter     "     a new URL with which it shares no common version control ancestry.\n"
1675251881Speter     "     Use the '--ignore-ancestry' option to override this sanity check.\n"
1676251881Speter     "\n"
1677251881Speter     "  2. The '--relocate' option is deprecated. This syntax is equivalent to\n"
1678251881Speter     "     'svn relocate FROM-PREFIX TO-PREFIX [PATH]'.\n"
1679251881Speter     "\n"
1680251881Speter     "  See also 'svn help update' for a list of possible characters\n"
1681251881Speter     "  reporting the action taken.\n"
1682251881Speter     "\n"
1683251881Speter     "  Examples:\n"
1684251881Speter     "    svn switch ^/branches/1.x-release\n"
1685251881Speter     "    svn switch --relocate http:// svn://\n"
1686251881Speter     "    svn switch --relocate http://www.example.com/repo/project \\\n"
1687251881Speter     "                          svn://svn.example.com/repo/project\n"),
1688251881Speter    { 'r', 'N', opt_depth, opt_set_depth, 'q', opt_merge_cmd, opt_relocate,
1689251881Speter      opt_ignore_externals, opt_ignore_ancestry, opt_force, opt_accept},
1690251881Speter    {{opt_ignore_ancestry,
1691299742Sdim     N_("allow switching to a node with no common ancestor")},
1692299742Sdim     {opt_force,
1693299742Sdim      N_("handle unversioned obstructions as changes")}}
1694251881Speter  },
1695251881Speter
1696251881Speter  { "unlock", svn_cl__unlock, {0}, N_
1697251881Speter    ("Unlock working copy paths or URLs.\n"
1698251881Speter     "usage: unlock TARGET...\n"
1699251881Speter     "\n"
1700251881Speter     "  Use --force to break the lock.\n"),
1701251881Speter    { opt_targets, opt_force } },
1702251881Speter
1703251881Speter  { "update", svn_cl__update, {"up"},  N_
1704251881Speter    ("Bring changes from the repository into the working copy.\n"
1705251881Speter     "usage: update [PATH...]\n"
1706251881Speter     "\n"
1707251881Speter     "  If no revision is given, bring working copy up-to-date with HEAD rev.\n"
1708251881Speter     "  Else synchronize working copy to revision given by -r.\n"
1709251881Speter     "\n"
1710251881Speter     "  For each updated item a line will be printed with characters reporting\n"
1711251881Speter     "  the action taken. These characters have the following meaning:\n"
1712251881Speter     "\n"
1713251881Speter     "    A  Added\n"
1714251881Speter     "    D  Deleted\n"
1715251881Speter     "    U  Updated\n"
1716251881Speter     "    C  Conflict\n"
1717251881Speter     "    G  Merged\n"
1718251881Speter     "    E  Existed\n"
1719251881Speter     "    R  Replaced\n"
1720251881Speter     "\n"
1721251881Speter     "  Characters in the first column report about the item itself.\n"
1722251881Speter     "  Characters in the second column report about properties of the item.\n"
1723251881Speter     "  A 'B' in the third column signifies that the lock for the file has\n"
1724251881Speter     "  been broken or stolen.\n"
1725251881Speter     "  A 'C' in the fourth column indicates a tree conflict, while a 'C' in\n"
1726251881Speter     "  the first and second columns indicate textual conflicts in files\n"
1727251881Speter     "  and in property values, respectively.\n"
1728251881Speter     "\n"
1729251881Speter     "  If --force is used, unversioned obstructing paths in the working\n"
1730251881Speter     "  copy do not automatically cause a failure if the update attempts to\n"
1731251881Speter     "  add the same path.  If the obstructing path is the same type (file\n"
1732251881Speter     "  or directory) as the corresponding path in the repository it becomes\n"
1733251881Speter     "  versioned but its contents are left 'as-is' in the working copy.\n"
1734251881Speter     "  This means that an obstructing directory's unversioned children may\n"
1735251881Speter     "  also obstruct and become versioned.  For files, any content differences\n"
1736251881Speter     "  between the obstruction and the repository are treated like a local\n"
1737251881Speter     "  modification to the working copy.  All properties from the repository\n"
1738251881Speter     "  are applied to the obstructing path.  Obstructing paths are reported\n"
1739251881Speter     "  in the first column with code 'E'.\n"
1740251881Speter     "\n"
1741251881Speter     "  If the specified update target is missing from the working copy but its\n"
1742251881Speter     "  immediate parent directory is present, checkout the target into its\n"
1743251881Speter     "  parent directory at the specified depth.  If --parents is specified,\n"
1744251881Speter     "  create any missing parent directories of the target by checking them\n"
1745251881Speter     "  out, too, at depth=empty.\n"
1746251881Speter     "\n"
1747251881Speter     "  Use the --set-depth option to set a new working copy depth on the\n"
1748251881Speter     "  targets of this operation.\n"),
1749251881Speter    {'r', 'N', opt_depth, opt_set_depth, 'q', opt_merge_cmd, opt_force,
1750251881Speter     opt_ignore_externals, opt_changelist, opt_editor_cmd, opt_accept,
1751299742Sdim     opt_parents},
1752299742Sdim    { {opt_force,
1753299742Sdim       N_("handle unversioned obstructions as changes")} } },
1754251881Speter
1755251881Speter  { "upgrade", svn_cl__upgrade, {0}, N_
1756251881Speter    ("Upgrade the metadata storage format for a working copy.\n"
1757251881Speter     "usage: upgrade [WCPATH...]\n"
1758251881Speter     "\n"
1759251881Speter     "  Local modifications are preserved.\n"),
1760251881Speter    { 'q' } },
1761251881Speter
1762251881Speter  { NULL, NULL, {0}, NULL, {0} }
1763251881Speter};
1764251881Speter
1765251881Speter
1766251881Speter/* Version compatibility check */
1767251881Speterstatic svn_error_t *
1768251881Spetercheck_lib_versions(void)
1769251881Speter{
1770251881Speter  static const svn_version_checklist_t checklist[] =
1771251881Speter    {
1772251881Speter      { "svn_subr",   svn_subr_version },
1773251881Speter      { "svn_client", svn_client_version },
1774251881Speter      { "svn_wc",     svn_wc_version },
1775251881Speter      { "svn_ra",     svn_ra_version },
1776251881Speter      { "svn_delta",  svn_delta_version },
1777251881Speter      { "svn_diff",   svn_diff_version },
1778251881Speter      { NULL, NULL }
1779251881Speter    };
1780251881Speter  SVN_VERSION_DEFINE(my_version);
1781251881Speter
1782262253Speter  return svn_ver_check_list2(&my_version, checklist, svn_ver_equal);
1783251881Speter}
1784251881Speter
1785251881Speter
1786251881Speter/* A flag to see if we've been cancelled by the client or not. */
1787251881Speterstatic volatile sig_atomic_t cancelled = FALSE;
1788251881Speter
1789251881Speter/* A signal handler to support cancellation. */
1790251881Speterstatic void
1791251881Spetersignal_handler(int signum)
1792251881Speter{
1793251881Speter  apr_signal(signum, SIG_IGN);
1794251881Speter  cancelled = TRUE;
1795251881Speter}
1796251881Speter
1797251881Speter/* Our cancellation callback. */
1798251881Spetersvn_error_t *
1799251881Spetersvn_cl__check_cancel(void *baton)
1800251881Speter{
1801299742Sdim  /* Cancel baton should be always NULL in command line client. */
1802299742Sdim  SVN_ERR_ASSERT(baton == NULL);
1803251881Speter  if (cancelled)
1804251881Speter    return svn_error_create(SVN_ERR_CANCELLED, NULL, _("Caught signal"));
1805251881Speter  else
1806251881Speter    return SVN_NO_ERROR;
1807251881Speter}
1808251881Speter
1809251881Speter/* Add a --search argument to OPT_STATE.
1810251881Speter * These options start a new search pattern group. */
1811251881Speterstatic void
1812251881Speteradd_search_pattern_group(svn_cl__opt_state_t *opt_state,
1813251881Speter                         const char *pattern,
1814251881Speter                         apr_pool_t *result_pool)
1815251881Speter{
1816251881Speter  apr_array_header_t *group = NULL;
1817251881Speter
1818251881Speter  if (opt_state->search_patterns == NULL)
1819251881Speter    opt_state->search_patterns = apr_array_make(result_pool, 1,
1820251881Speter                                                sizeof(apr_array_header_t *));
1821251881Speter
1822251881Speter  group = apr_array_make(result_pool, 1, sizeof(const char *));
1823251881Speter  APR_ARRAY_PUSH(group, const char *) = pattern;
1824251881Speter  APR_ARRAY_PUSH(opt_state->search_patterns, apr_array_header_t *) = group;
1825251881Speter}
1826251881Speter
1827251881Speter/* Add a --search-and argument to OPT_STATE.
1828251881Speter * These patterns are added to an existing pattern group, if any. */
1829251881Speterstatic void
1830251881Speteradd_search_pattern_to_latest_group(svn_cl__opt_state_t *opt_state,
1831251881Speter                                   const char *pattern,
1832251881Speter                                   apr_pool_t *result_pool)
1833251881Speter{
1834251881Speter  apr_array_header_t *group;
1835251881Speter
1836251881Speter  if (opt_state->search_patterns == NULL)
1837251881Speter    {
1838251881Speter      add_search_pattern_group(opt_state, pattern, result_pool);
1839251881Speter      return;
1840251881Speter    }
1841251881Speter
1842251881Speter  group = APR_ARRAY_IDX(opt_state->search_patterns,
1843251881Speter                        opt_state->search_patterns->nelts - 1,
1844251881Speter                        apr_array_header_t *);
1845251881Speter  APR_ARRAY_PUSH(group, const char *) = pattern;
1846251881Speter}
1847251881Speter
1848251881Speter
1849251881Speter/*** Main. ***/
1850251881Speter
1851299742Sdim/*
1852299742Sdim * On success, leave *EXIT_CODE untouched and return SVN_NO_ERROR. On error,
1853299742Sdim * either return an error to be displayed, or set *EXIT_CODE to non-zero and
1854299742Sdim * return SVN_NO_ERROR.
1855299742Sdim */
1856299742Sdimstatic svn_error_t *
1857299742Sdimsub_main(int *exit_code, int argc, const char *argv[], apr_pool_t *pool)
1858251881Speter{
1859251881Speter  svn_error_t *err;
1860251881Speter  int opt_id;
1861251881Speter  apr_getopt_t *os;
1862251881Speter  svn_cl__opt_state_t opt_state = { 0, { 0 } };
1863251881Speter  svn_client_ctx_t *ctx;
1864251881Speter  apr_array_header_t *received_opts;
1865251881Speter  int i;
1866251881Speter  const svn_opt_subcommand_desc2_t *subcommand = NULL;
1867299742Sdim  const char *dash_F_arg = NULL;
1868251881Speter  svn_cl__cmd_baton_t command_baton;
1869251881Speter  svn_auth_baton_t *ab;
1870251881Speter  svn_config_t *cfg_config;
1871251881Speter  svn_boolean_t descend = TRUE;
1872251881Speter  svn_boolean_t interactive_conflicts = FALSE;
1873251881Speter  svn_boolean_t force_interactive = FALSE;
1874251881Speter  svn_cl__conflict_stats_t *conflict_stats
1875251881Speter    = svn_cl__conflict_stats_create(pool);
1876251881Speter  svn_boolean_t use_notifier = TRUE;
1877251881Speter  svn_boolean_t reading_file_from_stdin = FALSE;
1878251881Speter  apr_hash_t *changelists;
1879251881Speter  apr_hash_t *cfg_hash;
1880251881Speter
1881251881Speter  received_opts = apr_array_make(pool, SVN_OPT_MAX_OPTIONS, sizeof(int));
1882251881Speter
1883251881Speter  /* Check library versions */
1884299742Sdim  SVN_ERR(check_lib_versions());
1885251881Speter
1886251881Speter#if defined(WIN32) || defined(__CYGWIN__)
1887251881Speter  /* Set the working copy administrative directory name. */
1888251881Speter  if (getenv("SVN_ASP_DOT_NET_HACK"))
1889251881Speter    {
1890299742Sdim      SVN_ERR(svn_wc_set_adm_dir("_svn", pool));
1891251881Speter    }
1892251881Speter#endif
1893251881Speter
1894251881Speter  /* Initialize the RA library. */
1895299742Sdim  SVN_ERR(svn_ra_initialize(pool));
1896251881Speter
1897251881Speter  /* Init our changelists hash. */
1898251881Speter  changelists = apr_hash_make(pool);
1899251881Speter
1900251881Speter  /* Begin processing arguments. */
1901251881Speter  opt_state.start_revision.kind = svn_opt_revision_unspecified;
1902251881Speter  opt_state.end_revision.kind = svn_opt_revision_unspecified;
1903251881Speter  opt_state.revision_ranges =
1904251881Speter    apr_array_make(pool, 0, sizeof(svn_opt_revision_range_t *));
1905251881Speter  opt_state.depth = svn_depth_unknown;
1906251881Speter  opt_state.set_depth = svn_depth_unknown;
1907251881Speter  opt_state.accept_which = svn_cl__accept_unspecified;
1908251881Speter  opt_state.show_revs = svn_cl__show_revs_invalid;
1909251881Speter
1910251881Speter  /* No args?  Show usage. */
1911251881Speter  if (argc <= 1)
1912251881Speter    {
1913299742Sdim      SVN_ERR(svn_cl__help(NULL, NULL, pool));
1914299742Sdim      *exit_code = EXIT_FAILURE;
1915299742Sdim      return SVN_NO_ERROR;
1916251881Speter    }
1917251881Speter
1918251881Speter  /* Else, parse options. */
1919299742Sdim  SVN_ERR(svn_cmdline__getopt_init(&os, argc, argv, pool));
1920251881Speter
1921251881Speter  os->interleave = 1;
1922251881Speter  while (1)
1923251881Speter    {
1924251881Speter      const char *opt_arg;
1925251881Speter      const char *utf8_opt_arg;
1926251881Speter
1927251881Speter      /* Parse the next option. */
1928251881Speter      apr_status_t apr_err = apr_getopt_long(os, svn_cl__options, &opt_id,
1929251881Speter                                             &opt_arg);
1930251881Speter      if (APR_STATUS_IS_EOF(apr_err))
1931251881Speter        break;
1932251881Speter      else if (apr_err)
1933251881Speter        {
1934299742Sdim          SVN_ERR(svn_cl__help(NULL, NULL, pool));
1935299742Sdim          *exit_code = EXIT_FAILURE;
1936299742Sdim          return SVN_NO_ERROR;
1937251881Speter        }
1938251881Speter
1939251881Speter      /* Stash the option code in an array before parsing it. */
1940251881Speter      APR_ARRAY_PUSH(received_opts, int) = opt_id;
1941251881Speter
1942251881Speter      switch (opt_id) {
1943251881Speter      case 'l':
1944251881Speter        {
1945299742Sdim          SVN_ERR(svn_utf_cstring_to_utf8(&utf8_opt_arg, opt_arg, pool));
1946299742Sdim          err = svn_cstring_atoi(&opt_state.limit, utf8_opt_arg);
1947251881Speter          if (err)
1948251881Speter            {
1949299742Sdim              return svn_error_create(SVN_ERR_CL_ARG_PARSING_ERROR, err,
1950299742Sdim                                      _("Non-numeric limit argument given"));
1951251881Speter            }
1952251881Speter          if (opt_state.limit <= 0)
1953251881Speter            {
1954299742Sdim              return svn_error_create(SVN_ERR_INCORRECT_PARAMS, NULL,
1955299742Sdim                                      _("Argument to --limit must be positive"));
1956251881Speter            }
1957251881Speter        }
1958251881Speter        break;
1959251881Speter      case 'm':
1960299742Sdim        /* We store the raw message here.  We will convert it to UTF-8
1961299742Sdim         * later, according to the value of the '--encoding' option. */
1962251881Speter        opt_state.message = apr_pstrdup(pool, opt_arg);
1963251881Speter        break;
1964251881Speter      case 'c':
1965251881Speter        {
1966299742Sdim          apr_array_header_t *change_revs;
1967251881Speter
1968299742Sdim          SVN_ERR(svn_utf_cstring_to_utf8(&utf8_opt_arg, opt_arg, pool));
1969299742Sdim          change_revs = svn_cstring_split(utf8_opt_arg, ", \n\r\t\v", TRUE,
1970299742Sdim                                          pool);
1971299742Sdim
1972251881Speter          if (opt_state.old_target)
1973251881Speter            {
1974299742Sdim              return svn_error_create(SVN_ERR_CL_ARG_PARSING_ERROR, NULL,
1975299742Sdim                                      _("Can't specify -c with --old"));
1976251881Speter            }
1977251881Speter
1978251881Speter          for (i = 0; i < change_revs->nelts; i++)
1979251881Speter            {
1980251881Speter              char *end;
1981251881Speter              svn_revnum_t changeno, changeno_end;
1982251881Speter              const char *change_str =
1983251881Speter                APR_ARRAY_IDX(change_revs, i, const char *);
1984251881Speter              const char *s = change_str;
1985251881Speter              svn_boolean_t is_negative;
1986251881Speter
1987251881Speter              /* Check for a leading minus to allow "-c -r42".
1988251881Speter               * The is_negative flag is used to handle "-c -42" and "-c -r42".
1989251881Speter               * The "-c r-42" case is handled by strtol() returning a
1990251881Speter               * negative number. */
1991251881Speter              is_negative = (*s == '-');
1992251881Speter              if (is_negative)
1993251881Speter                s++;
1994251881Speter
1995251881Speter              /* Allow any number of 'r's to prefix a revision number. */
1996251881Speter              while (*s == 'r')
1997251881Speter                s++;
1998251881Speter              changeno = changeno_end = strtol(s, &end, 10);
1999251881Speter              if (end != s && *end == '-')
2000251881Speter                {
2001251881Speter                  if (changeno < 0 || is_negative)
2002251881Speter                    {
2003299742Sdim                      return svn_error_createf(SVN_ERR_CL_ARG_PARSING_ERROR,
2004299742Sdim                                               NULL,
2005299742Sdim                                               _("Negative number in range (%s)"
2006299742Sdim                                                 " not supported with -c"),
2007299742Sdim                                               change_str);
2008251881Speter                    }
2009251881Speter                  s = end + 1;
2010251881Speter                  while (*s == 'r')
2011251881Speter                    s++;
2012251881Speter                  changeno_end = strtol(s, &end, 10);
2013251881Speter                }
2014251881Speter              if (end == change_str || *end != '\0')
2015251881Speter                {
2016299742Sdim                  return svn_error_createf(SVN_ERR_CL_ARG_PARSING_ERROR, NULL,
2017299742Sdim                                           _("Non-numeric change argument (%s) "
2018299742Sdim                                             "given to -c"), change_str);
2019251881Speter                }
2020251881Speter
2021251881Speter              if (changeno == 0)
2022251881Speter                {
2023299742Sdim                  return svn_error_create(SVN_ERR_CL_ARG_PARSING_ERROR, NULL,
2024299742Sdim                                          _("There is no change 0"));
2025251881Speter                }
2026251881Speter
2027251881Speter              if (is_negative)
2028251881Speter                changeno = -changeno;
2029251881Speter
2030251881Speter              /* Figure out the range:
2031251881Speter                    -c N  -> -r N-1:N
2032251881Speter                    -c -N -> -r N:N-1
2033251881Speter                    -c M-N -> -r M-1:N for M < N
2034251881Speter                    -c M-N -> -r M:N-1 for M > N
2035251881Speter                    -c -M-N -> error (too confusing/no valid use case)
2036251881Speter              */
2037251881Speter              if (changeno > 0)
2038251881Speter                {
2039251881Speter                  if (changeno <= changeno_end)
2040251881Speter                    changeno--;
2041251881Speter                  else
2042251881Speter                    changeno_end--;
2043251881Speter                }
2044251881Speter              else
2045251881Speter                {
2046251881Speter                  changeno = -changeno;
2047251881Speter                  changeno_end = changeno - 1;
2048251881Speter                }
2049251881Speter
2050251881Speter              opt_state.used_change_arg = TRUE;
2051251881Speter              APR_ARRAY_PUSH(opt_state.revision_ranges,
2052251881Speter                             svn_opt_revision_range_t *)
2053251881Speter                = svn_opt__revision_range_from_revnums(changeno, changeno_end,
2054251881Speter                                                       pool);
2055251881Speter            }
2056251881Speter        }
2057251881Speter        break;
2058251881Speter      case 'r':
2059251881Speter        opt_state.used_revision_arg = TRUE;
2060299742Sdim        SVN_ERR(svn_utf_cstring_to_utf8(&utf8_opt_arg, opt_arg, pool));
2061251881Speter        if (svn_opt_parse_revision_to_range(opt_state.revision_ranges,
2062299742Sdim                                            utf8_opt_arg, pool) != 0)
2063251881Speter          {
2064299742Sdim            return svn_error_createf(SVN_ERR_CL_ARG_PARSING_ERROR, NULL,
2065251881Speter                 _("Syntax error in revision argument '%s'"),
2066251881Speter                 utf8_opt_arg);
2067251881Speter          }
2068251881Speter        break;
2069251881Speter      case 'v':
2070251881Speter        opt_state.verbose = TRUE;
2071251881Speter        break;
2072251881Speter      case 'u':
2073251881Speter        opt_state.update = TRUE;
2074251881Speter        break;
2075251881Speter      case 'h':
2076251881Speter      case '?':
2077251881Speter        opt_state.help = TRUE;
2078251881Speter        break;
2079251881Speter      case 'q':
2080251881Speter        opt_state.quiet = TRUE;
2081251881Speter        break;
2082251881Speter      case opt_incremental:
2083251881Speter        opt_state.incremental = TRUE;
2084251881Speter        break;
2085251881Speter      case 'F':
2086299742Sdim        /* We read the raw file content here.  We will convert it to UTF-8
2087299742Sdim         * later (if it's a log/lock message or an svn:* prop value),
2088299742Sdim         * according to the value of the '--encoding' option. */
2089299742Sdim        SVN_ERR(svn_utf_cstring_to_utf8(&utf8_opt_arg, opt_arg, pool));
2090299742Sdim        SVN_ERR(svn_stringbuf_from_file2(&(opt_state.filedata),
2091299742Sdim                                         utf8_opt_arg, pool));
2092251881Speter        reading_file_from_stdin = (strcmp(utf8_opt_arg, "-") == 0);
2093299742Sdim        dash_F_arg = utf8_opt_arg;
2094251881Speter        break;
2095251881Speter      case opt_targets:
2096251881Speter        {
2097251881Speter          svn_stringbuf_t *buffer, *buffer_utf8;
2098251881Speter
2099299742Sdim          SVN_ERR(svn_utf_cstring_to_utf8(&utf8_opt_arg, opt_arg, pool));
2100299742Sdim          SVN_ERR(svn_stringbuf_from_file2(&buffer, utf8_opt_arg, pool));
2101299742Sdim          SVN_ERR(svn_utf_stringbuf_to_utf8(&buffer_utf8, buffer, pool));
2102251881Speter          opt_state.targets = svn_cstring_split(buffer_utf8->data, "\n\r",
2103251881Speter                                                TRUE, pool);
2104251881Speter        }
2105251881Speter        break;
2106251881Speter      case opt_force:
2107251881Speter        opt_state.force = TRUE;
2108251881Speter        break;
2109251881Speter      case opt_force_log:
2110251881Speter        opt_state.force_log = TRUE;
2111251881Speter        break;
2112251881Speter      case opt_dry_run:
2113251881Speter        opt_state.dry_run = TRUE;
2114251881Speter        break;
2115251881Speter      case opt_revprop:
2116251881Speter        opt_state.revprop = TRUE;
2117251881Speter        break;
2118251881Speter      case 'R':
2119251881Speter        opt_state.depth = svn_depth_infinity;
2120251881Speter        break;
2121251881Speter      case 'N':
2122251881Speter        descend = FALSE;
2123251881Speter        break;
2124251881Speter      case opt_depth:
2125251881Speter        err = svn_utf_cstring_to_utf8(&utf8_opt_arg, opt_arg, pool);
2126251881Speter        if (err)
2127299742Sdim          return svn_error_createf(SVN_ERR_CL_ARG_PARSING_ERROR, err,
2128299742Sdim                                   _("Error converting depth "
2129299742Sdim                                     "from locale to UTF-8"));
2130251881Speter        opt_state.depth = svn_depth_from_word(utf8_opt_arg);
2131251881Speter        if (opt_state.depth == svn_depth_unknown
2132251881Speter            || opt_state.depth == svn_depth_exclude)
2133251881Speter          {
2134299742Sdim            return svn_error_createf(SVN_ERR_CL_ARG_PARSING_ERROR, NULL,
2135299742Sdim                                     _("'%s' is not a valid depth; try "
2136299742Sdim                                       "'empty', 'files', 'immediates', "
2137299742Sdim                                       "or 'infinity'"),
2138299742Sdim                                     utf8_opt_arg);
2139251881Speter          }
2140251881Speter        break;
2141251881Speter      case opt_set_depth:
2142251881Speter        err = svn_utf_cstring_to_utf8(&utf8_opt_arg, opt_arg, pool);
2143251881Speter        if (err)
2144299742Sdim          return svn_error_createf(SVN_ERR_CL_ARG_PARSING_ERROR, err,
2145299742Sdim                                   _("Error converting depth "
2146299742Sdim                                     "from locale to UTF-8"));
2147251881Speter        opt_state.set_depth = svn_depth_from_word(utf8_opt_arg);
2148251881Speter        /* svn_depth_exclude is okay for --set-depth. */
2149251881Speter        if (opt_state.set_depth == svn_depth_unknown)
2150251881Speter          {
2151299742Sdim            return svn_error_createf(SVN_ERR_CL_ARG_PARSING_ERROR, NULL,
2152299742Sdim                                     _("'%s' is not a valid depth; try "
2153299742Sdim                                       "'exclude', 'empty', 'files', "
2154299742Sdim                                       "'immediates', or 'infinity'"),
2155299742Sdim                                     utf8_opt_arg);
2156251881Speter          }
2157251881Speter        break;
2158251881Speter      case opt_version:
2159251881Speter        opt_state.version = TRUE;
2160251881Speter        break;
2161251881Speter      case opt_auth_username:
2162299742Sdim        SVN_ERR(svn_utf_cstring_to_utf8(&opt_state.auth_username,
2163299742Sdim                                        opt_arg, pool));
2164251881Speter        break;
2165251881Speter      case opt_auth_password:
2166299742Sdim        SVN_ERR(svn_utf_cstring_to_utf8(&opt_state.auth_password,
2167299742Sdim                                        opt_arg, pool));
2168251881Speter        break;
2169251881Speter      case opt_encoding:
2170251881Speter        opt_state.encoding = apr_pstrdup(pool, opt_arg);
2171251881Speter        break;
2172251881Speter      case opt_xml:
2173251881Speter        opt_state.xml = TRUE;
2174251881Speter        break;
2175251881Speter      case opt_stop_on_copy:
2176251881Speter        opt_state.stop_on_copy = TRUE;
2177251881Speter        break;
2178251881Speter      case opt_no_ignore:
2179251881Speter        opt_state.no_ignore = TRUE;
2180251881Speter        break;
2181251881Speter      case opt_no_auth_cache:
2182251881Speter        opt_state.no_auth_cache = TRUE;
2183251881Speter        break;
2184251881Speter      case opt_non_interactive:
2185251881Speter        opt_state.non_interactive = TRUE;
2186251881Speter        break;
2187251881Speter      case opt_force_interactive:
2188251881Speter        force_interactive = TRUE;
2189251881Speter        break;
2190299742Sdim      case opt_trust_server_cert: /* backwards compat to 1.8 */
2191299742Sdim        opt_state.trust_server_cert_unknown_ca = TRUE;
2192251881Speter        break;
2193299742Sdim      case opt_trust_server_cert_failures:
2194299742Sdim        SVN_ERR(svn_utf_cstring_to_utf8(&utf8_opt_arg, opt_arg, pool));
2195299742Sdim        SVN_ERR(svn_cmdline__parse_trust_options(
2196299742Sdim                      &opt_state.trust_server_cert_unknown_ca,
2197299742Sdim                      &opt_state.trust_server_cert_cn_mismatch,
2198299742Sdim                      &opt_state.trust_server_cert_expired,
2199299742Sdim                      &opt_state.trust_server_cert_not_yet_valid,
2200299742Sdim                      &opt_state.trust_server_cert_other_failure,
2201299742Sdim                      utf8_opt_arg, pool));
2202299742Sdim        break;
2203251881Speter      case opt_no_diff_added:
2204251881Speter        opt_state.diff.no_diff_added = TRUE;
2205251881Speter        break;
2206251881Speter      case opt_no_diff_deleted:
2207251881Speter        opt_state.diff.no_diff_deleted = TRUE;
2208251881Speter        break;
2209251881Speter      case opt_ignore_properties:
2210251881Speter        opt_state.diff.ignore_properties = TRUE;
2211251881Speter        break;
2212251881Speter      case opt_show_copies_as_adds:
2213251881Speter        opt_state.diff.show_copies_as_adds = TRUE;
2214251881Speter        break;
2215251881Speter      case opt_notice_ancestry:
2216251881Speter        opt_state.diff.notice_ancestry = TRUE;
2217251881Speter        break;
2218251881Speter      case opt_ignore_ancestry:
2219251881Speter        opt_state.ignore_ancestry = TRUE;
2220251881Speter        break;
2221251881Speter      case opt_ignore_externals:
2222251881Speter        opt_state.ignore_externals = TRUE;
2223251881Speter        break;
2224251881Speter      case opt_relocate:
2225251881Speter        opt_state.relocate = TRUE;
2226251881Speter        break;
2227251881Speter      case 'x':
2228299742Sdim        SVN_ERR(svn_utf_cstring_to_utf8(&opt_state.extensions,
2229299742Sdim                                        opt_arg, pool));
2230251881Speter        break;
2231251881Speter      case opt_diff_cmd:
2232251881Speter        opt_state.diff.diff_cmd = apr_pstrdup(pool, opt_arg);
2233251881Speter        break;
2234251881Speter      case opt_merge_cmd:
2235251881Speter        opt_state.merge_cmd = apr_pstrdup(pool, opt_arg);
2236251881Speter        break;
2237251881Speter      case opt_record_only:
2238251881Speter        opt_state.record_only = TRUE;
2239251881Speter        break;
2240251881Speter      case opt_editor_cmd:
2241251881Speter        opt_state.editor_cmd = apr_pstrdup(pool, opt_arg);
2242251881Speter        break;
2243251881Speter      case opt_old_cmd:
2244251881Speter        if (opt_state.used_change_arg)
2245251881Speter          {
2246299742Sdim            return svn_error_create(SVN_ERR_CL_ARG_PARSING_ERROR, NULL,
2247299742Sdim                                    _("Can't specify -c with --old"));
2248251881Speter          }
2249299742Sdim        SVN_ERR(svn_utf_cstring_to_utf8(&utf8_opt_arg, opt_arg, pool));
2250299742Sdim        opt_state.old_target = apr_pstrdup(pool, utf8_opt_arg);
2251251881Speter        break;
2252251881Speter      case opt_new_cmd:
2253299742Sdim        SVN_ERR(svn_utf_cstring_to_utf8(&utf8_opt_arg, opt_arg, pool));
2254299742Sdim        opt_state.new_target = apr_pstrdup(pool, utf8_opt_arg);
2255251881Speter        break;
2256251881Speter      case opt_config_dir:
2257299742Sdim        SVN_ERR(svn_utf_cstring_to_utf8(&utf8_opt_arg, opt_arg, pool));
2258299742Sdim        opt_state.config_dir = svn_dirent_internal_style(utf8_opt_arg, pool);
2259251881Speter        break;
2260251881Speter      case opt_config_options:
2261251881Speter        if (!opt_state.config_options)
2262251881Speter          opt_state.config_options =
2263251881Speter                   apr_array_make(pool, 1,
2264251881Speter                                  sizeof(svn_cmdline__config_argument_t*));
2265251881Speter
2266299742Sdim        SVN_ERR(svn_utf_cstring_to_utf8(&utf8_opt_arg, opt_arg, pool));
2267299742Sdim        SVN_ERR(svn_cmdline__parse_config_option(opt_state.config_options,
2268299742Sdim                                                 utf8_opt_arg, "svn: ", pool));
2269251881Speter        break;
2270251881Speter      case opt_autoprops:
2271251881Speter        opt_state.autoprops = TRUE;
2272251881Speter        break;
2273251881Speter      case opt_no_autoprops:
2274251881Speter        opt_state.no_autoprops = TRUE;
2275251881Speter        break;
2276251881Speter      case opt_native_eol:
2277299742Sdim        SVN_ERR(svn_utf_cstring_to_utf8(&utf8_opt_arg, opt_arg, pool));
2278299742Sdim        if ( !strcmp("LF", utf8_opt_arg) || !strcmp("CR", utf8_opt_arg) ||
2279299742Sdim             !strcmp("CRLF", utf8_opt_arg))
2280299742Sdim          opt_state.native_eol = utf8_opt_arg;
2281251881Speter        else
2282251881Speter          {
2283299742Sdim            return svn_error_createf(SVN_ERR_CL_ARG_PARSING_ERROR, NULL,
2284251881Speter                 _("Syntax error in native-eol argument '%s'"),
2285251881Speter                 utf8_opt_arg);
2286251881Speter          }
2287251881Speter        break;
2288251881Speter      case opt_no_unlock:
2289251881Speter        opt_state.no_unlock = TRUE;
2290251881Speter        break;
2291251881Speter      case opt_summarize:
2292251881Speter        opt_state.diff.summarize = TRUE;
2293251881Speter        break;
2294251881Speter      case opt_remove:
2295251881Speter        opt_state.remove = TRUE;
2296251881Speter        break;
2297251881Speter      case opt_changelist:
2298299742Sdim        SVN_ERR(svn_utf_cstring_to_utf8(&utf8_opt_arg, opt_arg, pool));
2299299742Sdim        if (utf8_opt_arg[0] == '\0')
2300251881Speter          {
2301299742Sdim            return svn_error_create(SVN_ERR_CL_ARG_PARSING_ERROR, NULL,
2302299742Sdim                                    _("Changelist names must not be empty"));
2303251881Speter          }
2304299742Sdim        svn_hash_sets(changelists, utf8_opt_arg, (void *)1);
2305251881Speter        break;
2306251881Speter      case opt_keep_changelists:
2307251881Speter        opt_state.keep_changelists = TRUE;
2308251881Speter        break;
2309251881Speter      case opt_keep_local:
2310251881Speter        opt_state.keep_local = TRUE;
2311251881Speter        break;
2312251881Speter      case opt_with_all_revprops:
2313251881Speter        /* If --with-all-revprops is specified along with one or more
2314251881Speter         * --with-revprops options, --with-all-revprops takes precedence. */
2315251881Speter        opt_state.all_revprops = TRUE;
2316251881Speter        break;
2317251881Speter      case opt_with_no_revprops:
2318251881Speter        opt_state.no_revprops = TRUE;
2319251881Speter        break;
2320251881Speter      case opt_with_revprop:
2321299742Sdim        SVN_ERR(svn_opt_parse_revprop(&opt_state.revprop_table,
2322299742Sdim                                      opt_arg, pool));
2323251881Speter        break;
2324251881Speter      case opt_parents:
2325251881Speter        opt_state.parents = TRUE;
2326251881Speter        break;
2327251881Speter      case 'g':
2328251881Speter        opt_state.use_merge_history = TRUE;
2329251881Speter        break;
2330251881Speter      case opt_accept:
2331299742Sdim        SVN_ERR(svn_utf_cstring_to_utf8(&utf8_opt_arg, opt_arg, pool));
2332299742Sdim        opt_state.accept_which = svn_cl__accept_from_word(utf8_opt_arg);
2333251881Speter        if (opt_state.accept_which == svn_cl__accept_invalid)
2334299742Sdim          return svn_error_createf(SVN_ERR_CL_ARG_PARSING_ERROR, NULL,
2335299742Sdim                                   _("'%s' is not a valid --accept value"),
2336299742Sdim                                   utf8_opt_arg);
2337251881Speter        break;
2338251881Speter      case opt_show_revs:
2339299742Sdim        SVN_ERR(svn_utf_cstring_to_utf8(&utf8_opt_arg, opt_arg, pool));
2340299742Sdim        opt_state.show_revs = svn_cl__show_revs_from_word(utf8_opt_arg);
2341251881Speter        if (opt_state.show_revs == svn_cl__show_revs_invalid)
2342299742Sdim          return svn_error_createf(SVN_ERR_CL_ARG_PARSING_ERROR, NULL,
2343299742Sdim                                   _("'%s' is not a valid --show-revs value"),
2344299742Sdim                                   utf8_opt_arg);
2345251881Speter        break;
2346299742Sdim      case opt_mergeinfo_log:
2347299742Sdim        opt_state.mergeinfo_log = TRUE;
2348299742Sdim        break;
2349251881Speter      case opt_reintegrate:
2350251881Speter        opt_state.reintegrate = TRUE;
2351251881Speter        break;
2352251881Speter      case opt_strip:
2353251881Speter        {
2354299742Sdim          SVN_ERR(svn_utf_cstring_to_utf8(&utf8_opt_arg, opt_arg, pool));
2355299742Sdim          err = svn_cstring_atoi(&opt_state.strip, utf8_opt_arg);
2356251881Speter          if (err)
2357251881Speter            {
2358299742Sdim              return svn_error_createf(SVN_ERR_CL_ARG_PARSING_ERROR, err,
2359299742Sdim                                       _("Invalid strip count '%s'"),
2360299742Sdim                                       utf8_opt_arg);
2361251881Speter            }
2362251881Speter          if (opt_state.strip < 0)
2363251881Speter            {
2364299742Sdim              return svn_error_create(SVN_ERR_INCORRECT_PARAMS, NULL,
2365299742Sdim                                      _("Argument to --strip must be positive"));
2366251881Speter            }
2367251881Speter        }
2368251881Speter        break;
2369251881Speter      case opt_ignore_keywords:
2370251881Speter        opt_state.ignore_keywords = TRUE;
2371251881Speter        break;
2372251881Speter      case opt_reverse_diff:
2373251881Speter        opt_state.reverse_diff = TRUE;
2374251881Speter        break;
2375251881Speter      case opt_ignore_whitespace:
2376251881Speter          opt_state.ignore_whitespace = TRUE;
2377251881Speter          break;
2378251881Speter      case opt_diff:
2379251881Speter          opt_state.show_diff = TRUE;
2380251881Speter          break;
2381251881Speter      case opt_internal_diff:
2382251881Speter        opt_state.diff.internal_diff = TRUE;
2383251881Speter        break;
2384251881Speter      case opt_patch_compatible:
2385251881Speter        opt_state.diff.patch_compatible = TRUE;
2386251881Speter        break;
2387251881Speter      case opt_use_git_diff_format:
2388251881Speter        opt_state.diff.use_git_diff_format = TRUE;
2389251881Speter        break;
2390251881Speter      case opt_allow_mixed_revisions:
2391251881Speter        opt_state.allow_mixed_rev = TRUE;
2392251881Speter        break;
2393251881Speter      case opt_include_externals:
2394251881Speter        opt_state.include_externals = TRUE;
2395251881Speter        break;
2396251881Speter      case opt_show_inherited_props:
2397251881Speter        opt_state.show_inherited_props = TRUE;
2398251881Speter        break;
2399251881Speter      case opt_properties_only:
2400251881Speter        opt_state.diff.properties_only = TRUE;
2401251881Speter        break;
2402251881Speter      case opt_search:
2403299742Sdim        SVN_ERR(svn_utf_cstring_to_utf8(&utf8_opt_arg, opt_arg, pool));
2404299742Sdim        add_search_pattern_group(&opt_state, utf8_opt_arg, pool);
2405251881Speter        break;
2406251881Speter      case opt_search_and:
2407299742Sdim        SVN_ERR(svn_utf_cstring_to_utf8(&utf8_opt_arg, opt_arg, pool));
2408299742Sdim        add_search_pattern_to_latest_group(&opt_state, utf8_opt_arg, pool);
2409299742Sdim      case opt_remove_unversioned:
2410299742Sdim        opt_state.remove_unversioned = TRUE;
2411299742Sdim        break;
2412299742Sdim      case opt_remove_ignored:
2413299742Sdim        opt_state.remove_ignored = TRUE;
2414299742Sdim        break;
2415299742Sdim      case opt_no_newline:
2416299742Sdim      case opt_strict:          /* ### DEPRECATED */
2417299742Sdim        opt_state.no_newline = TRUE;
2418299742Sdim        break;
2419299742Sdim      case opt_show_passwords:
2420299742Sdim        opt_state.show_passwords = TRUE;
2421299742Sdim        break;
2422299742Sdim      case opt_pin_externals:
2423299742Sdim        opt_state.pin_externals = TRUE;
2424299742Sdim        break;
2425299742Sdim      case opt_show_item:
2426299742Sdim        SVN_ERR(svn_utf_cstring_to_utf8(&utf8_opt_arg, opt_arg, pool));
2427299742Sdim        opt_state.show_item = utf8_opt_arg;
2428299742Sdim        break;
2429251881Speter      default:
2430251881Speter        /* Hmmm. Perhaps this would be a good place to squirrel away
2431251881Speter           opts that commands like svn diff might need. Hmmm indeed. */
2432251881Speter        break;
2433251881Speter      }
2434251881Speter    }
2435251881Speter
2436251881Speter  /* The --non-interactive and --force-interactive options are mutually
2437251881Speter   * exclusive. */
2438251881Speter  if (opt_state.non_interactive && force_interactive)
2439251881Speter    {
2440299742Sdim      return svn_error_create(SVN_ERR_CL_ARG_PARSING_ERROR, NULL,
2441299742Sdim                              _("--non-interactive and --force-interactive "
2442299742Sdim                                "are mutually exclusive"));
2443251881Speter    }
2444251881Speter  else
2445251881Speter    opt_state.non_interactive = !svn_cmdline__be_interactive(
2446251881Speter                                  opt_state.non_interactive,
2447251881Speter                                  force_interactive);
2448251881Speter
2449251881Speter  /* Turn our hash of changelists into an array of unique ones. */
2450299742Sdim  SVN_ERR(svn_hash_keys(&(opt_state.changelists), changelists, pool));
2451251881Speter
2452251881Speter  /* ### This really belongs in libsvn_client.  The trouble is,
2453251881Speter     there's no one place there to run it from, no
2454251881Speter     svn_client_init().  We'd have to add it to all the public
2455251881Speter     functions that a client might call.  It's unmaintainable to do
2456251881Speter     initialization from within libsvn_client itself, but it seems
2457251881Speter     burdensome to demand that all clients call svn_client_init()
2458251881Speter     before calling any other libsvn_client function... On the other
2459251881Speter     hand, the alternative is effectively to demand that they call
2460251881Speter     svn_config_ensure() instead, so maybe we should have a generic
2461251881Speter     init function anyway.  Thoughts?  */
2462299742Sdim  SVN_ERR(svn_config_ensure(opt_state.config_dir, pool));
2463251881Speter
2464251881Speter  /* If the user asked for help, then the rest of the arguments are
2465251881Speter     the names of subcommands to get help on (if any), or else they're
2466251881Speter     just typos/mistakes.  Whatever the case, the subcommand to
2467251881Speter     actually run is svn_cl__help(). */
2468251881Speter  if (opt_state.help)
2469251881Speter    subcommand = svn_opt_get_canonical_subcommand2(svn_cl__cmd_table, "help");
2470251881Speter
2471251881Speter  /* If we're not running the `help' subcommand, then look for a
2472251881Speter     subcommand in the first argument. */
2473251881Speter  if (subcommand == NULL)
2474251881Speter    {
2475251881Speter      if (os->ind >= os->argc)
2476251881Speter        {
2477251881Speter          if (opt_state.version)
2478251881Speter            {
2479251881Speter              /* Use the "help" subcommand to handle the "--version" option. */
2480251881Speter              static const svn_opt_subcommand_desc2_t pseudo_cmd =
2481251881Speter                { "--version", svn_cl__help, {0}, "",
2482251881Speter                  {opt_version,    /* must accept its own option */
2483251881Speter                   'q',            /* brief output */
2484251881Speter                   'v',            /* verbose output */
2485251881Speter                   opt_config_dir  /* all commands accept this */
2486251881Speter                  } };
2487251881Speter
2488251881Speter              subcommand = &pseudo_cmd;
2489251881Speter            }
2490251881Speter          else
2491251881Speter            {
2492251881Speter              svn_error_clear
2493251881Speter                (svn_cmdline_fprintf(stderr, pool,
2494251881Speter                                     _("Subcommand argument required\n")));
2495251881Speter              svn_error_clear(svn_cl__help(NULL, NULL, pool));
2496299742Sdim              *exit_code = EXIT_FAILURE;
2497299742Sdim              return SVN_NO_ERROR;
2498251881Speter            }
2499251881Speter        }
2500251881Speter      else
2501251881Speter        {
2502251881Speter          const char *first_arg = os->argv[os->ind++];
2503251881Speter          subcommand = svn_opt_get_canonical_subcommand2(svn_cl__cmd_table,
2504251881Speter                                                         first_arg);
2505251881Speter          if (subcommand == NULL)
2506251881Speter            {
2507251881Speter              const char *first_arg_utf8;
2508299742Sdim              SVN_ERR(svn_utf_cstring_to_utf8(&first_arg_utf8,
2509299742Sdim                                              first_arg, pool));
2510251881Speter              svn_error_clear
2511251881Speter                (svn_cmdline_fprintf(stderr, pool,
2512251881Speter                                     _("Unknown subcommand: '%s'\n"),
2513251881Speter                                     first_arg_utf8));
2514251881Speter              svn_error_clear(svn_cl__help(NULL, NULL, pool));
2515251881Speter
2516251881Speter              /* Be kind to people who try 'svn undo'. */
2517251881Speter              if (strcmp(first_arg_utf8, "undo") == 0)
2518251881Speter                {
2519251881Speter                  svn_error_clear
2520251881Speter                    (svn_cmdline_fprintf(stderr, pool,
2521251881Speter                                         _("Undo is done using either the "
2522251881Speter                                           "'svn revert' or the 'svn merge' "
2523251881Speter                                           "command.\n")));
2524251881Speter                }
2525251881Speter
2526299742Sdim              *exit_code = EXIT_FAILURE;
2527299742Sdim              return SVN_NO_ERROR;
2528251881Speter            }
2529251881Speter        }
2530251881Speter    }
2531251881Speter
2532251881Speter  /* Check that the subcommand wasn't passed any inappropriate options. */
2533251881Speter  for (i = 0; i < received_opts->nelts; i++)
2534251881Speter    {
2535251881Speter      opt_id = APR_ARRAY_IDX(received_opts, i, int);
2536251881Speter
2537251881Speter      /* All commands implicitly accept --help, so just skip over this
2538251881Speter         when we see it. Note that we don't want to include this option
2539251881Speter         in their "accepted options" list because it would be awfully
2540251881Speter         redundant to display it in every commands' help text. */
2541251881Speter      if (opt_id == 'h' || opt_id == '?')
2542251881Speter        continue;
2543251881Speter
2544251881Speter      if (! svn_opt_subcommand_takes_option3(subcommand, opt_id,
2545251881Speter                                             svn_cl__global_options))
2546251881Speter        {
2547251881Speter          const char *optstr;
2548251881Speter          const apr_getopt_option_t *badopt =
2549251881Speter            svn_opt_get_option_from_code2(opt_id, svn_cl__options,
2550251881Speter                                          subcommand, pool);
2551251881Speter          svn_opt_format_option(&optstr, badopt, FALSE, pool);
2552251881Speter          if (subcommand->name[0] == '-')
2553251881Speter            svn_error_clear(svn_cl__help(NULL, NULL, pool));
2554251881Speter          else
2555251881Speter            svn_error_clear
2556251881Speter              (svn_cmdline_fprintf
2557251881Speter               (stderr, pool, _("Subcommand '%s' doesn't accept option '%s'\n"
2558251881Speter                                "Type 'svn help %s' for usage.\n"),
2559251881Speter                subcommand->name, optstr, subcommand->name));
2560299742Sdim          *exit_code = EXIT_FAILURE;
2561299742Sdim          return SVN_NO_ERROR;
2562251881Speter        }
2563251881Speter    }
2564251881Speter
2565251881Speter  /* Only merge and log support multiple revisions/revision ranges. */
2566251881Speter  if (subcommand->cmd_func != svn_cl__merge
2567251881Speter      && subcommand->cmd_func != svn_cl__log)
2568251881Speter    {
2569251881Speter      if (opt_state.revision_ranges->nelts > 1)
2570251881Speter        {
2571299742Sdim          return svn_error_create(SVN_ERR_CL_ARG_PARSING_ERROR, NULL,
2572299742Sdim                                  _("Multiple revision arguments "
2573299742Sdim                                    "encountered; can't specify -c twice, "
2574299742Sdim                                    "or both -c and -r"));
2575251881Speter        }
2576251881Speter    }
2577251881Speter
2578251881Speter  /* Disallow simultaneous use of both --depth and --set-depth. */
2579251881Speter  if ((opt_state.depth != svn_depth_unknown)
2580251881Speter      && (opt_state.set_depth != svn_depth_unknown))
2581251881Speter    {
2582299742Sdim      return svn_error_create(SVN_ERR_CL_ARG_PARSING_ERROR, NULL,
2583299742Sdim                              _("--depth and --set-depth are mutually "
2584299742Sdim                                "exclusive"));
2585251881Speter    }
2586251881Speter
2587251881Speter  /* Disallow simultaneous use of both --with-all-revprops and
2588251881Speter     --with-no-revprops.  */
2589251881Speter  if (opt_state.all_revprops && opt_state.no_revprops)
2590251881Speter    {
2591299742Sdim      return svn_error_create(SVN_ERR_CL_ARG_PARSING_ERROR, NULL,
2592299742Sdim                              _("--with-all-revprops and --with-no-revprops "
2593299742Sdim                                "are mutually exclusive"));
2594251881Speter    }
2595251881Speter
2596251881Speter  /* Disallow simultaneous use of both --with-revprop and
2597251881Speter     --with-no-revprops.  */
2598251881Speter  if (opt_state.revprop_table && opt_state.no_revprops)
2599251881Speter    {
2600299742Sdim      return svn_error_create(SVN_ERR_CL_ARG_PARSING_ERROR, NULL,
2601299742Sdim                              _("--with-revprop and --with-no-revprops "
2602299742Sdim                                "are mutually exclusive"));
2603251881Speter    }
2604251881Speter
2605299742Sdim#ifdef SVN_CL__OPTION_WITH_REVPROP_CAN_SET_PROPERTIES_IN_SVN_NAMESPACE
2606299742Sdim  /* XXX This is incomplete, since we do not yet check for --force, nor
2607299742Sdim     do all the commands that accept --with-revprop also accept --force. */
2608299742Sdim
2609299742Sdim  /* Check the spelling of the revision properties given by --with-revprop. */
2610299742Sdim  if (opt_state.revprop_table)
2611299742Sdim    {
2612299742Sdim      apr_hash_index_t *hi;
2613299742Sdim      for (hi = apr_hash_first(pool, opt_state.revprop_table);
2614299742Sdim           hi; hi = apr_hash_next(hi))
2615299742Sdim        {
2616299742Sdim          SVN_ERR(svn_cl__check_svn_prop_name(apr_hash_this_key(hi),
2617299742Sdim                                              TRUE, svn_cl__prop_use_use,
2618299742Sdim                                              pool));
2619299742Sdim        }
2620299742Sdim    }
2621299742Sdim#endif /* SVN_CL__OPTION_WITH_REVPROP_CAN_SET_PROPERTIES_IN_SVN_NAMESPACE */
2622299742Sdim
2623251881Speter  /* Disallow simultaneous use of both -m and -F, when they are
2624251881Speter     both used to pass a commit message or lock comment.  ('propset'
2625251881Speter     takes the property value, not a commit message, from -F.)
2626251881Speter   */
2627251881Speter  if (opt_state.filedata && opt_state.message
2628251881Speter      && subcommand->cmd_func != svn_cl__propset)
2629251881Speter    {
2630299742Sdim      return svn_error_create(SVN_ERR_CL_ARG_PARSING_ERROR, NULL,
2631299742Sdim                              _("--message (-m) and --file (-F) "
2632299742Sdim                                "are mutually exclusive"));
2633251881Speter    }
2634251881Speter
2635299742Sdim  /* --trust-* options can only be used with --non-interactive */
2636299742Sdim  if (!opt_state.non_interactive)
2637251881Speter    {
2638299742Sdim      if (opt_state.trust_server_cert_unknown_ca
2639299742Sdim          || opt_state.trust_server_cert_cn_mismatch
2640299742Sdim          || opt_state.trust_server_cert_expired
2641299742Sdim          || opt_state.trust_server_cert_not_yet_valid
2642299742Sdim          || opt_state.trust_server_cert_other_failure)
2643299742Sdim        return svn_error_create(SVN_ERR_CL_ARG_PARSING_ERROR, NULL,
2644299742Sdim                                _("--trust-server-cert-failures requires "
2645299742Sdim                                  "--non-interactive"));
2646251881Speter    }
2647251881Speter
2648251881Speter  /* Disallow simultaneous use of both --diff-cmd and
2649251881Speter     --internal-diff.  */
2650251881Speter  if (opt_state.diff.diff_cmd && opt_state.diff.internal_diff)
2651251881Speter    {
2652299742Sdim      return svn_error_create(SVN_ERR_CL_ARG_PARSING_ERROR, NULL,
2653299742Sdim                              _("--diff-cmd and --internal-diff "
2654299742Sdim                                "are mutually exclusive"));
2655251881Speter    }
2656251881Speter
2657251881Speter  /* Ensure that 'revision_ranges' has at least one item, and make
2658251881Speter     'start_revision' and 'end_revision' match that item. */
2659251881Speter  if (opt_state.revision_ranges->nelts == 0)
2660251881Speter    {
2661251881Speter      svn_opt_revision_range_t *range = apr_palloc(pool, sizeof(*range));
2662251881Speter      range->start.kind = svn_opt_revision_unspecified;
2663251881Speter      range->end.kind = svn_opt_revision_unspecified;
2664251881Speter      APR_ARRAY_PUSH(opt_state.revision_ranges,
2665251881Speter                     svn_opt_revision_range_t *) = range;
2666251881Speter    }
2667251881Speter  opt_state.start_revision = APR_ARRAY_IDX(opt_state.revision_ranges, 0,
2668251881Speter                                           svn_opt_revision_range_t *)->start;
2669251881Speter  opt_state.end_revision = APR_ARRAY_IDX(opt_state.revision_ranges, 0,
2670251881Speter                                         svn_opt_revision_range_t *)->end;
2671251881Speter
2672251881Speter  err = svn_config_get_config(&cfg_hash, opt_state.config_dir, pool);
2673251881Speter  if (err)
2674251881Speter    {
2675251881Speter      /* Fallback to default config if the config directory isn't readable
2676251881Speter         or is not a directory. */
2677251881Speter      if (APR_STATUS_IS_EACCES(err->apr_err)
2678251881Speter          || SVN__APR_STATUS_IS_ENOTDIR(err->apr_err))
2679251881Speter        {
2680251881Speter          svn_handle_warning2(stderr, err, "svn: ");
2681251881Speter          svn_error_clear(err);
2682299742Sdim
2683299742Sdim          SVN_ERR(svn_config__get_default_config(&cfg_hash, pool));
2684251881Speter        }
2685251881Speter      else
2686299742Sdim        return err;
2687251881Speter    }
2688251881Speter
2689251881Speter  /* Relocation is infinite-depth only. */
2690251881Speter  if (opt_state.relocate)
2691251881Speter    {
2692251881Speter      if (opt_state.depth != svn_depth_unknown)
2693251881Speter        {
2694299742Sdim          return svn_error_create(SVN_ERR_CL_MUTUALLY_EXCLUSIVE_ARGS, NULL,
2695299742Sdim                                  _("--relocate and --depth are mutually "
2696299742Sdim                                    "exclusive"));
2697251881Speter        }
2698251881Speter      if (! descend)
2699251881Speter        {
2700299742Sdim          return svn_error_create(
2701251881Speter                    SVN_ERR_CL_MUTUALLY_EXCLUSIVE_ARGS, NULL,
2702251881Speter                    _("--relocate and --non-recursive (-N) are mutually "
2703251881Speter                      "exclusive"));
2704251881Speter        }
2705251881Speter    }
2706251881Speter
2707251881Speter  /* Only a few commands can accept a revision range; the rest can take at
2708251881Speter     most one revision number. */
2709251881Speter  if (subcommand->cmd_func != svn_cl__blame
2710251881Speter      && subcommand->cmd_func != svn_cl__diff
2711251881Speter      && subcommand->cmd_func != svn_cl__log
2712251881Speter      && subcommand->cmd_func != svn_cl__mergeinfo
2713251881Speter      && subcommand->cmd_func != svn_cl__merge)
2714251881Speter    {
2715251881Speter      if (opt_state.end_revision.kind != svn_opt_revision_unspecified)
2716251881Speter        {
2717299742Sdim          return svn_error_create(SVN_ERR_CLIENT_REVISION_RANGE, NULL, NULL);
2718251881Speter        }
2719251881Speter    }
2720251881Speter
2721251881Speter  /* -N has a different meaning depending on the command */
2722251881Speter  if (!descend)
2723251881Speter    {
2724251881Speter      if (subcommand->cmd_func == svn_cl__status)
2725251881Speter        {
2726251881Speter          opt_state.depth = svn_depth_immediates;
2727251881Speter        }
2728251881Speter      else if (subcommand->cmd_func == svn_cl__revert
2729251881Speter               || subcommand->cmd_func == svn_cl__add
2730251881Speter               || subcommand->cmd_func == svn_cl__commit)
2731251881Speter        {
2732251881Speter          /* In pre-1.5 Subversion, some commands treated -N like
2733251881Speter             --depth=empty, so force that mapping here.  Anyway, with
2734251881Speter             revert it makes sense to be especially conservative,
2735251881Speter             since revert can lose data. */
2736251881Speter          opt_state.depth = svn_depth_empty;
2737251881Speter        }
2738251881Speter      else
2739251881Speter        {
2740251881Speter          opt_state.depth = svn_depth_files;
2741251881Speter        }
2742251881Speter    }
2743251881Speter
2744251881Speter  /* Update the options in the config */
2745251881Speter  if (opt_state.config_options)
2746251881Speter    {
2747251881Speter      svn_error_clear(
2748251881Speter          svn_cmdline__apply_config_options(cfg_hash,
2749251881Speter                                            opt_state.config_options,
2750251881Speter                                            "svn: ", "--config-option"));
2751251881Speter    }
2752251881Speter
2753299742Sdim  cfg_config = svn_hash_gets(cfg_hash, SVN_CONFIG_CATEGORY_CONFIG);
2754251881Speter#if !defined(SVN_CL_NO_EXCLUSIVE_LOCK)
2755251881Speter  {
2756251881Speter    const char *exclusive_clients_option;
2757251881Speter    apr_array_header_t *exclusive_clients;
2758251881Speter
2759251881Speter    svn_config_get(cfg_config, &exclusive_clients_option,
2760251881Speter                   SVN_CONFIG_SECTION_WORKING_COPY,
2761251881Speter                   SVN_CONFIG_OPTION_SQLITE_EXCLUSIVE_CLIENTS,
2762251881Speter                   NULL);
2763251881Speter    exclusive_clients = svn_cstring_split(exclusive_clients_option,
2764251881Speter                                          " ,", TRUE, pool);
2765251881Speter    for (i = 0; i < exclusive_clients->nelts; ++i)
2766251881Speter      {
2767251881Speter        const char *exclusive_client = APR_ARRAY_IDX(exclusive_clients, i,
2768251881Speter                                                     const char *);
2769251881Speter
2770251881Speter        /* This blocks other clients from accessing the wc.db so it must
2771251881Speter           be explicitly enabled.*/
2772251881Speter        if (!strcmp(exclusive_client, "svn"))
2773251881Speter          svn_config_set(cfg_config,
2774251881Speter                         SVN_CONFIG_SECTION_WORKING_COPY,
2775251881Speter                         SVN_CONFIG_OPTION_SQLITE_EXCLUSIVE,
2776251881Speter                         "true");
2777251881Speter      }
2778251881Speter  }
2779251881Speter#endif
2780251881Speter
2781251881Speter  /* Create a client context object. */
2782251881Speter  command_baton.opt_state = &opt_state;
2783299742Sdim  SVN_ERR(svn_client_create_context2(&ctx, cfg_hash, pool));
2784251881Speter  command_baton.ctx = ctx;
2785251881Speter
2786251881Speter  /* If we're running a command that could result in a commit, verify
2787251881Speter     that any log message we were given on the command line makes
2788251881Speter     sense (unless we've also been instructed not to care).  This may
2789251881Speter     access the working copy so do it after setting the locking mode. */
2790251881Speter  if ((! opt_state.force_log)
2791251881Speter      && (subcommand->cmd_func == svn_cl__commit
2792251881Speter          || subcommand->cmd_func == svn_cl__copy
2793251881Speter          || subcommand->cmd_func == svn_cl__delete
2794251881Speter          || subcommand->cmd_func == svn_cl__import
2795251881Speter          || subcommand->cmd_func == svn_cl__mkdir
2796251881Speter          || subcommand->cmd_func == svn_cl__move
2797251881Speter          || subcommand->cmd_func == svn_cl__lock
2798251881Speter          || subcommand->cmd_func == svn_cl__propedit))
2799251881Speter    {
2800251881Speter      /* If the -F argument is a file that's under revision control,
2801251881Speter         that's probably not what the user intended. */
2802251881Speter      if (dash_F_arg)
2803251881Speter        {
2804251881Speter          svn_node_kind_t kind;
2805251881Speter          const char *local_abspath;
2806251881Speter          const char *fname_utf8 = svn_dirent_internal_style(dash_F_arg, pool);
2807251881Speter
2808251881Speter          err = svn_dirent_get_absolute(&local_abspath, fname_utf8, pool);
2809251881Speter
2810251881Speter          if (!err)
2811251881Speter            {
2812251881Speter              err = svn_wc_read_kind2(&kind, ctx->wc_ctx, local_abspath, TRUE,
2813251881Speter                                      FALSE, pool);
2814251881Speter
2815251881Speter              if (!err && kind != svn_node_none && kind != svn_node_unknown)
2816251881Speter                {
2817251881Speter                  if (subcommand->cmd_func != svn_cl__lock)
2818251881Speter                    {
2819299742Sdim                      return svn_error_create(
2820251881Speter                         SVN_ERR_CL_LOG_MESSAGE_IS_VERSIONED_FILE, NULL,
2821251881Speter                         _("Log message file is a versioned file; "
2822251881Speter                           "use '--force-log' to override"));
2823251881Speter                    }
2824251881Speter                  else
2825251881Speter                    {
2826299742Sdim                      return svn_error_create(
2827251881Speter                         SVN_ERR_CL_LOG_MESSAGE_IS_VERSIONED_FILE, NULL,
2828251881Speter                         _("Lock comment file is a versioned file; "
2829251881Speter                           "use '--force-log' to override"));
2830251881Speter                    }
2831251881Speter                }
2832251881Speter            }
2833251881Speter          svn_error_clear(err);
2834251881Speter        }
2835251881Speter
2836251881Speter      /* If the -m argument is a file at all, that's probably not what
2837251881Speter         the user intended. */
2838299742Sdim      if (opt_state.message)
2839251881Speter        {
2840251881Speter          apr_finfo_t finfo;
2841299742Sdim          if (apr_stat(&finfo, opt_state.message /* not converted to UTF-8 */,
2842251881Speter                       APR_FINFO_MIN, pool) == APR_SUCCESS)
2843251881Speter            {
2844251881Speter              if (subcommand->cmd_func != svn_cl__lock)
2845251881Speter                {
2846299742Sdim                  return svn_error_create
2847251881Speter                    (SVN_ERR_CL_LOG_MESSAGE_IS_PATHNAME, NULL,
2848251881Speter                     _("The log message is a pathname "
2849251881Speter                       "(was -F intended?); use '--force-log' to override"));
2850251881Speter                }
2851251881Speter              else
2852251881Speter                {
2853299742Sdim                  return svn_error_create
2854251881Speter                    (SVN_ERR_CL_LOG_MESSAGE_IS_PATHNAME, NULL,
2855251881Speter                     _("The lock comment is a pathname "
2856251881Speter                       "(was -F intended?); use '--force-log' to override"));
2857251881Speter                }
2858251881Speter            }
2859251881Speter        }
2860251881Speter    }
2861251881Speter
2862251881Speter  /* XXX: Only diff_cmd for now, overlay rest later and stop passing
2863251881Speter     opt_state altogether? */
2864251881Speter  if (opt_state.diff.diff_cmd)
2865251881Speter    svn_config_set(cfg_config, SVN_CONFIG_SECTION_HELPERS,
2866251881Speter                   SVN_CONFIG_OPTION_DIFF_CMD, opt_state.diff.diff_cmd);
2867251881Speter  if (opt_state.merge_cmd)
2868251881Speter    svn_config_set(cfg_config, SVN_CONFIG_SECTION_HELPERS,
2869251881Speter                   SVN_CONFIG_OPTION_DIFF3_CMD, opt_state.merge_cmd);
2870251881Speter  if (opt_state.diff.internal_diff)
2871251881Speter    svn_config_set(cfg_config, SVN_CONFIG_SECTION_HELPERS,
2872251881Speter                   SVN_CONFIG_OPTION_DIFF_CMD, NULL);
2873251881Speter
2874251881Speter  /* Check for mutually exclusive args --auto-props and --no-auto-props */
2875251881Speter  if (opt_state.autoprops && opt_state.no_autoprops)
2876251881Speter    {
2877299742Sdim      return svn_error_create(SVN_ERR_CL_MUTUALLY_EXCLUSIVE_ARGS, NULL,
2878299742Sdim                              _("--auto-props and --no-auto-props are "
2879299742Sdim                                "mutually exclusive"));
2880251881Speter    }
2881251881Speter
2882251881Speter  /* Update auto-props-enable option, and populate the MIME types map,
2883251881Speter     for add/import commands */
2884251881Speter  if (subcommand->cmd_func == svn_cl__add
2885251881Speter      || subcommand->cmd_func == svn_cl__import)
2886251881Speter    {
2887251881Speter      const char *mimetypes_file;
2888251881Speter      svn_config_get(cfg_config, &mimetypes_file,
2889251881Speter                     SVN_CONFIG_SECTION_MISCELLANY,
2890251881Speter                     SVN_CONFIG_OPTION_MIMETYPES_FILE, FALSE);
2891251881Speter      if (mimetypes_file && *mimetypes_file)
2892251881Speter        {
2893299742Sdim          SVN_ERR(svn_io_parse_mimetypes_file(&(ctx->mimetypes_map),
2894299742Sdim                                              mimetypes_file, pool));
2895251881Speter        }
2896251881Speter
2897251881Speter      if (opt_state.autoprops)
2898251881Speter        {
2899251881Speter          svn_config_set_bool(cfg_config, SVN_CONFIG_SECTION_MISCELLANY,
2900251881Speter                              SVN_CONFIG_OPTION_ENABLE_AUTO_PROPS, TRUE);
2901251881Speter        }
2902251881Speter      if (opt_state.no_autoprops)
2903251881Speter        {
2904251881Speter          svn_config_set_bool(cfg_config, SVN_CONFIG_SECTION_MISCELLANY,
2905251881Speter                              SVN_CONFIG_OPTION_ENABLE_AUTO_PROPS, FALSE);
2906251881Speter        }
2907251881Speter    }
2908251881Speter
2909251881Speter  /* Update the 'keep-locks' runtime option */
2910251881Speter  if (opt_state.no_unlock)
2911251881Speter    svn_config_set_bool(cfg_config, SVN_CONFIG_SECTION_MISCELLANY,
2912251881Speter                        SVN_CONFIG_OPTION_NO_UNLOCK, TRUE);
2913251881Speter
2914251881Speter  /* Set the log message callback function.  Note that individual
2915251881Speter     subcommands will populate the ctx->log_msg_baton3. */
2916251881Speter  ctx->log_msg_func3 = svn_cl__get_log_message;
2917251881Speter
2918251881Speter  /* Set up the notifier.
2919251881Speter
2920251881Speter     In general, we use it any time we aren't in --quiet mode.  'svn
2921251881Speter     status' is unique, though, in that we don't want it in --quiet mode
2922251881Speter     unless we're also in --verbose mode.  When in --xml mode,
2923251881Speter     though, we never want it.  */
2924251881Speter  if (opt_state.quiet)
2925251881Speter    use_notifier = FALSE;
2926251881Speter  if ((subcommand->cmd_func == svn_cl__status) && opt_state.verbose)
2927251881Speter    use_notifier = TRUE;
2928251881Speter  if (opt_state.xml)
2929251881Speter    use_notifier = FALSE;
2930251881Speter  if (use_notifier)
2931251881Speter    {
2932299742Sdim      SVN_ERR(svn_cl__get_notifier(&ctx->notify_func2, &ctx->notify_baton2,
2933299742Sdim                                   conflict_stats, pool));
2934251881Speter    }
2935251881Speter
2936251881Speter  /* Set up our cancellation support. */
2937251881Speter  ctx->cancel_func = svn_cl__check_cancel;
2938251881Speter  apr_signal(SIGINT, signal_handler);
2939251881Speter#ifdef SIGBREAK
2940251881Speter  /* SIGBREAK is a Win32 specific signal generated by ctrl-break. */
2941251881Speter  apr_signal(SIGBREAK, signal_handler);
2942251881Speter#endif
2943251881Speter#ifdef SIGHUP
2944251881Speter  apr_signal(SIGHUP, signal_handler);
2945251881Speter#endif
2946251881Speter#ifdef SIGTERM
2947251881Speter  apr_signal(SIGTERM, signal_handler);
2948251881Speter#endif
2949251881Speter
2950251881Speter#ifdef SIGPIPE
2951251881Speter  /* Disable SIGPIPE generation for the platforms that have it. */
2952251881Speter  apr_signal(SIGPIPE, SIG_IGN);
2953251881Speter#endif
2954251881Speter
2955251881Speter#ifdef SIGXFSZ
2956251881Speter  /* Disable SIGXFSZ generation for the platforms that have it, otherwise
2957251881Speter   * working with large files when compiled against an APR that doesn't have
2958251881Speter   * large file support will crash the program, which is uncool. */
2959251881Speter  apr_signal(SIGXFSZ, SIG_IGN);
2960251881Speter#endif
2961251881Speter
2962251881Speter  /* Set up Authentication stuff. */
2963299742Sdim  SVN_ERR(svn_cmdline_create_auth_baton2(
2964299742Sdim            &ab,
2965299742Sdim            opt_state.non_interactive,
2966299742Sdim            opt_state.auth_username,
2967299742Sdim            opt_state.auth_password,
2968299742Sdim            opt_state.config_dir,
2969299742Sdim            opt_state.no_auth_cache,
2970299742Sdim            opt_state.trust_server_cert_unknown_ca,
2971299742Sdim            opt_state.trust_server_cert_cn_mismatch,
2972299742Sdim            opt_state.trust_server_cert_expired,
2973299742Sdim            opt_state.trust_server_cert_not_yet_valid,
2974299742Sdim            opt_state.trust_server_cert_other_failure,
2975299742Sdim            cfg_config,
2976299742Sdim            ctx->cancel_func,
2977299742Sdim            ctx->cancel_baton,
2978299742Sdim            pool));
2979251881Speter
2980251881Speter  ctx->auth_baton = ab;
2981251881Speter
2982251881Speter  if (opt_state.non_interactive)
2983251881Speter    {
2984251881Speter      if (opt_state.accept_which == svn_cl__accept_edit)
2985299742Sdim        {
2986299742Sdim          return svn_error_createf(SVN_ERR_CL_ARG_PARSING_ERROR, NULL,
2987251881Speter                                   _("--accept=%s incompatible with"
2988251881Speter                                     " --non-interactive"),
2989299742Sdim                                   SVN_CL__ACCEPT_EDIT);
2990299742Sdim        }
2991251881Speter      if (opt_state.accept_which == svn_cl__accept_launch)
2992299742Sdim        {
2993299742Sdim          return svn_error_createf(SVN_ERR_CL_ARG_PARSING_ERROR, NULL,
2994251881Speter                                   _("--accept=%s incompatible with"
2995251881Speter                                     " --non-interactive"),
2996299742Sdim                                   SVN_CL__ACCEPT_LAUNCH);
2997299742Sdim        }
2998251881Speter
2999251881Speter      /* The default action when we're non-interactive is to postpone
3000251881Speter       * conflict resolution. */
3001251881Speter      if (opt_state.accept_which == svn_cl__accept_unspecified)
3002251881Speter        opt_state.accept_which = svn_cl__accept_postpone;
3003251881Speter    }
3004251881Speter
3005251881Speter  /* Check whether interactive conflict resolution is disabled by
3006251881Speter   * the configuration file. If no --accept option was specified
3007251881Speter   * we postpone all conflicts in this case. */
3008299742Sdim  SVN_ERR(svn_config_get_bool(cfg_config, &interactive_conflicts,
3009299742Sdim                              SVN_CONFIG_SECTION_MISCELLANY,
3010299742Sdim                              SVN_CONFIG_OPTION_INTERACTIVE_CONFLICTS,
3011299742Sdim                              TRUE));
3012251881Speter  if (!interactive_conflicts)
3013251881Speter    {
3014251881Speter      /* Make 'svn resolve' non-interactive. */
3015251881Speter      if (subcommand->cmd_func == svn_cl__resolve)
3016251881Speter        opt_state.non_interactive = TRUE;
3017251881Speter
3018251881Speter      /* We're not resolving conflicts interactively. If no --accept option
3019251881Speter       * was provided the default behaviour is to postpone all conflicts. */
3020251881Speter      if (opt_state.accept_which == svn_cl__accept_unspecified)
3021251881Speter        opt_state.accept_which = svn_cl__accept_postpone;
3022251881Speter    }
3023251881Speter
3024251881Speter  /* Install the default conflict handler. */
3025251881Speter  {
3026251881Speter    svn_cl__interactive_conflict_baton_t *b;
3027251881Speter
3028251881Speter    ctx->conflict_func = NULL;
3029251881Speter    ctx->conflict_baton = NULL;
3030251881Speter
3031251881Speter    ctx->conflict_func2 = svn_cl__conflict_func_interactive;
3032299742Sdim    SVN_ERR(svn_cl__get_conflict_func_interactive_baton(
3033251881Speter                &b,
3034251881Speter                opt_state.accept_which,
3035251881Speter                ctx->config, opt_state.editor_cmd, conflict_stats,
3036251881Speter                ctx->cancel_func, ctx->cancel_baton, pool));
3037251881Speter    ctx->conflict_baton2 = b;
3038251881Speter  }
3039251881Speter
3040251881Speter  /* And now we finally run the subcommand. */
3041251881Speter  err = (*subcommand->cmd_func)(os, &command_baton, pool);
3042251881Speter  if (err)
3043251881Speter    {
3044251881Speter      /* For argument-related problems, suggest using the 'help'
3045251881Speter         subcommand. */
3046251881Speter      if (err->apr_err == SVN_ERR_CL_INSUFFICIENT_ARGS
3047251881Speter          || err->apr_err == SVN_ERR_CL_ARG_PARSING_ERROR)
3048251881Speter        {
3049299742Sdim          err = svn_error_quick_wrapf(
3050299742Sdim                  err, _("Try 'svn help %s' for more information"),
3051299742Sdim                  subcommand->name);
3052251881Speter        }
3053251881Speter      if (err->apr_err == SVN_ERR_WC_UPGRADE_REQUIRED)
3054251881Speter        {
3055251881Speter          err = svn_error_quick_wrap(err,
3056251881Speter                                     _("Please see the 'svn upgrade' command"));
3057251881Speter        }
3058251881Speter
3059251881Speter      if (err->apr_err == SVN_ERR_AUTHN_FAILED && opt_state.non_interactive)
3060251881Speter        {
3061251881Speter          err = svn_error_quick_wrap(err,
3062251881Speter                                     _("Authentication failed and interactive"
3063251881Speter                                       " prompting is disabled; see the"
3064251881Speter                                       " --force-interactive option"));
3065251881Speter          if (reading_file_from_stdin)
3066251881Speter            err = svn_error_quick_wrap(err,
3067251881Speter                                       _("Reading file from standard input "
3068251881Speter                                         "because of -F option; this can "
3069251881Speter                                         "interfere with interactive "
3070251881Speter                                         "prompting"));
3071251881Speter        }
3072251881Speter
3073251881Speter      /* Tell the user about 'svn cleanup' if any error on the stack
3074251881Speter         was about locked working copies. */
3075251881Speter      if (svn_error_find_cause(err, SVN_ERR_WC_LOCKED))
3076251881Speter        {
3077251881Speter          err = svn_error_quick_wrap(
3078251881Speter                  err, _("Run 'svn cleanup' to remove locks "
3079251881Speter                         "(type 'svn help cleanup' for details)"));
3080251881Speter        }
3081251881Speter
3082251881Speter      if (err->apr_err == SVN_ERR_SQLITE_BUSY)
3083251881Speter        {
3084251881Speter          err = svn_error_quick_wrap(err,
3085251881Speter                                     _("Another process is blocking the "
3086251881Speter                                       "working copy database, or the "
3087251881Speter                                       "underlying filesystem does not "
3088251881Speter                                       "support file locking; if the working "
3089251881Speter                                       "copy is on a network filesystem, make "
3090251881Speter                                       "sure file locking has been enabled "
3091251881Speter                                       "on the file server"));
3092251881Speter        }
3093251881Speter
3094251881Speter      if (svn_error_find_cause(err, SVN_ERR_RA_CANNOT_CREATE_TUNNEL) &&
3095251881Speter          (opt_state.auth_username || opt_state.auth_password))
3096251881Speter        {
3097251881Speter          err = svn_error_quick_wrap(
3098251881Speter                  err, _("When using svn+ssh:// URLs, keep in mind that the "
3099251881Speter                         "--username and --password options are ignored "
3100251881Speter                         "because authentication is performed by SSH, not "
3101251881Speter                         "Subversion"));
3102251881Speter        }
3103251881Speter
3104299742Sdim      return err;
3105251881Speter    }
3106251881Speter
3107299742Sdim  return SVN_NO_ERROR;
3108251881Speter}
3109251881Speter
3110251881Speterint
3111251881Spetermain(int argc, const char *argv[])
3112251881Speter{
3113251881Speter  apr_pool_t *pool;
3114299742Sdim  int exit_code = EXIT_SUCCESS;
3115299742Sdim  svn_error_t *err;
3116251881Speter
3117251881Speter  /* Initialize the app. */
3118251881Speter  if (svn_cmdline_init("svn", stderr) != EXIT_SUCCESS)
3119251881Speter    return EXIT_FAILURE;
3120251881Speter
3121251881Speter  /* Create our top-level pool.  Use a separate mutexless allocator,
3122251881Speter   * given this application is single threaded.
3123251881Speter   */
3124251881Speter  pool = apr_allocator_owner_get(svn_pool_create_allocator(FALSE));
3125251881Speter
3126299742Sdim  err = sub_main(&exit_code, argc, argv, pool);
3127251881Speter
3128299742Sdim  /* Flush stdout and report if it fails. It would be flushed on exit anyway
3129299742Sdim     but this makes sure that output is not silently lost if it fails. */
3130299742Sdim  err = svn_error_compose_create(err, svn_cmdline_fflush(stdout));
3131299742Sdim
3132299742Sdim  if (err)
3133299742Sdim    {
3134299742Sdim      exit_code = EXIT_FAILURE;
3135299742Sdim      svn_cmdline_handle_exit_error(err, NULL, "svn: ");
3136299742Sdim    }
3137299742Sdim
3138251881Speter  svn_pool_destroy(pool);
3139251881Speter  return exit_code;
3140251881Speter}
3141