Exemplo n.º 1
0
/* Retrieve the current HEAD revision at SVN URL <path> */
static svn_revnum_t
mw_get_head_rev(const char *path, struct callback_args *args,
    const char *project, FILE *logfp)
{
	apr_pool_t *subpool;
	svn_revnum_t rev;
	svn_opt_revision_t pegrev, headrev;
	svn_error_t *err = NULL;

	subpool = svn_pool_create(args->pool);
	pegrev.kind = svn_opt_revision_unspecified;
	headrev.kind = svn_opt_revision_head;
	err = svn_client_info2(path,
	    &pegrev,
	    &headrev,
	    &mw_revision_info_cb, &rev,
	    svn_depth_empty, NULL, args->ctx, args->pool);

	if (err != NULL) {
		mw_log(logfp,
		    "Error fetching info for project `%s' "
		    "at path `%s': %s\n",
		    project, path, err->message);
		fprintf(stderr,
		    "Error fetching info for project `%s' "
		    "at path `%s': %s\n",
		    project, path, err->message);
		exit(1);
	}
	svn_pool_destroy(subpool);

	return (rev);
}
Exemplo n.º 2
0
Arquivo: info.c Projeto: vocho/openqnx
svn_error_t *
svn_client_info(const char *path_or_url,
                const svn_opt_revision_t *peg_revision,
                const svn_opt_revision_t *revision,
                svn_info_receiver_t receiver,
                void *receiver_baton,
                svn_boolean_t recurse,
                svn_client_ctx_t *ctx,
                apr_pool_t *pool)
{
  return svn_client_info2(path_or_url, peg_revision, revision,
                          receiver, receiver_baton,
                          SVN_DEPTH_INFINITY_OR_EMPTY(recurse), 
                          NULL, ctx, pool);
}
Exemplo n.º 3
0
/*const svn_info_t **/ 
int svn_support_info(apr_pool_t *pool,svn_client_ctx_t *ctx,const char *path)
{
  svn_error_t *err;
  svn_opt_revision_t peg_revision;
  svn_stringbuf_t *res = svn_stringbuf_create("",pool);
  peg_revision.kind = svn_opt_revision_head;
  
  err = svn_client_info2 (path, 
                          &peg_revision, 
                          &peg_revision, 
                          svn_info_callback,
                          res,
                          svn_depth_empty,
                          NULL,
                          ctx,
                          pool);
  if (err) {
    svn_handle_error2(err, stderr, FALSE, "svn_support_info: ");
  }
  return atoi(res->data);
}
bool SvnClientImpl::FileIsUnderVersionControl(const fs::path& path)
{
	if (!_isActive) return true; // deactivated clients will return true on all cases

	apr_pool_t* subpool = svn_pool_create(_pool);

	svn_error_t* err = svn_client_info2(path.string().c_str(),
		NULL,	// peg_revision
		NULL,	// revision
		info_receiver_dummy, // receiver
		NULL,	// receiver_baton
		svn_depth_empty,
		NULL,	// changelists
		_context,
		subpool
	);

	bool isUnderVersionControl = (err == NULL);

	svn_pool_destroy(subpool);

	return isUnderVersionControl;
}
Exemplo n.º 5
0
Py::Object pysvn_client::cmd_info2( const Py::Tuple &a_args, const Py::Dict &a_kws )
{
    static argument_description args_desc[] =
    {
    { true,  name_url_or_path },
    { false, name_revision },
    { false, name_peg_revision},
    { false, name_recurse },
#if defined( PYSVN_HAS_CLIENT_INFO2 )
    { false, name_depth },
    { false, name_changelists },
#endif
    { false, NULL }
    };
    FunctionArguments args( "info2", args_desc, a_args, a_kws );
    args.check();

    std::string path( args.getUtf8String( name_url_or_path ) );

    svn_opt_revision_kind kind = svn_opt_revision_unspecified;
    if( is_svn_url( path ) )
        kind = svn_opt_revision_head;

    svn_opt_revision_t revision = args.getRevision( name_revision, kind );
    svn_opt_revision_t peg_revision = args.getRevision( name_peg_revision, revision );

    SvnPool pool( m_context );

#if defined( PYSVN_HAS_CLIENT_INFO2 )
    apr_array_header_t *changelists = NULL;

    if( args.hasArg( name_changelists ) )
    {
        changelists = arrayOfStringsFromListOfStrings( args.getArg( name_changelists ), pool );
    }

    svn_depth_t depth = args.getDepth( name_depth, name_recurse, svn_depth_infinity, svn_depth_infinity, svn_depth_empty );
#else
    bool recurse = args.getBoolean( name_recurse, true );
#endif

    bool is_url = is_svn_url( path );
    revisionKindCompatibleCheck( is_url, peg_revision, name_peg_revision, name_url_or_path );
    revisionKindCompatibleCheck( is_url, revision, name_revision, name_url_or_path );

    Py::List info_list;

    try
    {
        std::string norm_path( svnNormalisedIfPath( path, pool ) );

        checkThreadPermission();

        PythonAllowThreads permission( m_context );

        InfoReceiveBaton info_baton( &permission, info_list, m_wrapper_info, m_wrapper_lock, m_wrapper_wc_info );

#if defined( PYSVN_HAS_CLIENT_INFO2 )
        svn_error_t *error = 
            svn_client_info2
                (
                norm_path.c_str(),
                &peg_revision,
                &revision,
                info_receiver_c,
                reinterpret_cast<void *>( &info_baton ),
                depth,
                changelists,
                m_context,
                pool
                );
#else
        svn_error_t *error = 
            svn_client_info
                (
                norm_path.c_str(),
                &peg_revision,
                &revision,
                info_receiver_c,
                reinterpret_cast<void *>( &info_baton ),
                recurse,
                m_context,
                pool
                );
#endif
        permission.allowThisThread();
        if( error != NULL )
            throw SvnException( error );
    }
    catch( SvnException &e )
    {
        // use callback error over ClientException
        m_context.checkForError( m_module.client_error );

        throw_client_error( e );
    }

    return info_list;
}
Exemplo n.º 6
0
/* This implements the `svn_opt_subcommand_t' interface. */
svn_error_t *
svn_cl__info(apr_getopt_t *os,
             void *baton,
             apr_pool_t *pool)
{
  svn_cl__opt_state_t *opt_state = ((svn_cl__cmd_baton_t *) baton)->opt_state;
  svn_client_ctx_t *ctx = ((svn_cl__cmd_baton_t *) baton)->ctx;
  apr_array_header_t *targets = NULL;
  apr_pool_t *subpool = svn_pool_create(pool);
  int i;
  svn_error_t *err;
  svn_boolean_t saw_a_problem = FALSE;
  svn_opt_revision_t peg_revision;
  svn_info_receiver_t receiver;

  SVN_ERR(svn_cl__args_to_target_array_print_reserved(&targets, os,
                                                      opt_state->targets,
                                                      ctx, pool));

  /* Add "." if user passed 0 arguments. */
  svn_opt_push_implicit_dot_target(targets, pool);

  if (opt_state->xml)
    {
      receiver = print_info_xml;

      /* If output is not incremental, output the XML header and wrap
         everything in a top-level element. This makes the output in
         its entirety a well-formed XML document. */
      if (! opt_state->incremental)
        SVN_ERR(svn_cl__xml_print_header("info", pool));
    }
  else
    {
      receiver = print_info;

      if (opt_state->incremental)
        return svn_error_create(SVN_ERR_CL_ARG_PARSING_ERROR, NULL,
                                _("'incremental' option only valid in XML "
                                  "mode"));
    }

  if (opt_state->depth == svn_depth_unknown)
    opt_state->depth = svn_depth_empty;

  for (i = 0; i < targets->nelts; i++)
    {
      const char *truepath;
      const char *target = APR_ARRAY_IDX(targets, i, const char *);

      svn_pool_clear(subpool);
      SVN_ERR(svn_cl__check_cancel(ctx->cancel_baton));

      /* Get peg revisions. */
      SVN_ERR(svn_opt_parse_path(&peg_revision, &truepath, target, subpool));

      /* If no peg-rev was attached to a URL target, then assume HEAD. */
      if ((svn_path_is_url(target))
          && (peg_revision.kind == svn_opt_revision_unspecified))
        peg_revision.kind = svn_opt_revision_head;

      err = svn_client_info2(truepath,
                             &peg_revision, &(opt_state->start_revision),
                             receiver, NULL, opt_state->depth,
                             opt_state->changelists, ctx, subpool);

      if (err)
        {
          /* If one of the targets is a non-existent URL or wc-entry,
             don't bail out.  Just warn and move on to the next target. */
          if (err->apr_err == SVN_ERR_UNVERSIONED_RESOURCE
              || err->apr_err == SVN_ERR_ENTRY_NOT_FOUND)
            {
              SVN_ERR(svn_cmdline_fprintf
                      (stderr, subpool,
                       _("%s:  (Not a versioned resource)\n\n"),
                       svn_path_local_style(target, pool)));
            }
          else if (err->apr_err == SVN_ERR_RA_ILLEGAL_URL)
            {
              SVN_ERR(svn_cmdline_fprintf
                      (stderr, subpool,
                       _("%s:  (Not a valid URL)\n\n"),
                       svn_path_local_style(target, pool)));
            }
          else
            {
              return err;
            }

          svn_error_clear(err);
          err = NULL;
          saw_a_problem = TRUE;
        }
    }
  svn_pool_destroy(subpool);

  if (opt_state->xml && (! opt_state->incremental))
    SVN_ERR(svn_cl__xml_print_footer("info", pool));

  if (saw_a_problem)
    return svn_error_create(SVN_ERR_BASE, NULL, NULL);
  else
    return SVN_NO_ERROR;
}