ClearCase: Is it possible to version control the config spec itself? - clearcase

I have complicated Config Spec, which changes quite often.
Is it possible to version control the config spec itself?
e.g.,
suppose the current config spec is:
element * CHECKEDOUT
element /vobs/a/b/c.v /main/34
element /vobs/a/d/e.v /main/20
element /vobs/f/g.f LABEL_0.592
element /vobs/... LABEL_0.596
While the previous config spec was:
element * CHECKEDOUT
element /vobs/h/i/j.v /main/31
element /vobs/... LABEL_0.595
I'd like to be able to "go back" to my previous config spec, without having to keep it in comments inside the config spec, or copy-paste it every time to seperate file, and have that file version controlled.
Is it possible? How?

You could version the config spec itself (obtained with cleartool catcs -tag YourViewTag > aConfigSpecFile) in its own branch (in order to not interfere with the regular versioning of the other files)
The idea is that you can set a config spec from a file at any time, with cleartool setcs:
cleartool setcs -tag yourViewTag yourConfigSpecFile
To get a specific version of that config spec (since it is stored in its own branch), you can use cleartool get
cleartool get –to yourConfigSpec yourConfigSpec##\main\aBranch\x

Related

How to do code merge from one branch to another in ClearCase

I an new to ClearCase and started studying the ClearCase documentation.
UseCase : I have two branches - 'Branch_A' and 'Branch_B'.
I need to merge all my changes from 'Branch_A' to 'Branch_B'
I won't be able to use the ClearTeamExplorer, so only option is command line.
I read the documentation and its mentioned that cleartool findmerge command is the option for it.
But there is no direct example given for this.
Could someone please provide an command line example for this please?
Any help on this is appreciated.
Assuming a base ClearCase view/branch (no UCM views/Streams):
cleartool findmerge include a relevant example:
for the current directory subtree, compare versions visible in the current view against versions on another branch and perform any required merges.
cd /path/to/target/Branch_B/view
cleartool findmerge . –fversion /main/Branch_A/LATEST –merge –gmerge.
The idea is to be in the view set on the target branch, with a config spec ready to create new versions.
element * CHECKEDOUT
element * .../Branch_B/LATEST
element * /main/0 -mkbranch Branch_B
element * /main/LATEST -mkbranch Branch_B
The merge is done in the target view, on the target branch.
Now if you are using UCM, then the view done on a Stream has already the right config spec.
The idea remains the same: Execute the findmerge in the target view (after setting a dedicated activity, to record that merge)
In that case, check "How to merge changes from a specific UCM activity from one ClearCase stream to another"
You do not merge branches in UCM, you would merge UCM activities.

ClearCase checkout branch in VOB

I'm new to CC and I'm coming from Git and Mercurial background, probably thats why ClearCase confused me so much. I've been assigned a task to migrate latest CC's revisions to Git. Problem is that I couldn't manage to checkout any branch other than main in CC.
I have a view that displays all VOB's /main/LATEST revision. I assume, main branch's latest revision.
element * CHECKEDOUT
element * /main/LATEST
Now I need to get the list of other branches in a particular VOB. To do that, I navigate from terminal in that folder and run
cleartool lstype -kind brtype -invob /%VOB_NAME%
and I can see the list of branches. Correct me if I'm wrong, but I assume, it displays only the branches relevant to VOB(%VOB_NAME%).
Now I need to checkout the branches. What is the standard way of doing this. I tried updating config spec with something like:
element * /%VOB_NAME%/%BRANCH_NAME%/LATEST but it doesn't seem to work.
Pretty sure I'm not doing it correctly.
Also for migration purpose, I'll need to automate the steps to acquire branches and checkout the branches. I guess updating config spec to switch branch in a view takes some time and probably is an async operation, so is there a way to determine when view finishes updating?
Or maybe there's command line option to switch branch for a particular VOB in a view?
So in short, here's my questions I'm struggling with:
Than
Am I acquiring VOB branches correctly?
How can I checkout a particular branch?
Is there a way to determine when checkout finishes?
thanks
UPDATE
ok I tried #VonC's recommendation so my config spec looks like this:
element * CHECKEDOUT
element * .../heine_1/LATEST
element * /main/LATEST
If I'm guessing correctly, one VOB containing branch named heine_1 should checkout that particular branch, the rest of VOBs will stay on main branch, but this is not the case. When I run cleartool ls inside that VOB, its still on main branch. All folders are postfixed with Rule: /main/LATEST. So I guess it didn't switch the branch.
Thanks
There are a few questions in the original question and the comments.
Addressing the configspec issue first...
The syntax of an element rule is:
element {path} {version rule} {optional clauses}
If you need a VOB-specific rule, you can do something like this:
element \myvob\... ...\myvobbranch\LATEST
element \myvob\... \main\LATEST -mkbranch myvobbranch
The "..." in the path means "this location and everything underneath it."
The "..." in the "version rule" means that the branch name is at the end, so this would match /main/myvobbranch/LATEST, /main/br1/myvobbranch/LATEST, etc.
If you're working on a branch, you generally want new files or work to appear on the branch you are working in, and the second line makes that happen.
Everything in a configspec is case sensitive, so be aware that "LATEST" is not "latest."
Since the view was created for you, I'm reasonably certain that it is a dynamic view. If it is mapped to a drive, it's definitely dynamic. If you need to know for sure, you can CD into the "working area" of your view and run "cleartool lsview -pro -full -cview" and look at the "attributes" line. The line for a dynamic view will look like this:
Properties: dynamic readwrite shareable_dos
On the direct questions:
Yes, you are acquiring the branch list correctly.
By default the checkout is done using the version selected by the view, you can use cleartool checkout -branch {full branch path} {file name} to check out the latest on a branch, or cleartool checkout -version {version id} {file name} to check out a version other than the latest on a branch. I would not recommend either as a normal practice. The -branch will cause checkins to go to the element's parent branch. The -version would require add a requirement to perform a merge to get the checkin to complete, which would also go to the version's parent branch.
Checkout is finished when the command finishes.
A big "new user gotcha" is that directories are also versioned objects. If you're adding files to source control, you need to remember to check the directory in so that they are visible by others with similarly configured views. The ClearCase GUIs have this behavior as a default if you started the process with the directory NOT checked out, but not if you explicitly checked out the directory beforehand.

