예제 #1
0
        private void UpdateOriginUri(IVsHierarchy pHierarchy)
        {
            string         location;
            SccProjectData data;

            if (string.IsNullOrEmpty(SolutionDirectory))
            {
                return;
            }

            if (!MapProject(pHierarchy, out location, out data))
            {
                return;
            }

            if (data == null)
            {
                return;
            }

            SccSvnOrigin origin;

            if (!_originMap.TryGetValue(location, out origin))
            {
                return;
            }

            if (data.ProjectDirectory == null)
            {
                return;
            }

            SvnItem dirItem    = StatusCache[data.ProjectDirectory];
            SvnItem slnDirItem = StatusCache[SolutionDirectory];

            if (!dirItem.IsVersioned)
            {
                return;
            }

            Uri dirUri = dirItem.Uri;
            Uri slnDirUri;

            SvnWorkingCopy slnWc = slnDirItem.WorkingCopy;

            if (slnWc == null)
            {
                return;
            }

            if (slnDirItem.IsVersioned)
            {
                slnDirUri = slnDirItem.Uri;
            }
            else
            {
                origin.SvnUri = dirItem.Uri.AbsoluteUri;
                return;
            }

            Uri relUri = slnDirUri.MakeRelativeUri(dirUri);

            if (relUri.IsAbsoluteUri)
            {
                origin.SvnUri = relUri.AbsoluteUri;
            }
            else
            {
                origin.SvnUri = relUri.ToString();
            }
        }
예제 #2
0
        private IEnumerable <SvnItem> GetSolutionProjectRoots()
        {
            Dictionary <string, SvnItem> roots = new Dictionary <string, SvnItem>(StringComparer.OrdinalIgnoreCase);

            SvnItem root = SolutionSettings.ProjectRootSvnItem;

            if (root != null)
            {
                if (root.IsVersioned)
                {
                    roots.Add(root.FullPath, root);
                }
            }

            List <SccProjectData> projects = new List <SccProjectData>(ProjectMap.AllSccProjects);

            foreach (SccProjectData pb in projects)
            {
                // TODO: Move to SccProjectRoot
                string dir = pb.ProjectDirectory;
                if (dir == null || roots.ContainsKey(dir))
                {
                    continue;
                }

                SvnItem pItem = StatusCache[dir];
                if (pItem == null || !pItem.Exists)
                {
                    continue;
                }

                SvnWorkingCopy wc = pItem.WorkingCopy;

                if (wc == null || roots.ContainsKey(wc.FullPath))
                {
                    continue;
                }

                SvnItem wcItem = StatusCache[wc.FullPath];

                bool below = false;
                foreach (SvnItem r in roots.Values)
                {
                    if (r.WorkingCopy != wc) // same working copy?
                    {
                        continue;
                    }

                    if (r == pItem || pItem.IsBelowPath(r))
                    {
                        below = true;
                        break;
                    }
                    else if (r.IsBelowPath(pItem))
                    {
                        roots.Remove(r.FullPath);
                        break;
                    }
                }

                if (!below && !roots.ContainsKey(pItem.FullPath))
                {
                    roots.Add(pItem.FullPath, pItem);
                }
            }

            return(roots.Values);
        }