按照此处找到的代码: How to check if file is under source control in SharpSvn?
我正在尝试制作一个小型实用程序,它将遍历指定的文件夹并打印出所有文件的状态。
private void btnCheckSVN_Click(object sender, EventArgs e)
{
ParseSVNResults(CheckSVN());
}
private Collection<SvnStatusEventArgs> CheckSVN()
{
string path = @"C:\AMG\trunk\AMC";
if (!Directory.Exists(path))
return null;
DevExpress.Utils.WaitDialogForm wait = new DevExpress.Utils.WaitDialogForm();
wait.Caption = "Please wait, loading SVN file statuses. This may take a moment.";
wait.Caption += Environment.NewLine + path;
wait.Show();
SvnClient client = new SvnClient();
SvnStatusArgs sa = new SvnStatusArgs();
sa.Depth = SvnDepth.Infinity;
Collection<SvnStatusEventArgs> statuses;
client.GetStatus(path, sa, out statuses);
wait.Close();
return statuses;
}
private void ParseSVNResults(Collection<SvnStatusEventArgs> results)
{
if (results == null)
return;
int modified = 0;
int unversioned = 0;
foreach (SvnStatusEventArgs item in results)
{
memoEditSVNFiles.Text += item.LocalContentStatus.ToString() + " -- " + item.Path + Environment.NewLine;
if (item.LocalContentStatus.ToString() == "Modified")
modified++;
else if (item.LocalContentStatus.ToString() == "NotVersioned")
unversioned++;
}
memoEditSVNFiles.Text += Environment.NewLine + "Modified: " + modified + Environment.NewLine;
memoEditSVNFiles.Text += "Not Versioned: " + unversioned + Environment.NewLine;
memoEditSVNFiles.Text += "Total: " + results.Count;
}
当代码执行时,我总共得到147个文件&amp;文件夹。实际文件夹有几千个文件。有可能我正在查看太多文件而SharpSVN会在一段时间后退出吗?
编辑;我只是尝试创建大约100个文本文件并将30个放入3个文件夹,然后“嵌套”它们。所以我有;
C:\ AMG \ trunk \ test,有~30个文件 C:\ AMG \ trunk \ test \ Folder1有~30个文件 C:\ AMG \ trunk \ test \ Folder1 \ Sub还有另外30个
如果不将此操作存储到存储库,当我在C:\ AMG \ trunk \ test而不是我的代码片段中的给定路径上运行上述代码时,输出将显示1个文件。
答案 0 :(得分:2)
事实证明,SvnStatusArgs类有一个“RetrieveAllEntries”布尔标志,默认为false。
顾名思义,将此设置为true将返回每个文件,无论是修改/未修改还是最新。
我原帖中的CheckSVN()方法中有1行:
SvnClient client = new SvnClient();
SvnStatusArgs sa = new SvnStatusArgs();
sa.Depth = SvnDepth.Infinity;
sa.RetrieveAllEntries = true; //the new line
Collection<SvnStatusEventArgs> statuses;
client.GetStatus(path, sa, out statuses);