output file difference and type

This forum is now locked, since Gold Support is no longer offered.

Moderator: SourceGear

Locked
kschmeichel
Posts: 5
Joined: Thu Jun 09, 2005 2:12 pm

output file difference and type

Post by kschmeichel » Mon Jun 13, 2005 8:28 am

Is there a way to compare the current vault file with the previous and output only the differences?

ie: line 235: added: string s = "this is an added line"

I have looked through posts and the API, but nothing sticks out.

thanks,

dan
Posts: 2448
Joined: Wed Dec 17, 2003 5:03 pm
Location: SourceGear
Contact:

Post by dan » Mon Jun 13, 2005 9:04 am

Our diff tool is setup to display the entire file, and graphically mark differences. However, we also support the ability to use different diff tools, so if you have one that will display just the differences, you can specify it under Tools->Options->Diff/Merge.

jeremy_sg
Posts: 1821
Joined: Thu Dec 18, 2003 11:39 am
Location: Sourcegear
Contact:

Post by jeremy_sg » Mon Jun 13, 2005 9:38 am

If you're willing to dig into the client API, you could try using the Blame function to get close.

http://weblogs.asp.net/jeremy_sheeley/a ... 12/15.aspx

kschmeichel
Posts: 5
Joined: Thu Jun 09, 2005 2:12 pm

Post by kschmeichel » Mon Jun 13, 2005 11:06 am

Thanks for the suggestions.

I was hoping the API had functions to automatically get the differences, ie: VaultFile.GetNewLines, .GetRemovedLines, etc.

when comparing two files...

Any other ideas that may send me in that direction? The blame function just uses Regex to find matching strings.

jeremy_sg
Posts: 1821
Joined: Thu Dec 18, 2003 11:39 am
Location: Sourcegear
Contact:

Post by jeremy_sg » Mon Jun 13, 2005 11:14 am

I think that my article wasn't clear about what blame does in general, as opposed to the purpose I put it to for the example code. Blame on the server loads the last 20 versions (by default) of a file and compares them, noting which version was the last to touch a particular line, along with the user and comment for that version. This won't tell you if the line was added versus deleted, but it will give you a line by line history of the file.

As for the example, blame does not use a regex. The example code used a regex to parse the output of a build to find out which line failed to build. The line number was then fed to blame to determine who the last user to change that line was.

You can see a graphical representation of blame in the GUI client by selecting a file and choosing Show Blame from the View menu.

Blame is built off the SGDiff library, which ships with Vault. You could use SGDiff to analyze the two versions of a file and report back lines added/deleted/changed. You would need to download the two versions to a place on disk first.

kschmeichel
Posts: 5
Joined: Thu Jun 09, 2005 2:12 pm

Post by kschmeichel » Mon Jun 13, 2005 11:21 am

That sounds exactly like what i want to do. Thank you.

kschmeichel
Posts: 5
Joined: Thu Jun 09, 2005 2:12 pm

Post by kschmeichel » Mon Jun 13, 2005 12:28 pm

ok, im with you so far. I am able to get the VaultBlameNodes returned which includes the person, # of lines, first/last lines, etc....

Now is there any easy way to extract the actual content of those lines?

so I could have

308 string s = "hello"
309 ' This is a comment that was added (or removed)

Thanks in advance.

jeremy_sg
Posts: 1821
Joined: Thu Dec 18, 2003 11:39 am
Location: Sourcegear
Contact:

Post by jeremy_sg » Mon Jun 13, 2005 12:40 pm

In the blame web page, I use a SourceGear.diff.FileOfLines Lines = new SourceGear.diff.FileOfLines(strTempFile); from the SGDiff library.

Locked