📄 main.c
字号:
if (err) return svn_cmdline_handle_exit_error(err, pool, "svn: "); /* If the user asked for help, then the rest of the arguments are the names of subcommands to get help on (if any), or else they're just typos/mistakes. Whatever the case, the subcommand to actually run is svn_cl__help(). */ if (opt_state.help) subcommand = svn_opt_get_canonical_subcommand2(svn_cl__cmd_table, "help"); /* If we're not running the `help' subcommand, then look for a subcommand in the first argument. */ if (subcommand == NULL) { if (os->ind >= os->argc) { if (opt_state.version) { /* Use the "help" subcommand to handle the "--version" option. */ static const svn_opt_subcommand_desc2_t pseudo_cmd = { "--version", svn_cl__help, {0}, "", {svn_cl__version_opt, /* must accept its own option */ 'q', /* brief output */ svn_cl__config_dir_opt /* all commands accept this */ } }; subcommand = &pseudo_cmd; } else { svn_error_clear (svn_cmdline_fprintf(stderr, pool, _("Subcommand argument required\n"))); svn_cl__help(NULL, NULL, pool); svn_pool_destroy(pool); return EXIT_FAILURE; } } else { const char *first_arg = os->argv[os->ind++]; subcommand = svn_opt_get_canonical_subcommand2(svn_cl__cmd_table, first_arg); if (subcommand == NULL) { const char *first_arg_utf8; err = svn_utf_cstring_to_utf8(&first_arg_utf8, first_arg, pool); if (err) return svn_cmdline_handle_exit_error(err, pool, "svn: "); svn_error_clear (svn_cmdline_fprintf(stderr, pool, _("Unknown command: '%s'\n"), first_arg_utf8)); svn_cl__help(NULL, NULL, pool); svn_pool_destroy(pool); return EXIT_FAILURE; } } } /* Check that the subcommand wasn't passed any inappropriate options. */ for (i = 0; i < received_opts->nelts; i++) { opt_id = APR_ARRAY_IDX(received_opts, i, int); /* All commands implicitly accept --help, so just skip over this when we see it. Note that we don't want to include this option in their "accepted options" list because it would be awfully redundant to display it in every commands' help text. */ if (opt_id == 'h' || opt_id == '?') continue; if (! svn_opt_subcommand_takes_option2(subcommand, opt_id)) { const char *optstr; const apr_getopt_option_t *badopt = svn_opt_get_option_from_code2(opt_id, svn_cl__options, subcommand, pool); svn_opt_format_option(&optstr, badopt, FALSE, pool); if (subcommand->name[0] == '-') svn_cl__help(NULL, NULL, pool); else svn_error_clear (svn_cmdline_fprintf (stderr, pool, _("Subcommand '%s' doesn't accept option '%s'\n" "Type 'svn help %s' for usage.\n"), subcommand->name, optstr, subcommand->name)); svn_pool_destroy(pool); return EXIT_FAILURE; } } /* if we're running a command that could result in a commit, verify that any log message we were given on the command line makes sense (unless we've also been instructed not to care). */ if ((! opt_state.force_log) && (subcommand->cmd_func == svn_cl__commit || subcommand->cmd_func == svn_cl__copy || subcommand->cmd_func == svn_cl__delete || subcommand->cmd_func == svn_cl__import || subcommand->cmd_func == svn_cl__mkdir || subcommand->cmd_func == svn_cl__move || subcommand->cmd_func == svn_cl__lock)) { /* If the -F argument is a file that's under revision control, that's probably not what the user intended. */ if (dash_F_arg) { svn_wc_adm_access_t *adm_access; const svn_wc_entry_t *e; const char *fname_utf8 = svn_path_internal_style(dash_F_arg, pool); err = svn_wc_adm_probe_open3(&adm_access, NULL, fname_utf8, FALSE, 0, NULL, NULL, pool); if (! err) err = svn_wc_entry(&e, fname_utf8, adm_access, FALSE, pool); if ((err == SVN_NO_ERROR) && e) { if (subcommand->cmd_func != svn_cl__lock) { err = svn_error_create (SVN_ERR_CL_LOG_MESSAGE_IS_VERSIONED_FILE, NULL, _("Log message file is a versioned file; " "use '--force-log' to override")); } else { err = svn_error_create (SVN_ERR_CL_LOG_MESSAGE_IS_VERSIONED_FILE, NULL, _("Lock comment file is a versioned file; " "use '--force-log' to override")); } return svn_cmdline_handle_exit_error(err, pool, "svn: "); } if (err) svn_error_clear(err); } /* If the -m argument is a file at all, that's probably not what the user intended. */ if (dash_m_arg) { apr_finfo_t finfo; if (apr_stat(&finfo, dash_m_arg, APR_FINFO_MIN, pool) == APR_SUCCESS) { if (subcommand->cmd_func != svn_cl__lock) { err = svn_error_create (SVN_ERR_CL_LOG_MESSAGE_IS_PATHNAME, NULL, _("The log message is a pathname " "(was -F intended?); use '--force-log' to override")); } else { err = svn_error_create (SVN_ERR_CL_LOG_MESSAGE_IS_PATHNAME, NULL, _("The lock comment is a pathname " "(was -F intended?); use '--force-log' to override")); } return svn_cmdline_handle_exit_error(err, pool, "svn: "); } } } /* Only a few commands can accept a revision range; the rest can take at most one revision number. */ if (subcommand->cmd_func != svn_cl__blame && subcommand->cmd_func != svn_cl__diff && subcommand->cmd_func != svn_cl__log && subcommand->cmd_func != svn_cl__merge) { if (opt_state.end_revision.kind != svn_opt_revision_unspecified) { err = svn_error_create(SVN_ERR_CLIENT_REVISION_RANGE, NULL, NULL); return svn_cmdline_handle_exit_error(err, pool, "svn: "); } } /* Create a client context object. */ command_baton.opt_state = &opt_state; if ((err = svn_client_create_context(&ctx, pool))) return svn_cmdline_handle_exit_error(err, pool, "svn: "); command_baton.ctx = ctx; if ((err = svn_config_get_config(&(ctx->config), opt_state.config_dir, pool))) return svn_cmdline_handle_exit_error(err, pool, "svn: "); cfg = apr_hash_get(ctx->config, SVN_CONFIG_CATEGORY_CONFIG, APR_HASH_KEY_STRING); /* Update the options in the config */ /* XXX: Only diff_cmd for now, overlay rest later and stop passing opt_state altogether? */ if (opt_state.diff_cmd) svn_config_set(cfg, SVN_CONFIG_SECTION_HELPERS, SVN_CONFIG_OPTION_DIFF_CMD, opt_state.diff_cmd); if (opt_state.merge_cmd) svn_config_set(cfg, SVN_CONFIG_SECTION_HELPERS, SVN_CONFIG_OPTION_DIFF3_CMD, opt_state.merge_cmd); /* Update auto-props-enable option for add/import commands */ if (subcommand->cmd_func == svn_cl__add || subcommand->cmd_func == svn_cl__import) { if (opt_state.autoprops) { svn_config_set_bool(cfg, SVN_CONFIG_SECTION_MISCELLANY, SVN_CONFIG_OPTION_ENABLE_AUTO_PROPS, TRUE); } if (opt_state.no_autoprops) { svn_config_set_bool(cfg, SVN_CONFIG_SECTION_MISCELLANY, SVN_CONFIG_OPTION_ENABLE_AUTO_PROPS, FALSE); } } /* Update the 'keep-locks' runtime option */ if (opt_state.no_unlock) svn_config_set_bool(cfg, SVN_CONFIG_SECTION_MISCELLANY, SVN_CONFIG_OPTION_NO_UNLOCK, TRUE); /* Set the log message callback function. Note that individual subcommands will populate the ctx->log_msg_baton2 */ ctx->log_msg_func2 = svn_cl__get_log_message; /* Set up our cancellation support. */ ctx->cancel_func = svn_cl__check_cancel; apr_signal(SIGINT, signal_handler);#ifdef SIGBREAK /* SIGBREAK is a Win32 specific signal generated by ctrl-break. */ apr_signal(SIGBREAK, signal_handler);#endif#ifdef SIGHUP apr_signal(SIGHUP, signal_handler);#endif#ifdef SIGTERM apr_signal(SIGTERM, signal_handler);#endif#ifdef SIGPIPE /* Disable SIGPIPE generation for the platforms that have it. */ apr_signal(SIGPIPE, SIG_IGN);#endif#ifdef SIGXFSZ /* Disable SIGXFSZ generation for the platforms that have it, otherwise * working with large files when compiled against an APR that doesn't have * large file support will crash the program, which is uncool. */ apr_signal(SIGXFSZ, SIG_IGN);#endif /* Set up Authentication stuff. */ if ((err = svn_cmdline_setup_auth_baton(&ab, opt_state.non_interactive, opt_state.auth_username, opt_state.auth_password, opt_state.config_dir, opt_state.no_auth_cache, cfg, ctx->cancel_func, ctx->cancel_baton, pool))) svn_handle_error2(err, stderr, TRUE, "svn: "); ctx->auth_baton = ab; /* And now we finally run the subcommand. */ err = (*subcommand->cmd_func)(os, &command_baton, pool); if (err) { svn_error_t *tmp_err; svn_handle_error2(err, stderr, FALSE, "svn: "); /* Tell the user about 'svn cleanup' if any error on the stack was about locked working copies. */ for (tmp_err = err; tmp_err; tmp_err = tmp_err->child) if (tmp_err->apr_err == SVN_ERR_WC_LOCKED) { svn_error_clear (svn_cmdline_fputs(_("svn: run 'svn cleanup' to remove locks " "(type 'svn help cleanup' for details)\n"), stderr, pool)); break; } svn_error_clear(err); svn_pool_destroy(pool); return EXIT_FAILURE; } else { /* Ensure that stdout is flushed, so the user will see any write errors. This makes sure that output is not silently lost. */ err = svn_cmdline_fflush(stdout); if (err) return svn_cmdline_handle_exit_error(err, pool, "svn: "); svn_pool_destroy(pool); return EXIT_SUCCESS; }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -