svn_revnum_t
  Client::checkout(const char * url,
                   const Path & destPath,
                   const Revision & revision,
                   bool recurse,
                   bool ignore_externals,
                   const Revision & peg_revision) throw(ClientException)
  {
    Pool subPool;
    apr_pool_t * apr_pool = subPool.pool();
    svn_revnum_t revnum = 0;

    svn_error_t * error =
      svn_client_checkout2(&revnum,
                           url,
                           destPath.c_str(),
                           peg_revision.revision(),  // peg_revision
                           revision.revision(),  // revision
                           recurse,
                           ignore_externals,
                           *m_context,
                           apr_pool);

    if (error != NULL)
      throw ClientException(error);

    return revnum;
  }
Beispiel #2
0
static int
l_checkout (lua_State *L) {
	const char *path = luaL_checkstring (L, 1);
	const char *dir = luaL_checkstring (L, 2);

	svn_opt_revision_t revision;
	svn_opt_revision_t peg_revision;

	peg_revision.kind = svn_opt_revision_unspecified;

	if (lua_gettop (L) < 3 || lua_isnil (L, 3)) {
		revision.kind = svn_opt_revision_head;	
	} else {
		revision.kind = svn_opt_revision_number;
		revision.value.number = lua_tointeger (L, 3);
	}

	svn_boolean_t recursive = TRUE;
	svn_boolean_t ignore_externals = FALSE;

	int itable = 4;
	if (lua_gettop (L) >= itable && lua_istable (L, itable)) {
		lua_getfield (L, itable, "recursive");
		if (lua_isboolean (L, -1)) {
			recursive = lua_toboolean (L, -1);
		}

		lua_getfield (L, itable, "ignore_externals");
		if (lua_isboolean (L, -1)) {
			ignore_externals = lua_toboolean (L, -1);
		}
	} 


	apr_pool_t *pool;
	svn_error_t *err;
	svn_client_ctx_t *ctx;

	init_function (&ctx, &pool, L);

	path = svn_path_canonicalize (path, pool);
	dir = svn_path_canonicalize (dir, pool);

	svn_revnum_t rev;

	err = svn_client_checkout2 (&rev, path, dir, &peg_revision, &revision, recursive, ignore_externals, ctx, pool);
	IF_ERROR_RETURN (err, pool, L);
	
	lua_pushinteger (L, rev);

	svn_pool_destroy (pool);

	return 1;
}
Beispiel #3
0
static int
l_checkout (lua_State *L) {
	const char *path = luaL_checkstring (L, 1);
	const char *dir = luaL_checkstring (L, 2);

	svn_opt_revision_t revision;
	svn_opt_revision_t peg_revision;

	peg_revision.kind = svn_opt_revision_unspecified;

	if (lua_gettop (L) < 3 || lua_isnil (L, 3)) {
		revision.kind = svn_opt_revision_head;	
	} else {
		revision.kind = svn_opt_revision_number;
		revision.value.number = lua_tointeger (L, 3);
	}

	apr_pool_t *pool;
	svn_error_t *err;
	svn_client_ctx_t *ctx;

	init_function (&ctx, &pool, L);

	path = svn_path_canonicalize (path, pool);
	dir = svn_path_canonicalize (dir, pool);

	svn_revnum_t rev;

	err = svn_client_checkout2 (&rev, path, dir, &peg_revision, &revision, TRUE, FALSE, ctx, pool);
	IF_ERROR_RETURN (err, pool, L);
	
	lua_pushinteger (L, rev);

	svn_pool_destroy (pool);

	return 1;
}
Beispiel #4
0
/* This is called by the project processor, and runs a checkout for each
 * project.
 */
static void
mw_conf_list_get(struct mw_conf_head *r, const char *project,
    struct callback_args *args)
{
	struct conf_list_entry *node;
	FILE *logfp;
	char *approot, *cpos, *project_dir, buf[MAXPATHLEN], canonical[MAXPATHLEN];
	char slink[MAXPATHLEN];
	char true_url[MAXPATHLEN];
	int found = 0;
	svn_revnum_t revnum, result_revnum;
	svn_opt_revision_t revision, pegrev;
	apr_pool_t *subpool;
	svn_error_t *err = NULL;

	pegrev.kind = svn_opt_revision_unspecified;
	/* Open our per-project checkout log.  This needs to go in /tmp
	 * initially, because we don't have a project checked out */
	if ((logfp = fdopen(args->logfd, "a")) == NULL) {
		exit(1);
		syslog(LOG_ERR,
		    "mwbuild: %s failed for %s", "get", project);
	}

