## C# API To get Diff btwn Current and Previous Check in

Post your questions regarding using the Vault and Fortress API in your programs.

Moderator: SourceGear

jclausius
Posts: 3617
Joined: Tue Dec 16, 2003 1:17 pm
Location: SourceGear
Contact:

### Re: C# API To get Diff btwn Current and Previous Check in

ejhansen71 wrote:how do I actually get the diff?
The answer to this will depend on what diff utility you are using.

If you are using Vault's DiffMerge or SourceGear's full blown DiffMerge utility, try adding the '{-d | -diff}="\\path\to\diff\output.diff" ' to the Diff process's arguments For example, '-d="C:\Temp\output.diff"'

If you are using a different diff utility, refer to its documentation regarding outputting the diff to a file.
Jeff Clausius
SourceGear

ejhansen71
Posts: 58
Joined: Thu Nov 13, 2014 10:12 am
Location: Lake in the Hills, IL

### Re: C# API To get Diff btwn Current and Previous Check in

I never get a file with differences. Can you find a problem with my code?

"plink.exe -P 44022 ehansen@ghelsiapp \"DIFF -repository \"Chicago\" -vaultdiff_options \"{-diff=\"J:\\vault\\logs\\test.test.diff\"}\" -compareto lastget \"$/DATAOps/custom/test.test\"\"" Breaks down to : DIFF -repository "Chicago" -vaultdiff_options "{-diff=\"J:\\vault\\logs\\test.test.diff\"}" -compareto lastget "$/DATAOps/custom/test.test"
<vault>
<result>
<success>True</success>
</result>
</vault>
Return code = 0
This would mean that the files are identical

However, all three items below are different. I've tried lastget, current and repository
Latest Version: $/DATAOps/custom/test.test = "Testing this FIle Is it different than the laST?" Previous Version:$/DATAOps/custom/test.test = "Testing this FIle"
Working File: \\ghprodetl1\DATAOps\custom\test.test = " WRONG Testing this FIle" <--Made change to this to see if current or repository would work.

I even tried the C# API ProcessCommandDiff() method. It kept failing complaining that the right file was null no matter what compareTo object I passed. Even the ones that didn't need a right file. I know this only because I copied out the method and its supporting methods into my program so I could trace the problem. Interstingly, we set up an environment variable on all the servers to point to sgdm.exe and in the C# API, it tried to set the program using the environment variable and failed. After the third attempt, I gave up and went back to command line code.
Thanks!

Eric

jclausius
Posts: 3617
Joined: Tue Dec 16, 2003 1:17 pm
Location: SourceGear
Contact:

### Re: C# API To get Diff btwn Current and Previous Check in

Sorry for the confusion. The curly braces you see around the diff argument are not a part of the command. It was there to merely point out you could use -d or -diff for the argument. In the command you provided:

-diff option

Code: Select all

DIFF -repository "Chicago" -vaultdiff_options "-diff=\"J:\\vault\\logs\\test.test.diff\"" -compareto lastget "$/DATAOps/custom/test.test" or you could do -d option Code: Select all DIFF -repository "Chicago" -vaultdiff_options "-d=\"J:\\vault\\logs\\test.test.diff\"" -compareto lastget "$/DATAOps/custom/test.test"
Jeff Clausius
SourceGear

ejhansen71
Posts: 58
Joined: Thu Nov 13, 2014 10:12 am
Location: Lake in the Hills, IL

### Re: C# API To get Diff btwn Current and Previous Check in

Corrected the code. It still always results in "True" with exit code of 0 showing no differences.

test.txt is different from current to lastget.

I set the working folder
I did a GetLatest on test.txt to the workingfolder
I make a change in development to test.txt and check it in
I do a second GetLatest to the working folder
I attempt the DIFF with option lastget
I get "True" Error Code = 0 No differences so no output file.

I am at a loss.
Thanks!

Eric

jclausius
Posts: 3617
Joined: Tue Dec 16, 2003 1:17 pm
Location: SourceGear
Contact:

### Re: C# API To get Diff btwn Current and Previous Check in

You need to control which -compareto operator to use in different situations.

In previous posts, you mentioned trying to determine the changes in a GETLABEL vs. the repository, so your choice of compareto of 'lastget' works here.

In the last post, "I did a GetLatest on test.txt to the workingfolder". Were there any changes made to the working folder copy? The compareto option using 'lastget' will show differences in the working folder copy and the file at the time of the last GET. Since nothing has changed in the working folder copy, there will be no differences. You could try using compareto of 'current' in this case.

Also, from this link http://download.sourcegear.com/misc/vau ... c.htm#DIFF (or running "vault.exe help diff" from the command line) you can see all of the options for '-compareto'. In regards to the initial posts to this thread, have you investigated using the 'label' compareto option?
Jeff Clausius
SourceGear

ejhansen71
Posts: 58
Joined: Thu Nov 13, 2014 10:12 am
Location: Lake in the Hills, IL

### Re: C# API To get Diff btwn Current and Previous Check in

Just a final update to this. I was unable to make it work with the built-in DIFF tool. Instead, I do a GET to a separate folder and then use a third party DIFF tool to do the work.
Thanks!

Eric