1

I am having 2 branches: Branch-1: Stable Branch, Branch-2: Develpoment Branch.

There are several checked-in nodes in Branch-2. Out of them, around 3 nodes have labels: L1, L2 & L3:

x  [Branch-1: Stable Branch (only one node)]
   \ 
    x - x - x (L1) - x - x(L2) - x (L3) - x - x 

[Branch-2: Dev Branch (several checked-in
 nodes), 3 nodes labelled with: L1, L2, L3 => I want to copy these 3 nodes 
 to Branch-1]

Can you please provide a clearcase command to do this?

Thanks.

Best Regards,

Sandeep Singh

Sandeep Singh
  • 4,941
  • 8
  • 36
  • 56

1 Answers1

0

First you need a dynamic view:

So you define a dynamic view for updating Branch1 (ie with a selection rule ending with -mkbranch Branch1: see "How to create a branch" for the three selection rules you need).

Then you need to find each relevant versions for L1 and copy them on top of your current view, putting a different label on that new version in Branch1 (create a L1B1 lbtype first, for instance):
Windows syntax:

 cleartool find . -ver "lbtype(LBL1)" \
 -exec "cleartool co -c \"LBL1 import\" \"%CLEARCASE_PN%\" ; \
        cp \"%CLEARCASE_XPN%\" \"%CLEARCASE_PN%\" ; \
        cleartool ci -nc \"%CLEARCASE_PN%\" ; \
        cleartool mklabel –replace L1B1 \"%CLEARCASE_PN%\""

(in one line: cleartool find . -ver "lbtype(LBL1)" -exec "cleartool co -c \"LBL1 import\" \"%CLEARCASE_PN%\" ; cp \"%CLEARCASE_XPN%\" \"%CLEARCASE_PN%\" ; cleartool ci -nc \"%CLEARCASE_PN%\" ; cleartool mklabel –replace L1B1 \"%CLEARCASE_PN%\"")

Unix syntax:

 cleartool find . -ver "lbtype(LBL1)" \
 -exec "cleartool co -c \"LBL1 import\" \"$CLEARCASE_PN\" ; \
        cp \"$CLEARCASE_XPN\" \"$CLEARCASE_PN\" ; \
        cleartool ci -nc \"$CLEARCASE_PN\"; \ 
        cleartool mklabel –replace L1B1 \"$CLEARCASE_PN\""

(one line: cleartool find . -ver "lbtype(LBL1)" -exec "cleartool co -c \"LBL1 import\" \"$CLEARCASE_PN\" ; cp \"$CLEARCASE_XPN\" \"$CLEARCASE_PN\" ; cleartool ci -nc \"$CLEARCASE_PN\"; cleartool mklabel –replace L1B1 \"$CLEARCASE_PN\"")

CLEARCASE_XPN reference the full extended pathname, accessible from a dynamic view, CLEARCASE_PN references the path without the extended path, ie without the part after the @@.
There are environment variables set by the cleartool find command, hence the %...% or $ used.

Repeat that for L2 and L3, and you will get, for a given file:

x - y (L1B1) - y (L2B1) - y (L3B1)  [Branch-1: Stable Branch (only one node)]
 \ 
  x - x - x (L1) - x - x(L2) - x (L3) - x - x 
Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • Thanks a lot for the reply. But if I am having a large code-base, is there any way of doing the same with the help of Labels only, rather than working on individual files? – Sandeep Singh Dec 29 '11 at 13:44
  • @SandeepSingh: please read http://stackoverflow.com/questions/645008/what-are-the-basic-clearcase-concepts-every-developer-should-know/645771#645771: ClearCase always works file-by-file. But the `cleartool find` is there to help you apply a sequence of commands for each version found with a specific label. So you need to repeat the `cleartool find` command I mention only for each label name, not for each file. It will checkout, copy, checkin and apply a new label (`L1B1`) for each file found with a version already labelled `L1`. So in that respect, you will work with the help of labels. – VonC Dec 29 '11 at 15:13
  • @SandeepSingh: so did you manage to make it work? Don't forget you can first test it with a more simpler find command: `cleartool find . -ver "lbtype(LBL1)" -exec "echo \"%CLEARCASE_XPN%, %CLEARCASE_PN%\""` in order to display the version to copy, and the file to overwrite. Then you can try the more complete and complexe sequence of commands within the "`exec`" directive. – VonC Dec 30 '11 at 08:17
  • Happy New Year & Thanks a lot for your help. This time, I was not able to make it. Faced issues even after giving absolute paths for file names. I resolved the issue through merging & then automatic labeling (through a script - for intermediate nodes). Actually, I was working on a development branch. We placed 3 major labels on the code. Now, the last job was to bring the labeled nodes on the destined parent branch. I will certainly give this method a better try so that I don't face this problem in future. – Sandeep Singh Jan 01 '12 at 06:57