tags:

views:

1506

answers:

3

I've previously documented my opinions on Clearcase as a source control system, but unfortunately I am still using it. So I turn to you guys to help me alleviate one of my frustrations.

We have just moved from a one-branch-per-developer system, to a one-branch-per-task in an attempt to improve some of the issues that we've been having with determining why certain files were changed. Generally I am happy with the solution, but there is one major issue. We are using simple scripts to start and end tasks which create a new branch named with the username and task number and then updates the local snapshot view to have a config spec similar to the following:

    element * CHECKEDOUT 
    element * .../martin_2322/LATEST  
    element * /main/LATEST -mkbranch martin_2322 
    load /Project/Application

Let's say that my project has two coupled files A.cs and B.cs. For my first task I make changes to A on the branch. Then I need to stop working on task 2322 for whatever reason and start work on task 2345 (task 2322 is not finished, so I don't merge it back into main). I create a new task branch 2345, edit both A.cs and B.cs and merge the results back into main. Now I go back to work on 2322, so I change my config spec back to one defined above. At this point I see the A.cs file from the task branch (as I edited it earlier, so I get the version local to that branch) and the latest version of B.cs from main. Since I don't have the changes made to A.cs on the 2345 branch the build breaks. What I need instead is to be able to pick up task 2322 from where I left off and see it with the old version of A.cs - the one that was latest in main when the branch was created.

The way I see it I have a few options to fix this:

  • Change the config spec so that it gets files from main at the right date. This is easy enough to do if I know the date and don't mind setting it by hand, but I can't figure out how to automate this into our task switching scripts. Is there anyway to get the creation date of a branch?

  • Create a label for each branch on main. Theoretically simple to do, but the labelling system in our install of CC is already collapsing under the weight of a few hundred labels, so I don't know if it will cope with one per developer per branch (notice that the task in my example is 2322 and we're only about an quarter of the way through the project)

  • Merge out from main into the task branch. Once again should work, but then long running branches won't just contain the files changed for that task, but all files that needed to be merged across to get unrelated things working. This makes them as complicated as the branch-per-developer approach. I want to see which files were changed to complete a specific task.

I hope I'm just missing something here and there is a way of setting my config spec so that it retrieves the expected files from main without clunky workarounds. So, how are you guys branching in Clearcase?

+1  A: 

We use Clearcase, and we find that creating a branch for a release is often much easier than doing it by task. If you do create it by task, then I'd have a 'main branch' for that release, and branch the tasks off that branch, and then merge them back in when finished to merge them back to the trunk.

George Stocker
Your suggestion of main branch / branch for release / branch for task / is exactly what we are doing, but that leads to the problem outlined above where you can't really work on two tasks in parallel. We were branching per developer, which meant that we didn't get these problems as all tasks were in the same branch, but as there is no "unit of work" concept in Clearcase it became impossible to determine which changes belonged to which task.
Martin Harris
Yes you can. Create two views, one for each 'task'. You then can use the diff tool and the ability to merge changes to port changes from one branch to another.
George Stocker
I get the feeling that what you are saying here is useful, but I'm just not understanding it. When you say views do you mean snapshot views? I'm not really looking to merge changes from one branch to another, I'm looking for a system where changes that are merged into main don't get shown in already existing branches.
Martin Harris
If you take out the line of the config spec: element element * /main/LATEST -mkbranch martin_2322 then you won't get the changes to main automatically.
George Stocker
+1  A: 

You can get the creation date for a branch by using the describe command in cleartool.

cleartool describe -fmt "%d" -type martin_2322

This will printout the date and time that the branch was created. You can use this to implement your first option. For more information, you could read the following cleartool man pages, but hopefully the above command is all you need.

cleartool man describe

cleartool man fmt_ccase
A. Levy
Perfect, thanks. I don't have time today to put my batch writing skills to the test and fix our start task scripts, but at the very least I can easily find the right time to update the config spec by hand.
Martin Harris
+3  A: 

A few comments:

  • a branch per task is the right granularity for modifying a set of file within a "unit of work". Provided the "task" is not too narrow, otherwise you end up with a gazillon of branches (and their associated merges)

  • when you create a config spec for a branch, you apparently forget the line for new elements (the one you "add to source control")

  • Plus you may consider branching for a fix starting point, which would solve the "old version of A.cs - the one that was latest in main when the branch was created" bit.
    I know you have too much labels already, but you could have a script to "close" a task which would (amongst other things) delete that starting label, avoiding label cluttering.

Here the config spec I would use:

element * CHECKEDOUT 
element * .../martin_2322/LATEST  
element * STARTING_LABEL_2322 -mkbranch martin_2322 
# selection rule for new "added to source control" file
element * /main/0 -mkbranch martin_2322 
load /Project/Application

I would find this much more easier than computing the date of a branch.

  • do not forget you can merge back your task to main, and merge some your files from your finished task branch to the your new current task branch as well, if you need to retrofit some your fixes back to that current task as well.
VonC
Thanks for the comments, I haven't run into any problems with my config spec and adding new files, but I'll take another look at it. I agree that labels would be the best way, but there are various logistical issues with doing anything that has a footprint on the server so right now it isn't really an option. Good to know that I was on the right path though and not missing a "Make task branch that works the way I want command" - that was my main fear.
Martin Harris
> I haven't run into any problems with my config spec and adding new files. Hum... I would look into that indeed: with your current config spec, a new file would be directly visible in the main branch! (no isolation). If that new file is then modified, it would be in the task branch. I would recommend creating a new file directly in the task branch, merging it back in the main branch only when needed.
VonC