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

📄 main.c

📁 linux subdivision ying gai ke yi le ba
💻 C
📖 第 1 页 / 共 4 页
字号:
  /* 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_subcommand (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)
        {
          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_subcommand (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 error_exit (err, stderr, FALSE, pool);
              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 < num_opts; i++)
    {
      opt_id = received_opts[i];

      /* 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_option (subcommand, opt_id))
        {
          const char *optstr, *optstr_utf8, *cmdname_utf8;
          const apr_getopt_option_t *badopt = 
            svn_opt_get_option_from_code (opt_id, svn_cl__options);
          svn_opt_format_option (&optstr, badopt, FALSE, pool);
          if ((err = svn_utf_cstring_to_utf8 (&optstr_utf8, optstr, pool))
              || (err = svn_utf_cstring_to_utf8 (&cmdname_utf8,
                                                 subcommand->name, pool)))
            return error_exit (err, stderr, FALSE, pool);
          svn_error_clear
            (svn_cmdline_fprintf
             (stderr, pool, _("Subcommand '%s' doesn't accept option '%s'\n"
                              "Type 'svn help %s' for usage.\n"),
              cmdname_utf8, optstr_utf8, cmdname_utf8));
          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))
    {
      /* 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_open2 (&adm_access, NULL, fname_utf8,
                                        FALSE, 0, pool);
          if (! err)
            err = svn_wc_entry (&e, fname_utf8, adm_access, FALSE, pool);
          if ((err == SVN_NO_ERROR) && e)
            {
              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"));
              return error_exit (err, stderr, FALSE, pool);
            }
          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)
            {
              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"));
              return error_exit (err, stderr, FALSE, pool);
            }
        }
    }

  /* 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 error_exit (err, stderr, FALSE, pool);
        }
    }

  /* Create a client context object. */
  command_baton.opt_state = &opt_state;
  if ((err = svn_client_create_context (&ctx, pool)))
    return error_exit (err, stderr, FALSE, pool);
  command_baton.ctx = ctx;

  if ((err = svn_config_get_config (&(ctx->config),
                                    opt_state.config_dir, pool)))
    return error_exit (err, stderr, FALSE, pool);

  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);
        }
    }

  /* Set the log message callback function.  Note that individual
     subcommands will populate the ctx->log_msg_baton */
  ctx->log_msg_func = svn_cl__get_log_message;

  /* Authentication set-up. */
  {
    svn_boolean_t store_password_val = TRUE;
    svn_auth_provider_object_t *provider;

    /* The whole list of registered providers */
    apr_array_header_t *providers
      = apr_array_make (pool, 10, sizeof (svn_auth_provider_object_t *));

    /* The main disk-caching auth providers, for both
       'username/password' creds and 'username' creds.  */
    svn_client_get_simple_provider (&provider, pool);
    APR_ARRAY_PUSH (providers, svn_auth_provider_object_t *) = provider;
    svn_client_get_username_provider (&provider, pool);
    APR_ARRAY_PUSH (providers, svn_auth_provider_object_t *) = provider;

    /* The server-cert, client-cert, and client-cert-password providers. */
    svn_client_get_ssl_server_trust_file_provider (&provider, pool);
    APR_ARRAY_PUSH (providers, svn_auth_provider_object_t *) = provider;
    svn_client_get_ssl_client_cert_file_provider (&provider, pool);
    APR_ARRAY_PUSH (providers, svn_auth_provider_object_t *) = provider;
    svn_client_get_ssl_client_cert_pw_file_provider (&provider, pool);
    APR_ARRAY_PUSH (providers, svn_auth_provider_object_t *) = provider;

    if (opt_state.non_interactive == FALSE)
      {
        /* Two basic prompt providers: username/password, and just username. */
        svn_client_get_simple_prompt_provider (&provider,
                                               svn_cl__auth_simple_prompt,
                                               ctx,
                                               2, /* retry limit */
                                               pool);
        APR_ARRAY_PUSH (providers, svn_auth_provider_object_t *) = provider;

        svn_client_get_username_prompt_provider (&provider,
                                                 svn_cl__auth_username_prompt,
                                                 ctx, 
                                                 2, /* retry limit */
                                                 pool);
        APR_ARRAY_PUSH (providers, svn_auth_provider_object_t *) = provider;

        /* Three ssl prompt providers, for server-certs, client-certs,
           and client-cert-passphrases.  */
        svn_client_get_ssl_server_trust_prompt_provider
          (&provider, svn_cl__auth_ssl_server_trust_prompt, ctx, pool);
        APR_ARRAY_PUSH (providers, svn_auth_provider_object_t *) = provider;

        svn_client_get_ssl_client_cert_prompt_provider
          (&provider, svn_cl__auth_ssl_client_cert_prompt, ctx, 2, pool);
        APR_ARRAY_PUSH (providers, svn_auth_provider_object_t *) = provider;

        svn_client_get_ssl_client_cert_pw_prompt_provider
          (&provider, svn_cl__auth_ssl_client_cert_pw_prompt, ctx, 2, pool);
        APR_ARRAY_PUSH (providers, svn_auth_provider_object_t *) = provider;
      }

    /* Build an authentication baton to give to libsvn_client. */
    svn_auth_open (&ab, providers, pool);
    ctx->auth_baton = ab;

    /* Place any default --username or --password credentials into the
       auth_baton's run-time parameter hash. */
    if (opt_state.auth_username)
      svn_auth_set_parameter(ab, SVN_AUTH_PARAM_DEFAULT_USERNAME,
                             opt_state.auth_username);
    if (opt_state.auth_password)
      svn_auth_set_parameter(ab, SVN_AUTH_PARAM_DEFAULT_PASSWORD,
                             opt_state.auth_password);

    /* Same with the --non-interactive option. */
    if (opt_state.non_interactive)
      svn_auth_set_parameter(ab, SVN_AUTH_PARAM_NON_INTERACTIVE, "");

    if (opt_state.config_dir)
      svn_auth_set_parameter(ab, SVN_AUTH_PARAM_CONFIG_DIR,
                             opt_state.config_dir);

    if ((err = svn_config_get_bool (cfg, &store_password_val,
                                    SVN_CONFIG_SECTION_AUTH,
                                    SVN_CONFIG_OPTION_STORE_PASSWORDS,
                                    TRUE)))
      svn_handle_error (err, stderr, TRUE);
    if (! store_password_val)
      svn_auth_set_parameter(ab, SVN_AUTH_PARAM_DONT_STORE_PASSWORDS, "");

    /* There are two different ways the user can disable disk caching
       of credentials:  either via --no-auth-cache, or in the config
       file ('store-auth-creds = no'). */
    if ((err = svn_config_get_bool (cfg, &store_password_val,
                                    SVN_CONFIG_SECTION_AUTH,
                                    SVN_CONFIG_OPTION_STORE_AUTH_CREDS,
                                    TRUE)))
      svn_handle_error (err, stderr, TRUE);
    if (opt_state.no_auth_cache || ! store_password_val)
      svn_auth_set_parameter(ab, SVN_AUTH_PARAM_NO_AUTH_CACHE, "");
  }

  /* 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

  /* And now we finally run the subcommand. */
  err = (*subcommand->cmd_func) (os, &command_baton, pool);
  if (err)
    {
      svn_error_t *tmp_err;

      /* If we got an SVN_ERR_CL_ARG_PARSING_ERROR with no useful content
         (i.e. a NULL or empty message), display help, otherwise just display 
         the errors as usual, since the error output will probably be just as 
         much help to them as our help output, if not more. */
      if (err->apr_err == SVN_ERR_CL_ARG_PARSING_ERROR
          && (err->message == NULL || err->message[0] == '\0'))
        svn_opt_subcommand_help (subcommand->name, svn_cl__cmd_table,
                                 svn_cl__options, pool);
      else
        svn_handle_error (err, stderr, FALSE);

      /* 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 error_exit (err, stdout, FALSE, pool);

      svn_pool_destroy (pool);
      return EXIT_SUCCESS;
    }
}

⌨️ 快捷键说明

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