Branching from ' 0 ' Version - clearcase

Any one please let me know, How can we create branch from Main 0 -version.
we have Main & The latest Current Version is 50-version. But i want to make branch from O-Version.So that Branch should not ahve any data into it.
Please let me know how can this be done !.

You should be able to do it by modifying the config spec of your view (assuming you are in Base ClearCase, not UCM)
element .../aNewBranch /main/LATEST
element /path/... /main/0 -mkbranch aNewBranch
Note the order:
first try to select the LATEST version of the "aNewBranch",
then select version 0 with possibility of making a branch if there is a checkout
See How a ConfigSpec works and Writing a ConfigSpec for more.

In addition to the answer by VonC, do not assume that branch with name /main always exist. The type of the "main" branch can be changed, so for example it can be called /head instead.

Related

How can I select a specific version of the root folder (.) in a snapshot view (Base ClearCase 7.1.2.9, no UCM)?

Stumbled over this at work yesterday: I have a small VOB and created a snapshot view to access the data (source files) in it. If I give the ConfigSpec as:
load /vob/extern
element * CHECKEDOUT
element * /main/LATEST
, I will see all elements in their "LATEST" version and running a cleartool describe or xlsvtree on a single element can confirm this. Fine.
There is a src folder at the top level, having the versions "0-2", and when I setup the ConfigSpec as
load /vob/extern
element * CHECKEDOUT
element src /main/1
element * /main/LATEST
I can select the "1" version of the src directory, while keeping all other elements at "LATEST". Super.
However, this doesn't seem to work with the root folder (versions "0-7"). When I edit the ConfigSpec to
load /vob/extern
element * CHECKEDOUT
element . /main/6
element * /main/LATEST
, the version "6" of "." doesn't get selected (it's at "7"=LATEST again)! How can I accomplish this in a snapshot view?
I have also made the following, admittedly desperate, attempts
element "." /main/6
and
element "\." /main/6
, but to no avail. Searched the web/stackoverflow for quite a while and the man pages for "version_selector", "config_spec" and "wildcards_ccase" didn't offer me any explanation for the current behaviour.
I also tried another
rm -rf *
cleartool update
after setting the ConfigSpec, but the version of "." stays at "7".
The relative path '.' does not seem to work, and the config spec falls back to the next valid rule.
Try and use, after reading config_spec Pattern, an absolute path:
element /vob/extern /main/6
# or
element /vob/extern/ /main/6

version selection based on creation date

I would like to select the LATEST version of all elements in a directory based on the creation date otherwise select version 0. Does any one know if this can be achieved using the available config_spec syntax?
eg:
if (created_on >= 01-jan-2014)
element * /main/LATEST
else
element * /main/0
You can try a time directive of selection rule.
element /myPath/... /main/{created_since(01-Jan-2014)}
element /myPath/... /main/LATEST
That could enable you to see versions based on their creation date (see time and query)
See also "time-based rule" answer.
The second rule selection LATEST, not 0, as a way to test the first rule: remember that if a parent folder was not selected by the first rule, none of its sub-elements would be considered if it was in version 0.
Thanks for the hint VonC, I have achieved exactly what I need based on the following rules.
element -dir /myPath/... /main/LATEST
element /myPath/... /main/{created_since(01-Jan-2014)}
element /myPath/... /main/0

ClearCase How to make a baseline with specific version of elements

Can I do this in the clearcase UCM environment and how?
Current recommended bl is BL_A
Lets say I have the following files in the int stream among other files
a. fileA##/main/int/22
b. fileB##/main/int/17
c. fileC##/main/int/4
create and recommend a baseline BL_B = BL_A + fileA##/main/int/21 + fileB##/main/int/13 + fileC##/main/int/4
The version of file fileA, fileB and fileC in #3 are, ofcourse, greater than the versions in BL_A
Thank you in advance for the help.
When you put a baseline, you are labelling all the currently checked in and selected versions in your UCM view.
You can edit said current UCM view:
cd /path/to/my/view
cleartool edcs
Add at the beginning selection rules to select the right versions for your files:
element /path/to/file/A /main/int/22
element /path/to/file/B /main/int/17
element /path/to/file/C /main/int/4
Then put your baseline.

ClearCase Branching using configspec

