protected override void Execute(string filename, AbstractProjectBrowserTreeNode node, Action callback)
        {
            var item = TFS.GetTfsItem(filename);

            if (item != null)
            {
                try {
                    //   var historyList = item.Workspace.VersionControlServer.QueryHistory(item.ItemSpec).ToList();
                    //    var earliest = historyList.OrderByDescending(x => x.CreationDate).FirstOrDefault();

                    var wrapper = new TfsHistoryDialogWrapper(
                        item.Workspace.VersionControlServer,
                        filename,
                        VersionSpec.Latest,
                        item.ItemSpec.DeletionId,
                        RecursionType.OneLevel,
                        null,
                        null,
                        string.Empty,
                        int.MaxValue,
                        true);
                    wrapper.ShowDialog();

                    //item.Workspace.VersionControlServer.GetItem(filename);
                }
                catch (Exception ex)
                {
                }
            }
        }
Esempio n. 2
0
        public Task <Stream> OpenBaseVersionAsync(FileName fileName)
        {
            return(Task <Stream> .Factory.StartNew(
                       () =>
            {
                var path = Path.GetTempFileName();
                if (!TFS.IsUnderTfsControl(fileName))
                {
                    return null;
                }

                var item = TFS.GetTfsItem(fileName.ToString());
                if (item == null)
                {
                    return null;
                }

                var tfsItem = item.Workspace.VersionControlServer.GetItem(fileName, VersionSpec.Latest, DeletedState.Any, true);
                if (tfsItem == null)
                {
                    return null;
                }

                return tfsItem.DownloadFile();
            }));
        }
        public bool IsValid(object caller, Condition condition)
        {
            var node = ProjectBrowserPad.Instance.SelectedNode as FileNode;

            if (node != null)
            {
                return(TFS.IsUnderTfsControl(node.FileName));
            }

            var proj = ProjectBrowserPad.Instance.SelectedNode as ProjectNode;

            if (proj != null)
            {
                return(TFS.IsUnderTfsControl(proj.Project.FileName));
            }

            var dir = ProjectBrowserPad.Instance.SelectedNode as DirectoryNode;

            if (dir != null)
            {
                return(TFS.IsUnderTfsControl(dir.Directory));
            }

            var sol = ProjectBrowserPad.Instance.SelectedNode as SolutionNode;

            if (sol != null)
            {
                return(TFS.IsUnderTfsControl(sol.Solution.Directory));
            }

            return(false);
        }
Esempio n. 4
0
        private static void RunStep(AbstractProjectBrowserTreeNode node)
        {
            if (node.IsDisposed)
            {
                return;
            }

            var       fileNode = node as FileNode;
            TFSStatus status;

            if (fileNode != null)
            {
                status = TFS.GetFileStatus(fileNode.FileName);
            }
            else
            {
                var projectNode = node as ProjectNode;
                if (projectNode != null)
                {
                    status = TFS.GetFileStatus(projectNode.Project.FileName);
                }
                else
                {
                    //var directoryNode = node as DirectoryNode;
                    //if (directoryNode != null)
                    //{
                    //    status = TFS.GetFileStatus(directoryNode.Directory);
                    //}
                    //else
                    //{
                    var solNode = node as SolutionNode;
                    if (solNode != null)
                    {
                        status = TFS.GetFileStatus(solNode.Solution.Directory);
                    }
                    else
                    {
                        return;
                    }
                    // }
                }
            }

            SD.MainThread.InvokeAsyncAndForget(delegate
            {
                Image image = GetImage(status);
                if (image != null)
                {
                    node.Overlay = image;
                }
                else if (node.Overlay != null && (node.Overlay.Tag as Type) == typeof(OverlayIconManager))
                {
                    // reset overlay to null only if the old overlay belongs to the OverlayIconManager
                    node.Overlay = null;
                }
            });
        }
