问题
I have written a simple C# app using SharpSVN to query the status of a file prior to attempting an add. The examples I've seen in various places for this very purpose involve calling the GetStatus method of the SvnClient, passing in the full path and an out parameter to a collection of SvnStatusEventArgs.
My understanding is that, for a file, GetStatus should return with an SvnStatusEventArgs collection having a count of exactly one, with a status among NotVersioned, Missing, Normal, and so on.
In my application, my call to GetStatus to a file under source control returns a Collection count of zero.
SvnClient foo = new SvnClient();
Collection<SvnStatusEventArgs> statuses;
foo.GetStatus("C:\\Temp\\svnu\\Program.cs", new SvnStatusArgs {Depth = SvnDepth.Empty}, out statuses);
The value of statuses.Count is zero, when I am expecting 1 with a statuses[0].LocalContentStatus value of Normal. Is this expectation incorrect? For a call to a path referencing a file not in source control, the call works with a status[0].LocalContentStatus value of NotVersioned.
The path is verified to be a working copy, and the file Program.cs is, in fact, enlisted in Subversion. I'm running SharpSVN version 1.7005.2163.13448 and VS2010.
Many thanks in advance for clearing up my obvious confusion.
EDIT Some more info: After modifying, but not committing, Program.cs, this same code snippet now returns a single status value with LocalContentStatus of "Modified." After committing the file, the original behavior (no returned status value) returned.
回答1:
Apologies for the delay in getting the answer posted based on Bert Huijben's feedback. I'm posting the answer here just FYI for everyone's benefit.
Modifying the original GetStatus call to set the RetrieveAllEntries
property of the SvnStatusArgs object did, in fact, solve this problem, and causes local (but uninteresting :) ) copies of files to have a return status count of 1, with a .LocalContentStatus of "Normal," as desired.
foo.GetStatus("C:\\Temp\\svnu\\Program.cs", new SvnStatusArgs {Depth = SvnDepth.Empty,
RetrieveAllEntries = true}, out statuses);
Many thanks.
来源:https://stackoverflow.com/questions/11130666/svnclient-getstatuspath-args-statuses-returning-0-for-versioned-file