Ejemplo n.º 1
0
/**
 * Creates a staging area and returns an initialized instance data structure.
 */
static void _pull_init(SG_context* pCtx, 
					   SG_client* pClient,
					   const char* pszPullIntoRepoDescriptorName,
					   sg_pull_instance_data** ppMe)
{
	char* pszThisRepoId = NULL;
	char* pszThisHashMethod = NULL;
	char* pszOtherRepoId = NULL;
	char* pszOtherHashMethod = NULL;

	sg_pull_instance_data* pMe = NULL;
	
	SG_repo* pPullIntoRepo = NULL;

	SG_NULLARGCHECK_RETURN(pszPullIntoRepoDescriptorName);
	SG_NULLARGCHECK_RETURN(ppMe);

	SG_ERR_CHECK(  SG_client__get_repo_info(pCtx, pClient, &pszOtherRepoId, NULL, &pszOtherHashMethod)  );

	SG_ERR_CHECK(  SG_repo__open_repo_instance(pCtx, pszPullIntoRepoDescriptorName, &pPullIntoRepo)  );

	/* TODO This will care about dagnums once we're using the user dag. */
	SG_ERR_CHECK(  SG_repo__get_repo_id(pCtx, pPullIntoRepo, &pszThisRepoId)  );
	if (strcmp(pszThisRepoId, pszOtherRepoId) != 0)
		SG_ERR_THROW(SG_ERR_REPO_ID_MISMATCH);

	/* TODO check admin id when appropriate */

	SG_ERR_CHECK(  SG_repo__get_hash_method(pCtx, pPullIntoRepo, &pszThisHashMethod)  );
	if (strcmp(pszThisHashMethod, pszOtherHashMethod) != 0)
		SG_ERR_THROW(SG_ERR_REPO_HASH_METHOD_MISMATCH);

	// alloc instance data, store pull id in it (which identifies the staging area)
	SG_ERR_CHECK(  SG_alloc1(pCtx, pMe)  );
	SG_ERR_CHECK(  SG_staging__create(pCtx, pszPullIntoRepoDescriptorName, &pMe->pszPullId, &pMe->pStaging)  );
	pMe->pPullIntoRepo = pPullIntoRepo;
	pPullIntoRepo = NULL;

	SG_RETURN_AND_NULL(pMe, ppMe);

	/* fall through */
fail:
	SG_NULLFREE(pCtx, pszThisRepoId);
	SG_NULLFREE(pCtx, pszThisHashMethod);
	SG_NULLFREE(pCtx, pszOtherRepoId);
	SG_NULLFREE(pCtx, pszOtherHashMethod);
	SG_NULLFREE(pCtx, pPullIntoRepo);
	_NULLFREE_INSTANCE_DATA(pCtx, pMe);
}
void SG_sync_remote__push_begin(
	SG_context* pCtx,
	const char** ppszPushId
	)
{
	char* psz_staging_area_name = NULL;

	SG_NULLARGCHECK_RETURN(ppszPushId);

	SG_ERR_CHECK(  SG_staging__create(pCtx, &psz_staging_area_name, NULL)  );

	SG_RETURN_AND_NULL(psz_staging_area_name, ppszPushId);

	/* fallthru */

fail:
	SG_NULLFREE(pCtx, psz_staging_area_name);
}
Ejemplo n.º 3
0
void SG_server__push_begin(
	SG_context* pCtx,
	SG_server * pServer,
	const char* psz_repo_descriptor_name,
	const char** ppszPushId
	)
{
	char* psz_staging_area_name = NULL;

	SG_NULLARGCHECK_RETURN(pServer);
	SG_NULLARGCHECK_RETURN(ppszPushId);

	SG_ERR_CHECK(  SG_staging__create(pCtx, psz_repo_descriptor_name, &psz_staging_area_name, NULL)  );

	SG_RETURN_AND_NULL(psz_staging_area_name, ppszPushId);

	/* fallthru */

fail:
	SG_NULLFREE(pCtx, psz_staging_area_name);
}