⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 main.c

📁 linux subdivision ying gai ke yi le ba
💻 C
📖 第 1 页 / 共 4 页
字号:
/*
 * main.c:  Subversion command line client.
 *
 * ====================================================================
 * Copyright (c) 2000-2004 CollabNet.  All rights reserved.
 *
 * This software is licensed as described in the file COPYING, which
 * you should have received as part of this distribution.  The terms
 * are also available at http://subversion.tigris.org/license-1.html.
 * If newer versions of this license are posted there, you may use a
 * newer version instead, at your option.
 *
 * This software consists of voluntary contributions made by many
 * individuals.  For exact contribution history, see the revision
 * history and logs, available at http://subversion.tigris.org/.
 * ====================================================================
 */

/* ==================================================================== */



/*** Includes. ***/

#include <string.h>
#include <assert.h>

#include <apr_strings.h>
#include <apr_tables.h>
#include <apr_general.h>
#include <apr_lib.h>
#include <apr_signal.h>

#include "svn_cmdline.h"
#include "svn_pools.h"
#include "svn_wc.h"
#include "svn_client.h"
#include "svn_config.h"
#include "svn_string.h"
#include "svn_path.h"
#include "svn_delta.h"
#include "svn_error.h"
#include "svn_io.h"
#include "svn_opt.h"
#include "svn_time.h"
#include "svn_utf.h"
#include "svn_auth.h"
#include "cl.h"

#include "svn_private_config.h"


/*** Option Processing ***/

/* Option codes and descriptions for the command line client.
 *
 * This must not have more than SVN_OPT_MAX_OPTIONS entries; if you
 * need more, increase that limit first. 
 *
 * The entire list must be terminated with an entry of nulls.
 */
const apr_getopt_option_t svn_cl__options[] =
  {
    {"force",         svn_cl__force_opt, 0, N_("force operation to run")},
    {"force-log",     svn_cl__force_log_opt, 0, 
                      N_("force validity of log message source")},
    {"help",          'h', 0, N_("show help on a subcommand")},
    {NULL,            '?', 0, N_("show help on a subcommand")},
    {"message",       'm', 1, N_("specify commit message ARG")},
    {"quiet",         'q', 0, N_("print as little as possible")},
    {"recursive",     'R', 0, N_("descend recursively")},
    {"non-recursive", 'N', 0, N_("operate on single directory only")},
    {"revision",      'r', 1, N_
     ("ARG (some commands also take ARG1:ARG2 range)\n"
      "                             A revision argument can be one of:\n"
      "                                NUMBER       revision number\n"
      "                                \"{\" DATE \"}\" revision at start "
      "of the date\n"
      "                                \"HEAD\"       latest in repository\n"
      "                                \"BASE\"       base rev of item's "
      "working copy\n"
      "                                \"COMMITTED\"  last commit at or "
      "before BASE\n"
      "                                \"PREV\"       revision just before "
      "COMMITTED")
     /* spacing corresponds to svn_opt_format_option */
    },
    {"file",          'F', 1, N_("read data from file ARG")},
    {"incremental",   svn_cl__incremental_opt, 0,
                      N_("give output suitable for concatenation")},
    {"encoding",      svn_cl__encoding_opt, 1,
                      N_("treat value as being in charset encoding ARG")},
    {"version",       svn_cl__version_opt, 0, N_("print client version info")},
    {"verbose",       'v', 0, N_("print extra information")},
    {"show-updates",  'u', 0, N_("display update information")},
    {"username",      svn_cl__auth_username_opt, 1, 
                      N_("specify a username ARG")},
    {"password",      svn_cl__auth_password_opt, 1, 
                      N_("specify a password ARG")},
    {"extensions",    'x', 1, N_("pass ARG as bundled options to GNU diff")},
    {"targets",       svn_cl__targets_opt, 1,
                      N_("pass contents of file ARG as additional args")},
    {"xml",           svn_cl__xml_opt, 0, N_("output in XML")},
    {"strict",        svn_cl__strict_opt, 0, N_("use strict semantics")},
    {"stop-on-copy",  svn_cl__stop_on_copy_opt, 0, 
                      N_("do not cross copies while traversing history")},
    {"no-ignore",     svn_cl__no_ignore_opt, 0,
                      N_("disregard default and svn:ignore property ignores")},
    {"no-auth-cache", svn_cl__no_auth_cache_opt, 0,
                      N_("do not cache authentication tokens")},
    {"non-interactive", svn_cl__non_interactive_opt, 0,
                      N_("do no interactive prompting")},
    {"dry-run",       svn_cl__dry_run_opt, 0,
                      N_("try operation but make no changes")},
    {"no-diff-deleted", svn_cl__no_diff_deleted, 0,
                       N_("do not print differences for deleted files")},
    {"notice-ancestry", svn_cl__notice_ancestry_opt, 0,
                       N_("notice ancestry when calculating differences")},
    {"ignore-ancestry", svn_cl__ignore_ancestry_opt, 0,
                       N_("ignore ancestry when calculating merges")},
    {"diff-cmd",      svn_cl__diff_cmd_opt, 1,
                      N_("use ARG as diff command")},
    {"diff3-cmd",     svn_cl__merge_cmd_opt, 1,
                      N_("use ARG as merge command")},
    {"editor-cmd",    svn_cl__editor_cmd_opt, 1,
                      N_("use ARG as external editor")},
    {"old",           svn_cl__old_cmd_opt, 1, 
                      N_("use ARG as the older target")},
    {"new",           svn_cl__new_cmd_opt, 1, 
                      N_("use ARG as the newer target")},
    {"revprop",       svn_cl__revprop_opt, 0,
                      N_("operate on a revision property (use with -r)")},
    {"relocate",      svn_cl__relocate_opt, 0,
                      N_("relocate via URL-rewriting")},
    {"config-dir",    svn_cl__config_dir_opt, 1,
                      N_("read user configuration files from directory ARG")},
    {"auto-props",    svn_cl__autoprops_opt, 0,
                      N_("enable automatic properties")},
    {"no-auto-props", svn_cl__no_autoprops_opt, 0,
                      N_("disable automatic properties")},
    {"native-eol",    svn_cl__native_eol_opt, 1,
                      N_("use a different EOL marker than the standard\n"
                      "                             system marker for files "
                      "with a native svn:eol-style\n"
                      "                             property.  ARG may be one "
                      "of 'LF', 'CR', 'CRLF'")},
    {0,               0, 0, 0}
  };



