public void StoreProjectProperties(IVsHierarchy pHierarchy, IPropertyMap map) { ThreadHelper.ThrowIfNotOnUIThread(); string location; SccProjectData data; if (!MapProject(pHierarchy, out location, out data)) { return; } SccSvnOrigin origin; if (!_originMap.TryGetValue(location, out origin)) { if (data == null || data.EnlistMode == SccEnlistChoice.Never) { return; } /* This project type wants to be enlisted. * Store that information now to allow handling it on sln opening */ _originMap[location] = origin = new SccSvnOrigin(); } if (data != null) { SccEnlistChoice choice = data.EnlistMode; if (choice != SccEnlistChoice.Never) { origin.Enlist = choice.ToString(); if (string.IsNullOrEmpty(origin.SvnUri)) { UpdateOriginUri(pHierarchy); } } else { origin.Enlist = null; } } origin.Write(map); }
public void ReadProjectProperties(IVsHierarchy pHierarchy, string pszProjectName, string pszProjectMk, IPropertyMap map) { string slnProjectName; if (!_trueNameMap.TryGetValue(pszProjectMk, out slnProjectName)) { slnProjectName = pszProjectMk; } SccSvnOrigin origin = new SccSvnOrigin(); origin.Load(map); _originMap[slnProjectName] = origin; if (!string.IsNullOrEmpty(origin.Enlist)) { EnsureEnlistment(slnProjectName, pszProjectMk, origin); } }
void EnsureEnlistment(string slnProjectName, string pszProjectMk, SccSvnOrigin origin) { SccTranslatePathInfo tpi; if (TryGetTranslation(slnProjectName, out tpi)) { return; // We have existing local data } IVsSolution sol = GetService <IVsSolution>(typeof(SVsSolution)); if (sol == null) { return; } IVsProjectFactory factory; if (!VSErr.Succeeded(sol.GetProjectFactory(0, null, pszProjectMk, out factory))) { return; } IVsSccProjectEnlistmentFactory enlistFactory = factory as IVsSccProjectEnlistmentFactory; if (enlistFactory == null) { return; } string enlistPath, enlistPathUNC; if (!VSErr.Succeeded(enlistFactory.GetDefaultEnlistment(pszProjectMk, out enlistPath, out enlistPathUNC))) { return; } // ### We should now proceed with the editing operations as documented // ### in IVsSccEnlistmentPathTranslation.idl // ### But since we don't have per user settings yet we currently just // ### pass the defaults as that happens to be the same behavior as // ### before if (IsSafeSccPath(pszProjectMk) && !string.IsNullOrEmpty(SolutionSettings.ProjectRoot) /*&& (SvnItem.IsBelowRoot(pszProjectMk, SolutionSettings.ProjectRoot) || string.IsNullOrEmpty(origin.SvnUri))*/ && StatusCache != null && StatusCache[pszProjectMk].Exists) { int pfValidEnlistment; string chosenUNC; // We have a website that has a default location below our project root or without a Svn Uri // At least for now we should default to enlist at that location to make // sure we don't break backwards compatibility string suffix = ".sccEnlistAttemptLocation"; if (VSErr.Succeeded(enlistFactory.ValidateEnlistmentEdit(0, slnProjectName, pszProjectMk + suffix, out chosenUNC, out pfValidEnlistment)) && pfValidEnlistment != 0 && chosenUNC.EndsWith(suffix)) { enlistPath = pszProjectMk; enlistPathUNC = chosenUNC.Substring(0, chosenUNC.Length - suffix.Length); } } string slnProjectMk; // Maybe we already translated the path? if (!_trueNameMap.TryGetValue(pszProjectMk, out slnProjectMk)) { slnProjectMk = pszProjectMk; } tpi = new SccTranslatePathInfo(slnProjectMk, enlistPath, CalculateTruePath(enlistPathUNC)); _translationMap[slnProjectMk] = tpi; if (enlistPathUNC != slnProjectMk) { _trueNameMap[enlistPathUNC] = slnProjectMk; } }