SharpSvn还原

时间:2016-01-25 10:40:46

标签: c# svn revert sharpsvn

我试图在SharpSvn的帮助下将文件/目录恢复到特定版本。我目前的方法几乎完美。问题是,当我要求SVN向我提供有关最近恢复的文件的一些信息时,它总是声称它是最新版本。

TortoiseSVN的:

  • 选择“更新到修订版本...”
  • 选择任何修订版本及其
  • 如果您查看日志,您会看到您在上一步中选择的修订版已突出显示(粗体)

SharpSvn:

  • 还原工作副本上的所有更改
  • 进行反向合并
  • 解决所有未解决的合并问题
  • 这是相关的代码:

    public override bool Revert(ICollection<string> fileNamesWithPath, long revision = -1)
    {
        Console.Write("Reverting changes on file {0}... ", GetListOfFilesAsString(fileNamesWithPath));
        SvnRevertArgs revertArgs = new SvnRevertArgs()
        {
            Depth = SvnDepth.Infinity
        };
        bool result = svnClient.Revert(fileNamesWithPath, revertArgs);
        Console.WriteLine(result ? "done" : "failed");
    
        if (result && revision > -1)
        {
            foreach (string fileNameWithPath in fileNamesWithPath)
            {
                Console.Write("Reverting changes on file {0} to revision {1}... ", fileNameWithPath, revision);
                SvnMergeArgs mergeArgs = new SvnMergeArgs()
                {
                    Depth = SvnDepth.Infinity
                };
                SvnRevisionRange revisionRange = new SvnRevisionRange(SvnRevision.Head, revision);
                result = result && svnClient.Merge(fileNameWithPath, SvnTarget.FromString(fileNameWithPath), revisionRange, mergeArgs);
                Console.WriteLine(result ? "done" : "failed");
    
                Console.Write("Resolve any eventually unresolved merge issues by taking 'theirs' on file {0}... ", fileNameWithPath);
                SvnResolveArgs resolveArgs = new SvnResolveArgs()
                {
                    Depth = SvnDepth.Infinity
                };
                result = result && svnClient.Resolve(fileNameWithPath, SvnAccept.TheirsFull, resolveArgs);
                Console.WriteLine(result ? "done" : "failed");
            }
        }
        Console.WriteLine();
    
        return result;
    }
    
  • 无论我之后使用GetStatus()还是GetInfo(),都会返回最新的修订号。

这种方法有什么问题?

我还尝试使用svnClient.Update()并指定修订版。但是,如果我尝试提交此文件,它会告诉我“File 'D:\test.svn\1.txt' is out of date”。所以我想,这不是要走的路。

祝你好运,    卡斯滕

0 个答案:

没有答案