/*** Command dispatch. ***/

/* Our array of available subcommands.
 *
 * The entire list must be terminated with an entry of nulls.
 *
 * In most of the help text "PATH" is used where a working copy path is
 * required, "URL" where a repository URL is required and "TARGET" when
 * either a path or an url can be used.  Hmm, should this be part of the
 * help text?
 */
#define SVN_CL__AUTH_OPTIONS svn_cl__auth_username_opt, \
                             svn_cl__auth_password_opt, \
                             svn_cl__no_auth_cache_opt, \
                             svn_cl__non_interactive_opt
 
const svn_opt_subcommand_desc_t svn_cl__cmd_table[] =
{
  { "add", svn_cl__add, {0},
    N_("Put files and directories under version control, scheduling\n"
       "them for addition to repository.  They will be added in next commit.\n"
       "usage: add PATH...\n"),
    {svn_cl__targets_opt, 'N', 'q', svn_cl__config_dir_opt,
     svn_cl__force_opt, svn_cl__autoprops_opt, svn_cl__no_autoprops_opt} },

  { "blame", svn_cl__blame, {"praise", "annotate", "ann"},
    N_("Output the content of specified files or\n"
       "URLs with revision and author information in-line.\n"
       "usage: blame TARGET...\n"),
    {'r', 'v', SVN_CL__AUTH_OPTIONS, svn_cl__config_dir_opt} },

  { "cat", svn_cl__cat, {0},
    N_("Output the content of specified files or URLs.\n"
       "usage: cat TARGET...\n"),
    {'r', SVN_CL__AUTH_OPTIONS, svn_cl__config_dir_opt} },

  { "checkout", svn_cl__checkout, {"co"}, N_
    ("Check out a working copy from a repository.\n"
     "usage: checkout URL... [PATH]\n"
     "\n"
     "  Note: If PATH is omitted, the basename of the URL will be used as\n"
     "  the destination. If multiple URLs are given each will be checked\n"
     "  out into a sub-directory of PATH, with the name of the sub-directory\n"
     "  being the basename of the URL.\n"),
    {'r', 'q', 'N', SVN_CL__AUTH_OPTIONS, svn_cl__config_dir_opt} },

  { "cleanup", svn_cl__cleanup, {0},
    N_("Recursively clean up the working copy, removing locks, resuming\n"
       "unfinished operations, etc.\n"
       "usage: cleanup [PATH...]\n"),
    {svn_cl__merge_cmd_opt, svn_cl__config_dir_opt} },
  
  { "commit", svn_cl__commit, {"ci"},
    N_("Send changes from your working copy to the repository.\n"
     "usage: commit [PATH...]\n"
     "\n"
     "  A log message must be provided, but it can be empty.  If it is not\n"
     "  given by a --message or --file option, an editor will be started.\n"),
    {'m', 'F', 'q', 'N', svn_cl__targets_opt,
     svn_cl__force_log_opt, SVN_CL__AUTH_OPTIONS,
     svn_cl__editor_cmd_opt, svn_cl__encoding_opt, svn_cl__config_dir_opt} },
  
  { "copy", svn_cl__copy, {"cp"},
    N_("Duplicate something in working copy or repository, remembering "
       "history.\n"
       "usage: copy SRC DST\n"
       "\n"
       "  SRC and DST can each be either a working copy (WC) path or URL:\n"
       "    WC  -> WC:   copy and schedule for addition (with history)\n"
       "    WC  -> URL:  immediately commit a copy of WC to URL\n"
       "    URL -> WC:   check out URL into WC, schedule for addition\n"
       "    URL -> URL:  complete server-side copy;  used to branch & tag\n"),
    {'m', 'F', 'r', 'q', SVN_CL__AUTH_OPTIONS, svn_cl__force_log_opt,
     svn_cl__editor_cmd_opt, svn_cl__encoding_opt, svn_cl__config_dir_opt} },
  
  { "delete", svn_cl__delete, {"del", "remove", "rm"},
    N_("Remove files and directories from version control.\n"
       "usage: 1. delete PATH...\n"
       "       2. delete URL...\n"
       "\n"
       "  1. Each item specified by a PATH is scheduled for deletion upon\n"
       "    the next commit.  Files, and directories that have not been\n"
       "    committed, are immediately removed from the working copy.\n"
       "    PATHs that are, or contain, unversioned or modified items will\n"
       "    not be removed unless the --force option is given.\n"
       "\n"
       "  2. Each item specified by a URL is deleted from the repository\n"
       "    via an immediate commit.\n"),
    {svn_cl__force_opt, svn_cl__force_log_opt, 'm', 'F', 'q', 
     svn_cl__targets_opt, SVN_CL__AUTH_OPTIONS,
     svn_cl__editor_cmd_opt, svn_cl__encoding_opt, svn_cl__config_dir_opt} },
  
  { "diff", svn_cl__diff, {"di"},
    N_("Display the differences between two paths.\n"
       "usage: 1. diff [-r N[:M]] [TARGET[@REV]...]\n"
       "       2. diff [-r N[:M]] --old=OLD-TGT[@OLDREV] "
       "[--new=NEW-TGT[@NEWREV]] \\\n"
       "               [PATH...]\n"
       "       3. diff OLD-URL[@OLDREV] NEW-URL[@NEWREV]\n"
       "\n"
       "  1. Display the changes made to TARGETs as they are seen in REV "
       "between\n"
       "     two revisions.  TARGETs may be working copy paths or URLs.\n"
       "\n"
       "     N defaults to BASE if any TARGET is a working copy path, otherwise "
       "it\n"
       "     must be specified.  M defaults to the current working version if "
       "any\n"
       "     TARGET is a working copy path, otherwise it defaults to HEAD.\n"
       "\n"
       "  2. Display the differences between OLD-TGT as it was seen in OLDREV "
       "and\n"
       "     NEW-TGT as it was seen in NEWREV.  PATHs, if given, are relative "
       "to\n"
       "     OLD-TGT and NEW-TGT and restrict the output to differences for "
       "those\n"
       "     paths.  OLD-TGT and NEW-TGT may be working copy paths or "
       "URL[@REV]. \n"
       "     NEW-TGT defaults to OLD-TGT if not specified.  -r N makes OLDREV "
       "default\n"
       "     to N, -r N:M makes OLDREV default to N and NEWREV default to M.\n"
       "\n"
       "  3. Shorthand for 'svn diff --old=OLD-URL[@OLDREV] "
       "--new=NEW-URL[@NEWREV]'\n"
       "\n"
       "  Use just 'svn diff' to display local modifications in "
       "a working copy.\n"),
    {'r', svn_cl__old_cmd_opt, svn_cl__new_cmd_opt, 'x', 'N',
     svn_cl__diff_cmd_opt, svn_cl__no_diff_deleted,
     svn_cl__notice_ancestry_opt, SVN_CL__AUTH_OPTIONS,
     svn_cl__config_dir_opt} },

  { "export", svn_cl__export, {0},
    N_("Create an unversioned copy of a tree.\n"
       "usage: 1. export [-r REV] URL [PATH]\n"
       "       2. export [-r REV] PATH1 [PATH2]\n"
       "\n"
       "  1. Exports a clean directory tree from the repository specified by\n"
       "     URL, at revision REV if it is given, otherwise at HEAD, into\n"
       "     PATH. If PATH is omitted, the last component of the URL is used\n"
       "     for the local directory name.\n"
       "\n"
       "  2. Exports a clean directory tree from the working copy specified "
       "by\n"
       "     PATH1, at revision REV if it is given, otherwise at WORKING, "
       "into\n"
       "     PATH2.  If PATH2 is omitted, the last component of the "
       "PATH1 is used\n"
       "     for the local directory name. If REV is not specified,"
       " all local\n"
       "     changes will be preserved, but files not under version "
       "control will\n"
       "     not be copied.\n"),
    {'r', 'q', svn_cl__force_opt, SVN_CL__AUTH_OPTIONS,
     svn_cl__config_dir_opt, svn_cl__native_eol_opt} },

  { "help", svn_cl__help, {"?", "h"},
    N_("Describe the usage of this program or its subcommands.\n"
       "usage: help [SUBCOMMAND...]\n"),
    {svn_cl__version_opt, 'q', svn_cl__config_dir_opt} },
  /* We need to support "--help", "-?", and all that good stuff, of
     course.  But those options, since unknown, will result in the
     help message being printed out anyway, so there's no need to
     support them explicitly. */
  
  { "import", svn_cl__import, {0},
    N_("Commit an unversioned file or tree into the repository.\n"
       "usage: import [PATH] URL\n"
       "\n"
       "  Recursively commit a copy of PATH to URL.\n"
       "  If PATH is omitted '.' is assumed.  Parent directories are created\n"
       "  as necessary in the repository.\n"),
    {'m', 'F', 'q', 'N', SVN_CL__AUTH_OPTIONS, svn_cl__force_log_opt,
     svn_cl__editor_cmd_opt, svn_cl__encoding_opt, svn_cl__config_dir_opt,
     svn_cl__autoprops_opt, svn_cl__no_autoprops_opt} },
 
  { "info", svn_cl__info, {0},
    N_("Display information about a file or directory.\n"
       "usage: info [PATH...]\n"
       "\n"
       "  Print information about each PATH (default: '.').\n"),
    {svn_cl__targets_opt, 'R', svn_cl__config_dir_opt} },
 
  { "list", svn_cl__ls, {"ls"},
    N_("List directory entries in the repository.\n"
       "usage: list [TARGET...]\n"
       "\n"
       "  List each TARGET file and the contents of each TARGET directory as\n"
       "  they exist in the repository.  If TARGET is a working copy path, "
       "the\n"
       "  corresponding repository URL will be used.\n"
       "\n"
       "  The default TARGET is '.', meaning the repository URL of the "

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -