Beispiel #1
0
void SG_workingdir__construct_absolute_path_from_repo_path2(SG_context * pCtx,
															const SG_pendingtree * pPendingTree,
															const char * pszRepoPath,
															SG_pathname ** ppPathAbsolute)
{
	const SG_pathname * pPathWorkingDirectoryTop;				// we do not own this

	SG_ERR_CHECK_RETURN(  SG_pendingtree__get_working_directory_top__ref(pCtx, pPendingTree, &pPathWorkingDirectoryTop)  );
	SG_ERR_CHECK_RETURN(  SG_workingdir__construct_absolute_path_from_repo_path(pCtx, pPathWorkingDirectoryTop, pszRepoPath, ppPathAbsolute)  );
}
Beispiel #2
0
/**
 * Compute the pathnames to the various input/output files for 1 step
 * in the file content merge plan.
 *
 * When we computed the merge and modified the WD, we put the various
 * 'foo~mine' and etc files in the same directory where we put the
 * (candidate) merge result.  If there are multiple steps in the plan,
 * the intermediate (sub-results) need to be placed in this directory
 * too.
 *
 * The final result can go in this directory.  *BUT* if there was also
 * a MOVE/RENAME conflict (so the ultimate final location is yet to be
 * determined), the final result may get moved/renamed when we deal
 * with the structural issue in [2].
 *
 * Since it is possible that the user could have done a "vv rename foo ..."
 * or "vv move foo ..." to manually deal with the structural conflict, we
 * respect that and dynamically compute the final destination (and ignore
 * the "result" field in the last step).
 *
 * pStrRepoPath_FinalResult should be NON-NULL when we are the final
 * step in the plan.
 */
static void _resolve__step_pathnames__compute(SG_context * pCtx,
											  struct _resolve_data * pData,
											  const SG_vhash * pvhIssue,
											  const SG_vhash * pvhStep,
											  SG_string * pStrRepoPath_Result,
											  _resolve__step_pathnames ** ppStepPathnames)
{
	_resolve__step_pathnames * pStepPathnames = NULL;
	SG_string * pStrRepoPath_Parent = NULL;
	SG_pathname * pPath_Parent = NULL;
	const SG_pathname * pPath_WorkingDirectoryTop;
	const char * pszGidParent;
	const char * pszEntryname_Mine;
	const char * pszEntryname_Other;
	const char * pszEntryname_Ancestor;

	SG_ERR_CHECK_RETURN(  SG_alloc1(pCtx, pStepPathnames)  );

	// lookup the parent directory where we initially placed all
	// of the files, find where it is currently in the WD, and
	// build absolute paths for each of the mine/other/ancestor
	// files.

	SG_ERR_CHECK(  SG_vhash__get__sz(pCtx, pvhIssue, "gid_parent", &pszGidParent)  );
	SG_ERR_CHECK(  SG_pendingtree__find_repo_path_by_gid(pCtx, pData->pPendingTree, pszGidParent, &pStrRepoPath_Parent)  );
	SG_ERR_CHECK(  SG_pendingtree__get_working_directory_top__ref(pCtx, pData->pPendingTree, &pPath_WorkingDirectoryTop)  );
	SG_ERR_CHECK(  SG_workingdir__construct_absolute_path_from_repo_path(pCtx,
																		 pPath_WorkingDirectoryTop,
																		 SG_string__sz(pStrRepoPath_Parent),
																		 &pPath_Parent)  );

	SG_ERR_CHECK(  SG_vhash__get__sz(pCtx, pvhStep, "mine",     &pszEntryname_Mine)  );
	SG_ERR_CHECK(  SG_vhash__get__sz(pCtx, pvhStep, "other",    &pszEntryname_Other)  );
	SG_ERR_CHECK(  SG_vhash__get__sz(pCtx, pvhStep, "ancestor", &pszEntryname_Ancestor)  );

	SG_ERR_CHECK(  SG_PATHNAME__ALLOC__PATHNAME_SZ(pCtx, &pStepPathnames->pPath_Mine,     pPath_Parent, pszEntryname_Mine    )  );
	SG_ERR_CHECK(  SG_PATHNAME__ALLOC__PATHNAME_SZ(pCtx, &pStepPathnames->pPath_Other,    pPath_Parent, pszEntryname_Other   )  );
	SG_ERR_CHECK(  SG_PATHNAME__ALLOC__PATHNAME_SZ(pCtx, &pStepPathnames->pPath_Ancestor, pPath_Parent, pszEntryname_Ancestor)  );
	
	if (pStrRepoPath_Result)
	{
		SG_ERR_CHECK(  SG_workingdir__construct_absolute_path_from_repo_path(pCtx,
																			 pPath_WorkingDirectoryTop,
																			 SG_string__sz(pStrRepoPath_Result),
																			 &pStepPathnames->pPath_Result)  );
	}
	else
	{
		const char * pszEntryname_InternalResult;
		
		SG_ERR_CHECK(  SG_vhash__get__sz(pCtx, pvhStep, "result", &pszEntryname_InternalResult)  );
		SG_ERR_CHECK(  SG_PATHNAME__ALLOC__PATHNAME_SZ(pCtx, &pStepPathnames->pPath_Result, pPath_Parent, pszEntryname_InternalResult)  );
	}

	*ppStepPathnames = pStepPathnames;
	pStepPathnames = NULL;

fail:
	SG_PATHNAME_NULLFREE(pCtx, pPath_Parent);
	SG_STRING_NULLFREE(pCtx, pStrRepoPath_Parent);
	_RESOLVE__STEP_PATHNAMES__NULLFREE(pCtx, pStepPathnames);
}