gpt4 book ai didi

c# - 使用 SharpSvn 获取 "mergable revisions"

转载 作者:太空宇宙 更新时间:2023-11-03 12:42:32 26 4
gpt4 key购买 nike

设置合并时,TortoiseSvn 客户端有一个很棒的复选框,标记为“隐藏不可合并的修订”。我希望重现使用 SharpSvn 启用时显示的修订列表。

TortoiseSvn

TortoiseSvn documentation解释这个复选框:

When merge tracking is used, the log dialog will show previously merged revisions, and revisions pre-dating the common ancestor point, i.e. before the branch was copied, as greyed out. The Hide non-mergeable revisions checkbox allows you to filter out these revisions completely so you see only the revisions which can be merged.

如何在 SharpSvn 代码中重现此功能? 我需要一个 SvnLogEventArgs(或类似的)列表,它们是合并的候选对象。

当前状态:我只得到了两个分支的日志。我无法弄清楚如何获得适当的 svn:mergeinfo 属性,或者在获得它后如何处理它。

最佳答案

我一直在努力,并点击链接,这就是我最终得到的:

using (var client = new SvnClient())
{
var release = SvnTarget.FromUri(new Uri(@"https://******/branches/Release"));
var trunk = SvnTarget.FromUri(new Uri(@"https://******/trunk"));

string trunkMergeinfo, releaseMergeinfo;
client.GetProperty(release, "svn:mergeinfo", out releaseMergeinfo);
client.GetProperty(trunk, "svn:mergeinfo", out trunkMergeinfo);
var relInfos = releaseMergeinfo.Split("\n");
var trunkInfos = trunkMergeinfo.Split("\n");

// This is here because I don't know what will happen once I merge something into trunk.
Debug.Assert(relInfos.Except(trunkInfos).Count() == 1,"Too many unknown merge paths");

var trunklist = relInfos.SingleOrDefault(i => i.StartsWith("/trunk:"));
var revisions = trunklist.Replace("/trunk:", "").Split(",").SelectMany(t =>
{
// If the log contains a range, break it out to it's specific revisions.
if (t.Contains("-"))
{
var match = Regex.Match(t, @"(\d+)-(\d+)");
var start = int.Parse(match.Groups[1].Value);
var end = int.Parse(match.Groups[2].Value);
return Enumerable.Range(start, end - start + 1).ToArray();
}
else
return new[] { int.Parse(t) };
}).Select(x => (long)x);

Collection<SvnLogEventArgs> baseRevs;
// Why can't this take "trunk" or a property thereof as an argument?
client.GetLog(new Uri(@"https://******/trunk"), new SvnLogArgs { Start = 1725, End = SvnRevisionType.Head }, out baseRevs);
baseRevs.Reverse().Where(r => !revisions.Contains(r.Revision) ).Select(x => x.LogMessage).Dump();
}

希望这对其他人有帮助,尽管我会注意到它没有我在生产代码中放入的大量健全性检查 - 这是快速和肮脏的版本。

关于c# - 使用 SharpSvn 获取 "mergable revisions",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38386103/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com