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,
113251881Speter  opt_strict,
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,
128251881Speter  opt_strip,
129251881Speter  opt_ignore_keywords,
130251881Speter  opt_reverse_diff,
131251881Speter  opt_ignore_whitespace,
132251881Speter  opt_diff,
133251881Speter  opt_allow_mixed_revisions,
134251881Speter  opt_include_externals,
135251881Speter  opt_show_inherited_props,
136251881Speter  opt_search,
137251881Speter  opt_search_and
138251881Speter} svn_cl__longopt_t;
139251881Speter
140251881Speter
141251881Speter/* Option codes and descriptions for the command line client.
142251881Speter *
143251881Speter * The entire list must be terminated with an entry of nulls.
144251881Speter */
145251881Speterconst apr_getopt_option_t svn_cl__options[] =
146251881Speter{
147251881Speter  {"force",         opt_force, 0, N_("force operation to run")},
148251881Speter  {"force-log",     opt_force_log, 0,
149251881Speter                    N_("force validity of log message source")},
150251881Speter  {"help",          'h', 0, N_("show help on a subcommand")},
151251881Speter  {NULL,            '?', 0, N_("show help on a subcommand")},
152251881Speter  {"message",       'm', 1, N_("specify log message ARG")},
153251881Speter  {"quiet",         'q', 0, N_("print nothing, or only summary information")},
154251881Speter  {"recursive",     'R', 0, N_("descend recursively, same as --depth=infinity")},
155251881Speter  {"non-recursive", 'N', 0, N_("obsolete; try --depth=files or --depth=immediates")},
156251881Speter  {"change",        'c', 1,
157251881Speter                    N_("the change made by revision ARG (like -r ARG-1:ARG)\n"
158251881Speter                       "                             "
159251881Speter                       "If ARG is negative this is like -r ARG:ARG-1\n"
160251881Speter                       "                             "
161251881Speter                       "If ARG is of the form ARG1-ARG2 then this is like\n"
162251881Speter                       "                             "
163251881Speter                       "ARG1:ARG2, where ARG1 is inclusive")},
164251881Speter  {"revision",      'r', 1,
165251881Speter                    N_("ARG (some commands also take ARG1:ARG2 range)\n"
166251881Speter                       "                             "
167251881Speter                       "A revision argument can be one of:\n"
168251881Speter                       "                             "
169251881Speter                       "   NUMBER       revision number\n"
170251881Speter                       "                             "
171251881Speter                       "   '{' DATE '}' revision at start of the date\n"
172251881Speter                       "                             "
173251881Speter                       "   'HEAD'       latest in repository\n"
174251881Speter                       "                             "
175251881Speter                       "   'BASE'       base rev of item's working copy\n"
176251881Speter                       "                             "
177251881Speter                       "   'COMMITTED'  last commit at or before BASE\n"
178251881Speter                       "                             "
179251881Speter                       "   'PREV'       revision just before COMMITTED")},
180251881Speter  {"file",          'F', 1, N_("read log message from file ARG")},
181251881Speter  {"incremental",   opt_incremental, 0,
182251881Speter                    N_("give output suitable for concatenation")},
183251881Speter  {"encoding",      opt_encoding, 1,
184251881Speter                    N_("treat value as being in charset encoding ARG")},
185251881Speter  {"version",       opt_version, 0, N_("show program version information")},
186251881Speter  {"verbose",       'v', 0, N_("print extra information")},
187251881Speter  {"show-updates",  'u', 0, N_("display update information")},
188251881Speter  {"username",      opt_auth_username, 1, N_("specify a username ARG")},
189251881Speter  {"password",      opt_auth_password, 1, N_("specify a password ARG")},
190251881Speter  {"extensions",    'x', 1,
191251881Speter                    N_("Specify differencing options for external diff or\n"
192251881Speter                       "                             "
193251881Speter                       "internal diff or blame. Default: '-u'. Options are\n"
194251881Speter                       "                             "
195251881Speter                       "separated by spaces. Internal diff and blame take:\n"
196251881Speter                       "                             "
197251881Speter                       "  -u, --unified: Show 3 lines of unified context\n"
198251881Speter                       "                             "
199251881Speter                       "  -b, --ignore-space-change: Ignore changes in\n"
200251881Speter                       "                             "
201251881Speter                       "    amount of white space\n"
202251881Speter                       "                             "
203251881Speter                       "  -w, --ignore-all-space: Ignore all white space\n"
204251881Speter                       "                             "
205251881Speter                       "  --ignore-eol-style: Ignore changes in EOL style\n"
206251881Speter                       "                             "
207251881Speter                       "  -p, --show-c-function: Show C function name")},
208251881Speter  {"targets",       opt_targets, 1,
209251881Speter                    N_("pass contents of file ARG as additional args")},
210251881Speter  {"depth",         opt_depth, 1,
211251881Speter                    N_("limit operation by depth ARG ('empty', 'files',\n"
212251881Speter                       "                             "
213251881Speter                       "'immediates', or 'infinity')")},
214251881Speter  {"set-depth",     opt_set_depth, 1,
215251881Speter                    N_("set new working copy depth to ARG ('exclude',\n"
216251881Speter                       "                             "
217251881Speter                       "'empty', 'files', 'immediates', or 'infinity')")},
218251881Speter  {"xml",           opt_xml, 0, N_("output in XML")},
219251881Speter  {"strict",        opt_strict, 0, N_("use strict semantics")},
220251881Speter  {"stop-on-copy",  opt_stop_on_copy, 0,
221251881Speter                    N_("do not cross copies while traversing history")},
222251881Speter  {"no-ignore",     opt_no_ignore, 0,
223251881Speter                    N_("disregard default and svn:ignore and\n"
224251881Speter                       "                             "
225251881Speter                       "svn:global-ignores property ignores")},
226251881Speter  {"no-auth-cache", opt_no_auth_cache, 0,
227251881Speter                    N_("do not cache authentication tokens")},
228251881Speter  {"trust-server-cert", opt_trust_server_cert, 0,
229251881Speter                    N_("accept SSL server certificates from unknown\n"
230251881Speter                       "                             "
231251881Speter                       "certificate authorities without prompting (but only\n"
232251881Speter                       "                             "
233251881Speter                       "with '--non-interactive')") },
234251881Speter  {"non-interactive", opt_non_interactive, 0,
235251881Speter                    N_("do no interactive prompting (default is to prompt\n"
236251881Speter                       "                             "
237251881Speter                       "only if standard input is a terminal device)")},
238251881Speter  {"force-interactive", opt_force_interactive, 0,
239251881Speter                    N_("do interactive prompting even if standard input\n"
240251881Speter                       "                             "
241251881Speter                       "is not a terminal device")},
242251881Speter  {"dry-run",       opt_dry_run, 0,
243251881Speter                    N_("try operation but make no changes")},
244251881Speter  {"ignore-ancestry", opt_ignore_ancestry, 0,
245251881Speter                    N_("disable merge tracking; diff nodes as if related")},
246251881Speter  {"ignore-externals", opt_ignore_externals, 0,
247251881Speter                    N_("ignore externals definitions")},
248251881Speter  {"diff3-cmd",     opt_merge_cmd, 1, N_("use ARG as merge command")},
249251881Speter  {"editor-cmd",    opt_editor_cmd, 1, N_("use ARG as external editor")},
250251881Speter  {"record-only",   opt_record_only, 0,
251251881Speter                    N_("merge only mergeinfo differences")},
252251881Speter  {"old",           opt_old_cmd, 1, N_("use ARG as the older target")},
253251881Speter  {"new",           opt_new_cmd, 1, N_("use ARG as the newer target")},
254251881Speter  {"revprop",       opt_revprop, 0,
255251881Speter                    N_("operate on a revision property (use with -r)")},
256251881Speter  {"relocate",      opt_relocate, 0, N_("relocate via URL-rewriting")},
257251881Speter  {"config-dir",    opt_config_dir, 1,
258251881Speter                    N_("read user configuration files from directory ARG")},
259251881Speter  {"config-option", opt_config_options, 1,
260251881Speter                    N_("set user configuration option in the format:\n"
261251881Speter                       "                             "
262251881Speter                       "    FILE:SECTION:OPTION=[VALUE]\n"
263251881Speter                       "                             "
264251881Speter                       "For example:\n"
265251881Speter                       "                             "
266251881Speter                       "    servers:global:http-library=serf")},
267251881Speter  {"auto-props",    opt_autoprops, 0, N_("enable automatic properties")},
268251881Speter  {"no-auto-props", opt_no_autoprops, 0, N_("disable automatic properties")},
269251881Speter  {"native-eol",    opt_native_eol, 1,
270251881Speter                    N_("use a different EOL marker than the standard\n"
271251881Speter                       "                             "
272251881Speter                       "system marker for files with the svn:eol-style\n"
273251881Speter                       "                             "
274251881Speter                       "property set to 'native'.\n"
275251881Speter                       "                             "
276251881Speter                       "ARG may be one of 'LF', 'CR', 'CRLF'")},
277251881Speter  {"limit",         'l', 1, N_("maximum number of log entries")},
278251881Speter  {"no-unlock",     opt_no_unlock, 0, N_("don't unlock the targets")},
279251881Speter  {"remove",         opt_remove, 0, N_("remove changelist association")},
280251881Speter  {"changelist",    opt_changelist, 1,
281251881Speter                    N_("operate only on members of changelist ARG")},
282251881Speter  {"keep-changelists", opt_keep_changelists, 0,
283251881Speter                    N_("don't delete changelists after commit")},
284251881Speter  {"keep-local",    opt_keep_local, 0, N_("keep path in working copy")},
285251881Speter  {"with-all-revprops",  opt_with_all_revprops, 0,
286251881Speter                    N_("retrieve all revision properties")},
287251881Speter  {"with-no-revprops",  opt_with_no_revprops, 0,
288251881Speter                    N_("retrieve no revision properties")},
289251881Speter  {"with-revprop",  opt_with_revprop, 1,
290251881Speter                    N_("set revision property ARG in new revision\n"
291251881Speter                       "                             "
292251881Speter                       "using the name[=value] format")},
293251881Speter  {"parents",       opt_parents, 0, N_("make intermediate directories")},
294251881Speter  {"use-merge-history", 'g', 0,
295251881Speter                    N_("use/display additional information from merge\n"
296251881Speter                       "                             "
297251881Speter                       "history")},
298251881Speter  {"accept",        opt_accept, 1,
299251881Speter                    N_("specify automatic conflict resolution action\n"
300251881Speter                       "                             "
301251881Speter                       "('postpone', 'working', 'base', 'mine-conflict',\n"
302251881Speter                       "                             "
303251881Speter                       "'theirs-conflict', 'mine-full', 'theirs-full',\n"
304251881Speter                       "                             "
305251881Speter                       "'edit', 'launch')\n"
306251881Speter                       "                             "
307251881Speter                       "(shorthand: 'p', 'mc', 'tc', 'mf', 'tf', 'e', 'l')"
308251881Speter                       )},
309251881Speter  {"show-revs",     opt_show_revs, 1,
310251881Speter                    N_("specify which collection of revisions to display\n"
311251881Speter                       "                             "
312251881Speter                       "('merged', 'eligible')")},
313251881Speter  {"reintegrate",   opt_reintegrate, 0,
314251881Speter                    N_("deprecated")},
315251881Speter  {"strip",         opt_strip, 1,
316251881Speter                    N_("number of leading path components to strip from\n"
317251881Speter                       "                             "
318251881Speter                       "paths parsed from the patch file. --strip 0\n"
319251881Speter                       "                             "
320251881Speter                       "is the default and leaves paths unmodified.\n"
321251881Speter                       "                             "
322251881Speter                       "--strip 1 would change the path\n"
323251881Speter                       "                             "
324251881Speter                       "'doc/fudge/crunchy.html' to 'fudge/crunchy.html'.\n"
325251881Speter                       "                             "
326251881Speter                       "--strip 2 would leave just 'crunchy.html'\n"
327251881Speter                       "                             "
328251881Speter                       "The expected component separator is '/' on all\n"
329251881Speter                       "                             "
330251881Speter                       "platforms. A leading '/' counts as one component.")},
331251881Speter  {"ignore-keywords", opt_ignore_keywords, 0,
332251881Speter                    N_("don't expand keywords")},
333251881Speter  {"reverse-diff", opt_reverse_diff, 0,
334251881Speter                    N_("apply the unidiff in reverse")},
335251881Speter  {"ignore-whitespace", opt_ignore_whitespace, 0,
336251881Speter                       N_("ignore whitespace during pattern matching")},
337251881Speter  {"diff", opt_diff, 0, N_("produce diff output")}, /* maps to show_diff */
338251881Speter  /* diff options */
339251881Speter  {"diff-cmd",      opt_diff_cmd, 1, N_("use ARG as diff command")},
340251881Speter  {"internal-diff", opt_internal_diff, 0,
341251881Speter                       N_("override diff-cmd specified in config file")},
342251881Speter  {"no-diff-added", opt_no_diff_added, 0,
343251881Speter                    N_("do not print differences for added files")},
344251881Speter  {"no-diff-deleted", opt_no_diff_deleted, 0,
345251881Speter                    N_("do not print differences for deleted files")},
346251881Speter  {"show-copies-as-adds", opt_show_copies_as_adds, 0,
347251881Speter                    N_("don't diff copied or moved files with their source")},
348251881Speter  {"notice-ancestry", opt_notice_ancestry, 0,
349251881Speter                    N_("diff unrelated nodes as delete and add")},
350251881Speter  {"summarize",     opt_summarize, 0, N_("show a summary of the results")},
351251881Speter  {"git", opt_use_git_diff_format, 0,
352251881Speter                       N_("use git's extended diff format")},
353251881Speter  {"ignore-properties", opt_ignore_properties, 0,
354251881Speter                    N_("ignore properties during the operation")},
355251881Speter  {"properties-only", opt_properties_only, 0,
356251881Speter                       N_("show only properties during the operation")},
357251881Speter  {"patch-compatible", opt_patch_compatible, 0,
358251881Speter                       N_("generate diff suitable for generic third-party\n"
359251881Speter                       "                             "
360251881Speter                       "patch tools; currently the same as\n"
361251881Speter                       "                             "
362251881Speter                       "--show-copies-as-adds --ignore-properties"
363251881Speter                       )},
364251881Speter  /* end of diff options */
365251881Speter  {"allow-mixed-revisions", opt_allow_mixed_revisions, 0,
366251881Speter                       N_("Allow operation on mixed-revision working copy.\n"
367251881Speter                       "                             "
368251881Speter                       "Use of this option is not recommended!\n"
369251881Speter                       "                             "
370251881Speter                       "Please run 'svn update' instead.")},
371251881Speter  {"include-externals", opt_include_externals, 0,
372251881Speter                       N_("Also commit file and dir externals reached by\n"
373251881Speter                       "                             "
374251881Speter                       "recursion. This does not include externals with a\n"
375251881Speter                       "                             "
376251881Speter                       "fixed revision. (See the svn:externals property)")},
377251881Speter  {"show-inherited-props", opt_show_inherited_props, 0,
378251881Speter                       N_("retrieve target's inherited properties")},
379251881Speter  {"search", opt_search, 1,
380251881Speter                       N_("use ARG as search pattern (glob syntax)")},
381251881Speter  {"search-and", opt_search_and, 1,
382251881Speter                       N_("combine ARG with the previous search pattern")},
383251881Speter
384251881Speter  /* Long-opt Aliases
385251881Speter   *
386251881Speter   * These have NULL desriptions, but an option code that matches some
387251881Speter   * other option (whose description should probably mention its aliases).
388251881Speter  */
389251881Speter
390251881Speter  {"cl",            opt_changelist, 1, NULL},
391251881Speter
392251881Speter  {0,               0, 0, 0},
393251881Speter};
394251881Speter
395251881Speter
396251881Speter
397251881Speter/*** Command dispatch. ***/
398251881Speter
399251881Speter/* Our array of available subcommands.
400251881Speter *
401251881Speter * The entire list must be terminated with an entry of nulls.
402251881Speter *
403251881Speter * In most of the help text "PATH" is used where a working copy path is
404251881Speter * required, "URL" where a repository URL is required and "TARGET" when
405251881Speter * either a path or a url can be used.  Hmm, should this be part of the
406251881Speter * help text?
407251881Speter */
408251881Speter
409251881Speter/* Options that apply to all commands.  (While not every command may
410251881Speter   currently require authentication or be interactive, allowing every
411251881Speter   command to take these arguments allows scripts to just pass them
412251881Speter   willy-nilly to every invocation of 'svn') . */
413251881Speterconst int svn_cl__global_options[] =
414251881Speter{ opt_auth_username, opt_auth_password, opt_no_auth_cache, opt_non_interactive,
415251881Speter  opt_force_interactive, opt_trust_server_cert, opt_config_dir,
416251881Speter  opt_config_options, 0
417251881Speter};
418251881Speter
419251881Speter/* Options for giving a log message.  (Some of these also have other uses.)
420251881Speter */
421251881Speter#define SVN_CL__LOG_MSG_OPTIONS 'm', 'F', \
422251881Speter                                opt_force_log, \
423251881Speter                                opt_editor_cmd, \
424251881Speter                                opt_encoding, \
425251881Speter                                opt_with_revprop
426251881Speter
427251881Speterconst svn_opt_subcommand_desc2_t svn_cl__cmd_table[] =
428251881Speter{
429251881Speter  { "add", svn_cl__add, {0}, N_
430251881Speter    ("Put files and directories under version control, scheduling\n"
431251881Speter     "them for addition to repository.  They will be added in next commit.\n"
432251881Speter     "usage: add PATH...\n"),
433251881Speter    {opt_targets, 'N', opt_depth, 'q', opt_force, opt_no_ignore, opt_autoprops,
434251881Speter     opt_no_autoprops, opt_parents },
435251881Speter     {{opt_parents, N_("add intermediate parents")}} },
436251881Speter
437251881Speter  { "blame", svn_cl__blame, {"praise", "annotate", "ann"}, N_
438251881Speter    ("Output the content of specified files or\n"
439251881Speter     "URLs with revision and author information in-line.\n"
440251881Speter     "usage: blame TARGET[@REV]...\n"
441251881Speter     "\n"
442251881Speter     "  If specified, REV determines in which revision the target is first\n"
443251881Speter     "  looked up.\n"),
444251881Speter    {'r', 'v', 'g', opt_incremental, opt_xml, 'x', opt_force} },
445251881Speter
446251881Speter  { "cat", svn_cl__cat, {0}, N_
447251881Speter    ("Output the content of specified files or URLs.\n"
448251881Speter     "usage: cat TARGET[@REV]...\n"
449251881Speter     "\n"
450251881Speter     "  If specified, REV determines in which revision the target is first\n"
451251881Speter     "  looked up.\n"),
452251881Speter    {'r'} },
453251881Speter
454251881Speter  { "changelist", svn_cl__changelist, {"cl"}, N_
455251881Speter    ("Associate (or dissociate) changelist CLNAME with the named files.\n"
456251881Speter     "usage: 1. changelist CLNAME PATH...\n"
457251881Speter     "       2. changelist --remove PATH...\n"),
458251881Speter    { 'q', 'R', opt_depth, opt_remove, opt_targets, opt_changelist} },
459251881Speter
460251881Speter  { "checkout", svn_cl__checkout, {"co"}, N_
461251881Speter    ("Check out a working copy from a repository.\n"
462251881Speter     "usage: checkout URL[@REV]... [PATH]\n"
463251881Speter     "\n"
464251881Speter     "  If specified, REV determines in which revision the URL is first\n"
465251881Speter     "  looked up.\n"
466251881Speter     "\n"
467251881Speter     "  If PATH is omitted, the basename of the URL will be used as\n"
468251881Speter     "  the destination. If multiple URLs are given each will be checked\n"
469251881Speter     "  out into a sub-directory of PATH, with the name of the sub-directory\n"
470251881Speter     "  being the basename of the URL.\n"
471251881Speter     "\n"
472251881Speter     "  If --force is used, unversioned obstructing paths in the working\n"
473251881Speter     "  copy destination do not automatically cause the check out to fail.\n"
474251881Speter     "  If the obstructing path is the same type (file or directory) as the\n"
475251881Speter     "  corresponding path in the repository it becomes versioned but its\n"
476251881Speter     "  contents are left 'as-is' in the working copy.  This means that an\n"
477251881Speter     "  obstructing directory's unversioned children may also obstruct and\n"
478251881Speter     "  become versioned.  For files, any content differences between the\n"
479251881Speter     "  obstruction and the repository are treated like a local modification\n"
480251881Speter     "  to the working copy.  All properties from the repository are applied\n"
481251881Speter     "  to the obstructing path.\n"
482251881Speter     "\n"
483251881Speter     "  See also 'svn help update' for a list of possible characters\n"
484251881Speter     "  reporting the action taken.\n"),
485251881Speter    {'r', 'q', 'N', opt_depth, opt_force, opt_ignore_externals} },
486251881Speter
487251881Speter  { "cleanup", svn_cl__cleanup, {0}, N_
488253734Speter    ("Recursively clean up the working copy, removing write locks, resuming\n"
489251881Speter     "unfinished operations, etc.\n"
490253734Speter     "usage: cleanup [WCPATH...]\n"
491253734Speter     "\n"
492253734Speter     "  Finish any unfinished business in the working copy at WCPATH, and remove\n"
493253734Speter     "  write locks (shown as 'L' by the 'svn status' command) from the working\n"
494253734Speter     "  copy. Usually, this is only necessary if a Subversion client has crashed\n"
495253734Speter     "  while using the working copy, leaving it in an unusable state.\n"
496253734Speter     "\n"
497253734Speter     "  WARNING: There is no mechanism that will protect write locks still\n"
498253734Speter     "           being used by other Subversion clients. Running this command\n"
499253734Speter     "           while another client is using the working copy can corrupt\n"
500253734Speter     "           the working copy beyond repair!\n"),
501251881Speter    {opt_merge_cmd} },
502251881Speter
503251881Speter  { "commit", svn_cl__commit, {"ci"},
504251881Speter    N_("Send changes from your working copy to the repository.\n"
505251881Speter       "usage: commit [PATH...]\n"
506251881Speter       "\n"
507251881Speter       "  A log message must be provided, but it can be empty.  If it is not\n"
508251881Speter       "  given by a --message or --file option, an editor will be started.\n"
509251881Speter       "  If any targets are (or contain) locked items, those will be\n"
510251881Speter       "  unlocked after a successful commit.\n"),
511251881Speter    {'q', 'N', opt_depth, opt_targets, opt_no_unlock, SVN_CL__LOG_MSG_OPTIONS,
512251881Speter     opt_changelist, opt_keep_changelists, opt_include_externals} },
513251881Speter
514251881Speter  { "copy", svn_cl__copy, {"cp"}, N_
515251881Speter    ("Copy files and directories in a working copy or repository.\n"
516251881Speter     "usage: copy SRC[@REV]... DST\n"
517251881Speter     "\n"
518251881Speter     "  SRC and DST can each be either a working copy (WC) path or URL:\n"
519251881Speter     "    WC  -> WC:   copy and schedule for addition (with history)\n"
520251881Speter     "    WC  -> URL:  immediately commit a copy of WC to URL\n"
521251881Speter     "    URL -> WC:   check out URL into WC, schedule for addition\n"
522251881Speter     "    URL -> URL:  complete server-side copy;  used to branch and tag\n"
523251881Speter     "  All the SRCs must be of the same type. When copying multiple sources,\n"
524251881Speter     "  they will be added as children of DST, which must be a directory.\n"
525251881Speter     "\n"
526251881Speter     "  WARNING: For compatibility with previous versions of Subversion,\n"
527251881Speter     "  copies performed using two working copy paths (WC -> WC) will not\n"
528251881Speter     "  contact the repository.  As such, they may not, by default, be able\n"
529251881Speter     "  to propagate merge tracking information from the source of the copy\n"
530251881Speter     "  to the destination.\n"),
531251881Speter    {'r', 'q', opt_ignore_externals, opt_parents, SVN_CL__LOG_MSG_OPTIONS} },
532251881Speter
533251881Speter  { "delete", svn_cl__delete, {"del", "remove", "rm"}, N_
534251881Speter    ("Remove files and directories from version control.\n"
535251881Speter     "usage: 1. delete PATH...\n"
536251881Speter     "       2. delete URL...\n"
537251881Speter     "\n"
538251881Speter     "  1. Each item specified by a PATH is scheduled for deletion upon\n"
539251881Speter     "    the next commit.  Files, and directories that have not been\n"
540251881Speter     "    committed, are immediately removed from the working copy\n"
541251881Speter     "    unless the --keep-local option is given.\n"
542251881Speter     "    PATHs that are, or contain, unversioned or modified items will\n"
543251881Speter     "    not be removed unless the --force or --keep-local option is given.\n"
544251881Speter     "\n"
545251881Speter     "  2. Each item specified by a URL is deleted from the repository\n"
546251881Speter     "    via an immediate commit.\n"),
547251881Speter    {opt_force, 'q', opt_targets, SVN_CL__LOG_MSG_OPTIONS, opt_keep_local} },
548251881Speter
549251881Speter  { "diff", svn_cl__diff, {"di"}, N_
550251881Speter    ("Display local changes or differences between two revisions or paths.\n"
551251881Speter     "usage: 1. diff\n"
552251881Speter     "       2. diff [-c M | -r N[:M]] [TARGET[@REV]...]\n"
553251881Speter     "       3. diff [-r N[:M]] --old=OLD-TGT[@OLDREV] [--new=NEW-TGT[@NEWREV]] \\\n"
554251881Speter     "               [PATH...]\n"
555251881Speter     "       4. diff OLD-URL[@OLDREV] NEW-URL[@NEWREV]\n"
556251881Speter     "       5. diff OLD-URL[@OLDREV] NEW-PATH[@NEWREV]\n"
557251881Speter     "       6. diff OLD-PATH[@OLDREV] NEW-URL[@NEWREV]\n"
558251881Speter     "\n"
559251881Speter     "  1. Use just 'svn diff' to display local modifications in a working copy.\n"
560251881Speter     "\n"
561251881Speter     "  2. Display the changes made to TARGETs as they are seen in REV between\n"
562251881Speter     "     two revisions.  TARGETs may be all working copy paths or all URLs.\n"
563251881Speter     "     If TARGETs are working copy paths, N defaults to BASE and M to the\n"
564251881Speter     "     working copy; if URLs, N must be specified and M defaults to HEAD.\n"
565251881Speter     "     The '-c M' option is equivalent to '-r N:M' where N = M-1.\n"
566251881Speter     "     Using '-c -M' does the reverse: '-r M:N' where N = M-1.\n"
567251881Speter     "\n"
568251881Speter     "  3. Display the differences between OLD-TGT as it was seen in OLDREV and\n"
569251881Speter     "     NEW-TGT as it was seen in NEWREV.  PATHs, if given, are relative to\n"
570251881Speter     "     OLD-TGT and NEW-TGT and restrict the output to differences for those\n"
571251881Speter     "     paths.  OLD-TGT and NEW-TGT may be working copy paths or URL[@REV].\n"
572251881Speter     "     NEW-TGT defaults to OLD-TGT if not specified.  -r N makes OLDREV default\n"
573251881Speter     "     to N, -r N:M makes OLDREV default to N and NEWREV default to M.\n"
574251881Speter     "     If OLDREV or NEWREV are not specified, they default to WORKING for\n"
575251881Speter     "     working copy targets and to HEAD for URL targets.\n"
576251881Speter     "\n"
577251881Speter     "     Either or both OLD-TGT and NEW-TGT may also be paths to unversioned\n"
578251881Speter     "     targets. Revisions cannot be specified for unversioned targets.\n"
579251881Speter     "     Both targets must be of the same node kind (file or directory).\n"
580251881Speter     "     Diffing unversioned targets against URL targets is not supported.\n"
581251881Speter     "\n"
582251881Speter     "  4. Shorthand for 'svn diff --old=OLD-URL[@OLDREV] --new=NEW-URL[@NEWREV]'\n"
583251881Speter     "  5. Shorthand for 'svn diff --old=OLD-URL[@OLDREV] --new=NEW-PATH[@NEWREV]'\n"
584251881Speter     "  6. Shorthand for 'svn diff --old=OLD-PATH[@OLDREV] --new=NEW-URL[@NEWREV]'\n"),
585251881Speter    {'r', 'c', opt_old_cmd, opt_new_cmd, 'N', opt_depth, opt_diff_cmd,
586251881Speter     opt_internal_diff, 'x', opt_no_diff_added, opt_no_diff_deleted,
587251881Speter     opt_ignore_properties, opt_properties_only,
588251881Speter     opt_show_copies_as_adds, opt_notice_ancestry, opt_summarize, opt_changelist,
589251881Speter     opt_force, opt_xml, opt_use_git_diff_format, opt_patch_compatible} },
590251881Speter  { "export", svn_cl__export, {0}, N_
591251881Speter    ("Create an unversioned copy of a tree.\n"
592251881Speter     "usage: 1. export [-r REV] URL[@PEGREV] [PATH]\n"
593251881Speter     "       2. export [-r REV] PATH1[@PEGREV] [PATH2]\n"
594251881Speter     "\n"
595251881Speter     "  1. Exports a clean directory tree from the repository specified by\n"
596251881Speter     "     URL, at revision REV if it is given, otherwise at HEAD, into\n"
597251881Speter     "     PATH. If PATH is omitted, the last component of the URL is used\n"
598251881Speter     "     for the local directory name.\n"
599251881Speter     "\n"
600251881Speter     "  2. Exports a clean directory tree from the working copy specified by\n"
601251881Speter     "     PATH1, at revision REV if it is given, otherwise at WORKING, into\n"
602251881Speter     "     PATH2.  If PATH2 is omitted, the last component of the PATH1 is used\n"
603251881Speter     "     for the local directory name. If REV is not specified, all local\n"
604251881Speter     "     changes will be preserved.  Files not under version control will\n"
605251881Speter     "     not be copied.\n"
606251881Speter     "\n"
607251881Speter     "  If specified, PEGREV determines in which revision the target is first\n"
608251881Speter     "  looked up.\n"),
609251881Speter    {'r', 'q', 'N', opt_depth, opt_force, opt_native_eol, opt_ignore_externals,
610251881Speter     opt_ignore_keywords} },
611251881Speter
612251881Speter  { "help", svn_cl__help, {"?", "h"}, N_
613251881Speter    ("Describe the usage of this program or its subcommands.\n"
614251881Speter     "usage: help [SUBCOMMAND...]\n"),
615251881Speter    {0} },
616251881Speter  /* This command is also invoked if we see option "--help", "-h" or "-?". */
617251881Speter
618251881Speter  { "import", svn_cl__import, {0}, N_
619251881Speter    ("Commit an unversioned file or tree into the repository.\n"
620251881Speter     "usage: import [PATH] URL\n"
621251881Speter     "\n"
622251881Speter     "  Recursively commit a copy of PATH to URL.\n"
623251881Speter     "  If PATH is omitted '.' is assumed.\n"
624251881Speter     "  Parent directories are created as necessary in the repository.\n"
625251881Speter     "  If PATH is a directory, the contents of the directory are added\n"
626251881Speter     "  directly under URL.\n"
627251881Speter     "  Unversionable items such as device files and pipes are ignored\n"
628251881Speter     "  if --force is specified.\n"),
629251881Speter    {'q', 'N', opt_depth, opt_autoprops, opt_force, opt_no_autoprops,
630251881Speter     SVN_CL__LOG_MSG_OPTIONS, opt_no_ignore} },
631251881Speter
632251881Speter  { "info", svn_cl__info, {0}, N_
633251881Speter    ("Display information about a local or remote item.\n"
634251881Speter     "usage: info [TARGET[@REV]...]\n"
635251881Speter     "\n"
636251881Speter     "  Print information about each TARGET (default: '.').\n"
637251881Speter     "  TARGET may be either a working-copy path or URL.  If specified, REV\n"
638251881Speter     "  determines in which revision the target is first looked up.\n"),
639251881Speter    {'r', 'R', opt_depth, opt_targets, opt_incremental, opt_xml, opt_changelist}
640251881Speter  },
641251881Speter
642251881Speter  { "list", svn_cl__list, {"ls"}, N_
643251881Speter    ("List directory entries in the repository.\n"
644251881Speter     "usage: list [TARGET[@REV]...]\n"
645251881Speter     "\n"
646251881Speter     "  List each TARGET file and the contents of each TARGET directory as\n"
647251881Speter     "  they exist in the repository.  If TARGET is a working copy path, the\n"
648251881Speter     "  corresponding repository URL will be used. If specified, REV determines\n"
649251881Speter     "  in which revision the target is first looked up.\n"
650251881Speter     "\n"
651251881Speter     "  The default TARGET is '.', meaning the repository URL of the current\n"
652251881Speter     "  working directory.\n"
653251881Speter     "\n"
654251881Speter     "  With --verbose, the following fields will be shown for each item:\n"
655251881Speter     "\n"
656251881Speter     "    Revision number of the last commit\n"
657251881Speter     "    Author of the last commit\n"
658251881Speter     "    If locked, the letter 'O'.  (Use 'svn info URL' to see details)\n"
659251881Speter     "    Size (in bytes)\n"
660251881Speter     "    Date and time of the last commit\n"),
661251881Speter    {'r', 'v', 'R', opt_depth, opt_incremental, opt_xml,
662251881Speter     opt_include_externals },
663251881Speter    {{opt_include_externals, N_("include externals definitions")}} },
664251881Speter
665251881Speter  { "lock", svn_cl__lock, {0}, N_
666251881Speter    ("Lock working copy paths or URLs in the repository, so that\n"
667251881Speter     "no other user can commit changes to them.\n"
668251881Speter     "usage: lock TARGET...\n"
669251881Speter     "\n"
670251881Speter     "  Use --force to steal the lock from another user or working copy.\n"),
671251881Speter    { opt_targets, 'm', 'F', opt_force_log, opt_encoding, opt_force },
672251881Speter    {{'F', N_("read lock comment from file ARG")},
673251881Speter     {'m', N_("specify lock comment ARG")},
674251881Speter     {opt_force_log, N_("force validity of lock comment source")}} },
675251881Speter
676251881Speter  { "log", svn_cl__log, {0}, N_
677251881Speter    ("Show the log messages for a set of revision(s) and/or path(s).\n"
678251881Speter     "usage: 1. log [PATH][@REV]\n"
679251881Speter     "       2. log URL[@REV] [PATH...]\n"
680251881Speter     "\n"
681251881Speter     "  1. Print the log messages for the URL corresponding to PATH\n"
682251881Speter     "     (default: '.'). If specified, REV is the revision in which the\n"
683251881Speter     "     URL is first looked up, and the default revision range is REV:1.\n"
684251881Speter     "     If REV is not specified, the default revision range is BASE:1,\n"
685251881Speter     "     since the URL might not exist in the HEAD revision.\n"
686251881Speter     "\n"
687251881Speter     "  2. Print the log messages for the PATHs (default: '.') under URL.\n"
688251881Speter     "     If specified, REV is the revision in which the URL is first\n"
689251881Speter     "     looked up, and the default revision range is REV:1; otherwise,\n"
690251881Speter     "     the URL is looked up in HEAD, and the default revision range is\n"
691251881Speter     "     HEAD:1.\n"
692251881Speter     "\n"
693251881Speter     "  Multiple '-c' or '-r' options may be specified (but not a\n"
694251881Speter     "  combination of '-c' and '-r' options), and mixing of forward and\n"
695251881Speter     "  reverse ranges is allowed.\n"
696251881Speter     "\n"
697251881Speter     "  With -v, also print all affected paths with each log message.\n"
698251881Speter     "  With -q, don't print the log message body itself (note that this is\n"
699251881Speter     "  compatible with -v).\n"
700251881Speter     "\n"
701251881Speter     "  Each log message is printed just once, even if more than one of the\n"
702251881Speter     "  affected paths for that revision were explicitly requested.  Logs\n"
703251881Speter     "  follow copy history by default.  Use --stop-on-copy to disable this\n"
704251881Speter     "  behavior, which can be useful for determining branchpoints.\n"
705251881Speter     "\n"
706251881Speter     "  The --depth option is only valid in combination with the --diff option\n"
707251881Speter     "  and limits the scope of the displayed diff to the specified depth.\n"
708251881Speter     "\n"
709251881Speter     "  If the --search option is used, log messages are displayed only if the\n"
710251881Speter     "  provided search pattern matches any of the author, date, log message\n"
711251881Speter     "  text (unless --quiet is used), or, if the --verbose option is also\n"
712251881Speter     "  provided, a changed path.\n"
713251881Speter     "  The search pattern may include \"glob syntax\" wildcards:\n"
714251881Speter     "      ?      matches any single character\n"
715251881Speter     "      *      matches a sequence of arbitrary characters\n"
716251881Speter     "      [abc]  matches any of the characters listed inside the brackets\n"
717251881Speter     "  If multiple --search options are provided, a log message is shown if\n"
718251881Speter     "  it matches any of the provided search patterns. If the --search-and\n"
719251881Speter     "  option is used, that option's argument is combined with the pattern\n"
720251881Speter     "  from the previous --search or --search-and option, and a log message\n"
721251881Speter     "  is shown only if it matches the combined search pattern.\n"
722251881Speter     "  If --limit is used in combination with --search, --limit restricts the\n"
723251881Speter     "  number of log messages searched, rather than restricting the output\n"
724251881Speter     "  to a particular number of matching log messages.\n"
725251881Speter     "\n"
726251881Speter     "  Examples:\n"
727251881Speter     "\n"
728251881Speter     "    Show the latest 5 log messages for the current working copy\n"
729251881Speter     "    directory and display paths changed in each commit:\n"
730251881Speter     "      svn log -l 5 -v\n"
731251881Speter     "\n"
732251881Speter     "    Show the log for bar.c as of revision 42:\n"
733251881Speter     "      svn log bar.c@42\n"
734251881Speter     "\n"
735251881Speter     "    Show log messages and diffs for each commit to foo.c:\n"
736251881Speter     "      svn log --diff http://www.example.com/repo/project/foo.c\n"
737251881Speter     "    (Because the above command uses a full URL it does not require\n"
738251881Speter     "     a working copy.)\n"
739251881Speter     "\n"
740251881Speter     "    Show log messages for the children foo.c and bar.c of the directory\n"
741251881Speter     "    '/trunk' as it appeared in revision 50, using the ^/ URL shortcut:\n"
742251881Speter     "      svn log ^/trunk@50 foo.c bar.c\n"
743251881Speter     "\n"
744251881Speter     "    Show the log messages for any incoming changes to foo.c during the\n"
745251881Speter     "    next 'svn update':\n"
746251881Speter     "      svn log -r BASE:HEAD foo.c\n"
747251881Speter     "\n"
748251881Speter     "    Show the log message for the revision in which /branches/foo\n"
749251881Speter     "    was created:\n"
750251881Speter     "      svn log --stop-on-copy --limit 1 -r0:HEAD ^/branches/foo\n"),
751251881Speter    {'r', 'q', 'v', 'g', 'c', opt_targets, opt_stop_on_copy, opt_incremental,
752251881Speter     opt_xml, 'l', opt_with_all_revprops, opt_with_no_revprops, opt_with_revprop,
753251881Speter     opt_depth, opt_diff, opt_diff_cmd, opt_internal_diff, 'x', opt_search,
754251881Speter     opt_search_and, },
755251881Speter    {{opt_with_revprop, N_("retrieve revision property ARG")},
756251881Speter     {'c', N_("the change made in revision ARG")}} },
757251881Speter
758251881Speter  { "merge", svn_cl__merge, {0}, N_
759251881Speter    ( /* For this large section, let's keep it unindented for easier
760251881Speter       * viewing/editing. It has been vim-treated with a textwidth=75 and 'gw'
761251881Speter       * (with quotes and newlines removed). */
762251881Speter"Merge changes into a working copy.\n"
763251881Speter"usage: 1. merge SOURCE[@REV] [TARGET_WCPATH]\n"
764253734Speter"          (the 'complete' merge)\n"
765251881Speter"       2. merge [-c M[,N...] | -r N:M ...] SOURCE[@REV] [TARGET_WCPATH]\n"
766251881Speter"          (the 'cherry-pick' merge)\n"
767251881Speter"       3. merge SOURCE1[@REV1] SOURCE2[@REV2] [TARGET_WCPATH]\n"
768251881Speter"          (the '2-URL' merge)\n"
769251881Speter"\n"
770251881Speter"  1. This form, with one source path and no revision range, is called\n"
771253734Speter"     a 'complete' merge:\n"
772251881Speter"\n"
773251881Speter"       svn merge SOURCE[@REV] [TARGET_WCPATH]\n"
774251881Speter"\n"
775253734Speter"     The complete merge is used for the 'sync' and 'reintegrate' merges\n"
776251881Speter"     in the 'feature branch' pattern described below. It finds all the\n"
777251881Speter"     changes on the source branch that have not already been merged to the\n"
778251881Speter"     target branch, and merges them into the working copy. Merge tracking\n"
779251881Speter"     is used to know which changes have already been merged.\n"
780251881Speter"\n"
781251881Speter"     SOURCE specifies the branch from where the changes will be pulled, and\n"
782251881Speter"     TARGET_WCPATH specifies a working copy of the target branch to which\n"
783251881Speter"     the changes will be applied. Normally SOURCE and TARGET_WCPATH should\n"
784251881Speter"     each correspond to the root of a branch. (If you want to merge only a\n"
785251881Speter"     subtree, then the subtree path must be included in both SOURCE and\n"
786251881Speter"     TARGET_WCPATH; this is discouraged, to avoid subtree mergeinfo.)\n"
787251881Speter"\n"
788251881Speter"     SOURCE is usually a URL. The optional '@REV' specifies both the peg\n"
789251881Speter"     revision of the URL and the latest revision that will be considered\n"
790251881Speter"     for merging; if REV is not specified, the HEAD revision is assumed. If\n"
791251881Speter"     SOURCE is a working copy path, the corresponding URL of the path is\n"
792251881Speter"     used, and the default value of 'REV' is the base revision (usually the\n"
793251881Speter"     revision last updated to).\n"
794251881Speter"\n"
795251881Speter"     TARGET_WCPATH is a working copy path; if omitted, '.' is generally\n"
796251881Speter"     assumed. There are some special cases:\n"
797251881Speter"\n"
798251881Speter"       - If SOURCE is a URL:\n"
799251881Speter"\n"
800251881Speter"           - If the basename of the URL and the basename of '.' are the\n"
801251881Speter"             same, then the differences are applied to '.'. Otherwise,\n"
802251881Speter"             if a file with the same basename as that of the URL is found\n"
803251881Speter"             within '.', then the differences are applied to that file.\n"
804251881Speter"             In all other cases, the target defaults to '.'.\n"
805251881Speter"\n"
806251881Speter"       - If SOURCE is a working copy path:\n"
807251881Speter"\n"
808251881Speter"           - If the source is a file, then differences are applied to that\n"
809251881Speter"             file (useful for reverse-merging earlier changes). Otherwise,\n"
810251881Speter"             if the source is a directory, then the target defaults to '.'.\n"
811251881Speter"\n"
812251881Speter"     In normal usage the working copy should be up to date, at a single\n"
813251881Speter"     revision, with no local modifications and no switched subtrees.\n"
814251881Speter"\n"
815251881Speter"       - The 'Feature Branch' Merging Pattern -\n"
816251881Speter"\n"
817251881Speter"     In this commonly used work flow, known also as the 'development\n"
818251881Speter"     branch' pattern, a developer creates a branch and commits a series of\n"
819251881Speter"     changes that implement a new feature. The developer periodically\n"
820251881Speter"     merges all the latest changes from the parent branch so as to keep the\n"
821251881Speter"     development branch up to date with those changes. When the feature is\n"
822251881Speter"     complete, the developer performs a merge from the feature branch to\n"
823251881Speter"     the parent branch to re-integrate the changes.\n"
824251881Speter"\n"
825251881Speter"         parent --+----------o------o-o-------------o--\n"
826251881Speter"                   \\            \\           \\      /\n"
827251881Speter"                    \\          merge      merge  merge\n"
828251881Speter"                     \\            \\           \\  /\n"
829251881Speter"         feature      +--o-o-------o----o-o----o-------\n"
830251881Speter"\n"
831251881Speter"     A merge from the parent branch to the feature branch is called a\n"
832251881Speter"     'sync' or 'catch-up' merge, and a merge from the feature branch to the\n"
833251881Speter"     parent branch is called a 'reintegrate' merge.\n"
834251881Speter"\n"
835251881Speter"       - Sync Merge Example -\n"
836251881Speter"                                 ............\n"
837251881Speter"                                .            .\n"
838251881Speter"         trunk  --+------------L--------------R------\n"
839251881Speter"                   \\                           \\\n"
840251881Speter"                    \\                          |\n"
841251881Speter"                     \\                         v\n"
842251881Speter"         feature      +------------------------o-----\n"
843251881Speter"                             r100            r200\n"
844251881Speter"\n"
845251881Speter"     Subversion will locate all the changes on 'trunk' that have not yet\n"
846251881Speter"     been merged into the 'feature' branch. In this case that is a single\n"
847251881Speter"     range, r100:200. In the diagram above, L marks the left side (trunk@100)\n"
848251881Speter"     and R marks the right side (trunk@200) of the merge source. The\n"
849251881Speter"     difference between L and R will be applied to the target working copy\n"
850251881Speter"     path. In this case, the working copy is a clean checkout of the entire\n"
851251881Speter"     'feature' branch.\n"
852251881Speter"\n"
853251881Speter"     To perform this sync merge, have a clean working copy of the feature\n"
854251881Speter"     branch and run the following command in its top-level directory:\n"
855251881Speter"\n"
856251881Speter"         svn merge ^/trunk\n"
857251881Speter"\n"
858251881Speter"     Note that the merge is now only in your local working copy and still\n"
859251881Speter"     needs to be committed to the repository so that it can be seen by\n"
860251881Speter"     others. You can review the changes and you may have to resolve\n"
861251881Speter"     conflicts before you commit the merge.\n"
862251881Speter"\n"
863251881Speter"       - Reintegrate Merge Example -\n"
864251881Speter"\n"
865251881Speter"     The feature branch was last synced with trunk up to revision X. So the\n"
866251881Speter"     difference between trunk@X and feature@HEAD contains the complete set\n"
867251881Speter"     of changes that implement the feature, and no other changes. These\n"
868251881Speter"     changes are applied to trunk.\n"
869251881Speter"\n"
870251881Speter"                    rW                   rX\n"
871251881Speter"         trunk ------+--------------------L------------------o\n"
872251881Speter"                      \\                    .                 ^\n"
873251881Speter"                       \\                    .............   /\n"
874251881Speter"                        \\                                . /\n"
875251881Speter"         feature         +--------------------------------R\n"
876251881Speter"\n"
877251881Speter"     In the diagram above, L marks the left side (trunk@X) and R marks the\n"
878251881Speter"     right side (feature@HEAD) of the merge. The difference between the\n"
879251881Speter"     left and right side is merged into trunk, the target.\n"
880251881Speter"\n"
881251881Speter"     To perform the merge, have a clean working copy of trunk and run the\n"
882251881Speter"     following command in its top-level directory:\n"
883251881Speter"\n"
884251881Speter"         svn merge ^/feature\n"
885251881Speter"\n"
886251881Speter"     To prevent unnecessary merge conflicts, a reintegrate merge requires\n"
887251881Speter"     that TARGET_WCPATH is not a mixed-revision working copy, has no local\n"
888251881Speter"     modifications, and has no switched subtrees.\n"
889251881Speter"\n"
890251881Speter"     A reintegrate merge also requires that the source branch is coherently\n"
891251881Speter"     synced with the target -- in the above example, this means that all\n"
892251881Speter"     revisions between the branch point W and the last merged revision X\n"
893251881Speter"     are merged to the feature branch, so that there are no unmerged\n"
894251881Speter"     revisions in-between.\n"
895251881Speter"\n"
896251881Speter"\n"
897251881Speter"  2. This form is called a 'cherry-pick' merge:\n"
898251881Speter"\n"
899251881Speter"       svn merge [-c M[,N...] | -r N:M ...] SOURCE[@REV] [TARGET_WCPATH]\n"
900251881Speter"\n"
901251881Speter"     A cherry-pick merge is used to merge specific revisions (or revision\n"
902251881Speter"     ranges) from one branch to another. By default, this uses merge\n"
903251881Speter"     tracking to automatically skip any revisions that have already been\n"
904251881Speter"     merged to the target; you can use the --ignore-ancestry option to\n"
905251881Speter"     disable such skipping.\n"
906251881Speter"\n"
907251881Speter"     SOURCE is usually a URL. The optional '@REV' specifies only the peg\n"
908251881Speter"     revision of the URL and does not affect the merge range; if REV is not\n"
909251881Speter"     specified, the HEAD revision is assumed. If SOURCE is a working copy\n"
910251881Speter"     path, the corresponding URL of the path is used, and the default value\n"
911251881Speter"     of 'REV' is the base revision (usually the revision last updated to).\n"
912251881Speter"\n"
913251881Speter"     TARGET_WCPATH is a working copy path; if omitted, '.' is generally\n"
914253734Speter"     assumed. The special cases noted above in the 'complete' merge form\n"
915251881Speter"     also apply here.\n"
916251881Speter"\n"
917251881Speter"     The revision ranges to be merged are specified by the '-r' and/or '-c'\n"
918251881Speter"     options. '-r N:M' refers to the difference in the history of the\n"
919251881Speter"     source branch between revisions N and M. You can use '-c M' to merge\n"
920251881Speter"     single revisions: '-c M' is equivalent to '-r <M-1>:M'. Each such\n"
921251881Speter"     difference is applied to TARGET_WCPATH.\n"
922251881Speter"\n"
923251881Speter"     If the mergeinfo in TARGET_WCPATH indicates that revisions within the\n"
924251881Speter"     range were already merged, changes made in those revisions are not\n"
925251881Speter"     merged again. If needed, the range is broken into multiple sub-ranges,\n"
926251881Speter"     and each sub-range is merged separately.\n"
927251881Speter"\n"
928251881Speter"     A 'reverse range' can be used to undo changes. For example, when\n"
929251881Speter"     source and target refer to the same branch, a previously committed\n"
930251881Speter"     revision can be 'undone'. In a reverse range, N is greater than M in\n"
931251881Speter"     '-r N:M', or the '-c' option is used with a negative number: '-c -M'\n"
932251881Speter"     is equivalent to '-r M:<M-1>'. Undoing changes like this is also known\n"
933251881Speter"     as performing a 'reverse merge'.\n"
934251881Speter"\n"
935251881Speter"     Multiple '-c' and/or '-r' options may be specified and mixing of\n"
936251881Speter"     forward and reverse ranges is allowed.\n"
937251881Speter"\n"
938251881Speter"       - Cherry-pick Merge Example -\n"
939251881Speter"\n"
940251881Speter"     A bug has been fixed on trunk in revision 50. This fix needs to\n"
941251881Speter"     be merged from trunk onto the release branch.\n"
942251881Speter"\n"
943251881Speter"            1.x-release  +-----------------------o-----\n"
944251881Speter"                        /                        ^\n"
945251881Speter"                       /                         |\n"
946251881Speter"                      /                          |\n"
947251881Speter"         trunk ------+--------------------------LR-----\n"
948251881Speter"                                                r50\n"
949251881Speter"\n"
950251881Speter"     In the above diagram, L marks the left side (trunk@49) and R marks the\n"
951251881Speter"     right side (trunk@50) of the merge. The difference between the left\n"
952251881Speter"     and right side is applied to the target working copy path.\n"
953251881Speter"\n"
954251881Speter"     Note that the difference between revision 49 and 50 is exactly those\n"
955251881Speter"     changes that were committed in revision 50, not including changes\n"
956251881Speter"     committed in revision 49.\n"
957251881Speter"\n"
958251881Speter"     To perform the merge, have a clean working copy of the release branch\n"
959251881Speter"     and run the following command in its top-level directory; remember\n"
960251881Speter"     that the default target is '.':\n"
961251881Speter"\n"
962251881Speter"         svn merge -c50 ^/trunk\n"
963251881Speter"\n"
964251881Speter"     You can also cherry-pick several revisions and/or revision ranges:\n"
965251881Speter"\n"
966251881Speter"         svn merge -c50,54,60 -r65:68 ^/trunk\n"
967251881Speter"\n"
968251881Speter"\n"
969251881Speter"  3. This form is called a '2-URL merge':\n"
970251881Speter"\n"
971251881Speter"       svn merge SOURCE1[@REV1] SOURCE2[@REV2] [TARGET_WCPATH]\n"
972251881Speter"\n"
973251881Speter"     You should use this merge variant only if the other variants do not\n"
974251881Speter"     apply to your situation, as this variant can be quite complex to\n"
975251881Speter"     master.\n"
976251881Speter"\n"
977251881Speter"     Two source URLs are specified, identifying two trees on the same\n"
978251881Speter"     branch or on different branches. The trees are compared and the\n"
979251881Speter"     difference from SOURCE1@REV1 to SOURCE2@REV2 is applied to the\n"
980251881Speter"     working copy of the target branch at TARGET_WCPATH. The target\n"
981251881Speter"     branch may be the same as one or both sources, or different again.\n"
982251881Speter"     The three branches involved can be completely unrelated.\n"
983251881Speter"\n"
984251881Speter"     TARGET_WCPATH is a working copy path; if omitted, '.' is generally\n"
985253734Speter"     assumed. The special cases noted above in the 'complete' merge form\n"
986251881Speter"     also apply here.\n"
987251881Speter"\n"
988251881Speter"     SOURCE1 and/or SOURCE2 can also be specified as a working copy path,\n"
989251881Speter"     in which case the merge source URL is derived from the working copy.\n"
990251881Speter"\n"
991251881Speter"       - 2-URL Merge Example -\n"
992251881Speter"\n"
993251881Speter"     Two features have been developed on separate branches called 'foo' and\n"
994251881Speter"     'bar'. It has since become clear that 'bar' should be combined with\n"
995251881Speter"     the 'foo' branch for further development before reintegration.\n"
996251881Speter"\n"
997251881Speter"     Although both feature branches originate from trunk, they are not\n"
998251881Speter"     directly related -- one is not a direct copy of the other. A 2-URL\n"
999251881Speter"     merge is necessary.\n"
1000251881Speter"\n"
1001251881Speter"     The 'bar' branch has been synced with trunk up to revision 500.\n"
1002251881Speter"     (If this revision number is not known, it can be located using the\n"
1003251881Speter"     'svn log' and/or 'svn mergeinfo' commands.)\n"
1004251881Speter"     The difference between trunk@500 and bar@HEAD contains the complete\n"
1005251881Speter"     set of changes related to feature 'bar', and no other changes. These\n"
1006251881Speter"     changes are applied to the 'foo' branch.\n"
1007251881Speter"\n"
1008251881Speter"                           foo  +-----------------------------------o\n"
1009251881Speter"                               /                                    ^\n"
1010251881Speter"                              /                                    /\n"
1011251881Speter"                             /              r500                  /\n"
1012251881Speter"         trunk ------+------+-----------------L--------->        /\n"
1013251881Speter"                      \\                        .                /\n"
1014251881Speter"                       \\                        ............   /\n"
1015251881Speter"                        \\                                   . /\n"
1016251881Speter"                    bar  +-----------------------------------R\n"
1017251881Speter"\n"
1018251881Speter"     In the diagram above, L marks the left side (trunk@500) and R marks\n"
1019251881Speter"     the right side (bar@HEAD) of the merge. The difference between the\n"
1020251881Speter"     left and right side is applied to the target working copy path, in\n"
1021251881Speter"     this case a working copy of the 'foo' branch.\n"
1022251881Speter"\n"
1023251881Speter"     To perform the merge, have a clean working copy of the 'foo' branch\n"
1024251881Speter"     and run the following command in its top-level directory:\n"
1025251881Speter"\n"
1026251881Speter"         svn merge ^/trunk@500 ^/bar\n"
1027251881Speter"\n"
1028251881Speter"     The exact changes applied by a 2-URL merge can be previewed with svn's\n"
1029251881Speter"     diff command, which is a good idea to verify if you do not have the\n"
1030251881Speter"     luxury of a clean working copy to merge to. In this case:\n"
1031251881Speter"\n"
1032251881Speter"         svn diff ^/trunk@500 ^/bar@HEAD\n"
1033251881Speter"\n"
1034251881Speter"\n"
1035251881Speter"  The following applies to all types of merges:\n"
1036251881Speter"\n"
1037251881Speter"  To prevent unnecessary merge conflicts, svn merge requires that\n"
1038251881Speter"  TARGET_WCPATH is not a mixed-revision working copy. Running 'svn update'\n"
1039251881Speter"  before starting a merge ensures that all items in the working copy are\n"
1040251881Speter"  based on the same revision.\n"
1041251881Speter"\n"
1042251881Speter"  If possible, you should have no local modifications in the merge's target\n"
1043251881Speter"  working copy prior to the merge, to keep things simpler. It will be\n"
1044251881Speter"  easier to revert the merge and to understand the branch's history.\n"
1045251881Speter"\n"
1046251881Speter"  Switched sub-paths should also be avoided during merging, as they may\n"
1047251881Speter"  cause incomplete merges and create subtree mergeinfo.\n"
1048251881Speter"\n"
1049251881Speter"  For each merged item a line will be printed with characters reporting the\n"
1050251881Speter"  action taken. These characters have the following meaning:\n"
1051251881Speter"\n"
1052251881Speter"    A  Added\n"
1053251881Speter"    D  Deleted\n"
1054251881Speter"    U  Updated\n"
1055251881Speter"    C  Conflict\n"
1056251881Speter"    G  Merged\n"
1057251881Speter"    E  Existed\n"
1058251881Speter"    R  Replaced\n"
1059251881Speter"\n"
1060251881Speter"  Characters in the first column report about the item itself.\n"
1061251881Speter"  Characters in the second column report about properties of the item.\n"
1062251881Speter"  A 'C' in the third column indicates a tree conflict, while a 'C' in\n"
1063251881Speter"  the first and second columns indicate textual conflicts in files\n"
1064251881Speter"  and in property values, respectively.\n"
1065251881Speter"\n"
1066251881Speter"    - Merge Tracking -\n"
1067251881Speter"\n"
1068251881Speter"  Subversion uses the svn:mergeinfo property to track merge history. This\n"
1069251881Speter"  property is considered at the start of a merge to determine what to merge\n"
1070251881Speter"  and it is updated at the conclusion of the merge to describe the merge\n"
1071251881Speter"  that took place. Mergeinfo is used only if the two sources are on the\n"
1072251881Speter"  same line of history -- if the first source is an ancestor of the second,\n"
1073251881Speter"  or vice-versa (i.e. if one has originally been created by copying the\n"
1074251881Speter"  other). This is verified and enforced when using sync merges and\n"
1075251881Speter"  reintegrate merges.\n"
1076251881Speter"\n"
1077251881Speter"  The --ignore-ancestry option prevents merge tracking and thus ignores\n"
1078251881Speter"  mergeinfo, neither considering it nor recording it.\n"
1079251881Speter"\n"
1080251881Speter"    - Merging from foreign repositories -\n"
1081251881Speter"\n"
1082251881Speter"  Subversion does support merging from foreign repositories.\n"
1083251881Speter"  While all merge source URLs must point to the same repository, the merge\n"
1084251881Speter"  target working copy may come from a different repository than the source.\n"
1085251881Speter"  However, there are some caveats. Most notably, copies made in the\n"
1086251881Speter"  merge source will be transformed into plain additions in the merge\n"
1087251881Speter"  target. Also, merge-tracking is not supported for merges from foreign\n"
1088251881Speter"  repositories.\n"),
1089251881Speter    {'r', 'c', 'N', opt_depth, 'q', opt_force, opt_dry_run, opt_merge_cmd,
1090251881Speter     opt_record_only, 'x', opt_ignore_ancestry, opt_accept, opt_reintegrate,
1091251881Speter     opt_allow_mixed_revisions, 'v'} },
1092251881Speter
1093251881Speter  { "mergeinfo", svn_cl__mergeinfo, {0}, N_
1094251881Speter    ("Display merge-related information.\n"
1095251881Speter     "usage: 1. mergeinfo SOURCE[@REV] [TARGET[@REV]]\n"
1096251881Speter     "       2. mergeinfo --show-revs=WHICH SOURCE[@REV] [TARGET[@REV]]\n"
1097251881Speter     "\n"
1098251881Speter     "  1. Summarize the history of merging between SOURCE and TARGET. The graph\n"
1099251881Speter     "     shows, from left to right:\n"
1100251881Speter     "       the youngest common ancestor of the branches;\n"
1101251881Speter     "       the latest full merge in either direction, and thus the common base\n"
1102253734Speter     "         that will be used for the next complete merge;\n"
1103251881Speter     "       the repository path and revision number of the tip of each branch.\n"
1104251881Speter     "\n"
1105251881Speter     "  2. Print the revision numbers on SOURCE that have been merged to TARGET\n"
1106251881Speter     "     (with --show-revs=merged), or that have not been merged to TARGET\n"
1107251881Speter     "     (with --show-revs=eligible). Print only revisions in which there was\n"
1108251881Speter     "     at least one change in SOURCE.\n"
1109251881Speter     "\n"
1110251881Speter     "     If --revision (-r) is provided, filter the displayed information to\n"
1111251881Speter     "     show only that which is associated with the revisions within the\n"
1112251881Speter     "     specified range.  Revision numbers, dates, and the 'HEAD' keyword are\n"
1113251881Speter     "     valid range values.\n"
1114251881Speter     "\n"
1115251881Speter     "  SOURCE and TARGET are the source and target branch URLs, respectively.\n"
1116251881Speter     "  (If a WC path is given, the corresponding base URL is used.) The default\n"
1117251881Speter     "  TARGET is the current working directory ('.'). REV specifies the revision\n"
1118251881Speter     "  to be considered the tip of the branch; the default for SOURCE is HEAD,\n"
1119251881Speter     "  and the default for TARGET is HEAD for a URL or BASE for a WC path.\n"
1120251881Speter     "\n"
1121251881Speter     "  The depth can be 'empty' or 'infinity'; the default is 'empty'.\n"),
1122251881Speter    {'r', 'R', opt_depth, opt_show_revs} },
1123251881Speter
1124251881Speter  { "mkdir", svn_cl__mkdir, {0}, N_
1125251881Speter    ("Create a new directory under version control.\n"
1126251881Speter     "usage: 1. mkdir PATH...\n"
1127251881Speter     "       2. mkdir URL...\n"
1128251881Speter     "\n"
1129251881Speter     "  Create version controlled directories.\n"
1130251881Speter     "\n"
1131251881Speter     "  1. Each directory specified by a working copy PATH is created locally\n"
1132251881Speter     "    and scheduled for addition upon the next commit.\n"
1133251881Speter     "\n"
1134251881Speter     "  2. Each directory specified by a URL is created in the repository via\n"
1135251881Speter     "    an immediate commit.\n"
1136251881Speter     "\n"
1137251881Speter     "  In both cases, all the intermediate directories must already exist,\n"
1138251881Speter     "  unless the --parents option is given.\n"),
1139251881Speter    {'q', opt_parents, SVN_CL__LOG_MSG_OPTIONS} },
1140251881Speter
1141251881Speter  { "move", svn_cl__move, {"mv", "rename", "ren"}, N_
1142251881Speter    ("Move (rename) an item in a working copy or repository.\n"
1143251881Speter     "usage: move SRC... DST\n"
1144251881Speter     "\n"
1145251881Speter     "  SRC and DST can both be working copy (WC) paths or URLs:\n"
1146251881Speter     "    WC  -> WC:  move an item in a working copy, as a local change to\n"
1147251881Speter     "                be committed later (with or without further changes)\n"
1148251881Speter     "    URL -> URL: move an item in the repository directly, immediately\n"
1149251881Speter     "                creating a new revision in the repository\n"
1150251881Speter     "  All the SRCs must be of the same type. When moving multiple sources,\n"
1151251881Speter     "  they will be added as children of DST, which must be a directory.\n"
1152251881Speter     "\n"
1153251881Speter     "  SRC and DST of WC -> WC moves must be committed in the same revision.\n"
1154251881Speter     "  Furthermore, WC -> WC moves will refuse to move a mixed-revision subtree.\n"
1155251881Speter     "  To avoid unnecessary conflicts, it is recommended to run 'svn update'\n"
1156251881Speter     "  to update the subtree to a single revision before moving it.\n"
1157251881Speter     "  The --allow-mixed-revisions option is provided for backward compatibility.\n"
1158251881Speter     "\n"
1159251881Speter     "  The --revision option has no use and is deprecated.\n"),
1160251881Speter    {'r', 'q', opt_force, opt_parents, opt_allow_mixed_revisions,
1161251881Speter     SVN_CL__LOG_MSG_OPTIONS} },
1162251881Speter
1163251881Speter  { "patch", svn_cl__patch, {0}, N_
1164251881Speter    ("Apply a patch to a working copy.\n"
1165251881Speter     "usage: patch PATCHFILE [WCPATH]\n"
1166251881Speter     "\n"
1167251881Speter     "  Apply a unidiff patch in PATCHFILE to the working copy WCPATH.\n"
1168251881Speter     "  If WCPATH is omitted, '.' is assumed.\n"
1169251881Speter     "\n"
1170251881Speter     "  A unidiff patch suitable for application to a working copy can be\n"
1171251881Speter     "  produced with the 'svn diff' command or third-party diffing tools.\n"
1172251881Speter     "  Any non-unidiff content of PATCHFILE is ignored, except for Subversion\n"
1173251881Speter     "  property diffs as produced by 'svn diff'.\n"
1174251881Speter     "\n"
1175251881Speter     "  Changes listed in the patch will either be applied or rejected.\n"
1176251881Speter     "  If a change does not match at its exact line offset, it may be applied\n"
1177251881Speter     "  earlier or later in the file if a match is found elsewhere for the\n"
1178251881Speter     "  surrounding lines of context provided by the patch.\n"
1179251881Speter     "  A change may also be applied with fuzz, which means that one\n"
1180251881Speter     "  or more lines of context are ignored when matching the change.\n"
1181251881Speter     "  If no matching context can be found for a change, the change conflicts\n"
1182251881Speter     "  and will be written to a reject file with the extension .svnpatch.rej.\n"
1183251881Speter     "\n"
1184251881Speter     "  For each patched file a line will be printed with characters reporting\n"
1185251881Speter     "  the action taken. These characters have the following meaning:\n"
1186251881Speter     "\n"
1187251881Speter     "    A  Added\n"
1188251881Speter     "    D  Deleted\n"
1189251881Speter     "    U  Updated\n"
1190251881Speter     "    C  Conflict\n"
1191251881Speter     "    G  Merged (with local uncommitted changes)\n"
1192251881Speter     "\n"
1193251881Speter     "  Changes applied with an offset or fuzz are reported on lines starting\n"
1194251881Speter     "  with the '>' symbol. You should review such changes carefully.\n"
1195251881Speter     "\n"
1196251881Speter     "  If the patch removes all content from a file, that file is scheduled\n"
1197251881Speter     "  for deletion. If the patch creates a new file, that file is scheduled\n"
1198251881Speter     "  for addition. Use 'svn revert' to undo deletions and additions you\n"
1199251881Speter     "  do not agree with.\n"
1200251881Speter     "\n"
1201251881Speter     "  Hint: If the patch file was created with Subversion, it will contain\n"
1202251881Speter     "        the number of a revision N the patch will cleanly apply to\n"
1203251881Speter     "        (look for lines like '--- foo/bar.txt        (revision N)').\n"
1204251881Speter     "        To avoid rejects, first update to the revision N using\n"
1205251881Speter     "        'svn update -r N', apply the patch, and then update back to the\n"
1206251881Speter     "        HEAD revision. This way, conflicts can be resolved interactively.\n"
1207251881Speter     ),
1208251881Speter    {'q', opt_dry_run, opt_strip, opt_reverse_diff,
1209251881Speter     opt_ignore_whitespace} },
1210251881Speter
1211251881Speter  { "propdel", svn_cl__propdel, {"pdel", "pd"}, N_
1212251881Speter    ("Remove a property from files, dirs, or revisions.\n"
1213251881Speter     "usage: 1. propdel PROPNAME [PATH...]\n"
1214251881Speter     "       2. propdel PROPNAME --revprop -r REV [TARGET]\n"
1215251881Speter     "\n"
1216251881Speter     "  1. Removes versioned props in working copy.\n"
1217251881Speter     "  2. Removes unversioned remote prop on repos revision.\n"
1218251881Speter     "     TARGET only determines which repository to access.\n"),
1219251881Speter    {'q', 'R', opt_depth, 'r', opt_revprop, opt_changelist} },
1220251881Speter
1221251881Speter  { "propedit", svn_cl__propedit, {"pedit", "pe"}, N_
1222251881Speter    ("Edit a property with an external editor.\n"
1223251881Speter     "usage: 1. propedit PROPNAME TARGET...\n"
1224251881Speter     "       2. propedit PROPNAME --revprop -r REV [TARGET]\n"
1225251881Speter     "\n"
1226251881Speter     "  1. Edits versioned prop in working copy or repository.\n"
1227251881Speter     "  2. Edits unversioned remote prop on repos revision.\n"
1228251881Speter     "     TARGET only determines which repository to access.\n"
1229251881Speter     "\n"
1230251881Speter     "  See 'svn help propset' for more on setting properties.\n"),
1231251881Speter    {'r', opt_revprop, SVN_CL__LOG_MSG_OPTIONS, opt_force} },
1232251881Speter
1233251881Speter  { "propget", svn_cl__propget, {"pget", "pg"}, N_
1234251881Speter    ("Print the value of a property on files, dirs, or revisions.\n"
1235251881Speter     "usage: 1. propget PROPNAME [TARGET[@REV]...]\n"
1236251881Speter     "       2. propget PROPNAME --revprop -r REV [TARGET]\n"
1237251881Speter     "\n"
1238251881Speter     "  1. Prints versioned props. If specified, REV determines in which\n"
1239251881Speter     "     revision the target is first looked up.\n"
1240251881Speter     "  2. Prints unversioned remote prop on repos revision.\n"
1241251881Speter     "     TARGET only determines which repository to access.\n"
1242251881Speter     "\n"
1243251881Speter     "  With --verbose, the target path and the property name are printed on\n"
1244251881Speter     "  separate lines before each value, like 'svn proplist --verbose'.\n"
1245251881Speter     "  Otherwise, if there is more than one TARGET or a depth other than\n"
1246251881Speter     "  'empty', the target path is printed on the same line before each value.\n"
1247251881Speter     "\n"
1248251881Speter     "  By default, an extra newline is printed after the property value so that\n"
1249251881Speter     "  the output looks pretty.  With a single TARGET and depth 'empty', you can\n"
1250251881Speter     "  use the --strict option to disable this (useful when redirecting a binary\n"
1251251881Speter     "  property value to a file, for example).\n"),
1252251881Speter    {'v', 'R', opt_depth, 'r', opt_revprop, opt_strict, opt_xml,
1253251881Speter     opt_changelist, opt_show_inherited_props },
1254251881Speter    {{'v', N_("print path, name and value on separate lines")},
1255251881Speter     {opt_strict, N_("don't print an extra newline")}} },
1256251881Speter
1257251881Speter  { "proplist", svn_cl__proplist, {"plist", "pl"}, N_
1258251881Speter    ("List all properties on files, dirs, or revisions.\n"
1259251881Speter     "usage: 1. proplist [TARGET[@REV]...]\n"
1260251881Speter     "       2. proplist --revprop -r REV [TARGET]\n"
1261251881Speter     "\n"
1262251881Speter     "  1. Lists versioned props. If specified, REV determines in which\n"
1263251881Speter     "     revision the target is first looked up.\n"
1264251881Speter     "  2. Lists unversioned remote props on repos revision.\n"
1265251881Speter     "     TARGET only determines which repository to access.\n"
1266251881Speter     "\n"
1267251881Speter     "  With --verbose, the property values are printed as well, like 'svn propget\n"
1268251881Speter     "  --verbose'.  With --quiet, the paths are not printed.\n"),
1269251881Speter    {'v', 'R', opt_depth, 'r', 'q', opt_revprop, opt_xml, opt_changelist,
1270251881Speter     opt_show_inherited_props },
1271251881Speter    {{'v', N_("print path, name and value on separate lines")},
1272251881Speter     {'q', N_("don't print the path")}} },
1273251881Speter
1274251881Speter  { "propset", svn_cl__propset, {"pset", "ps"}, N_
1275251881Speter    ("Set the value of a property on files, dirs, or revisions.\n"
1276251881Speter     "usage: 1. propset PROPNAME PROPVAL PATH...\n"
1277251881Speter     "       2. propset PROPNAME --revprop -r REV PROPVAL [TARGET]\n"
1278251881Speter     "\n"
1279251881Speter     "  1. Changes a versioned file or directory property in a working copy.\n"
1280251881Speter     "  2. Changes an unversioned property on a repository revision.\n"
1281251881Speter     "     (TARGET only determines which repository to access.)\n"
1282251881Speter     "\n"
1283251881Speter     "  The value may be provided with the --file option instead of PROPVAL.\n"
1284251881Speter     "\n"
1285251881Speter     "  Property names starting with 'svn:' are reserved.  Subversion recognizes\n"
1286251881Speter     "  the following special versioned properties on a file:\n"
1287251881Speter     "    svn:keywords   - Keywords to be expanded.  Valid keywords are:\n"
1288251881Speter     "      URL, HeadURL             - The URL for the head version of the file.\n"
1289251881Speter     "      Author, LastChangedBy    - The last person to modify the file.\n"
1290251881Speter     "      Date, LastChangedDate    - The date/time the file was last modified.\n"
1291251881Speter     "      Rev, Revision,           - The last revision the file changed.\n"
1292251881Speter     "        LastChangedRevision\n"
1293251881Speter     "      Id                       - A compressed summary of the previous four.\n"
1294251881Speter     "      Header                   - Similar to Id but includes the full URL.\n"
1295251881Speter     "\n"
1296251881Speter     "      Custom keywords can be defined with a format string separated from\n"
1297251881Speter     "      the keyword name with '='. Valid format substitutions are:\n"
1298251881Speter     "        %a   - The author of the revision given by %r.\n"
1299251881Speter     "        %b   - The basename of the URL of the file.\n"
1300251881Speter     "        %d   - Short format of the date of the revision given by %r.\n"
1301251881Speter     "        %D   - Long format of the date of the revision given by %r.\n"
1302251881Speter     "        %P   - The file's path, relative to the repository root.\n"
1303251881Speter     "        %r   - The number of the revision which last changed the file.\n"
1304251881Speter     "        %R   - The URL to the root of the repository.\n"
1305251881Speter     "        %u   - The URL of the file.\n"
1306251881Speter     "        %_   - A space (keyword definitions cannot contain a literal space).\n"
1307251881Speter     "        %%   - A literal '%'.\n"
1308251881Speter     "        %H   - Equivalent to %P%_%r%_%d%_%a.\n"
1309251881Speter     "        %I   - Equivalent to %b%_%r%_%d%_%a.\n"
1310251881Speter     "      Example custom keyword definition: MyKeyword=%r%_%a%_%P\n"
1311251881Speter     "      Once a custom keyword has been defined for a file, it can be used\n"
1312251881Speter     "      within the file like any other keyword: $MyKeyword$\n"
1313251881Speter     "\n"
1314251881Speter     "    svn:executable - If present, make the file executable.  Use\n"
1315251881Speter     "      'svn propdel svn:executable PATH...' to clear.\n"
1316251881Speter     "    svn:eol-style  - One of 'native', 'LF', 'CR', 'CRLF'.\n"
1317251881Speter     "    svn:mime-type  - The mimetype of the file.  Used to determine\n"
1318251881Speter     "      whether to merge the file, and how to serve it from Apache.\n"
1319251881Speter     "      A mimetype beginning with 'text/' (or an absent mimetype) is\n"
1320251881Speter     "      treated as text.  Anything else is treated as binary.\n"
1321251881Speter     "    svn:needs-lock - If present, indicates that the file should be locked\n"
1322251881Speter     "      before it is modified.  Makes the working copy file read-only\n"
1323251881Speter     "      when it is not locked.  Use 'svn propdel svn:needs-lock PATH...'\n"
1324251881Speter     "      to clear.\n"
1325251881Speter     "\n"
1326251881Speter     "  Subversion recognizes the following special versioned properties on a\n"
1327251881Speter     "  directory:\n"
1328251881Speter     "    svn:ignore         - A list of file glob patterns to ignore, one per line.\n"
1329251881Speter     "    svn:global-ignores - Like svn:ignore, but inheritable.\n"
1330251881Speter     "    svn:externals      - A list of module specifiers, one per line, in the\n"
1331251881Speter     "      following format similar to the syntax of 'svn checkout':\n"
1332251881Speter     "        [-r REV] URL[@PEG] LOCALPATH\n"
1333251881Speter     "      Example:\n"
1334251881Speter     "        http://example.com/repos/zig foo/bar\n"
1335251881Speter     "      The LOCALPATH is relative to the directory having this property.\n"
1336251881Speter     "      To pin the external to a known revision, specify the optional REV:\n"
1337251881Speter     "        -r25 http://example.com/repos/zig foo/bar\n"
1338251881Speter     "      To unambiguously identify an element at a path which may have been\n"
1339251881Speter     "      subsequently deleted or renamed, specify the optional PEG revision:\n"
1340251881Speter     "        -r25 http://example.com/repos/zig@42 foo/bar\n"
1341251881Speter     "      The URL may be a full URL or a relative URL starting with one of:\n"
1342251881Speter     "        ../  to the parent directory of the extracted external\n"
1343251881Speter     "        ^/   to the repository root\n"
1344251881Speter     "        /    to the server root\n"
1345251881Speter     "        //   to the URL scheme\n"
1346251881Speter     "      Use of the following format is discouraged but is supported for\n"
1347251881Speter     "      interoperability with Subversion 1.4 and earlier clients:\n"
1348251881Speter     "        LOCALPATH [-r PEG] URL\n"
1349251881Speter     "      The ambiguous format 'relative_path relative_path' is taken as\n"
1350251881Speter     "      'relative_url relative_path' with peg revision support.\n"
1351251881Speter     "      Lines starting with a '#' character are ignored.\n"),
1352251881Speter    {'F', opt_encoding, 'q', 'r', opt_targets, 'R', opt_depth, opt_revprop,
1353251881Speter     opt_force, opt_changelist },
1354251881Speter    {{'F', N_("read property value from file ARG")}} },
1355251881Speter
1356251881Speter  { "relocate", svn_cl__relocate, {0}, N_
1357251881Speter    ("Relocate the working copy to point to a different repository root URL.\n"
1358251881Speter     "usage: 1. relocate FROM-PREFIX TO-PREFIX [PATH...]\n"
1359251881Speter     "       2. relocate TO-URL [PATH]\n"
1360251881Speter     "\n"
1361251881Speter     "  Rewrite working copy URL metadata to reflect a syntactic change only.\n"
1362251881Speter     "  This is used when a repository's root URL changes (such as a scheme\n"
1363251881Speter     "  or hostname change) but your working copy still reflects the same\n"
1364251881Speter     "  directory within the same repository.\n"
1365251881Speter     "\n"
1366251881Speter     "  1. FROM-PREFIX and TO-PREFIX are initial substrings of the working\n"
1367251881Speter     "     copy's current and new URLs, respectively.  (You may specify the\n"
1368251881Speter     "     complete old and new URLs if you wish.)  Use 'svn info' to determine\n"
1369251881Speter     "     the current working copy URL.\n"
1370251881Speter     "\n"
1371251881Speter     "  2. TO-URL is the (complete) new repository URL to use for PATH.\n"
1372251881Speter     "\n"
1373251881Speter     "  Examples:\n"
1374251881Speter     "    svn relocate http:// svn:// project1 project2\n"
1375251881Speter     "    svn relocate http://www.example.com/repo/project \\\n"
1376251881Speter     "                 svn://svn.example.com/repo/project\n"),
1377251881Speter    {opt_ignore_externals} },
1378251881Speter
1379251881Speter  { "resolve", svn_cl__resolve, {0}, N_
1380251881Speter    ("Resolve conflicts on working copy files or directories.\n"
1381251881Speter     "usage: resolve [PATH...]\n"
1382251881Speter     "\n"
1383251881Speter     "  By default, perform interactive conflict resolution on PATH.\n"
1384251881Speter     "  In this mode, the command is recursive by default (depth 'infinity').\n"
1385251881Speter     "\n"
1386251881Speter     "  The --accept=ARG option prevents interactive prompting and forces\n"
1387251881Speter     "  conflicts on PATH to be resolved in the manner specified by ARG.\n"
1388251881Speter     "  In this mode, the command is not recursive by default (depth 'empty').\n"),
1389251881Speter    {opt_targets, 'R', opt_depth, 'q', opt_accept},
1390251881Speter    {{opt_accept, N_("specify automatic conflict resolution source\n"
1391251881Speter                     "                             "
1392251881Speter                     "('base', 'working', 'mine-conflict',\n"
1393251881Speter                     "                             "
1394251881Speter                     "'theirs-conflict', 'mine-full', 'theirs-full')")}} },
1395251881Speter
1396251881Speter  { "resolved", svn_cl__resolved, {0}, N_
1397251881Speter    ("Remove 'conflicted' state on working copy files or directories.\n"
1398251881Speter     "usage: resolved PATH...\n"
1399251881Speter     "\n"
1400251881Speter     "  Note:  this subcommand does not semantically resolve conflicts or\n"
1401251881Speter     "  remove conflict markers; it merely removes the conflict-related\n"
1402251881Speter     "  artifact files and allows PATH to be committed again.  It has been\n"
1403251881Speter     "  deprecated in favor of running 'svn resolve --accept working'.\n"),
1404251881Speter    {opt_targets, 'R', opt_depth, 'q'} },
1405251881Speter
1406251881Speter  { "revert", svn_cl__revert, {0}, N_
1407251881Speter    ("Restore pristine working copy state (undo local changes).\n"
1408251881Speter     "usage: revert PATH...\n"
1409251881Speter     "\n"
1410251881Speter     "  Revert changes in the working copy at or within PATH, and remove\n"
1411251881Speter     "  conflict markers as well, if any.\n"
1412251881Speter     "\n"
1413251881Speter     "  This subcommand does not revert already committed changes.\n"
1414251881Speter     "  For information about undoing already committed changes, search\n"
1415251881Speter     "  the output of 'svn help merge' for 'undo'.\n"),
1416251881Speter    {opt_targets, 'R', opt_depth, 'q', opt_changelist} },
1417251881Speter
1418251881Speter  { "status", svn_cl__status, {"stat", "st"}, N_
1419251881Speter    ("Print the status of working copy files and directories.\n"
1420251881Speter     "usage: status [PATH...]\n"
1421251881Speter     "\n"
1422251881Speter     "  With no args, print only locally modified items (no network access).\n"
1423251881Speter     "  With -q, print only summary information about locally modified items.\n"
1424251881Speter     "  With -u, add working revision and server out-of-date information.\n"
1425251881Speter     "  With -v, print full revision information on every item.\n"
1426251881Speter     "\n"
1427251881Speter     "  The first seven columns in the output are each one character wide:\n"
1428251881Speter     "    First column: Says if item was added, deleted, or otherwise changed\n"
1429251881Speter     "      ' ' no modifications\n"
1430251881Speter     "      'A' Added\n"
1431251881Speter     "      'C' Conflicted\n"
1432251881Speter     "      'D' Deleted\n"
1433251881Speter     "      'I' Ignored\n"
1434251881Speter     "      'M' Modified\n"
1435251881Speter     "      'R' Replaced\n"
1436251881Speter     "      'X' an unversioned directory created by an externals definition\n"
1437251881Speter     "      '?' item is not under version control\n"
1438251881Speter     "      '!' item is missing (removed by non-svn command) or incomplete\n"
1439251881Speter     "      '~' versioned item obstructed by some item of a different kind\n"
1440251881Speter     "    Second column: Modifications of a file's or directory's properties\n"
1441251881Speter     "      ' ' no modifications\n"
1442251881Speter     "      'C' Conflicted\n"
1443251881Speter     "      'M' Modified\n"
1444253734Speter     "    Third column: Whether the working copy is locked for writing by\n"
1445253734Speter     "                  another Subversion client modifying the working copy\n"
1446253734Speter     "      ' ' not locked for writing\n"
1447253734Speter     "      'L' locked for writing\n"
1448251881Speter     "    Fourth column: Scheduled commit will contain addition-with-history\n"
1449251881Speter     "      ' ' no history scheduled with commit\n"
1450251881Speter     "      '+' history scheduled with commit\n"
1451251881Speter     "    Fifth column: Whether the item is switched or a file external\n"
1452251881Speter     "      ' ' normal\n"
1453251881Speter     "      'S' the item has a Switched URL relative to the parent\n"
1454251881Speter     "      'X' a versioned file created by an eXternals definition\n"
1455253734Speter     "    Sixth column: Whether the item is locked in repository for exclusive commit\n"
1456251881Speter     "      (without -u)\n"
1457253734Speter     "      ' ' not locked by this working copy\n"
1458253734Speter     "      'K' locked by this working copy, but lock might be stolen or broken\n"
1459251881Speter     "      (with -u)\n"
1460253734Speter     "      ' ' not locked in repository, not locked by this working copy\n"
1461253734Speter     "      'K' locked in repository, lock owned by this working copy\n"
1462253734Speter     "      'O' locked in repository, lock owned by another working copy\n"
1463253734Speter     "      'T' locked in repository, lock owned by this working copy was stolen\n"
1464253734Speter     "      'B' not locked in repository, lock owned by this working copy is broken\n"
1465251881Speter     "    Seventh column: Whether the item is the victim of a tree conflict\n"
1466251881Speter     "      ' ' normal\n"
1467251881Speter     "      'C' tree-Conflicted\n"
1468251881Speter     "    If the item is a tree conflict victim, an additional line is printed\n"
1469251881Speter     "    after the item's status line, explaining the nature of the conflict.\n"
1470251881Speter     "\n"
1471251881Speter     "  The out-of-date information appears in the ninth column (with -u):\n"
1472251881Speter     "      '*' a newer revision exists on the server\n"
1473251881Speter     "      ' ' the working copy is up to date\n"
1474251881Speter     "\n"
1475251881Speter     "  Remaining fields are variable width and delimited by spaces:\n"
1476251881Speter     "    The working revision (with -u or -v; '-' if the item is copied)\n"
1477251881Speter     "    The last committed revision and last committed author (with -v)\n"
1478251881Speter     "    The working copy path is always the final field, so it can\n"
1479251881Speter     "      include spaces.\n"
1480251881Speter     "\n"
1481251881Speter     "  The presence of a question mark ('?') where a working revision, last\n"
1482251881Speter     "  committed revision, or last committed author was expected indicates\n"
1483251881Speter     "  that the information is unknown or irrelevant given the state of the\n"
1484251881Speter     "  item (for example, when the item is the result of a copy operation).\n"
1485251881Speter     "  The question mark serves as a visual placeholder to facilitate parsing.\n"
1486251881Speter     "\n"
1487251881Speter     "  Example output:\n"
1488251881Speter     "    svn status wc\n"
1489251881Speter     "     M      wc/bar.c\n"
1490251881Speter     "    A  +    wc/qax.c\n"
1491251881Speter     "\n"
1492251881Speter     "    svn status -u wc\n"
1493251881Speter     "     M             965   wc/bar.c\n"
1494251881Speter     "            *      965   wc/foo.c\n"
1495251881Speter     "    A  +             -   wc/qax.c\n"
1496251881Speter     "    Status against revision:   981\n"
1497251881Speter     "\n"
1498251881Speter     "    svn status --show-updates --verbose wc\n"
1499251881Speter     "     M             965      938 kfogel       wc/bar.c\n"
1500251881Speter     "            *      965      922 sussman      wc/foo.c\n"
1501251881Speter     "    A  +             -      687 joe          wc/qax.c\n"
1502251881Speter     "                   965      687 joe          wc/zig.c\n"
1503251881Speter     "    Status against revision:   981\n"
1504251881Speter     "\n"
1505251881Speter     "    svn status\n"
1506251881Speter     "     M      wc/bar.c\n"
1507251881Speter     "    !     C wc/qaz.c\n"
1508251881Speter     "          >   local missing, incoming edit upon update\n"
1509251881Speter     "    D       wc/qax.c\n"),
1510251881Speter    { 'u', 'v', 'N', opt_depth, 'q', opt_no_ignore, opt_incremental, opt_xml,
1511251881Speter      opt_ignore_externals, opt_changelist},
1512251881Speter    {{'q', N_("don't print unversioned items")}} },
1513251881Speter
1514251881Speter  { "switch", svn_cl__switch, {"sw"}, N_
1515251881Speter    ("Update the working copy to a different URL within the same repository.\n"
1516251881Speter     "usage: 1. switch URL[@PEGREV] [PATH]\n"
1517251881Speter     "       2. switch --relocate FROM-PREFIX TO-PREFIX [PATH...]\n"
1518251881Speter     "\n"
1519251881Speter     "  1. Update the working copy to mirror a new URL within the repository.\n"
1520251881Speter     "     This behavior is similar to 'svn update', and is the way to\n"
1521251881Speter     "     move a working copy to a branch or tag within the same repository.\n"
1522251881Speter     "     If specified, PEGREV determines in which revision the target is first\n"
1523251881Speter     "     looked up.\n"
1524251881Speter     "\n"
1525251881Speter     "     If --force is used, unversioned obstructing paths in the working\n"
1526251881Speter     "     copy do not automatically cause a failure if the switch attempts to\n"
1527251881Speter     "     add the same path.  If the obstructing path is the same type (file\n"
1528251881Speter     "     or directory) as the corresponding path in the repository it becomes\n"
1529251881Speter     "     versioned but its contents are left 'as-is' in the working copy.\n"
1530251881Speter     "     This means that an obstructing directory's unversioned children may\n"
1531251881Speter     "     also obstruct and become versioned.  For files, any content differences\n"
1532251881Speter     "     between the obstruction and the repository are treated like a local\n"
1533251881Speter     "     modification to the working copy.  All properties from the repository\n"
1534251881Speter     "     are applied to the obstructing path.\n"
1535251881Speter     "\n"
1536251881Speter     "     Use the --set-depth option to set a new working copy depth on the\n"
1537251881Speter     "     targets of this operation.\n"
1538251881Speter     "\n"
1539251881Speter     "     By default, Subversion will refuse to switch a working copy path to\n"
1540251881Speter     "     a new URL with which it shares no common version control ancestry.\n"
1541251881Speter     "     Use the '--ignore-ancestry' option to override this sanity check.\n"
1542251881Speter     "\n"
1543251881Speter     "  2. The '--relocate' option is deprecated. This syntax is equivalent to\n"
1544251881Speter     "     'svn relocate FROM-PREFIX TO-PREFIX [PATH]'.\n"
1545251881Speter     "\n"
1546251881Speter     "  See also 'svn help update' for a list of possible characters\n"
1547251881Speter     "  reporting the action taken.\n"
1548251881Speter     "\n"
1549251881Speter     "  Examples:\n"
1550251881Speter     "    svn switch ^/branches/1.x-release\n"
1551251881Speter     "    svn switch --relocate http:// svn://\n"
1552251881Speter     "    svn switch --relocate http://www.example.com/repo/project \\\n"
1553251881Speter     "                          svn://svn.example.com/repo/project\n"),
1554251881Speter    { 'r', 'N', opt_depth, opt_set_depth, 'q', opt_merge_cmd, opt_relocate,
1555251881Speter      opt_ignore_externals, opt_ignore_ancestry, opt_force, opt_accept},
1556251881Speter    {{opt_ignore_ancestry,
1557251881Speter      N_("allow switching to a node with no common ancestor")}}
1558251881Speter  },
1559251881Speter
1560251881Speter  { "unlock", svn_cl__unlock, {0}, N_
1561251881Speter    ("Unlock working copy paths or URLs.\n"
1562251881Speter     "usage: unlock TARGET...\n"
1563251881Speter     "\n"
1564251881Speter     "  Use --force to break the lock.\n"),
1565251881Speter    { opt_targets, opt_force } },
1566251881Speter
1567251881Speter  { "update", svn_cl__update, {"up"},  N_
1568251881Speter    ("Bring changes from the repository into the working copy.\n"
1569251881Speter     "usage: update [PATH...]\n"
1570251881Speter     "\n"
1571251881Speter     "  If no revision is given, bring working copy up-to-date with HEAD rev.\n"
1572251881Speter     "  Else synchronize working copy to revision given by -r.\n"
1573251881Speter     "\n"
1574251881Speter     "  For each updated item a line will be printed with characters reporting\n"
1575251881Speter     "  the action taken. These characters have the following meaning:\n"
1576251881Speter     "\n"
1577251881Speter     "    A  Added\n"
1578251881Speter     "    D  Deleted\n"
1579251881Speter     "    U  Updated\n"
1580251881Speter     "    C  Conflict\n"
1581251881Speter     "    G  Merged\n"
1582251881Speter     "    E  Existed\n"
1583251881Speter     "    R  Replaced\n"
1584251881Speter     "\n"
1585251881Speter     "  Characters in the first column report about the item itself.\n"
1586251881Speter     "  Characters in the second column report about properties of the item.\n"
1587251881Speter     "  A 'B' in the third column signifies that the lock for the file has\n"
1588251881Speter     "  been broken or stolen.\n"
1589251881Speter     "  A 'C' in the fourth column indicates a tree conflict, while a 'C' in\n"
1590251881Speter     "  the first and second columns indicate textual conflicts in files\n"
1591251881Speter     "  and in property values, respectively.\n"
1592251881Speter     "\n"
1593251881Speter     "  If --force is used, unversioned obstructing paths in the working\n"
1594251881Speter     "  copy do not automatically cause a failure if the update attempts to\n"
1595251881Speter     "  add the same path.  If the obstructing path is the same type (file\n"
1596251881Speter     "  or directory) as the corresponding path in the repository it becomes\n"
1597251881Speter     "  versioned but its contents are left 'as-is' in the working copy.\n"
1598251881Speter     "  This means that an obstructing directory's unversioned children may\n"
1599251881Speter     "  also obstruct and become versioned.  For files, any content differences\n"
1600251881Speter     "  between the obstruction and the repository are treated like a local\n"
1601251881Speter     "  modification to the working copy.  All properties from the repository\n"
1602251881Speter     "  are applied to the obstructing path.  Obstructing paths are reported\n"
1603251881Speter     "  in the first column with code 'E'.\n"
1604251881Speter     "\n"
1605251881Speter     "  If the specified update target is missing from the working copy but its\n"
1606251881Speter     "  immediate parent directory is present, checkout the target into its\n"
1607251881Speter     "  parent directory at the specified depth.  If --parents is specified,\n"
1608251881Speter     "  create any missing parent directories of the target by checking them\n"
1609251881Speter     "  out, too, at depth=empty.\n"
1610251881Speter     "\n"
1611251881Speter     "  Use the --set-depth option to set a new working copy depth on the\n"
1612251881Speter     "  targets of this operation.\n"),
1613251881Speter    {'r', 'N', opt_depth, opt_set_depth, 'q', opt_merge_cmd, opt_force,
1614251881Speter     opt_ignore_externals, opt_changelist, opt_editor_cmd, opt_accept,
1615251881Speter     opt_parents} },
1616251881Speter
1617251881Speter  { "upgrade", svn_cl__upgrade, {0}, N_
1618251881Speter    ("Upgrade the metadata storage format for a working copy.\n"
1619251881Speter     "usage: upgrade [WCPATH...]\n"
1620251881Speter     "\n"
1621251881Speter     "  Local modifications are preserved.\n"),
1622251881Speter    { 'q' } },
1623251881Speter
1624251881Speter  { NULL, NULL, {0}, NULL, {0} }
1625251881Speter};
1626251881Speter
1627251881Speter
1628251881Speter/* Version compatibility check */
1629251881Speterstatic svn_error_t *
1630251881Spetercheck_lib_versions(void)
1631251881Speter{
1632251881Speter  static const svn_version_checklist_t checklist[] =
1633251881Speter    {
1634251881Speter      { "svn_subr",   svn_subr_version },
1635251881Speter      { "svn_client", svn_client_version },
1636251881Speter      { "svn_wc",     svn_wc_version },
1637251881Speter      { "svn_ra",     svn_ra_version },
1638251881Speter      { "svn_delta",  svn_delta_version },
1639251881Speter      { "svn_diff",   svn_diff_version },
1640251881Speter      { NULL, NULL }
1641251881Speter    };
1642251881Speter  SVN_VERSION_DEFINE(my_version);
1643251881Speter
1644262253Speter  return svn_ver_check_list2(&my_version, checklist, svn_ver_equal);
1645251881Speter}
1646251881Speter
1647251881Speter
1648251881Speter/* A flag to see if we've been cancelled by the client or not. */
1649251881Speterstatic volatile sig_atomic_t cancelled = FALSE;
1650251881Speter
1651251881Speter/* A signal handler to support cancellation. */
1652251881Speterstatic void
1653251881Spetersignal_handler(int signum)
1654251881Speter{
1655251881Speter  apr_signal(signum, SIG_IGN);
1656251881Speter  cancelled = TRUE;
1657251881Speter}
1658251881Speter
1659251881Speter/* Our cancellation callback. */
1660251881Spetersvn_error_t *
1661251881Spetersvn_cl__check_cancel(void *baton)
1662251881Speter{
1663251881Speter  if (cancelled)
1664251881Speter    return svn_error_create(SVN_ERR_CANCELLED, NULL, _("Caught signal"));
1665251881Speter  else
1666251881Speter    return SVN_NO_ERROR;
1667251881Speter}
1668251881Speter
1669251881Speter/* Add a --search argument to OPT_STATE.
1670251881Speter * These options start a new search pattern group. */
1671251881Speterstatic void
1672251881Speteradd_search_pattern_group(svn_cl__opt_state_t *opt_state,
1673251881Speter                         const char *pattern,
1674251881Speter                         apr_pool_t *result_pool)
1675251881Speter{
1676251881Speter  apr_array_header_t *group = NULL;
1677251881Speter
1678251881Speter  if (opt_state->search_patterns == NULL)
1679251881Speter    opt_state->search_patterns = apr_array_make(result_pool, 1,
1680251881Speter                                                sizeof(apr_array_header_t *));
1681251881Speter
1682251881Speter  group = apr_array_make(result_pool, 1, sizeof(const char *));
1683251881Speter  APR_ARRAY_PUSH(group, const char *) = pattern;
1684251881Speter  APR_ARRAY_PUSH(opt_state->search_patterns, apr_array_header_t *) = group;
1685251881Speter}
1686251881Speter
1687251881Speter/* Add a --search-and argument to OPT_STATE.
1688251881Speter * These patterns are added to an existing pattern group, if any. */
1689251881Speterstatic void
1690251881Speteradd_search_pattern_to_latest_group(svn_cl__opt_state_t *opt_state,
1691251881Speter                                   const char *pattern,
1692251881Speter                                   apr_pool_t *result_pool)
1693251881Speter{
1694251881Speter  apr_array_header_t *group;
1695251881Speter
1696251881Speter  if (opt_state->search_patterns == NULL)
1697251881Speter    {
1698251881Speter      add_search_pattern_group(opt_state, pattern, result_pool);
1699251881Speter      return;
1700251881Speter    }
1701251881Speter
1702251881Speter  group = APR_ARRAY_IDX(opt_state->search_patterns,
1703251881Speter                        opt_state->search_patterns->nelts - 1,
1704251881Speter                        apr_array_header_t *);
1705251881Speter  APR_ARRAY_PUSH(group, const char *) = pattern;
1706251881Speter}
1707251881Speter
1708251881Speter
1709251881Speter/*** Main. ***/
1710251881Speter
1711251881Speter/* Report and clear the error ERR, and return EXIT_FAILURE. Suppress the
1712251881Speter * error message if it is SVN_ERR_IO_PIPE_WRITE_ERROR. */
1713251881Speter#define EXIT_ERROR(err)                                                 \
1714251881Speter  svn_cmdline_handle_exit_error(err, NULL, "svn: ")
1715251881Speter
1716251881Speter/* A redefinition of the public SVN_INT_ERR macro, that suppresses the
1717251881Speter * error message if it is SVN_ERR_IO_PIPE_WRITE_ERROR. */
1718251881Speter#undef SVN_INT_ERR
1719251881Speter#define SVN_INT_ERR(expr)                                        \
1720251881Speter  do {                                                           \
1721251881Speter    svn_error_t *svn_err__temp = (expr);                         \
1722251881Speter    if (svn_err__temp)                                           \
1723251881Speter      return EXIT_ERROR(svn_err__temp);                          \
1724251881Speter  } while (0)
1725251881Speter
1726251881Speterstatic int
1727251881Spetersub_main(int argc, const char *argv[], apr_pool_t *pool)
1728251881Speter{
1729251881Speter  svn_error_t *err;
1730251881Speter  int opt_id;
1731251881Speter  apr_getopt_t *os;
1732251881Speter  svn_cl__opt_state_t opt_state = { 0, { 0 } };
1733251881Speter  svn_client_ctx_t *ctx;
1734251881Speter  apr_array_header_t *received_opts;
1735251881Speter  int i;
1736251881Speter  const svn_opt_subcommand_desc2_t *subcommand = NULL;
1737251881Speter  const char *dash_m_arg = NULL, *dash_F_arg = NULL;
1738251881Speter  svn_cl__cmd_baton_t command_baton;
1739251881Speter  svn_auth_baton_t *ab;
1740251881Speter  svn_config_t *cfg_config;
1741251881Speter  svn_boolean_t descend = TRUE;
1742251881Speter  svn_boolean_t interactive_conflicts = FALSE;
1743251881Speter  svn_boolean_t force_interactive = FALSE;
1744251881Speter  svn_cl__conflict_stats_t *conflict_stats
1745251881Speter    = svn_cl__conflict_stats_create(pool);
1746251881Speter  svn_boolean_t use_notifier = TRUE;
1747251881Speter  svn_boolean_t reading_file_from_stdin = FALSE;
1748251881Speter  apr_hash_t *changelists;
1749251881Speter  apr_hash_t *cfg_hash;
1750251881Speter
1751251881Speter  received_opts = apr_array_make(pool, SVN_OPT_MAX_OPTIONS, sizeof(int));
1752251881Speter
1753251881Speter  /* Check library versions */
1754251881Speter  SVN_INT_ERR(check_lib_versions());
1755251881Speter
1756251881Speter#if defined(WIN32) || defined(__CYGWIN__)
1757251881Speter  /* Set the working copy administrative directory name. */
1758251881Speter  if (getenv("SVN_ASP_DOT_NET_HACK"))
1759251881Speter    {
1760251881Speter      SVN_INT_ERR(svn_wc_set_adm_dir("_svn", pool));
1761251881Speter    }
1762251881Speter#endif
1763251881Speter
1764251881Speter  /* Initialize the RA library. */
1765251881Speter  SVN_INT_ERR(svn_ra_initialize(pool));
1766251881Speter
1767251881Speter  /* Init our changelists hash. */
1768251881Speter  changelists = apr_hash_make(pool);
1769251881Speter
1770251881Speter  /* Begin processing arguments. */
1771251881Speter  opt_state.start_revision.kind = svn_opt_revision_unspecified;
1772251881Speter  opt_state.end_revision.kind = svn_opt_revision_unspecified;
1773251881Speter  opt_state.revision_ranges =
1774251881Speter    apr_array_make(pool, 0, sizeof(svn_opt_revision_range_t *));
1775251881Speter  opt_state.depth = svn_depth_unknown;
1776251881Speter  opt_state.set_depth = svn_depth_unknown;
1777251881Speter  opt_state.accept_which = svn_cl__accept_unspecified;
1778251881Speter  opt_state.show_revs = svn_cl__show_revs_invalid;
1779251881Speter
1780251881Speter  /* No args?  Show usage. */
1781251881Speter  if (argc <= 1)
1782251881Speter    {
1783251881Speter      SVN_INT_ERR(svn_cl__help(NULL, NULL, pool));
1784251881Speter      return EXIT_FAILURE;
1785251881Speter    }
1786251881Speter
1787251881Speter  /* Else, parse options. */
1788251881Speter  SVN_INT_ERR(svn_cmdline__getopt_init(&os, argc, argv, pool));
1789251881Speter
1790251881Speter  os->interleave = 1;
1791251881Speter  while (1)
1792251881Speter    {
1793251881Speter      const char *opt_arg;
1794251881Speter      const char *utf8_opt_arg;
1795251881Speter
1796251881Speter      /* Parse the next option. */
1797251881Speter      apr_status_t apr_err = apr_getopt_long(os, svn_cl__options, &opt_id,
1798251881Speter                                             &opt_arg);
1799251881Speter      if (APR_STATUS_IS_EOF(apr_err))
1800251881Speter        break;
1801251881Speter      else if (apr_err)
1802251881Speter        {
1803251881Speter          SVN_INT_ERR(svn_cl__help(NULL, NULL, pool));
1804251881Speter          return EXIT_FAILURE;
1805251881Speter        }
1806251881Speter
1807251881Speter      /* Stash the option code in an array before parsing it. */
1808251881Speter      APR_ARRAY_PUSH(received_opts, int) = opt_id;
1809251881Speter
1810251881Speter      switch (opt_id) {
1811251881Speter      case 'l':
1812251881Speter        {
1813251881Speter          err = svn_cstring_atoi(&opt_state.limit, opt_arg);
1814251881Speter          if (err)
1815251881Speter            {
1816251881Speter              err = svn_error_create(SVN_ERR_CL_ARG_PARSING_ERROR, err,
1817251881Speter                                     _("Non-numeric limit argument given"));
1818251881Speter              return EXIT_ERROR(err);
1819251881Speter            }
1820251881Speter          if (opt_state.limit <= 0)
1821251881Speter            {
1822251881Speter              err = svn_error_create(SVN_ERR_INCORRECT_PARAMS, NULL,
1823251881Speter                                    _("Argument to --limit must be positive"));
1824251881Speter              return EXIT_ERROR(err);
1825251881Speter            }
1826251881Speter        }
1827251881Speter        break;
1828251881Speter      case 'm':
1829251881Speter        /* Note that there's no way here to detect if the log message
1830251881Speter           contains a zero byte -- if it does, then opt_arg will just
1831251881Speter           be shorter than the user intended.  Oh well. */
1832251881Speter        opt_state.message = apr_pstrdup(pool, opt_arg);
1833251881Speter        dash_m_arg = opt_arg;
1834251881Speter        break;
1835251881Speter      case 'c':
1836251881Speter        {
1837251881Speter          apr_array_header_t *change_revs =
1838251881Speter            svn_cstring_split(opt_arg, ", \n\r\t\v", TRUE, pool);
1839251881Speter
1840251881Speter          if (opt_state.old_target)
1841251881Speter            {
1842251881Speter              err = svn_error_create
1843251881Speter                (SVN_ERR_CL_ARG_PARSING_ERROR, NULL,
1844251881Speter                 _("Can't specify -c with --old"));
1845251881Speter              return EXIT_ERROR(err);
1846251881Speter            }
1847251881Speter
1848251881Speter          for (i = 0; i < change_revs->nelts; i++)
1849251881Speter            {
1850251881Speter              char *end;
1851251881Speter              svn_revnum_t changeno, changeno_end;
1852251881Speter              const char *change_str =
1853251881Speter                APR_ARRAY_IDX(change_revs, i, const char *);
1854251881Speter              const char *s = change_str;
1855251881Speter              svn_boolean_t is_negative;
1856251881Speter
1857251881Speter              /* Check for a leading minus to allow "-c -r42".
1858251881Speter               * The is_negative flag is used to handle "-c -42" and "-c -r42".
1859251881Speter               * The "-c r-42" case is handled by strtol() returning a
1860251881Speter               * negative number. */
1861251881Speter              is_negative = (*s == '-');
1862251881Speter              if (is_negative)
1863251881Speter                s++;
1864251881Speter
1865251881Speter              /* Allow any number of 'r's to prefix a revision number. */
1866251881Speter              while (*s == 'r')
1867251881Speter                s++;
1868251881Speter              changeno = changeno_end = strtol(s, &end, 10);
1869251881Speter              if (end != s && *end == '-')
1870251881Speter                {
1871251881Speter                  if (changeno < 0 || is_negative)
1872251881Speter                    {
1873251881Speter                      err = svn_error_createf(SVN_ERR_CL_ARG_PARSING_ERROR,
1874251881Speter                                              NULL,
1875251881Speter                                              _("Negative number in range (%s)"
1876251881Speter                                                " not supported with -c"),
1877251881Speter                                              change_str);
1878251881Speter                      return EXIT_ERROR(err);
1879251881Speter                    }
1880251881Speter                  s = end + 1;
1881251881Speter                  while (*s == 'r')
1882251881Speter                    s++;
1883251881Speter                  changeno_end = strtol(s, &end, 10);
1884251881Speter                }
1885251881Speter              if (end == change_str || *end != '\0')
1886251881Speter                {
1887251881Speter                  err = svn_error_createf(SVN_ERR_CL_ARG_PARSING_ERROR, NULL,
1888251881Speter                                          _("Non-numeric change argument (%s) "
1889251881Speter                                            "given to -c"), change_str);
1890251881Speter                  return EXIT_ERROR(err);
1891251881Speter                }
1892251881Speter
1893251881Speter              if (changeno == 0)
1894251881Speter                {
1895251881Speter                  err = svn_error_create(SVN_ERR_CL_ARG_PARSING_ERROR, NULL,
1896251881Speter                                         _("There is no change 0"));
1897251881Speter                  return EXIT_ERROR(err);
1898251881Speter                }
1899251881Speter
1900251881Speter              if (is_negative)
1901251881Speter                changeno = -changeno;
1902251881Speter
1903251881Speter              /* Figure out the range:
1904251881Speter                    -c N  -> -r N-1:N
1905251881Speter                    -c -N -> -r N:N-1
1906251881Speter                    -c M-N -> -r M-1:N for M < N
1907251881Speter                    -c M-N -> -r M:N-1 for M > N
1908251881Speter                    -c -M-N -> error (too confusing/no valid use case)
1909251881Speter              */
1910251881Speter              if (changeno > 0)
1911251881Speter                {
1912251881Speter                  if (changeno <= changeno_end)
1913251881Speter                    changeno--;
1914251881Speter                  else
1915251881Speter                    changeno_end--;
1916251881Speter                }
1917251881Speter              else
1918251881Speter                {
1919251881Speter                  changeno = -changeno;
1920251881Speter                  changeno_end = changeno - 1;
1921251881Speter                }
1922251881Speter
1923251881Speter              opt_state.used_change_arg = TRUE;
1924251881Speter              APR_ARRAY_PUSH(opt_state.revision_ranges,
1925251881Speter                             svn_opt_revision_range_t *)
1926251881Speter                = svn_opt__revision_range_from_revnums(changeno, changeno_end,
1927251881Speter                                                       pool);
1928251881Speter            }
1929251881Speter        }
1930251881Speter        break;
1931251881Speter      case 'r':
1932251881Speter        opt_state.used_revision_arg = TRUE;
1933251881Speter        if (svn_opt_parse_revision_to_range(opt_state.revision_ranges,
1934251881Speter                                            opt_arg, pool) != 0)
1935251881Speter          {
1936251881Speter            SVN_INT_ERR(svn_utf_cstring_to_utf8(&utf8_opt_arg, opt_arg, pool));
1937251881Speter            err = svn_error_createf
1938251881Speter                (SVN_ERR_CL_ARG_PARSING_ERROR, NULL,
1939251881Speter                 _("Syntax error in revision argument '%s'"),
1940251881Speter                 utf8_opt_arg);
1941251881Speter            return EXIT_ERROR(err);
1942251881Speter          }
1943251881Speter        break;
1944251881Speter      case 'v':
1945251881Speter        opt_state.verbose = TRUE;
1946251881Speter        break;
1947251881Speter      case 'u':
1948251881Speter        opt_state.update = TRUE;
1949251881Speter        break;
1950251881Speter      case 'h':
1951251881Speter      case '?':
1952251881Speter        opt_state.help = TRUE;
1953251881Speter        break;
1954251881Speter      case 'q':
1955251881Speter        opt_state.quiet = TRUE;
1956251881Speter        break;
1957251881Speter      case opt_incremental:
1958251881Speter        opt_state.incremental = TRUE;
1959251881Speter        break;
1960251881Speter      case 'F':
1961251881Speter        SVN_INT_ERR(svn_utf_cstring_to_utf8(&utf8_opt_arg, opt_arg, pool));
1962251881Speter        SVN_INT_ERR(svn_stringbuf_from_file2(&(opt_state.filedata),
1963251881Speter                                             utf8_opt_arg, pool));
1964251881Speter        reading_file_from_stdin = (strcmp(utf8_opt_arg, "-") == 0);
1965251881Speter        dash_F_arg = opt_arg;
1966251881Speter        break;
1967251881Speter      case opt_targets:
1968251881Speter        {
1969251881Speter          svn_stringbuf_t *buffer, *buffer_utf8;
1970251881Speter
1971251881Speter          /* We need to convert to UTF-8 now, even before we divide
1972251881Speter             the targets into an array, because otherwise we wouldn't
1973251881Speter             know what delimiter to use for svn_cstring_split().  */
1974251881Speter
1975251881Speter          SVN_INT_ERR(svn_utf_cstring_to_utf8(&utf8_opt_arg, opt_arg, pool));
1976251881Speter          SVN_INT_ERR(svn_stringbuf_from_file2(&buffer, utf8_opt_arg, pool));
1977251881Speter          SVN_INT_ERR(svn_utf_stringbuf_to_utf8(&buffer_utf8, buffer, pool));
1978251881Speter          opt_state.targets = svn_cstring_split(buffer_utf8->data, "\n\r",
1979251881Speter                                                TRUE, pool);
1980251881Speter        }
1981251881Speter        break;
1982251881Speter      case opt_force:
1983251881Speter        opt_state.force = TRUE;
1984251881Speter        break;
1985251881Speter      case opt_force_log:
1986251881Speter        opt_state.force_log = TRUE;
1987251881Speter        break;
1988251881Speter      case opt_dry_run:
1989251881Speter        opt_state.dry_run = TRUE;
1990251881Speter        break;
1991251881Speter      case opt_revprop:
1992251881Speter        opt_state.revprop = TRUE;
1993251881Speter        break;
1994251881Speter      case 'R':
1995251881Speter        opt_state.depth = svn_depth_infinity;
1996251881Speter        break;
1997251881Speter      case 'N':
1998251881Speter        descend = FALSE;
1999251881Speter        break;
2000251881Speter      case opt_depth:
2001251881Speter        err = svn_utf_cstring_to_utf8(&utf8_opt_arg, opt_arg, pool);
2002251881Speter        if (err)
2003251881Speter          return EXIT_ERROR
2004251881Speter            (svn_error_createf(SVN_ERR_CL_ARG_PARSING_ERROR, err,
2005251881Speter                               _("Error converting depth "
2006251881Speter                                 "from locale to UTF-8")));
2007251881Speter        opt_state.depth = svn_depth_from_word(utf8_opt_arg);
2008251881Speter        if (opt_state.depth == svn_depth_unknown
2009251881Speter            || opt_state.depth == svn_depth_exclude)
2010251881Speter          {
2011251881Speter            return EXIT_ERROR
2012251881Speter              (svn_error_createf(SVN_ERR_CL_ARG_PARSING_ERROR, NULL,
2013251881Speter                                 _("'%s' is not a valid depth; try "
2014251881Speter                                   "'empty', 'files', 'immediates', "
2015251881Speter                                   "or 'infinity'"),
2016251881Speter                                 utf8_opt_arg));
2017251881Speter          }
2018251881Speter        break;
2019251881Speter      case opt_set_depth:
2020251881Speter        err = svn_utf_cstring_to_utf8(&utf8_opt_arg, opt_arg, pool);
2021251881Speter        if (err)
2022251881Speter          return EXIT_ERROR
2023251881Speter            (svn_error_createf(SVN_ERR_CL_ARG_PARSING_ERROR, err,
2024251881Speter                               _("Error converting depth "
2025251881Speter                                 "from locale to UTF-8")));
2026251881Speter        opt_state.set_depth = svn_depth_from_word(utf8_opt_arg);
2027251881Speter        /* svn_depth_exclude is okay for --set-depth. */
2028251881Speter        if (opt_state.set_depth == svn_depth_unknown)
2029251881Speter          {
2030251881Speter            return EXIT_ERROR
2031251881Speter              (svn_error_createf(SVN_ERR_CL_ARG_PARSING_ERROR, NULL,
2032251881Speter                                 _("'%s' is not a valid depth; try "
2033251881Speter                                   "'exclude', 'empty', 'files', "
2034251881Speter                                   "'immediates', or 'infinity'"),
2035251881Speter                                 utf8_opt_arg));
2036251881Speter          }
2037251881Speter        break;
2038251881Speter      case opt_version:
2039251881Speter        opt_state.version = TRUE;
2040251881Speter        break;
2041251881Speter      case opt_auth_username:
2042251881Speter        SVN_INT_ERR(svn_utf_cstring_to_utf8(&opt_state.auth_username,
2043251881Speter                                            opt_arg, pool));
2044251881Speter        break;
2045251881Speter      case opt_auth_password:
2046251881Speter        SVN_INT_ERR(svn_utf_cstring_to_utf8(&opt_state.auth_password,
2047251881Speter                                            opt_arg, pool));
2048251881Speter        break;
2049251881Speter      case opt_encoding:
2050251881Speter        opt_state.encoding = apr_pstrdup(pool, opt_arg);
2051251881Speter        break;
2052251881Speter      case opt_xml:
2053251881Speter        opt_state.xml = TRUE;
2054251881Speter        break;
2055251881Speter      case opt_stop_on_copy:
2056251881Speter        opt_state.stop_on_copy = TRUE;
2057251881Speter        break;
2058251881Speter      case opt_strict:
2059251881Speter        opt_state.strict = TRUE;
2060251881Speter        break;
2061251881Speter      case opt_no_ignore:
2062251881Speter        opt_state.no_ignore = TRUE;
2063251881Speter        break;
2064251881Speter      case opt_no_auth_cache:
2065251881Speter        opt_state.no_auth_cache = TRUE;
2066251881Speter        break;
2067251881Speter      case opt_non_interactive:
2068251881Speter        opt_state.non_interactive = TRUE;
2069251881Speter        break;
2070251881Speter      case opt_force_interactive:
2071251881Speter        force_interactive = TRUE;
2072251881Speter        break;
2073251881Speter      case opt_trust_server_cert:
2074251881Speter        opt_state.trust_server_cert = TRUE;
2075251881Speter        break;
2076251881Speter      case opt_no_diff_added:
2077251881Speter        opt_state.diff.no_diff_added = TRUE;
2078251881Speter        break;
2079251881Speter      case opt_no_diff_deleted:
2080251881Speter        opt_state.diff.no_diff_deleted = TRUE;
2081251881Speter        break;
2082251881Speter      case opt_ignore_properties:
2083251881Speter        opt_state.diff.ignore_properties = TRUE;
2084251881Speter        break;
2085251881Speter      case opt_show_copies_as_adds:
2086251881Speter        opt_state.diff.show_copies_as_adds = TRUE;
2087251881Speter        break;
2088251881Speter      case opt_notice_ancestry:
2089251881Speter        opt_state.diff.notice_ancestry = TRUE;
2090251881Speter        break;
2091251881Speter      case opt_ignore_ancestry:
2092251881Speter        opt_state.ignore_ancestry = TRUE;
2093251881Speter        break;
2094251881Speter      case opt_ignore_externals:
2095251881Speter        opt_state.ignore_externals = TRUE;
2096251881Speter        break;
2097251881Speter      case opt_relocate:
2098251881Speter        opt_state.relocate = TRUE;
2099251881Speter        break;
2100251881Speter      case 'x':
2101251881Speter        SVN_INT_ERR(svn_utf_cstring_to_utf8(&opt_state.extensions,
2102251881Speter                                            opt_arg, pool));
2103251881Speter        break;
2104251881Speter      case opt_diff_cmd:
2105251881Speter        opt_state.diff.diff_cmd = apr_pstrdup(pool, opt_arg);
2106251881Speter        break;
2107251881Speter      case opt_merge_cmd:
2108251881Speter        opt_state.merge_cmd = apr_pstrdup(pool, opt_arg);
2109251881Speter        break;
2110251881Speter      case opt_record_only:
2111251881Speter        opt_state.record_only = TRUE;
2112251881Speter        break;
2113251881Speter      case opt_editor_cmd:
2114251881Speter        opt_state.editor_cmd = apr_pstrdup(pool, opt_arg);
2115251881Speter        break;
2116251881Speter      case opt_old_cmd:
2117251881Speter        if (opt_state.used_change_arg)
2118251881Speter          {
2119251881Speter            err = svn_error_create
2120251881Speter              (SVN_ERR_CL_ARG_PARSING_ERROR, NULL,
2121251881Speter               _("Can't specify -c with --old"));
2122251881Speter            return EXIT_ERROR(err);
2123251881Speter          }
2124251881Speter        opt_state.old_target = apr_pstrdup(pool, opt_arg);
2125251881Speter        break;
2126251881Speter      case opt_new_cmd:
2127251881Speter        opt_state.new_target = apr_pstrdup(pool, opt_arg);
2128251881Speter        break;
2129251881Speter      case opt_config_dir:
2130251881Speter        {
2131251881Speter          const char *path_utf8;
2132251881Speter          SVN_INT_ERR(svn_utf_cstring_to_utf8(&path_utf8, opt_arg, pool));
2133251881Speter          opt_state.config_dir = svn_dirent_internal_style(path_utf8, pool);
2134251881Speter        }
2135251881Speter        break;
2136251881Speter      case opt_config_options:
2137251881Speter        if (!opt_state.config_options)
2138251881Speter          opt_state.config_options =
2139251881Speter                   apr_array_make(pool, 1,
2140251881Speter                                  sizeof(svn_cmdline__config_argument_t*));
2141251881Speter
2142251881Speter        SVN_INT_ERR(svn_utf_cstring_to_utf8(&opt_arg, opt_arg, pool));
2143251881Speter        SVN_INT_ERR(svn_cmdline__parse_config_option(opt_state.config_options,
2144251881Speter                                                     opt_arg, pool));
2145251881Speter        break;
2146251881Speter      case opt_autoprops:
2147251881Speter        opt_state.autoprops = TRUE;
2148251881Speter        break;
2149251881Speter      case opt_no_autoprops:
2150251881Speter        opt_state.no_autoprops = TRUE;
2151251881Speter        break;
2152251881Speter      case opt_native_eol:
2153251881Speter        if ( !strcmp("LF", opt_arg) || !strcmp("CR", opt_arg) ||
2154251881Speter             !strcmp("CRLF", opt_arg))
2155251881Speter          opt_state.native_eol = apr_pstrdup(pool, opt_arg);
2156251881Speter        else
2157251881Speter          {
2158251881Speter            SVN_INT_ERR(svn_utf_cstring_to_utf8(&utf8_opt_arg, opt_arg, pool));
2159251881Speter            err = svn_error_createf
2160251881Speter                (SVN_ERR_CL_ARG_PARSING_ERROR, NULL,
2161251881Speter                 _("Syntax error in native-eol argument '%s'"),
2162251881Speter                 utf8_opt_arg);
2163251881Speter            return EXIT_ERROR(err);
2164251881Speter          }
2165251881Speter        break;
2166251881Speter      case opt_no_unlock:
2167251881Speter        opt_state.no_unlock = TRUE;
2168251881Speter        break;
2169251881Speter      case opt_summarize:
2170251881Speter        opt_state.diff.summarize = TRUE;
2171251881Speter        break;
2172251881Speter      case opt_remove:
2173251881Speter        opt_state.remove = TRUE;
2174251881Speter        break;
2175251881Speter      case opt_changelist:
2176251881Speter        SVN_INT_ERR(svn_utf_cstring_to_utf8(&utf8_opt_arg, opt_arg, pool));
2177251881Speter        opt_state.changelist = utf8_opt_arg;
2178251881Speter        if (opt_state.changelist[0] == '\0')
2179251881Speter          {
2180251881Speter            err = svn_error_create(SVN_ERR_CL_ARG_PARSING_ERROR, NULL,
2181251881Speter                                   _("Changelist names must not be empty"));
2182251881Speter            return EXIT_ERROR(err);
2183251881Speter          }
2184251881Speter        svn_hash_sets(changelists, opt_state.changelist, (void *)1);
2185251881Speter        break;
2186251881Speter      case opt_keep_changelists:
2187251881Speter        opt_state.keep_changelists = TRUE;
2188251881Speter        break;
2189251881Speter      case opt_keep_local:
2190251881Speter        opt_state.keep_local = TRUE;
2191251881Speter        break;
2192251881Speter      case opt_with_all_revprops:
2193251881Speter        /* If --with-all-revprops is specified along with one or more
2194251881Speter         * --with-revprops options, --with-all-revprops takes precedence. */
2195251881Speter        opt_state.all_revprops = TRUE;
2196251881Speter        break;
2197251881Speter      case opt_with_no_revprops:
2198251881Speter        opt_state.no_revprops = TRUE;
2199251881Speter        break;
2200251881Speter      case opt_with_revprop:
2201251881Speter        SVN_INT_ERR(svn_opt_parse_revprop(&opt_state.revprop_table,
2202251881Speter                                          opt_arg, pool));
2203251881Speter        break;
2204251881Speter      case opt_parents:
2205251881Speter        opt_state.parents = TRUE;
2206251881Speter        break;
2207251881Speter      case 'g':
2208251881Speter        opt_state.use_merge_history = TRUE;
2209251881Speter        break;
2210251881Speter      case opt_accept:
2211251881Speter        opt_state.accept_which = svn_cl__accept_from_word(opt_arg);
2212251881Speter        if (opt_state.accept_which == svn_cl__accept_invalid)
2213251881Speter          return EXIT_ERROR
2214251881Speter            (svn_error_createf(SVN_ERR_CL_ARG_PARSING_ERROR, NULL,
2215251881Speter                               _("'%s' is not a valid --accept value"),
2216251881Speter                               opt_arg));
2217251881Speter        break;
2218251881Speter      case opt_show_revs:
2219251881Speter        opt_state.show_revs = svn_cl__show_revs_from_word(opt_arg);
2220251881Speter        if (opt_state.show_revs == svn_cl__show_revs_invalid)
2221251881Speter          return EXIT_ERROR
2222251881Speter            (svn_error_createf(SVN_ERR_CL_ARG_PARSING_ERROR, NULL,
2223251881Speter                               _("'%s' is not a valid --show-revs value"),
2224251881Speter                               opt_arg));
2225251881Speter        break;
2226251881Speter      case opt_reintegrate:
2227251881Speter        opt_state.reintegrate = TRUE;
2228251881Speter        break;
2229251881Speter      case opt_strip:
2230251881Speter        {
2231251881Speter          err = svn_cstring_atoi(&opt_state.strip, opt_arg);
2232251881Speter          if (err)
2233251881Speter            {
2234251881Speter              err = svn_error_createf(SVN_ERR_CL_ARG_PARSING_ERROR, err,
2235251881Speter                                      _("Invalid strip count '%s'"), opt_arg);
2236251881Speter              return EXIT_ERROR(err);
2237251881Speter            }
2238251881Speter          if (opt_state.strip < 0)
2239251881Speter            {
2240251881Speter              err = svn_error_create(SVN_ERR_INCORRECT_PARAMS, NULL,
2241251881Speter                                     _("Argument to --strip must be positive"));
2242251881Speter              return EXIT_ERROR(err);
2243251881Speter            }
2244251881Speter        }
2245251881Speter        break;
2246251881Speter      case opt_ignore_keywords:
2247251881Speter        opt_state.ignore_keywords = TRUE;
2248251881Speter        break;
2249251881Speter      case opt_reverse_diff:
2250251881Speter        opt_state.reverse_diff = TRUE;
2251251881Speter        break;
2252251881Speter      case opt_ignore_whitespace:
2253251881Speter          opt_state.ignore_whitespace = TRUE;
2254251881Speter          break;
2255251881Speter      case opt_diff:
2256251881Speter          opt_state.show_diff = TRUE;
2257251881Speter          break;
2258251881Speter      case opt_internal_diff:
2259251881Speter        opt_state.diff.internal_diff = TRUE;
2260251881Speter        break;
2261251881Speter      case opt_patch_compatible:
2262251881Speter        opt_state.diff.patch_compatible = TRUE;
2263251881Speter        break;
2264251881Speter      case opt_use_git_diff_format:
2265251881Speter        opt_state.diff.use_git_diff_format = TRUE;
2266251881Speter        break;
2267251881Speter      case opt_allow_mixed_revisions:
2268251881Speter        opt_state.allow_mixed_rev = TRUE;
2269251881Speter        break;
2270251881Speter      case opt_include_externals:
2271251881Speter        opt_state.include_externals = TRUE;
2272251881Speter        break;
2273251881Speter      case opt_show_inherited_props:
2274251881Speter        opt_state.show_inherited_props = TRUE;
2275251881Speter        break;
2276251881Speter      case opt_properties_only:
2277251881Speter        opt_state.diff.properties_only = TRUE;
2278251881Speter        break;
2279251881Speter      case opt_search:
2280251881Speter        add_search_pattern_group(&opt_state, opt_arg, pool);
2281251881Speter        break;
2282251881Speter      case opt_search_and:
2283251881Speter        add_search_pattern_to_latest_group(&opt_state, opt_arg, pool);
2284251881Speter      default:
2285251881Speter        /* Hmmm. Perhaps this would be a good place to squirrel away
2286251881Speter           opts that commands like svn diff might need. Hmmm indeed. */
2287251881Speter        break;
2288251881Speter      }
2289251881Speter    }
2290251881Speter
2291251881Speter  /* The --non-interactive and --force-interactive options are mutually
2292251881Speter   * exclusive. */
2293251881Speter  if (opt_state.non_interactive && force_interactive)
2294251881Speter    {
2295251881Speter      err = svn_error_create(SVN_ERR_CL_ARG_PARSING_ERROR, NULL,
2296251881Speter                             _("--non-interactive and --force-interactive "
2297251881Speter                               "are mutually exclusive"));
2298251881Speter      return EXIT_ERROR(err);
2299251881Speter    }
2300251881Speter  else
2301251881Speter    opt_state.non_interactive = !svn_cmdline__be_interactive(
2302251881Speter                                  opt_state.non_interactive,
2303251881Speter                                  force_interactive);
2304251881Speter
2305251881Speter  /* Turn our hash of changelists into an array of unique ones. */
2306251881Speter  SVN_INT_ERR(svn_hash_keys(&(opt_state.changelists), changelists, pool));
2307251881Speter
2308251881Speter  /* ### This really belongs in libsvn_client.  The trouble is,
2309251881Speter     there's no one place there to run it from, no
2310251881Speter     svn_client_init().  We'd have to add it to all the public
2311251881Speter     functions that a client might call.  It's unmaintainable to do
2312251881Speter     initialization from within libsvn_client itself, but it seems
2313251881Speter     burdensome to demand that all clients call svn_client_init()
2314251881Speter     before calling any other libsvn_client function... On the other
2315251881Speter     hand, the alternative is effectively to demand that they call
2316251881Speter     svn_config_ensure() instead, so maybe we should have a generic
2317251881Speter     init function anyway.  Thoughts?  */
2318251881Speter  SVN_INT_ERR(svn_config_ensure(opt_state.config_dir, pool));
2319251881Speter
2320251881Speter  /* If the user asked for help, then the rest of the arguments are
2321251881Speter     the names of subcommands to get help on (if any), or else they're
2322251881Speter     just typos/mistakes.  Whatever the case, the subcommand to
2323251881Speter     actually run is svn_cl__help(). */
2324251881Speter  if (opt_state.help)
2325251881Speter    subcommand = svn_opt_get_canonical_subcommand2(svn_cl__cmd_table, "help");
2326251881Speter
2327251881Speter  /* If we're not running the `help' subcommand, then look for a
2328251881Speter     subcommand in the first argument. */
2329251881Speter  if (subcommand == NULL)
2330251881Speter    {
2331251881Speter      if (os->ind >= os->argc)
2332251881Speter        {
2333251881Speter          if (opt_state.version)
2334251881Speter            {
2335251881Speter              /* Use the "help" subcommand to handle the "--version" option. */
2336251881Speter              static const svn_opt_subcommand_desc2_t pseudo_cmd =
2337251881Speter                { "--version", svn_cl__help, {0}, "",
2338251881Speter                  {opt_version,    /* must accept its own option */
2339251881Speter                   'q',            /* brief output */
2340251881Speter                   'v',            /* verbose output */
2341251881Speter                   opt_config_dir  /* all commands accept this */
2342251881Speter                  } };
2343251881Speter
2344251881Speter              subcommand = &pseudo_cmd;
2345251881Speter            }
2346251881Speter          else
2347251881Speter            {
2348251881Speter              svn_error_clear
2349251881Speter                (svn_cmdline_fprintf(stderr, pool,
2350251881Speter                                     _("Subcommand argument required\n")));
2351251881Speter              svn_error_clear(svn_cl__help(NULL, NULL, pool));
2352251881Speter              return EXIT_FAILURE;
2353251881Speter            }
2354251881Speter        }
2355251881Speter      else
2356251881Speter        {
2357251881Speter          const char *first_arg = os->argv[os->ind++];
2358251881Speter          subcommand = svn_opt_get_canonical_subcommand2(svn_cl__cmd_table,
2359251881Speter                                                         first_arg);
2360251881Speter          if (subcommand == NULL)
2361251881Speter            {
2362251881Speter              const char *first_arg_utf8;
2363251881Speter              SVN_INT_ERR(svn_utf_cstring_to_utf8(&first_arg_utf8,
2364251881Speter                                                  first_arg, pool));
2365251881Speter              svn_error_clear
2366251881Speter                (svn_cmdline_fprintf(stderr, pool,
2367251881Speter                                     _("Unknown subcommand: '%s'\n"),
2368251881Speter                                     first_arg_utf8));
2369251881Speter              svn_error_clear(svn_cl__help(NULL, NULL, pool));
2370251881Speter
2371251881Speter              /* Be kind to people who try 'svn undo'. */
2372251881Speter              if (strcmp(first_arg_utf8, "undo") == 0)
2373251881Speter                {
2374251881Speter                  svn_error_clear
2375251881Speter                    (svn_cmdline_fprintf(stderr, pool,
2376251881Speter                                         _("Undo is done using either the "
2377251881Speter                                           "'svn revert' or the 'svn merge' "
2378251881Speter                                           "command.\n")));
2379251881Speter                }
2380251881Speter
2381251881Speter              return EXIT_FAILURE;
2382251881Speter            }
2383251881Speter        }
2384251881Speter    }
2385251881Speter
2386251881Speter  /* Check that the subcommand wasn't passed any inappropriate options. */
2387251881Speter  for (i = 0; i < received_opts->nelts; i++)
2388251881Speter    {
2389251881Speter      opt_id = APR_ARRAY_IDX(received_opts, i, int);
2390251881Speter
2391251881Speter      /* All commands implicitly accept --help, so just skip over this
2392251881Speter         when we see it. Note that we don't want to include this option
2393251881Speter         in their "accepted options" list because it would be awfully
2394251881Speter         redundant to display it in every commands' help text. */
2395251881Speter      if (opt_id == 'h' || opt_id == '?')
2396251881Speter        continue;
2397251881Speter
2398251881Speter      if (! svn_opt_subcommand_takes_option3(subcommand, opt_id,
2399251881Speter                                             svn_cl__global_options))
2400251881Speter        {
2401251881Speter          const char *optstr;
2402251881Speter          const apr_getopt_option_t *badopt =
2403251881Speter            svn_opt_get_option_from_code2(opt_id, svn_cl__options,
2404251881Speter                                          subcommand, pool);
2405251881Speter          svn_opt_format_option(&optstr, badopt, FALSE, pool);
2406251881Speter          if (subcommand->name[0] == '-')
2407251881Speter            svn_error_clear(svn_cl__help(NULL, NULL, pool));
2408251881Speter          else
2409251881Speter            svn_error_clear
2410251881Speter              (svn_cmdline_fprintf
2411251881Speter               (stderr, pool, _("Subcommand '%s' doesn't accept option '%s'\n"
2412251881Speter                                "Type 'svn help %s' for usage.\n"),
2413251881Speter                subcommand->name, optstr, subcommand->name));
2414251881Speter          return EXIT_FAILURE;
2415251881Speter        }
2416251881Speter    }
2417251881Speter
2418251881Speter  /* Only merge and log support multiple revisions/revision ranges. */
2419251881Speter  if (subcommand->cmd_func != svn_cl__merge
2420251881Speter      && subcommand->cmd_func != svn_cl__log)
2421251881Speter    {
2422251881Speter      if (opt_state.revision_ranges->nelts > 1)
2423251881Speter        {
2424251881Speter          err = svn_error_create(SVN_ERR_CL_ARG_PARSING_ERROR, NULL,
2425251881Speter                                 _("Multiple revision arguments "
2426251881Speter                                   "encountered; can't specify -c twice, "
2427251881Speter                                   "or both -c and -r"));
2428251881Speter          return EXIT_ERROR(err);
2429251881Speter        }
2430251881Speter    }
2431251881Speter
2432251881Speter  /* Disallow simultaneous use of both --depth and --set-depth. */
2433251881Speter  if ((opt_state.depth != svn_depth_unknown)
2434251881Speter      && (opt_state.set_depth != svn_depth_unknown))
2435251881Speter    {
2436251881Speter      err = svn_error_create(SVN_ERR_CL_ARG_PARSING_ERROR, NULL,
2437251881Speter                             _("--depth and --set-depth are mutually "
2438251881Speter                               "exclusive"));
2439251881Speter      return EXIT_ERROR(err);
2440251881Speter    }
2441251881Speter
2442251881Speter  /* Disallow simultaneous use of both --with-all-revprops and
2443251881Speter     --with-no-revprops.  */
2444251881Speter  if (opt_state.all_revprops && opt_state.no_revprops)
2445251881Speter    {
2446251881Speter      err = svn_error_create(SVN_ERR_CL_ARG_PARSING_ERROR, NULL,
2447251881Speter                             _("--with-all-revprops and --with-no-revprops "
2448251881Speter                               "are mutually exclusive"));
2449251881Speter      return EXIT_ERROR(err);
2450251881Speter    }
2451251881Speter
2452251881Speter  /* Disallow simultaneous use of both --with-revprop and
2453251881Speter     --with-no-revprops.  */
2454251881Speter  if (opt_state.revprop_table && opt_state.no_revprops)
2455251881Speter    {
2456251881Speter      err = svn_error_create(SVN_ERR_CL_ARG_PARSING_ERROR, NULL,
2457251881Speter                             _("--with-revprop and --with-no-revprops "
2458251881Speter                               "are mutually exclusive"));
2459251881Speter      return EXIT_ERROR(err);
2460251881Speter    }
2461251881Speter
2462251881Speter  /* Disallow simultaneous use of both -m and -F, when they are
2463251881Speter     both used to pass a commit message or lock comment.  ('propset'
2464251881Speter     takes the property value, not a commit message, from -F.)
2465251881Speter   */
2466251881Speter  if (opt_state.filedata && opt_state.message
2467251881Speter      && subcommand->cmd_func != svn_cl__propset)
2468251881Speter    {
2469251881Speter      err = svn_error_create(SVN_ERR_CL_ARG_PARSING_ERROR, NULL,
2470251881Speter                             _("--message (-m) and --file (-F) "
2471251881Speter                               "are mutually exclusive"));
2472251881Speter      return EXIT_ERROR(err);
2473251881Speter    }
2474251881Speter
2475251881Speter  /* --trust-server-cert can only be used with --non-interactive */
2476251881Speter  if (opt_state.trust_server_cert && !opt_state.non_interactive)
2477251881Speter    {
2478251881Speter      err = svn_error_create(SVN_ERR_CL_ARG_PARSING_ERROR, NULL,
2479251881Speter                             _("--trust-server-cert requires "
2480251881Speter                               "--non-interactive"));
2481251881Speter      return EXIT_ERROR(err);
2482251881Speter    }
2483251881Speter
2484251881Speter  /* Disallow simultaneous use of both --diff-cmd and
2485251881Speter     --internal-diff.  */
2486251881Speter  if (opt_state.diff.diff_cmd && opt_state.diff.internal_diff)
2487251881Speter    {
2488251881Speter      err = svn_error_create(SVN_ERR_CL_ARG_PARSING_ERROR, NULL,
2489251881Speter                             _("--diff-cmd and --internal-diff "
2490251881Speter                               "are mutually exclusive"));
2491251881Speter      return EXIT_ERROR(err);
2492251881Speter    }
2493251881Speter
2494251881Speter  /* Ensure that 'revision_ranges' has at least one item, and make
2495251881Speter     'start_revision' and 'end_revision' match that item. */
2496251881Speter  if (opt_state.revision_ranges->nelts == 0)
2497251881Speter    {
2498251881Speter      svn_opt_revision_range_t *range = apr_palloc(pool, sizeof(*range));
2499251881Speter      range->start.kind = svn_opt_revision_unspecified;
2500251881Speter      range->end.kind = svn_opt_revision_unspecified;
2501251881Speter      APR_ARRAY_PUSH(opt_state.revision_ranges,
2502251881Speter                     svn_opt_revision_range_t *) = range;
2503251881Speter    }
2504251881Speter  opt_state.start_revision = APR_ARRAY_IDX(opt_state.revision_ranges, 0,
2505251881Speter                                           svn_opt_revision_range_t *)->start;
2506251881Speter  opt_state.end_revision = APR_ARRAY_IDX(opt_state.revision_ranges, 0,
2507251881Speter                                         svn_opt_revision_range_t *)->end;
2508251881Speter
2509251881Speter  err = svn_config_get_config(&cfg_hash, opt_state.config_dir, pool);
2510251881Speter  if (err)
2511251881Speter    {
2512251881Speter      /* Fallback to default config if the config directory isn't readable
2513251881Speter         or is not a directory. */
2514251881Speter      if (APR_STATUS_IS_EACCES(err->apr_err)
2515251881Speter          || SVN__APR_STATUS_IS_ENOTDIR(err->apr_err))
2516251881Speter        {
2517251881Speter          svn_handle_warning2(stderr, err, "svn: ");
2518251881Speter          svn_error_clear(err);
2519251881Speter          cfg_hash = NULL;
2520251881Speter        }
2521251881Speter      else
2522251881Speter        return EXIT_ERROR(err);
2523251881Speter    }
2524251881Speter
2525251881Speter  /* Relocation is infinite-depth only. */
2526251881Speter  if (opt_state.relocate)
2527251881Speter    {
2528251881Speter      if (opt_state.depth != svn_depth_unknown)
2529251881Speter        {
2530251881Speter          err = svn_error_create(SVN_ERR_CL_MUTUALLY_EXCLUSIVE_ARGS, NULL,
2531251881Speter                                 _("--relocate and --depth are mutually "
2532251881Speter                                   "exclusive"));
2533251881Speter          return EXIT_ERROR(err);
2534251881Speter        }
2535251881Speter      if (! descend)
2536251881Speter        {
2537251881Speter          err = svn_error_create(
2538251881Speter                    SVN_ERR_CL_MUTUALLY_EXCLUSIVE_ARGS, NULL,
2539251881Speter                    _("--relocate and --non-recursive (-N) are mutually "
2540251881Speter                      "exclusive"));
2541251881Speter          return EXIT_ERROR(err);
2542251881Speter        }
2543251881Speter    }
2544251881Speter
2545251881Speter  /* Only a few commands can accept a revision range; the rest can take at
2546251881Speter     most one revision number. */
2547251881Speter  if (subcommand->cmd_func != svn_cl__blame
2548251881Speter      && subcommand->cmd_func != svn_cl__diff
2549251881Speter      && subcommand->cmd_func != svn_cl__log
2550251881Speter      && subcommand->cmd_func != svn_cl__mergeinfo
2551251881Speter      && subcommand->cmd_func != svn_cl__merge)
2552251881Speter    {
2553251881Speter      if (opt_state.end_revision.kind != svn_opt_revision_unspecified)
2554251881Speter        {
2555251881Speter          err = svn_error_create(SVN_ERR_CLIENT_REVISION_RANGE, NULL, NULL);
2556251881Speter          return EXIT_ERROR(err);
2557251881Speter        }
2558251881Speter    }
2559251881Speter
2560251881Speter  /* -N has a different meaning depending on the command */
2561251881Speter  if (!descend)
2562251881Speter    {
2563251881Speter      if (subcommand->cmd_func == svn_cl__status)
2564251881Speter        {
2565251881Speter          opt_state.depth = svn_depth_immediates;
2566251881Speter        }
2567251881Speter      else if (subcommand->cmd_func == svn_cl__revert
2568251881Speter               || subcommand->cmd_func == svn_cl__add
2569251881Speter               || subcommand->cmd_func == svn_cl__commit)
2570251881Speter        {
2571251881Speter          /* In pre-1.5 Subversion, some commands treated -N like
2572251881Speter             --depth=empty, so force that mapping here.  Anyway, with
2573251881Speter             revert it makes sense to be especially conservative,
2574251881Speter             since revert can lose data. */
2575251881Speter          opt_state.depth = svn_depth_empty;
2576251881Speter        }
2577251881Speter      else
2578251881Speter        {
2579251881Speter          opt_state.depth = svn_depth_files;
2580251881Speter        }
2581251881Speter    }
2582251881Speter
2583251881Speter  cfg_config = svn_hash_gets(cfg_hash, SVN_CONFIG_CATEGORY_CONFIG);
2584251881Speter
2585251881Speter  /* Update the options in the config */
2586251881Speter  if (opt_state.config_options)
2587251881Speter    {
2588251881Speter      svn_error_clear(
2589251881Speter          svn_cmdline__apply_config_options(cfg_hash,
2590251881Speter                                            opt_state.config_options,
2591251881Speter                                            "svn: ", "--config-option"));
2592251881Speter    }
2593251881Speter
2594251881Speter#if !defined(SVN_CL_NO_EXCLUSIVE_LOCK)
2595251881Speter  {
2596251881Speter    const char *exclusive_clients_option;
2597251881Speter    apr_array_header_t *exclusive_clients;
2598251881Speter
2599251881Speter    svn_config_get(cfg_config, &exclusive_clients_option,
2600251881Speter                   SVN_CONFIG_SECTION_WORKING_COPY,
2601251881Speter                   SVN_CONFIG_OPTION_SQLITE_EXCLUSIVE_CLIENTS,
2602251881Speter                   NULL);
2603251881Speter    exclusive_clients = svn_cstring_split(exclusive_clients_option,
2604251881Speter                                          " ,", TRUE, pool);
2605251881Speter    for (i = 0; i < exclusive_clients->nelts; ++i)
2606251881Speter      {
2607251881Speter        const char *exclusive_client = APR_ARRAY_IDX(exclusive_clients, i,
2608251881Speter                                                     const char *);
2609251881Speter
2610251881Speter        /* This blocks other clients from accessing the wc.db so it must
2611251881Speter           be explicitly enabled.*/
2612251881Speter        if (!strcmp(exclusive_client, "svn"))
2613251881Speter          svn_config_set(cfg_config,
2614251881Speter                         SVN_CONFIG_SECTION_WORKING_COPY,
2615251881Speter                         SVN_CONFIG_OPTION_SQLITE_EXCLUSIVE,
2616251881Speter                         "true");
2617251881Speter      }
2618251881Speter  }
2619251881Speter#endif
2620251881Speter
2621251881Speter  /* Create a client context object. */
2622251881Speter  command_baton.opt_state = &opt_state;
2623251881Speter  SVN_INT_ERR(svn_client_create_context2(&ctx, cfg_hash, pool));
2624251881Speter  command_baton.ctx = ctx;
2625251881Speter
2626251881Speter  /* If we're running a command that could result in a commit, verify
2627251881Speter     that any log message we were given on the command line makes
2628251881Speter     sense (unless we've also been instructed not to care).  This may
2629251881Speter     access the working copy so do it after setting the locking mode. */
2630251881Speter  if ((! opt_state.force_log)
2631251881Speter      && (subcommand->cmd_func == svn_cl__commit
2632251881Speter          || subcommand->cmd_func == svn_cl__copy
2633251881Speter          || subcommand->cmd_func == svn_cl__delete
2634251881Speter          || subcommand->cmd_func == svn_cl__import
2635251881Speter          || subcommand->cmd_func == svn_cl__mkdir
2636251881Speter          || subcommand->cmd_func == svn_cl__move
2637251881Speter          || subcommand->cmd_func == svn_cl__lock
2638251881Speter          || subcommand->cmd_func == svn_cl__propedit))
2639251881Speter    {
2640251881Speter      /* If the -F argument is a file that's under revision control,
2641251881Speter         that's probably not what the user intended. */
2642251881Speter      if (dash_F_arg)
2643251881Speter        {
2644251881Speter          svn_node_kind_t kind;
2645251881Speter          const char *local_abspath;
2646251881Speter          const char *fname_utf8 = svn_dirent_internal_style(dash_F_arg, pool);
2647251881Speter
2648251881Speter          err = svn_dirent_get_absolute(&local_abspath, fname_utf8, pool);
2649251881Speter
2650251881Speter          if (!err)
2651251881Speter            {
2652251881Speter              err = svn_wc_read_kind2(&kind, ctx->wc_ctx, local_abspath, TRUE,
2653251881Speter                                      FALSE, pool);
2654251881Speter
2655251881Speter              if (!err && kind != svn_node_none && kind != svn_node_unknown)
2656251881Speter                {
2657251881Speter                  if (subcommand->cmd_func != svn_cl__lock)
2658251881Speter                    {
2659251881Speter                      err = svn_error_create(
2660251881Speter                         SVN_ERR_CL_LOG_MESSAGE_IS_VERSIONED_FILE, NULL,
2661251881Speter                         _("Log message file is a versioned file; "
2662251881Speter                           "use '--force-log' to override"));
2663251881Speter                    }
2664251881Speter                  else
2665251881Speter                    {
2666251881Speter                      err = svn_error_create(
2667251881Speter                         SVN_ERR_CL_LOG_MESSAGE_IS_VERSIONED_FILE, NULL,
2668251881Speter                         _("Lock comment file is a versioned file; "
2669251881Speter                           "use '--force-log' to override"));
2670251881Speter                    }
2671251881Speter                  return EXIT_ERROR(err);
2672251881Speter                }
2673251881Speter            }
2674251881Speter          svn_error_clear(err);
2675251881Speter        }
2676251881Speter
2677251881Speter      /* If the -m argument is a file at all, that's probably not what
2678251881Speter         the user intended. */
2679251881Speter      if (dash_m_arg)
2680251881Speter        {
2681251881Speter          apr_finfo_t finfo;
2682251881Speter          if (apr_stat(&finfo, dash_m_arg,
2683251881Speter                       APR_FINFO_MIN, pool) == APR_SUCCESS)
2684251881Speter            {
2685251881Speter              if (subcommand->cmd_func != svn_cl__lock)
2686251881Speter                {
2687251881Speter                  err = svn_error_create
2688251881Speter                    (SVN_ERR_CL_LOG_MESSAGE_IS_PATHNAME, NULL,
2689251881Speter                     _("The log message is a pathname "
2690251881Speter                       "(was -F intended?); use '--force-log' to override"));
2691251881Speter                }
2692251881Speter              else
2693251881Speter                {
2694251881Speter                  err = svn_error_create
2695251881Speter                    (SVN_ERR_CL_LOG_MESSAGE_IS_PATHNAME, NULL,
2696251881Speter                     _("The lock comment is a pathname "
2697251881Speter                       "(was -F intended?); use '--force-log' to override"));
2698251881Speter                }
2699251881Speter              return EXIT_ERROR(err);
2700251881Speter            }
2701251881Speter        }
2702251881Speter    }
2703251881Speter
2704251881Speter  /* XXX: Only diff_cmd for now, overlay rest later and stop passing
2705251881Speter     opt_state altogether? */
2706251881Speter  if (opt_state.diff.diff_cmd)
2707251881Speter    svn_config_set(cfg_config, SVN_CONFIG_SECTION_HELPERS,
2708251881Speter                   SVN_CONFIG_OPTION_DIFF_CMD, opt_state.diff.diff_cmd);
2709251881Speter  if (opt_state.merge_cmd)
2710251881Speter    svn_config_set(cfg_config, SVN_CONFIG_SECTION_HELPERS,
2711251881Speter                   SVN_CONFIG_OPTION_DIFF3_CMD, opt_state.merge_cmd);
2712251881Speter  if (opt_state.diff.internal_diff)
2713251881Speter    svn_config_set(cfg_config, SVN_CONFIG_SECTION_HELPERS,
2714251881Speter                   SVN_CONFIG_OPTION_DIFF_CMD, NULL);
2715251881Speter
2716251881Speter  /* Check for mutually exclusive args --auto-props and --no-auto-props */
2717251881Speter  if (opt_state.autoprops && opt_state.no_autoprops)
2718251881Speter    {
2719251881Speter      err = svn_error_create(SVN_ERR_CL_MUTUALLY_EXCLUSIVE_ARGS, NULL,
2720251881Speter                             _("--auto-props and --no-auto-props are "
2721251881Speter                               "mutually exclusive"));
2722251881Speter      return EXIT_ERROR(err);
2723251881Speter    }
2724251881Speter
2725251881Speter  /* Update auto-props-enable option, and populate the MIME types map,
2726251881Speter     for add/import commands */
2727251881Speter  if (subcommand->cmd_func == svn_cl__add
2728251881Speter      || subcommand->cmd_func == svn_cl__import)
2729251881Speter    {
2730251881Speter      const char *mimetypes_file;
2731251881Speter      svn_config_get(cfg_config, &mimetypes_file,
2732251881Speter                     SVN_CONFIG_SECTION_MISCELLANY,
2733251881Speter                     SVN_CONFIG_OPTION_MIMETYPES_FILE, FALSE);
2734251881Speter      if (mimetypes_file && *mimetypes_file)
2735251881Speter        {
2736251881Speter          SVN_INT_ERR(svn_io_parse_mimetypes_file(&(ctx->mimetypes_map),
2737251881Speter                                                  mimetypes_file, pool));
2738251881Speter        }
2739251881Speter
2740251881Speter      if (opt_state.autoprops)
2741251881Speter        {
2742251881Speter          svn_config_set_bool(cfg_config, SVN_CONFIG_SECTION_MISCELLANY,
2743251881Speter                              SVN_CONFIG_OPTION_ENABLE_AUTO_PROPS, TRUE);
2744251881Speter        }
2745251881Speter      if (opt_state.no_autoprops)
2746251881Speter        {
2747251881Speter          svn_config_set_bool(cfg_config, SVN_CONFIG_SECTION_MISCELLANY,
2748251881Speter                              SVN_CONFIG_OPTION_ENABLE_AUTO_PROPS, FALSE);
2749251881Speter        }
2750251881Speter    }
2751251881Speter
2752251881Speter  /* Update the 'keep-locks' runtime option */
2753251881Speter  if (opt_state.no_unlock)
2754251881Speter    svn_config_set_bool(cfg_config, SVN_CONFIG_SECTION_MISCELLANY,
2755251881Speter                        SVN_CONFIG_OPTION_NO_UNLOCK, TRUE);
2756251881Speter
2757251881Speter  /* Set the log message callback function.  Note that individual
2758251881Speter     subcommands will populate the ctx->log_msg_baton3. */
2759251881Speter  ctx->log_msg_func3 = svn_cl__get_log_message;
2760251881Speter
2761251881Speter  /* Set up the notifier.
2762251881Speter
2763251881Speter     In general, we use it any time we aren't in --quiet mode.  'svn
2764251881Speter     status' is unique, though, in that we don't want it in --quiet mode
2765251881Speter     unless we're also in --verbose mode.  When in --xml mode,
2766251881Speter     though, we never want it.  */
2767251881Speter  if (opt_state.quiet)
2768251881Speter    use_notifier = FALSE;
2769251881Speter  if ((subcommand->cmd_func == svn_cl__status) && opt_state.verbose)
2770251881Speter    use_notifier = TRUE;
2771251881Speter  if (opt_state.xml)
2772251881Speter    use_notifier = FALSE;
2773251881Speter  if (use_notifier)
2774251881Speter    {
2775251881Speter      SVN_INT_ERR(svn_cl__get_notifier(&ctx->notify_func2, &ctx->notify_baton2,
2776251881Speter                                       conflict_stats, pool));
2777251881Speter    }
2778251881Speter
2779251881Speter  /* Set up our cancellation support. */
2780251881Speter  ctx->cancel_func = svn_cl__check_cancel;
2781251881Speter  apr_signal(SIGINT, signal_handler);
2782251881Speter#ifdef SIGBREAK
2783251881Speter  /* SIGBREAK is a Win32 specific signal generated by ctrl-break. */
2784251881Speter  apr_signal(SIGBREAK, signal_handler);
2785251881Speter#endif
2786251881Speter#ifdef SIGHUP
2787251881Speter  apr_signal(SIGHUP, signal_handler);
2788251881Speter#endif
2789251881Speter#ifdef SIGTERM
2790251881Speter  apr_signal(SIGTERM, signal_handler);
2791251881Speter#endif
2792251881Speter
2793251881Speter#ifdef SIGPIPE
2794251881Speter  /* Disable SIGPIPE generation for the platforms that have it. */
2795251881Speter  apr_signal(SIGPIPE, SIG_IGN);
2796251881Speter#endif
2797251881Speter
2798251881Speter#ifdef SIGXFSZ
2799251881Speter  /* Disable SIGXFSZ generation for the platforms that have it, otherwise
2800251881Speter   * working with large files when compiled against an APR that doesn't have
2801251881Speter   * large file support will crash the program, which is uncool. */
2802251881Speter  apr_signal(SIGXFSZ, SIG_IGN);
2803251881Speter#endif
2804251881Speter
2805251881Speter  /* Set up Authentication stuff. */
2806251881Speter  SVN_INT_ERR(svn_cmdline_create_auth_baton(&ab,
2807251881Speter                                            opt_state.non_interactive,
2808251881Speter                                            opt_state.auth_username,
2809251881Speter                                            opt_state.auth_password,
2810251881Speter                                            opt_state.config_dir,
2811251881Speter                                            opt_state.no_auth_cache,
2812251881Speter                                            opt_state.trust_server_cert,
2813251881Speter                                            cfg_config,
2814251881Speter                                            ctx->cancel_func,
2815251881Speter                                            ctx->cancel_baton,
2816251881Speter                                            pool));
2817251881Speter
2818251881Speter  ctx->auth_baton = ab;
2819251881Speter
2820251881Speter  if (opt_state.non_interactive)
2821251881Speter    {
2822251881Speter      if (opt_state.accept_which == svn_cl__accept_edit)
2823251881Speter        return EXIT_ERROR(
2824251881Speter                 svn_error_createf(SVN_ERR_CL_ARG_PARSING_ERROR, NULL,
2825251881Speter                                   _("--accept=%s incompatible with"
2826251881Speter                                     " --non-interactive"),
2827251881Speter                                   SVN_CL__ACCEPT_EDIT));
2828251881Speter
2829251881Speter      if (opt_state.accept_which == svn_cl__accept_launch)
2830251881Speter        return EXIT_ERROR(
2831251881Speter                 svn_error_createf(SVN_ERR_CL_ARG_PARSING_ERROR, NULL,
2832251881Speter                                   _("--accept=%s incompatible with"
2833251881Speter                                     " --non-interactive"),
2834251881Speter                                   SVN_CL__ACCEPT_LAUNCH));
2835251881Speter
2836251881Speter      /* The default action when we're non-interactive is to postpone
2837251881Speter       * conflict resolution. */
2838251881Speter      if (opt_state.accept_which == svn_cl__accept_unspecified)
2839251881Speter        opt_state.accept_which = svn_cl__accept_postpone;
2840251881Speter    }
2841251881Speter
2842251881Speter  /* Check whether interactive conflict resolution is disabled by
2843251881Speter   * the configuration file. If no --accept option was specified
2844251881Speter   * we postpone all conflicts in this case. */
2845251881Speter  SVN_INT_ERR(svn_config_get_bool(cfg_config, &interactive_conflicts,
2846251881Speter                                  SVN_CONFIG_SECTION_MISCELLANY,
2847251881Speter                                  SVN_CONFIG_OPTION_INTERACTIVE_CONFLICTS,
2848251881Speter                                  TRUE));
2849251881Speter  if (!interactive_conflicts)
2850251881Speter    {
2851251881Speter      /* Make 'svn resolve' non-interactive. */
2852251881Speter      if (subcommand->cmd_func == svn_cl__resolve)
2853251881Speter        opt_state.non_interactive = TRUE;
2854251881Speter
2855251881Speter      /* We're not resolving conflicts interactively. If no --accept option
2856251881Speter       * was provided the default behaviour is to postpone all conflicts. */
2857251881Speter      if (opt_state.accept_which == svn_cl__accept_unspecified)
2858251881Speter        opt_state.accept_which = svn_cl__accept_postpone;
2859251881Speter    }
2860251881Speter
2861251881Speter  /* Install the default conflict handler. */
2862251881Speter  {
2863251881Speter    svn_cl__interactive_conflict_baton_t *b;
2864251881Speter
2865251881Speter    ctx->conflict_func = NULL;
2866251881Speter    ctx->conflict_baton = NULL;
2867251881Speter
2868251881Speter    ctx->conflict_func2 = svn_cl__conflict_func_interactive;
2869251881Speter    SVN_INT_ERR(svn_cl__get_conflict_func_interactive_baton(
2870251881Speter                &b,
2871251881Speter                opt_state.accept_which,
2872251881Speter                ctx->config, opt_state.editor_cmd, conflict_stats,
2873251881Speter                ctx->cancel_func, ctx->cancel_baton, pool));
2874251881Speter    ctx->conflict_baton2 = b;
2875251881Speter  }
2876251881Speter
2877251881Speter  /* And now we finally run the subcommand. */
2878251881Speter  err = (*subcommand->cmd_func)(os, &command_baton, pool);
2879251881Speter  if (err)
2880251881Speter    {
2881251881Speter      /* For argument-related problems, suggest using the 'help'
2882251881Speter         subcommand. */
2883251881Speter      if (err->apr_err == SVN_ERR_CL_INSUFFICIENT_ARGS
2884251881Speter          || err->apr_err == SVN_ERR_CL_ARG_PARSING_ERROR)
2885251881Speter        {
2886251881Speter          err = svn_error_quick_wrap(
2887251881Speter                  err, apr_psprintf(pool,
2888251881Speter                                    _("Try 'svn help %s' for more information"),
2889251881Speter                                    subcommand->name));
2890251881Speter        }
2891251881Speter      if (err->apr_err == SVN_ERR_WC_UPGRADE_REQUIRED)
2892251881Speter        {
2893251881Speter          err = svn_error_quick_wrap(err,
2894251881Speter                                     _("Please see the 'svn upgrade' command"));
2895251881Speter        }
2896251881Speter
2897251881Speter      if (err->apr_err == SVN_ERR_AUTHN_FAILED && opt_state.non_interactive)
2898251881Speter        {
2899251881Speter          err = svn_error_quick_wrap(err,
2900251881Speter                                     _("Authentication failed and interactive"
2901251881Speter                                       " prompting is disabled; see the"
2902251881Speter                                       " --force-interactive option"));
2903251881Speter          if (reading_file_from_stdin)
2904251881Speter            err = svn_error_quick_wrap(err,
2905251881Speter                                       _("Reading file from standard input "
2906251881Speter                                         "because of -F option; this can "
2907251881Speter                                         "interfere with interactive "
2908251881Speter                                         "prompting"));
2909251881Speter        }
2910251881Speter
2911251881Speter      /* Tell the user about 'svn cleanup' if any error on the stack
2912251881Speter         was about locked working copies. */
2913251881Speter      if (svn_error_find_cause(err, SVN_ERR_WC_LOCKED))
2914251881Speter        {
2915251881Speter          err = svn_error_quick_wrap(
2916251881Speter                  err, _("Run 'svn cleanup' to remove locks "
2917251881Speter                         "(type 'svn help cleanup' for details)"));
2918251881Speter        }
2919251881Speter
2920251881Speter      if (err->apr_err == SVN_ERR_SQLITE_BUSY)
2921251881Speter        {
2922251881Speter          err = svn_error_quick_wrap(err,
2923251881Speter                                     _("Another process is blocking the "
2924251881Speter                                       "working copy database, or the "
2925251881Speter                                       "underlying filesystem does not "
2926251881Speter                                       "support file locking; if the working "
2927251881Speter                                       "copy is on a network filesystem, make "
2928251881Speter                                       "sure file locking has been enabled "
2929251881Speter                                       "on the file server"));
2930251881Speter        }
2931251881Speter
2932251881Speter      if (svn_error_find_cause(err, SVN_ERR_RA_CANNOT_CREATE_TUNNEL) &&
2933251881Speter          (opt_state.auth_username || opt_state.auth_password))
2934251881Speter        {
2935251881Speter          err = svn_error_quick_wrap(
2936251881Speter                  err, _("When using svn+ssh:// URLs, keep in mind that the "
2937251881Speter                         "--username and --password options are ignored "
2938251881Speter                         "because authentication is performed by SSH, not "
2939251881Speter                         "Subversion"));
2940251881Speter        }
2941251881Speter
2942262253Speter      /* Ensure that stdout is flushed, so the user will see any write errors.
2943262253Speter         This makes sure that output is not silently lost. */
2944262253Speter      err = svn_error_compose_create(err, svn_cmdline_fflush(stdout));
2945262253Speter
2946251881Speter      return EXIT_ERROR(err);
2947251881Speter    }
2948251881Speter  else
2949251881Speter    {
2950251881Speter      /* Ensure that stdout is flushed, so the user will see any write errors.
2951251881Speter         This makes sure that output is not silently lost. */
2952251881Speter      SVN_INT_ERR(svn_cmdline_fflush(stdout));
2953251881Speter
2954251881Speter      return EXIT_SUCCESS;
2955251881Speter    }
2956251881Speter}
2957251881Speter
2958251881Speterint
2959251881Spetermain(int argc, const char *argv[])
2960251881Speter{
2961251881Speter  apr_pool_t *pool;
2962251881Speter  int exit_code;
2963251881Speter
2964251881Speter  /* Initialize the app. */
2965251881Speter  if (svn_cmdline_init("svn", stderr) != EXIT_SUCCESS)
2966251881Speter    return EXIT_FAILURE;
2967251881Speter
2968251881Speter  /* Create our top-level pool.  Use a separate mutexless allocator,
2969251881Speter   * given this application is single threaded.
2970251881Speter   */
2971251881Speter  pool = apr_allocator_owner_get(svn_pool_create_allocator(FALSE));
2972251881Speter
2973251881Speter  exit_code = sub_main(argc, argv, pool);
2974251881Speter
2975251881Speter  svn_pool_destroy(pool);
2976251881Speter  return exit_code;
2977251881Speter}
2978