当前位置: 首页>>代码示例>>C#>>正文


C# Workspace.PendEdit方法代码示例

本文整理汇总了C#中Microsoft.TeamFoundation.VersionControl.Client.Workspace.PendEdit方法的典型用法代码示例。如果您正苦于以下问题:C# Workspace.PendEdit方法的具体用法?C# Workspace.PendEdit怎么用?C# Workspace.PendEdit使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Microsoft.TeamFoundation.VersionControl.Client.Workspace的用法示例。


在下文中一共展示了Workspace.PendEdit方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ModifyFile

        /// <summary>
        /// 'Pends' a change to a file that was previously checked-in and then checks
        /// that change into the repository.
        /// </summary>
        /// <param name="workspace">Version control workspace to use when 
        /// changing the folder and file.</param>
        /// <param name="newFilename">Full path to the file to change</param>
        /// <exception cref="SecurityException">If the user doesn't have
        /// check-in permission for the specified <paramref name="workspace"/>.</exception>
        /// <exception cref="IOException">If there's a problem creating the file.</exception>
        /// <exception cref="VersionControlException">If </exception>
        private static void ModifyFile(Workspace workspace, String newFilename)
        {
            Debug.Assert(workspace != null);
            Debug.Assert(!String.IsNullOrEmpty(newFilename));

            try
            {
                // Checkout and modify the file
                workspace.PendEdit(newFilename);

                using (var streamWriter = new StreamWriter(newFilename))
                {
                    streamWriter.WriteLine("Revision 2");
                }

                // Get the pending change and check in the new revision.
                var pendingChanges = workspace.GetPendingChanges();
                int changesetForChange = workspace.CheckIn(pendingChanges, "Modified file contents");
                Console.WriteLine("Checked in changeset {0}", changesetForChange);
            }
            catch (IOException ex)
            {
                Console.Error.WriteLine("Error writing {1}: {0}", ex.Message, newFilename);
                throw;
            }
            catch (VersionControlException ex)
            {
                Console.Error.WriteLine("Error modifying file: {0}", ex.Message);
                throw;
            }
        }
开发者ID:spraints,项目名称:svn2tfs,代码行数:42,代码来源:Program.cs

示例2: Run

    public override void Run()
    {
        // must get server<->local mappings for GetServerItemForLocalItem
        workspace = GetWorkspaceFromCache();
        workspace.RefreshMappings();

        // by default, if nothing specified we process all changes
        if ((!OptionModified) && (!OptionDeleted) && (!OptionAdded))
            {
                OptionModified = OptionAdded = OptionDeleted = true;
            }

        Online(Arguments);
        if (OptionPreview) return;

        int changes = 0;
        changes += workspace.PendAdd(addedFiles.ToArray(), false);
        changes += workspace.PendEdit(editedFiles.ToArray(), RecursionType.None);
        changes += workspace.PendDelete(deletedFiles.ToArray(), RecursionType.None);
        Console.WriteLine("{0} pending changes.", changes);
    }
开发者ID:Jeff-Lewis,项目名称:opentf,代码行数:21,代码来源:OnlineCommand.cs

示例3: TryCheckout

        public static bool TryCheckout(Workspace workspace, string path)
        {
            if (workspace == null)
            {
                return false;
            }

            try
            {
                // Mark the file as a pending edit
                workspace.PendEdit(path);
            }
            catch
            {
                return false;
            }

            return true;
        }
开发者ID:garyjohnson,项目名称:wpnest,代码行数:19,代码来源:Tfs.cs

示例4: Run

    public override void Run()
    {
        workspace = GetWorkspaceFromCache();
        workspace.RefreshMappings();

        if (Arguments.Length < 1)
            {
                Console.WriteLine("No changeset specified.");
                Environment.Exit((int)ExitCode.Failure);
            }

        int cid = Convert.ToInt32(Arguments[0]);
        Changeset changeset = VersionControlServer.GetChangeset(cid, true, false);

        // fetch all items in one fell swoop
        List<int> ids = new List<int>();
        foreach (Change change in changeset.Changes)
            {
                if ((change.ChangeType & ChangeType.Add) == ChangeType.Add)
                    {
                        if (change.Item.ItemType != ItemType.Folder)
                            {
                                string localItem = workspace.GetLocalItemForServerItem(change.Item.ServerItem);
                                Console.WriteLine("Undo add: " + change.Item.ServerItem);
                                deletedFiles.Add(localItem);
                            }

                        continue;
                    }

                ids.Add(change.Item.ItemId);
            }

        ProcessEdits(changeset, ids.ToArray(), cid);

        if (OptionPreview) return;

        changeCount += workspace.PendAdd(addedFiles.ToArray(), false);
        changeCount += workspace.PendEdit(editedFiles.ToArray(), RecursionType.None);
        changeCount += workspace.PendDelete(deletedFiles.ToArray(), RecursionType.None);
        Console.WriteLine("{0} pending changes.", changeCount);
    }
开发者ID:Jeff-Lewis,项目名称:opentf,代码行数:42,代码来源:RollbackCommand.cs


注:本文中的Microsoft.TeamFoundation.VersionControl.Client.Workspace.PendEdit方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。