	/* Find the PROJECT_SVN path for this project */
	TAILQ_FOREACH(node, r, conf_node_list) {
		if (node->conf->key != NULL
		    && strcmp(node->conf->key, "PROJECT_SVN") == 0) {
			found = 1;
			break;
		}
	}
	/* We MUST have a PROJECT_SVN value for each project */
	if (!found) {
		fprintf(stderr,
		    "could not find valid PROJECT_SVN value for project `%s'\n",
		    project);
		mw_log(logfp,
		    "could not find valid PROJECT_SVN value for project `%s'",
		    project);
		syslog(LOG_ERR,
		    "mwbuild: %s failed for %s", "get", project);
		exit(1);
	}

	revision.kind = svn_opt_revision_number;
	/* Couldn't find a revision, fetch revision of HEAD */
	if ((revnum = mw_svn_rev(node->conf->value)) == -1) {
		/* Shorten SVN string to just the URL part */
		if ((cpos = strchr(node->conf->value, ':')) != NULL) {
			*cpos = '\0';
		}
		/* Build up the URL */
		xsnprintf(true_url, sizeof(true_url), "%s/%s", SVN_ROOT,
		    node->conf->value);
		revision.value.number =
		    mw_get_head_rev(true_url, args, project, logfp);
	} else {
		/* Shorten SVN string to just the URL part */
		if ((cpos = strchr(node->conf->value, ':')) != NULL) {
			*cpos = '\0';
		}
		/* Build up the URL */
		xsnprintf(true_url, sizeof(true_url), "%s/%s", SVN_ROOT,
		    node->conf->value);
		revision.value.number = revnum;
	}


	/* Build up the (temporary) local path for checkout */
	project_dir = mw_get_config_var(r, PROJECT_DIR);
	approot = mw_get_config_var(r, MWBUILD_APPROOT);
	xsnprintf(buf, sizeof(buf), "%s/%s_%ld", approot, project_dir,
	    revision.value.number);
	/* On some systems (notably linux), realpath(3) needs the full path to exist first */
	if (mw_mkpath(buf) == -1) {
		fprintf(stderr, "mw_mkpath() failure\n");
	}
	if (realpath(buf, canonical) == NULL) {
		fprintf(stderr, "Could not canonicalise path: %s: %s\n", buf, strerror(errno));
		mw_log(logfp, "Could not canonicalise path: %s: %s\n", buf, strerror(errno));
		syslog(LOG_ERR,
		    "mwbuild: %s failed for %s", "get",
		    mw_get_config_var(r, PROJECT_SVN));
		exit(1);
	}
	subpool = svn_pool_create(args->pool);
	printf("Checking out %s:%ld to %s\n", true_url,
	    revision.value.number, canonical);
	mw_log(logfp, "Checking out %s:%ld to %s", true_url,
	    revision.value.number, canonical);

	/* Run the actual checkout */
	err = svn_client_checkout2(&result_revnum, true_url, canonical,
	    &pegrev,
	    &revision,
	    TRUE,
	    args->opt_state->ignore_externals,
	    args->ctx, subpool);

	svn_pool_destroy(subpool);
	if (err != NULL) {
		fprintf(stderr,
		    "Error checking out project `%s' at URL `%s': %s\n",
		    project, true_url, err->message);
		mw_log(logfp,
		    "Error checking out project `%s' at URL `%s': %s",
		    project, true_url, err->message);
		syslog(LOG_ERR,
		    "mwbuild: %s failed for %s", "get",
		    mw_get_config_var(r, PROJECT_SVN));
		exit(1);
	}
	/* Update symlink */
	xsnprintf(slink, sizeof(slink), "%s/%s", approot, project_dir);
	(void) unlink(slink);
	if (symlink(canonical, slink) == -1) {
		fprintf(stderr,
		    "Error symlinking %s to %s: %s\n", slink, canonical,
		    strerror(errno));
		mw_log(logfp,
		    "Error symlinking %s to %s: %s", slink, canonical,
		    strerror(errno));
		syslog(LOG_ERR,
		    "mwbuild: %s failed for %s", "get",
		    mw_get_config_var(r, PROJECT_SVN));
		exit(1);
	}

	syslog(LOG_DEBUG,
	    "mwbuild: %s succeeded for %s", "get",
	    mw_get_config_var(r, PROJECT_SVN));
}