I have very little knowledge about ClearCase and would like to learn more.
I have created a branch BR_PHASE2 under /main.
I have used the following command to checkout the files into the branch:
element * CHECKEDOUT
element * .../BR_PHASE2/LATEST
element * /main/LBL_MS_PHASE2_04-NOV-2010 -mkbranch BR_PHASE2
The problem now is how do I access files from the branch ??
I am not able to even open the VOB if I switch to this config spec:
element * CHECKEDOUT
element * /main/BR_PHASE2/LATEST
Am I writing the config spec wrong ?? The error i am getting when I try to set the config spec as above:
Warning: New config spec makes current working dir invisible.
What are the steps to actually access the branch that I have created ??
The problem is:
What directories actually have:
a version in the branch BR_PHASE2 ?
a version labeled LBL_MS_PHASE2_04-NOV-2010 ?
If you only branch/labeled all files under /myVob/myDirectory, then the directory /myVob itself won't never be branched/labeled.
That means the following config spec won't be able to select any version for /myVob, making all the other rules for any file under /myVob useless:
Until ClearCase is able to select at leat one valid version of /myVob, it won't be able to select any version for any file under /myVob.
element * CHECKEDOUT
element * /main/BR_PHASE2/LATEST
You should always end your config spec with a "config stop-rule" like:
element * /main/LATEST
or at least:
element /myVob /main/LATEST
Add one of those at the end of your config spec, and the view should work as expected.
The ClearCase config spec mechanism is a composition-based one: to know more about it, see the SO answer "Flexible vs static branching (GIT vs Clearcase/Accurev)".
The OP adds:
You have mentioned to always end the cs with: element * /main/LATEST,
Not necessarily:
If you want to be sure to only view the files under /myVob/myDir with the right branch/label, you could use as I mentioned above:
element /myVob /main/LATEST
The rule applies only to /myVob (not to anything under /myVob).
That allows ClearCase to get past /myVob (because it can at least select a valid version for it) and start applying the other selection rules to the sub-directories.
but if I want to check out the files only from the branch BR_PHASE2, wont this create an error. I am saying that when I end it with /main/LATEST and checkout and check in files , it is updated in main branch. what do I do about it ?
It depends on the config spec you are using:
element * CHECKEDOUT
element * /main/BR_PHASE2/LATEST
element * /main/LATEST
would indeed create new version in the main branch
element * CHECKEDOUT
element * .../BR_PHASE2/LATEST
element * /main/LBL_MS_PHASE2_04-NOV-2010 -mkbranch BR_PHASE2
element * /main/LATEST
would not, because the third rule would apply first, if the element has been labeled LBL_MS_PHASE2_04-NOV-2010.
Your first config spec seems to be ok. It sais that all the files you try to change from the label 'LBL_MS_PHASE2_04-NOV-2010' will be branched to BR_PHASE2. Just try to checkout something, and watch the version tree.
Also, the second config spec tells to see all the files, that belong ONLY to the branch, but if you haven't checkout to branch any, then you will see nothing.
Try the following:
element * CHECKEDOUT
element * /main/LBL_MS_PHASE2_04-NOV-2010
element * /main/BR_PHASE2/LATEST
so that you have the directory structure by selecting the label and your files from branch.

ClearCase time and query

This config-spec show the files I need:
element -dir * '{version(/main/LATEST) && !version(SLT-T)}'
element -file * '{version(/main/LATEST) && !version(SLT)}'
Now I need to see how the source looked at some point in the future, so I do this:
time 01-Nov-2008
element -dir * '{version(/main/LATEST) && !version(SLT-T)}'
element -file * '{version(/main/LATEST) && !version(SLT)}'
Unfortunately this still shows me "the present". The manual says:
Time rules may be nested. They may not include any query language constructs.
Okay, but what do I do then?
How do I exclude files and directories with a certain label, without using query language? Or is there way to specify time in the query language?
(No files has a SLT-T label, and no directories has a SLT label.)
Did you try adding some query-language directives like:
&& !ver{created_since(1-Nov-2008)}
&& ver{created_since(1-Nov-2008)}
(all the versions existing before/after 1 Nov. 2008)
That is part of the query language and may help you refining your selection rules.
I confirm for having tested it:
element /myPath/... /main/{!created_since(01-Sep-2008)}
element /myPath/... /main/LATEST
would give you all version created before September the first in this instance.
I am not sure it can be combined with your rules to successfully achieve what you are looking for, though.
My point was just to make sure you can include time-based selection rules in your config spec.

Resources