Reputation: 18895
I have a tool that generates C# files. I've been able to programmatically checkout the file using this method:
private static void CheckoutFile(string fileName)
{
var workspaceInfo = Workstation.Current.GetLocalWorkspaceInfo(fileName);
var server = new TfsTeamProjectCollection(workspaceInfo.ServerUri);
var workspace = workspaceInfo.GetWorkspace(server);
workspace.PendEdit(fileName);
}
But after the file has been generated I want to determine if there has been any changes to the file, and if not, to undo the check out. How do I do that with the TFS SDK?
Upvotes: 1
Views: 1052
Reputation: 78883
Fundamentally, the TFS clients (tfpt uu
, for example) determine whether you've changed a checked-out file by comparing the hash of the local file against the hash of the server item at the version that you have in your workspace.
To implement this behavior:
workspace.VersionControlServer.GetItems(fileName, new WorkspaceVersionSpec(workspace), RecursionType.None)
Item
's HashValue
with the value computed in step 1.Upvotes: 2