Clearcase UCM - How to get the config spec of a given baseline?

I'd like to set-up a non-UCM clearcase (read only) view for debugging an issue reported on a old baseline which was delivered to customer.
How to view/retrieve/generate the config spec of the old baseline? so that I use this config spec to create a non-UCM clearcase view for debugging the issue.
The config spec is simple:
element * baseline_id
element * /main/0
element * /main/LATEST
(note that the /main/0 is important, especially in a multi-component vob, for the initial version of the component is registered in /main/0 when a new component is created)
What you need to find out is:
what is the baseline id? (which can differ from the baseline title).
See "Display Current Baseline with Cleartool".
You can for instance describe the stream to get the foundation baselines id:
cleartool descr -fmt "%[found_bls]CXp" stream:myStream#\myPVob
is the baseline a full or an incremental one? See "What is the difference between Full baseline and Incremental baseline in Clearcase UCM?".
If it is an incremental one, you need first to promote the baseline to a full one.
ct chbl -full -nc baseline:abaselinexxx.yyyy#\apvob
I think a much simple solution is to create a stream based on the baseline you have. That way you can even write into it without interfering nothing and even to save you changes in CC
It's very simple to create a stream based on a baseline, click the "advanced" option when creating stream as usual.
Enjoy,
Eli.

Editing config spec after creating branch

I wanted to create a dynamic view with the following config spec:
element * CHECKEDOUT
element * .../view_1_1/LATEST
element * LABEL_1 -mkbranch view_1_1
element * /main/LATEST -mkbranch view_1_1
Unfortunately I have written the config spec wrong; I didn't write the "..." in the second line (element * /view_1_1/LATEST). After this, I have given the 'mkbrtype -global -c "some comment" view_1_1' command and make it visible in Windows (ClearCase Explorer) using Region Synchronizer.
And I realized that I have forgotten '...', so I corrected the config spec. I corrected this before any checkouts, checkins or something.
Does this edit cause any problems, or any differences than other views created with the correct config specs?
Does this edit cause any problems, or any differences than other views created with the correct config specs?
No, this edit is in the config spec of your view, and remains local to this view.
It has nothing to do with the fact the view tag was made visible through the Region Synchronizer.
The OP groove asks in the comments:
Is this true for editing config spec after "mkbrtype" too?
Yes: the brtype can change, the config spec will use that modified brtype at the next refresh.
The '...' is a simple selection rule modification, which means it will select different elements based on the new rule (.../view_1_1/LATEST instead of /view_1_1/LATEST or /main/view_1_1/LATEST).
If the brtype doesn't exist yet, or if its comment changes, that selection rule would simply be ignored.
config spec is read from the top to bottom by actived view. If the view finds one version of file/folder's tree, stop reading the next config spec.
In your case, when the view read second line element * /view_1_1/LATEST, since there is no branch /view_1_1, just ignore it, nothing happens, and continuously read the rest.
mkbrtype is used to define the properties and create branch type view_1_1 (not create the branch on that element). You need know command mkbrtype and mkbranch are different.
mkbranch
Creates a new branch in the version tree of an element
http://publib.boulder.ibm.com/infocenter/cchelp/v7r0m0/index.jsp?topic=/com.ibm.rational.clearcase.cc_ref.doc/topics/ct_mkbranch.htm
mkbrtype
Creates/updates a branch type object
http://publib.boulder.ibm.com/infocenter/cchelp/v7r0m0/index.jsp?topic=/com.ibm.rational.clearcase.cc_ref.doc/topics/ct_mkbrtype.htm

ClearCase dynamic view doesn't show empty files

We usually use snapshot views and they work just fine.
However, I tried to use a dynamic view recently and doesn't show empty files in the working directory. We use Python so namely, it doesn't show empty __init__.py files, which breaks most of our code. All other files in the same directory, and non-empty __init__.py files exist.
Is this a known issue? What can I do?
Running cleartool ls says about the __init__py file: "no version selected".
My config spec looks something like this:
element * CHECKEDOUT
element * SubComponenet1_VersionX
element * SubComponenet2_VersionY
element * SubComponenet3_VersionZ
element /src_base /main/LATEST
Assuming the empty files are inside src_base and considering the last rule, how can a file not have a selected version?
First, try a cleartool ls in the parent directory of those file, in a shell or a DOS windows.
You can see there status, and see if they are selected by your config spec.
Check also that the config spec of your dynamic view is similar to your snapshot view:
cleartool catcs within your snapshot view
cleartool edcs from your dynamic view
For a non-UCM dynamic view to reflect an UCM snapshot view, it can be pretty complex.
It is best to create a dynamic UCM view on the same Stream.
At the very least, your config spec should end with a stop-rule:
element * /main/LATEST
# or
element /src_base/... /main/LATEST
Your last rule is only for /src_base directory, and not for the sub-elements.

Resources