Saturday, June 18, 2011

ClearCase - Promote Files From Sub Branches to Main Branch

ClearCase is a source control management (SCM) tool from IBM. I use ClearCase in the company that I'm working on right now. There are many things to learn for ClearCase and I find that it is so complicated. We have to deal with the cleartool commands most of the time to get something done.

There are times where we need to promote the codes from our development branch to the main branch, especially after the codes go into production. The purpose of doing so is ensure that all the related source files from development branch are "copied" to the main branch and the changes are visible in the future branches sprout out from main branch. We just don't want to miss any changes. Besides that, having the changes promoted to main also means that, the config spec of the future branches will be much more cleaner and will not dependent on the past release branch.

The promote to main process can be automated by using a series of cleartool commands. There is an article in IBM website that guide us how to do so, which you can refer it here. However, when we did it for my company, we found out some issues (perhaps it is more suitable to say, need some enhancement) on the cleartool commands provided from that article. The problem is when we have some files with very large version tree that never promote to main before. New branch sprout out from previous development branch and it keeps going on like that for few years. For this kind of files, we encountered failure in copying the files from development branch to the main branch. It failed at the native windows copy command. This is because, when the file's version tree grows huge, the version extended pathname also grows. When the path grows exceeding the pathname limitation of windows, the copy command will fail.

To prevent this, we can simply replace the windows copy command to use cleartool get command. However, there are some limitations using get command. The command only support static / snapshot view and it can only be used to copy file elements. Here's an example of using the get command in windows environment (make sure you run the command in the root directory of your clearcase view):






What the command above does is to first, find a file that we want to perform the "get" operation using the cleartool find command. After that, perform the get command towards the target file.

There are 2 ClearCase variables being used here, which are: %CLEARCASE_PN% and %CLEARCASE_XPN%. The first variable represents the file(s) on the branch your current view is pointing to (we usually set the current view to main branch for this purpose), while the latter, represents the development branch where you would like to get the file(s) from.

From my experience on this, it tells me that we should always plan, control and manage the source repository carefully which will save us a lots of time solving unforeseen issues.

No comments:

Post a Comment