Esempio n. 5
0
 protected override void Execute(string filename, AbstractProjectBrowserTreeNode node, Action callback)
 {
     try {
         TFS.AddFile(filename);
     }
     catch (Exception ex)
     {
         TFSMessageView.Log("TFSError: Add: " + ex.Message + " (" + filename + ")");
     }
 }
        public override void Execute(object parameter)
        {
            //	workbench.ActiveWorkbenchWindowChanged += ActiveWindowChanged;

            FileService.FileCreated += (sender, e) => AddFile(e.FileName);
            FileService.FileCopied  += (sender, e) => AddFile(e.TargetFile);
            FileService.FileRemoved += (sender, e) => RemoveFile(e.FileName);
            FileService.FileRenamed += (sender, e) => RenameFile(e.SourceFile, e.TargetFile);
            FileUtility.FileSaved   += (sender, e) => TFS.UpdateStatusCacheAndEnqueueFile(e.FileName);

            AbstractProjectBrowserTreeNode.OnNewNode += TreeNodeCreated;
        }
Esempio n. 7
0
        public TfsItem(string path)
        {
            Path = path;
            var info = Workstation.Current.GetLocalWorkspaceInfo(path);

            if (info != null)
            {
                Workspace     = TFS.GetWorkspace(info);
                PendingChange = Workspace.GetPendingChange(path);
            }

            WorkspaceInfo = info;
        }
        async void RenameFile(string sourceFileName, string targetFileName)
        {
            var item = TFS.GetTfsItem(sourceFileName);

            if (item != null)
            {
                if (item.Workspace.PendRename(sourceFileName, targetFileName, LockLevel.Unchanged, false, false) > 0)
                {
                    await TFS.UpdatePendingChanges(item.Workspace);

                    TFS.UpdateStatusCacheAndEnqueueFile(targetFileName);
                }
            }
        }
        async void RemoveFile(string fileName)
        {
            var item = TFS.GetTfsItem(fileName);

            if (item != null)
            {
                if (item.Workspace.PendDelete(fileName) > 0)
                {
                    await TFS.UpdatePendingChanges(item.Workspace);

                    TFS.UpdateStatusCacheAndEnqueueFile(fileName);
                }
            }
        }
        protected override void Execute(string filename, AbstractProjectBrowserTreeNode node, Action callback)
        {
            try
            {
                var nodes = new List <AbstractProjectBrowserTreeNode> {
                    node
                };

                GetNodesRecursive(nodes, node);
                var anythingUpdated = false;

                foreach (var treeNode in nodes)
                {
                    var itemPath = TFS.GetFileName(treeNode);
                    if (string.IsNullOrWhiteSpace(itemPath))
                    {
                        continue;
                    }
                    var item = TFS.GetTfsItem(itemPath);
                    if (item == null)
                    {
                        continue;
                    }
                    GetRequest request = new GetRequest(item.ItemSpec, VersionSpec.Latest);
                    GetStatus  status  = item.Workspace.Get(request, GetOptions.None);
                    if (!status.NoActionNeeded)
                    {
                        TFSMessageView.Log(item.Path + " updated.");
                    }

                    anythingUpdated = anythingUpdated || !status.NoActionNeeded;
                }

                if (!anythingUpdated)
                {
                    TFSMessageView.Log("All files are up to date.");
                }
            }
            catch (Exception ex)
            {
            }
        }
Esempio n. 11
0
        protected override void Execute(string filename, AbstractProjectBrowserTreeNode node, Action callback)
        {
            try
            {
                var item = TFS.GetTfsItem(filename);
                if (item == null)
                {
                    return;
                }
                var itemEx = item.Workspace.VersionControlServer.GetItem(filename, VersionSpec.Latest, DeletedState.Any, true);
                var path   = Path.GetTempPath() + itemEx.ChangesetId + "_" +
                             itemEx.ServerItem.Split('/')[itemEx.ServerItem.Split('/').Length - 1];
                itemEx.DownloadFile(path);

                Difference.VisualDiffFiles(path, filename, "Latest", "Local", "Latest", "Local", true, false, true, false);
            }
            catch (Exception ex)
            {
                TFSMessageView.Log("TFSError: Add: " + ex.Message + " (" + filename + ")");
            }
        }
Esempio n. 12
0
        public static bool IsUnControlledInTfsWorkspace(string fileName)
        {
            if (string.IsNullOrWhiteSpace(fileName))
            {
                return(false);
            }
            var item = GetTfsItem(fileName);

            if (item.Workspace == null)
            {
                return(false);
            }

            return(!item.Workspace.VersionControlServer.ServerItemExists(item.Path, Microsoft.TeamFoundation.VersionControl.Client.ItemType.Any) && (TFS.GetFileStatus(fileName) == TFSStatus.None));
        }
 void AddFile(string fileName)
 {
     TFS.AddFile(fileName);
 }