Update: If you just want a solution, the scripts for 3-way merging from within ClearCase are here. It seems some people are too hasty and seriously overlook the fact that it’s there in section 4. (see the first comment for instance)
Here’s the deal:
Araxis is nice, ClearCase is nice, let’s double the niceness.
There’s some info on how to use Araxis Merge with ClearCase: [1] for comparing files. Nothing about merging in ClearCase, though… (Update: this very page is linked there, so the last sentence is not true anymore)
1. Wrapper
ClearCase has type managers defined here:
ClearCase-dir\lib\mgrs\map
See [2], there’s also a description of a less blunt way of using type managers. The contents of the map file are straightforward:
each line is:
type-manager clearcase-action called-application
eg.
text_file_delta xcompare ..\..\bin\cleardiffmrg.exe
text_file_delta xmerge ..\..\bin\cleardiffmrg.exe
calls cleardiffmrg.exe to do a visual merge/visual compare of a file of text_file_delta type. That’s the lines we’ll want to hack…
It would be handy to use perl to play around with different parameters, rather than parse them in c++. Since ClearCase seems to expect an exe file, we need to craft some exe wrapper. Here’s the VC++ source: wrapper.cpp it just calls the merge.pl script with the parameters that it got, and returns the value it gets from merge.pl script. Simple. (never thought that argv strips the quotes from quoted parameters…). Now we replace ..\..\bin\cleardiffmrg.exe with the path to wrapper.exe that we just crafted.
2. Basic script
I made the first version of script quite neutral:
`echo cleardiffmrg.exe @ARGV >> some_log_of_mine`
exit system("cleardiffmrg.exe @ARGV");
just to see what happens under the hood. The script isn’t so neutral BTW (never thought that argv strips the quotes from quoted parameters…)
3. And this happens under the hood:
Assuming we are merging a file called file :-)
in dynamic view* clearcase calls cleardiffmrg with these arguments**:
-base common-ancestor-version -out file.merge source-version file
when the merge is successful, cleardiffmrg creates the file.merge.
cleardiffmrg returns to clearcase.
The dialog that appears (saying that that the merge was successful or not) depends on the return value from cleardiffmrg. The merge arrows are drawn depending on the existence of the file.merge.
* snapshot view has basically the same set of arguments, but the arguments not available in the view, are paths in the vob database. since this is not quite readable, the -fname arguments provide the titles of the panes in merge window. This -fname thingy is not limited to only snapshot views, which makes it quite handy, one can for example do a diff between two views, and explicitly put proper information in the window pane titles like this:
cleartool diff -graph -options "-fname bla1 -fname bla2" file-in-view1 file-in-view2
** if file.merge exists, it uses file.merge.1, file.merge.2 and so on. Actually it is not important as long as the file is passed as a parameter.
4. Less basic script
Now that we know the parameters, we can call Araxis compare.exe. The script and wrapper are here, together with a setup script for XP. NOTE: If you happen to use the scripts and something breaks, that’s because you shouldn’t have used it in the first place ;-). Actually nobody has been complaining yet, and it’s got already almost 1500 downloads. So it seems fairly safe…
5. Reality check - ongoing
For now, reality sucks. I must be able to force the user to merge to the right version, and force him to resolve all the differences, before closing, and compare.exe doesn’t do that. Maybe this could be solved playing with compare.exe examples, but I don’t have much time on my hands, and I am not even able to convert the sample vc++ 7 project to vc++ 6. . Forget it, I have been too conditioned by using the ClearCase merge. That subsided quickly :-)
Update 2007-11-06: As Jamil Taylor mentioned, CC 7 has a misbehaving perl version. As a result, the checks I made for contents of $! were failing. $! was set to “Bad file descriptor” despite `reg …` being successful. So I made a cleaner version of the install script which now uses Win32::TieRegistry instead. The merge script itself hasn’t changed. Old version here.
Update 2007-2-22: There’s an Araxis Merge 2007 preview, which uses a different registry key. I added it to the setup script.
Update: People are complaining that things don’t work after installing the merge script. The script sets a system variable. So don’t expect that you will be able to install it when in merge manager/version tree/etc., as they were started in the old context, so no variable was set at the time.
[1] http://www.araxis.com/merge/scm_integration.html
[2] http://www.guiffy.com/GuiffyHelp/ClearCase.html