简体   繁体   中英

Accessing Source Depot Changelists from C#

For my current project, I need to compare two build versions of a program and generate a report showing which files have changed. My own idea was to run through each file using the file system, comparing dates modified. It was suggested, however, that I instead find the changelists stored in Source Depot and compare that way.

Being unfamiliar with Source Depot, I was able to find two relevant commands - "changes" and "changelist". However, the documentation is very vague about explaining how to use the SD commands, and typing something like "sd changes 1249191" results in errors like "must create client 'MGURL' to access local files". The other problem is that even if I had that aspect working, making a call with "System.Diagnostics.Process.Start" would most likely only print info to the console and not return any data to me from within C#.

I think what I really need is a library similar to the Microsoft.TeamFoundation for TFS. However, I've found little to no info online about Source Depot at all, let alone a way to interface with it through C#. Anyone have any insights? Have you done something like this before?

Check out the internal toolbox website for Source Depot utilities. There should also be a internal email alias for Source Depot questions like this...

The solution I found was two-fold, and this was partly due to my own research into the tool and partly from a colleague's suggestion.

Firstly, upon re-examining the sd command list, I found I wasn't looking at the right commands to get the info back that I wanted.

Secondly, there is no way to directly interact with source depot, but I can redirect the console's output back to me by using RedirectStandardOuput:

Process process = new Process();
process.StartInfo.UseShellExecute = false;
process.StartInfo.RedirectStandardOutput = true;
process.StartInfo.FileName = "sd.exe";
process.StartInfo.Arguments = string.Format("describe {0}", newChangelist);
process.Start();

// read strings from process.StandardOutput here

process.WaitForExit();

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM