コード例 #1
0
        public void GetLatest(string item)
        {
            Workspace workspace = this.GetWorkspace(item);

            if (workspace == null)
            {
                return;
            }

            string serverPath = workspace.TryGetServerItemForLocalItem(item);

            if (serverPath != null)
            {
                using (UIHost.GetWaitCursor())
                {
                    IVsFileChangeEx fce = serviceProvider.GetService(typeof(SVsFileChangeEx)) as IVsFileChangeEx;
                    int             hr  = 0;

                    if (fce != null)
                    {
                        try
                        {
                            // Ignore file changes, so there is no Reload dialog
                            hr = fce.IgnoreFile(VSConstants.VSCOOKIE_NIL, item, 1);
                            Debug.Assert(hr == VSConstants.S_OK);
                            GetRequest getRequest = new GetRequest(serverPath, RecursionType.None, VersionSpec.Latest);
                            GetStatus  status     = workspace.Get(getRequest, GetOptions.None, null, null);
                            if (status != null && status.NumConflicts > 0)
                            {
                                // Trigger resolve conflicts tool window if there are any, to be consistent with solution explorer
                                this.dte.ExecuteCommand("File.TfsResumeConflictResolution");
                            }
                        }
                        finally
                        {
                            // Sync file so that file changes do not trigger events later when we un-ignore
                            hr = fce.SyncFile(item);
                            Debug.Assert(hr == VSConstants.S_OK);
                            hr = fce.IgnoreFile(VSConstants.VSCOOKIE_NIL, item, 0);
                            Debug.Assert(hr == VSConstants.S_OK);
                        }
                    }
                }
            }
        }
コード例 #2
0
 public static void ViewPendingChanges(Workspace workspace, IEnumerable <PendingChange> changes)
 {
     using (UIHost.GetWaitCursor())
     {
         foreach (PendingChange pendingChange in changes)
         {
             if (pendingChange.ItemType == ItemType.File)
             {
                 if ((pendingChange.ServerItem).EndsWith(".sln"))
                 {
                     TeamFoundationTrace.Info(VCTraceKeywordSets.PendingChanges, "View(VS):Opening solution/project '{0}'", (object)pendingChange.ServerItem);
                     OpenSolutionWithWorkspace(workspace, pendingChange.ServerItem, VersionSpec.Latest);
                 }
                 else
                 {
                     var str = VersionControlPath.GetTempFileName(pendingChange.ServerItem, pendingChange.Version);
                     pendingChange.DownloadBaseFile(str);
                     TryOpenFile(str);
                 }
             }
         }
     }
 }