Esempio n. 1
0
        /// <summary>
        /// Find the mapping entry for the given path.
        /// </summary>
        /// <param name="serverPath"></param>
        /// <returns>Null if the path is not mapped or cloaked. Otherwise, return the mapping entry.</returns>
        internal MappingEntry FindMappedPath(string serverPath)
        {
            MappingEntry mostSpecificMapping = null;

            foreach (MappingEntry current in ConfigurationService.Filters)
            {
                if (VersionControlPath.IsSubItem(serverPath, VersionControlPath.GetFullPath(current.Path)))
                {
                    if (mostSpecificMapping == null ||
                        VersionControlPath.IsSubItem(VersionControlPath.GetFullPath(current.Path),
                                                     VersionControlPath.GetFullPath(mostSpecificMapping.Path)))
                    {
                        mostSpecificMapping = current;
                    }
                }
            }

            if ((mostSpecificMapping != null) && (!mostSpecificMapping.Cloak))
            {
                return(mostSpecificMapping);
            }
            else
            {
                return(null);
            }
        }
Esempio n. 2
0
        public override void BasicActionHandler(MigrationAction action, ChangeGroup group)
        {
            try
            {
                VersionControlPath.GetFullPath(action.Path, true);
                if (!string.IsNullOrEmpty(action.FromPath))
                {
                    VersionControlPath.GetFullPath(action.FromPath, true);
                }
            }
            catch (Exception e)
            {
                MigrationConflict pathTooLongConflict = VCInvalidPathConflictType.CreateConflict(action, e.Message, action.Path);

                List <MigrationAction>   returnActions;
                ConflictResolutionResult resolutionResult = ((TfsVCAnalysisProvider)AnalysisProvider).ConflictManager.TryResolveNewConflict(
                    group.SourceId, pathTooLongConflict, out returnActions);
                if (resolutionResult.Resolved)
                {
                    switch (resolutionResult.ResolutionType)
                    {
                    case ConflictResolutionType.SkipConflictedChangeAction:
                        return;

                    default:
                        Debug.Fail("Unknown resolution result");
                        return;
                    }
                }
                return;
            }
            base.BasicActionHandler(action, group);
        }
Esempio n. 3
0
        internal static void OpenSolutionWithWorkspace(Workspace workspace, string serverItem, VersionSpec spec)
        {
            serverItem = VersionControlPath.GetFullPath(serverItem);
            WorkingFolder folderForServerItem1;

            try
            {
                folderForServerItem1 = workspace.TryGetWorkingFolderForServerItem(serverItem);
            }
            catch (Exception ex)
            {
                Output.Exception(ex);
                return;
            }
            if (folderForServerItem1 != null)
            {
                if (folderForServerItem1.IsCloaked)
                {
                    int num1 = (int)Error(UIHost.DefaultParentWindow, GuiResources.Format("SolutionIsCloaked", (object)VersionControlPath.GetFileName(serverItem)), string.Empty, MessageBoxButtons.OK, MessageBoxIcon.Hand);
                }
                else
                {
                    try
                    {
                        VssProvider.OpenFromSCC(serverItem, FileSpec.GetDirectoryName(folderForServerItem1.LocalItem), spec.DisplayString, VersionControlOpenFromSccOverwrite.openscc_open_local_version);
                    }
                    catch (Exception ex)
                    {
                        Output.Exception(ex);
                    }
                }
            }
            else
            {
                string folderName = VersionControlPath.GetFolderName(serverItem);
                using (var dialogSetLocalFolder = (Form)TeamControlFactory.CreateDialogSetLocalFolder(workspace, folderName))
                {
                    if (UIHost.ShowModalDialog((Form)dialogSetLocalFolder) != DialogResult.OK)
                    {
                        return;
                    }
                }
                try
                {
                    WorkingFolder folderForServerItem2 = workspace.GetWorkingFolderForServerItem(serverItem);
                    VssProvider.OpenFromSCC(serverItem, FileSpec.GetDirectoryName(folderForServerItem2.LocalItem), spec.DisplayString, VersionControlOpenFromSccOverwrite.openscc_open_local_version);
                }
                catch (Exception ex)
                {
                    Output.Exception(ex);
                }
            }
        }
