Progammatically getting the diff between two changesets
![]()
I have succeeded in programmatically loading and updating a file, but now wish to view the diff between the two changsets. In RTC, using firebug, I can see that the diff is performed:
I'm using RTC 2.0 rc2 btw Does anyone have any idea how I can access that diff using plain java? If more information is needed, please just shout! TIA, Crispin |
7 answers
![]()
Ok, I'll try a different tack. Does anyone know how the diff is extracted? Is it by doing a system call to to diff (I guess not, because RTC is available for Windows as well), or is there some implementation of diff in java which is not GPL'ed, and therefore suitable for commercial/proprietary use?
Thanks in advance, Crispin |
![]()
Crispin,
RTC uses its own implementation of an LCS based diff algorithm to generate the diff. The RTC implementation is not API but you can still look at it as it is available in the RTC source code (com.ibm.team.filesystem.common.internal.patch.LCS). This is only the low level portion of the patch generation. The code that determines what contents need to be compared is tightly coupled to the UI and is highly generalized (or, in other words, very complicated ;-) and there is no high level API in RTC for this. The command line also performs diffs. Perhaps you coudl use the command line client to get the diff you want. Michael crispibits wrote: Ok, I'll try a different tack. Does anyone know how the diff is |
![]() Crispin, Aha! Ace, thanks Michael - I'll have a gander now. I can already extract the file content for different versions of a file, so this might do the trick! |
![]() The code that determines what Blimey, you're right, it is a tad complicated isn't it? So far I've got:
I must say I'm flying blind here, and no idea if this will ever run, as I'm guessing what most of the objects/methods are or do. The last thing I can't work out before I finally debug all the NPE's that are bound to come my way is the IPathResolver. Any ideas what it is or how I get/set/create one? I don't really want to use the cli as I'm doing all this programmatically. Thanks again, Crispin |
![]()
Blimey indeed.
If you're digging around in the source, I recommend that you take a look at the CLI's 'diff' subcommand (com.ibm.team.filesystem.cli.client.internal.subcommands.DiffCmd). It sounds like its functionality is close to what you're looking for, and it has the advantage of being somewhat self contained. Start by looking at getFileStateFromChangeSet(), as it extracts a change from a change set. Regarding the diff: skip the whole diff thing, and pull the before and after states from each change set. You can then use external utilities/libraries to do the comparison and produce the diff. As Michael says, our libraries are complex. =) Out of curiosity: What are you trying to do? e |
![]() Blimey indeed. Your libraries, complex? Surely not ;-) I'm not envious of the people maintaining it I must say! What I'm trying to do is use the PlainJavaClient libs to write an interface to a (Tivoli) product to enable basic and easy web-side upload/checkin/compare of files. I've got all the basics pretty much together, so I can pull out two files (any version) from SCM - but currently I am actually doing a system call i.e:
This is fine if a) You know diff is on the system b) You're running *nix, cygwin or ported diff. c) You aren't running scared of the GPL d) You don't know that RTC already has the capability to do it already in there somewhere! The SCM CLI's diff command would do the job (and several others), but I can't seem to find the source for that (any pointers gratefully received!) Cheers, Crispin |
![]()
In our defense, I'd like to point out that we're the folks who maintain it. :-)
Assuming this is for an in-house tool, I'd suggest looking for a non-GPL LCS implementation. e |