Maintain Checkout Across Merge - clearcase

I have a file checked out unreserved, and am looking to merge it to the newest version, but not check it in.
IE, I have a file I have made extensive (but not complete) changes to, and want to merge it up to the current version (which also has extensive changes). I do not want to check it in because it would break other folks projects.
Is this even possible / how would I go about doing it?
Thanks in advance

One way would be to change your config spec in order to add an mkbranch option:
(assuming base ClearCase here, not UCM ClearCase)
element * .../aPrivateBranch/LATEST
element /path/to/file .../aBranch/LATEST -mkbranch aPrivateBranch
element * /main/0 -mkbranch aPrivateBranch
That way, a checkin of your file would:
trigger the merge with the LATEST version of the branch you are currently in ('aBranch')
check a new version in another branch ('aPrivateBranch'), not disturbing your colleagues.
And you would continue other works in a private branch.

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.

How to checkout multiple times using different branches for the same element inside same view of Clearcase

How do I checkout different branches of the same element in the same view by modifying the config_spec accrodingly in Clearcase?
Clearexplorer is giving message that already another version is checkedout in the same view, even though I have selected another branch in the config_spec rule correctly.
Any clue will help me.
Thank you.
Hello,
I added the VERSION TREE Picture where it shows that another CHECKEDOUT element is UNRESERVED mode. So, checkout on another branch of the same element in the same dynamic view fails with the message that another element version is already checkedout.
Error Message is also attached by creating another UNRESERVED CHECKOUT as shown.
The view is set to select only one version at a time.
If you want to checkout in another branch using the same view, you would always get the error message stating that the file is already checked out in the current view.
You can try change the config spec in order to:
select a non-checked out version of the file
make sure the checkout will create a new branch
But even in that case, ClearCase might refuse to check out twice that file in the same view.
Don't forget the selection rules in the config spec are read from top to bottom: the first one which can be applied applies.
So when you say "I have selected another branch in the config_spec rule correct", make sure that rule is in the top.
But I don't believe the error message will be different.
That issue is different from "How to Checkout (reserved) an element that is already checked out (reserved) in another view", where the solution is simply to checkout unreserved.
As your screenshot shows (from the position of the "eye"), your config spec select:
checked out version first
/main/LATEST
You would need to put a selection rule at the top of your config spec in order to:
select LATEST of app_build_changes
That is:
element * .../app_build_changes/LATEST
element * /main/LATEST -mkbranch app_build_changes
element /main/0 -mkbranch app_build_changes
But since:
the very first rule would still be element * CHECKEDOUT
you already have a CHECKEDOUT version
Your other rules would still be ignored, and the eye would still select the version you show in the first screenshot.
In short: use another dynamic view.
Instead of using
element * CHECKEDOUT rule in the config_spec,
if I change it to
element * /main/CHECKEDOUT -- one time when I am in main trunk
element * /main/app_build_changes/CHECKEDOUT -- another time when I am in branch
Then also it doesn't check out and gives me the same error of duplicate checkout in the same view.

branching from multiple files in clearcase

I have around 5000 files for which i have to create a branch(say my_branch) from main branch,checkout those files,check in and then apply label.
Its practically impossible to seperately create branch for each file and do the other steps.
There is a way to apply common label to all checkout files and check in all checked out files..that reduces my work but is there a way to create branch for 5000 files with just one cmd or are there any tool to do so
Thanks in advance
Yes, if you have a snapshot view ready to create that branch for you, meaning with a config spec like:
element * .../myBranch/LATEST
element * /main/LATEST -mkbranch myBranch
element /main/0 -mkbranch myBranch
(assuming here that your files are for now on /main)
In that case, what you do is:
copy and update your 5000 files somewhere else
clearfsimport them into your snapshot view: 5000 files will be checked out, updated, checked-in in the right branch for you, one by one, automatically.
See "How to run clearfsimport command for similar streams" as an example for the clearfsimport command.

Details of config spec in base ClearCase

My base ClearCase config spec reads like this:
element * CHECKEDOUT
element * .../Branch_F13R2/LATEST
All is good, but I am wondering what is the .../ doing at the beginning of the path? In UCM, we can see the streams and VOBS in Clear Case explorer, but in base ClearCase, how to know that if I want to check out from Branch_F13R2, I need .../ at the beginning?
That is because you don't know the parent branch.
.../ in a selection rule allows for ClearCase to select that branch, from whatever branch it comes from: /main, or any other branch.
To see more about that notation, called ellipsis wildcard, see "Find all files modified in a specific ClearCase branch?".
I would also recommend to add the rule
element * /main/LATEST
Not every parent directory has a version in the branch you are looking for, and without this last selection rule, it would have nothing to select, making any sub element inaccessible.

Resources