Esempio n. 4
0
        /// <summary>
        /// Given a path, find the mapped path according to session mappings
        /// </summary>
        /// <param name="path">the path to be searched</param>
        /// <param name="session">the session</param>
        /// <param name="useTarget">Given path is source path if this value is set to true</param>
        /// <returns></returns>
        public string FindMappedPath(string path, Session session, bool useSource)
        {
            if (session == null)
            {
                throw new ArgumentNullException("session");
            }
            if (string.IsNullOrEmpty(path))
            {
                throw new ArgumentNullException("path");
            }

            try
            {
                string sourcePath = null;
                string targetPath = null;

                foreach (var filterPair in m_serverDiffEngine.Session.Filters.FilterPair)
                {
                    if (!filterPair.Neglect)
                    {
                        sourcePath = GetSourcePath(filterPair);
                        targetPath = GetTargetPath(filterPair);
                        if (useSource)
                        {
                            if (VersionControlPath.IsSubItem(VersionControlPath.GetFullPath(path), VersionControlPath.GetFullPath(sourcePath)))
                            {
                                return(VersionControlPath.Combine(VersionControlPath.GetFullPath(targetPath),
                                                                  VersionControlPath.GetFullPath(path).Substring(VersionControlPath.GetFullPath(sourcePath).Length).TrimStart(VersionControlPath.Separator)));
                            }
                        }
                        else
                        {
                            if (VersionControlPath.IsSubItem(VersionControlPath.GetFullPath(path), VersionControlPath.GetFullPath(targetPath)))
                            {
                                return(VersionControlPath.Combine(VersionControlPath.GetFullPath(sourcePath),
                                                                  VersionControlPath.GetFullPath(path).Substring(VersionControlPath.GetFullPath(targetPath).Length).TrimStart(VersionControlPath.Separator)));
                            }
                        }
                    }
                }
            }
            catch (VersionControlException e)
            {
                // This is usually a InvalidPath exception.
                Trace.TraceError(e.Message);
            }
            return(null);
        }
        public IVCDiffItem InitializeForDiff(string treeFilterSpecifier, string version)
        {
            string tfsTreeRoot = VersionControlPath.GetFullPath(treeFilterSpecifier);

            if (string.IsNullOrEmpty(version))
            {
                m_versionSpec = VersionSpec.Latest;
            }
            else
            {
                m_versionSpec = VersionSpec.ParseSingleSpec(version, null);
            }

            TfsVCDiffItem rootDiffItem = null;

            List <IVCDiffItem> subDiffItems = new List <IVCDiffItem>();

            ItemSet tfsItemSet = m_tfsClient.GetItems(tfsTreeRoot, m_versionSpec, RecursionType.OneLevel);

            foreach (Item item in tfsItemSet.Items)
            {
                if (string.Equals(item.ServerItem, tfsTreeRoot, StringComparison.OrdinalIgnoreCase))
                {
                    rootDiffItem = new TfsVCDiffItem(item, 0);
                }
                else
                {
                    TfsVCDiffItem diffItem = new TfsVCDiffItem(item, 1);
                    subDiffItems.Add(diffItem);
                }
            }

            if (rootDiffItem == null)
            {
                return(null);
            }

            rootDiffItem.SubItems.AddRange(subDiffItems);
            m_cachedFolderItems.Add(rootDiffItem.ServerPath, rootDiffItem);

            return(rootDiffItem);
        }
Esempio n. 6
0
        public void Navigate(string initialPath)
        {
            if (initialPath != null && initialPath.StartsWith("$/") && initialPath.Length > 2)
            {
                initialPath = VersionControlPath.GetFullPath(initialPath);

                TreeNodeServerItem foundItem = null;
                if (TryFindNodeByServerItem(initialPath, null, out foundItem))
                {
                    foundItem.EnsureVisible();
                    m_navigateToWhenLoaded = null;
                    return;
                }

                string[] folders  = initialPath.Substring(2).Split('/');
                string   curPath  = "$/";
                string   prevPath = curPath;
                foundItem = null;
                m_navigateToWhenLoaded = null;
                for (int i = 0; i < folders.Length; i++)
                {
                    prevPath = curPath;
                    curPath  = curPath + "/" + folders[i];
                    if (TryFindNodeByServerItem(curPath, foundItem, out foundItem))
                    {
                        foundItem.EnsureVisible();
                    }
                    else
                    {
                        m_toExpand.Add(prevPath);
                        m_navigateToWhenLoaded = initialPath;
                    }
                }
                StartBackgroundWorkerIfNeeded();
            }
        }