Need script/utility to label MOST, if not all, Cle

2019-05-30 05:22发布

问题:

I found out that labels must be applied starting at the VOB if you want to successfully recreate a specific code (label) release. I thought you wouldn't have to start at the VOB name but you do :-(

My VOB has many programs in it. For example:

VOBname\programs\Java\Program1\files...
VOBname\programs\Java\Program2\files...
VOBname\programs\VB\Program1\files...
VOBname\programs\VB\Program2\files...

What I would like to do is have a script or program that takes two parameters, a path and label, and applies that label to the proper directories and files in that path.

It should not apply the label to other, non related, directories (i.e., if I am labeling Java\Program1 it should not also label Java\Program 2.

I also need the reverse - If someone incorrectly applies the label, then I need to remove the label from the path.

It seems like this feature would have been incorporated into the GUI or a script long ago but I don't see one available. Of course, you can do this manually but this takes longer especially if you have a long path.

I know you can label a directory and all contents underneath that directory but if you start at the VOB, that would label everything (what I don't want).

回答1:

The simplest solution is to:

  • apply recursively a label from the path

    cd /path
    cleartool mklabel -replace -recurse LABEL
    
  • for a given path, extract the parent folders, and label those:

    avob/
    avob/aParentFolder
    avob/aParentFolder/aParentSubFolder
    

Depending on your scripting language, extracting the parent folders can be as easy as perl File::Basename

my($filename, $directories, $suffix) = fileparse($path);
# On Unix returns ("baz", "/foo/bar/", "")
fileparse("/foo/bar/baz");


标签: clearcase