Is there any way to compare lines of code between two clearcase versions , or for that matter whatever the version controller , I want to compare two different version say compare main branch with the development branch. I'm looking this topic for Java
-
1What platform are you on? It sounds like you're using a VCS, which one? Are you using Eclipse? There are many, many file difference viewers out there, there's probably one in your VCS assuming you use an eclipse plugin. – Falmarri Dec 01 '10 at 20:05
-
You can use the version control system to compare branches. I'm not sure how it can be done in another tools, but `cvs`, `svn` support this. Also, `diff` for Unix, Linux, Mac OS X, `fc` for windows are utilities to compare files and directories. – khachik Dec 01 '10 at 20:17
-
The question is tagged clearcase which is a commersial VCS. Answers related to svn will not be of any use here. – hlovdal Dec 04 '10 at 17:41
5 Answers
if you need to compare+view+edit the lines then VonC's recommendation of WinMerge is excellent, but if you need to compare the Number Of Lines Of Code (count) then a sloc diff tool like ProjectCodeMeter or CLOC would be better.

- 36
- 2
-
-
The one thing I'm looking for though is some count of lines of code for other projects so that I can tell my manager "our project compares to the size of .... " – Someone Somewhere Jan 25 '12 at 23:36
-
Google Safe Browsing currently flags http://www.projectcodemeter.com/ as being dangerous. "The site ahead may contain harmful programs". – Alex Mar 03 '21 at 10:58
While you can use any diff/merge tool (like WinMerge on Windows) to get a comparison on an all set of files, I would recommend using:
- two ClearCase views with the right configuration to select the right versions
- two dynamic views in order to quickly get all the relevant versions (snapshot views would be too long to load)

- 1,262,500
- 529
- 4,410
- 5,250
there are loads of merge/diff tools. i use meld which has great visualisation and handling of file and directory comparision

- 29,118
- 24
- 122
- 168
If the only thing you want to do is to count lines and you are using svn I suggest you to run
svn blame -r N:M | wc -l
I cannot check that this command line is working right now but the idea is to use svn blame
between 2 interesting revisions (N and M) and then run wc -l
(line count).
I believe that every source control has command similar to svn blame
.

- 114,158
- 16
- 130
- 208
You can as VonC suggest use two different views. Alternatively you can use the file@@version
syntax to access both versions directly if you know exactly what you are looking for. Two views are probably the best option if you are going to automate something (which implementing something in java suggests to me).
When you say "compare lines of code between two clearcase versions" I assume you are looking for something other than the standard cleartool diff
(btw, KDiff3 is an excellent diff utility which have clearcase integration, I highly reccommend it), and assume it is more in the "count number of lines" direction you are looking.
However just counting difference in lines will only give limited information, usually it is also interesting to know if the lines that constitutes the difference are mostly added or removed. To give this kind of information you can use diffstat (see this answer for example output).
At my last job I wrote a java gui for running
diff -u file@@/main/branch1/LABEL1 file@@/main/branch2/LABEL2 | diffstat
given two labels, iterating over several files, but I then depended on bash, diff and diffstat from cygwin, I am not aware of any pure java alternatives here.