Exemple #1
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();
            }));
        }
        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)
                {
                }
            }
        }
        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)
            {
            }
        }
Exemple #6
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 + ")");
            }
        }