views:

205

answers:

3

Walking the line here, I know, but... How does StackOverflow show the revision changes in the diff-like format they use.

I don't care about SO per-se, it's just a convenient way to describe my requirement. I have an audit history of changes to a text field. I'd like to show the changes the same way SO shows revision history changes. I recall a SO podcast where Jeff discussed it, but can't find it in the transcripts and have no idea what podcast. IIRC, it's not .net based, maybe Python?

This is for end-user consumption so anything that looks like a unix-like diff is out. Tempting to show two blocks and text, old and new and let them figure it out, but the SO revision history is sooo much nicer.

Thx.

+2  A: 

The Python difflib standard library provides this sort of capability:

This module provides classes and functions for comparing sequences. It can be used for example, for comparing files, and can produce difference information in various formats, including HTML and context and unified diffs. For comparing directories and files, see also, the filecmp module.

Greg Hewgill
difflib seems to do line at a time diffing only. I'm looking for the in-line diffing that SO uses. Maybe I can use it though.
WaldenL
difflib can compare any two sequences; whether those are sequences of lines, characters, words, sentences, or images is up to you. I have used difflib to compare text at the word level and it works well for that.
Greg Hewgill
A: 

They used Beyond Compare. As far as I can tell, it's not a native .NET program, but you can use it as a command-line tool.

Nikhil Chelliah
I'm not sure that's correct. I beleive that's what the use on the development side (diffing source revisions, db scripts etc.) and not what they use for displaying the revisions online.
WaldenL
+1  A: 

Since you didn't really specify a language: I've done this using the PHP PEAR package Text_Diff.

Paolo Bergantino
Seems to have some promise. Need to figure out how to serve this up from w/in an asp.net app. Perhaps a php server on the back end that I can access from server-side code.
WaldenL
@WaldenL you can make a soap service in PHP. Last time I did it you had to manually make a WSDL, but somone finally made a soap object you can inherit and all your public functions get exposed in a WSDL automatically.
Justin Dearing