ClearCase : How Can I Revert to Earlier baseline? - clearcase

How Can I Revert to Earlier baseline? We have a UCM parallel development(multi-stream) project. Each developer have a snapshot view on Project's Integration stream.
Developers want to see earlier version of the application in their snapshot views so They can debug early version of application to find bugs.
When I want to change an existing snapshot views's foundition baselines, clearcase does not allow me. So How Can I do this?

Since you employ the term Baseline, I will assume you are using UCM.
On a stream, you can not revert backward a baseline.
One possibility is to make a parallel stream, with the desired baseline as foundation: this is the quickest way.
After changes on this new stream, you can make a new rebase to change the foundation baseline, but only if that new rebase is using a more recent baseline from the parent stream (not an older baseline)
For your specific need, I would recommand a non-UCM snapshot view with a simple rule
element * thePreviousBaseline
In order for the developer to have:
his/her current UCM view for development (always set on the LATEST of a branch associated to a stream)
a second snasphot view set to whatever baseline he/she needs.
That second snapshot view is completely not-related to the UCM project and takes advantage of the "full" nature of the baseline (do check that your baseline has been put as "full", not "incremental". If it is "incremental", simply change its type and upgrade it to full)
So, beside your current snapshot UCM view, you can create anywhere you want a non-snasphot view:
cleartool mkview -snap -tag mylogin_myComponentname_csl_snap -vws myPathToViewStorage myPathToRootView
cd myPathToRootView
cleartool edcs
[add the selection rule: element * myOlderBaseline]
[add the load rule at the end: 'load /myVob_Including_MyComponent]
[save, type 'yes']
That is fine for consultation/execution, but if you need to patch (that i is to write, check out and in some files), then I would recommend one UCM stream per baseline to be patched.
That way, the stream clearly represents the patch effort for a given baseline. There should not be too many of them, unless you put into production a new version of your application every five minutes... which is not advisable ;)
So to summarize:
the non-UCM snapshot view is unique and serve for a quick consultation/debug of one older baseline at a time.
for patches (source modification), you create a parallel stream properly named, with the correct foundation baseline, and then a UCM view on it. You can not only debug but also fix some bugs in an activity, the deliver that activity to the main Int stream if that bug need to be retro-fitted on an higher stream.
(note: all bugs do not always need to be delivered: they can be obsolete when compared with the current state of the development)

The way I have solved this problem is by making another Stream, a child Stream of the Integration Stream. The easiest way to create this Stream is to open ClearCase Project Explorer (not Rational ClearCase Explorer) and navigate to the Project and then the Stream in question. Right click on the Integration Stream and select "Create Child Stream..."
Click "Advanced Options" and select a baseline for each component. Do this by selecting the component and then selecting "Change..." and selecting the specific baseline you want to see. You probably want to select "Prompt me to create a View for this Stream." Select "OK".
Any developer can do this. You don't need to be a VOB owner or Project or Stream owner.

Well, it depends. Actually, the answer lies in setting up your config spec to point to the proper files. Your config spec tells your view which versions of elements to look at. But how you do write it depends on your project's approach to baselines. Did you apply a label to mark that baseline? If so, and if you only want to read and not checkout anything new, your config spec can be as simple as
element * <LABELNAME>
If you didn't use labels, you can also set up your config spec to show you files based on dates. It gets more complicated the more rules you need to add to constrain your element choices. If you have more specifics, I can try to elaborate on what rules you might need. Otherwise, I would read the manuals that come with ClearCase. If you view the Extended Help from ClearCase Explorer, and then do "Viewing Rational ClearCase Manuals On-Line" it should give you some links to the Command References. This is where I go whenever I need to modify my config spec in some new way.
Also, note that we only use dynamic views, so I don't know if snapshot views work differently.

Related

How to remove a Baseline from a clearcase stream?

I am encountering a problem with Clearcase. I do apologise in advance if I am unclear, or redundant since I am quite new to this VCS, coming from a Git background mainly, I might not know how to search correctly regarding my problems.
We have a new version (non-relevant to CC, business-wise) of the application every few months, and we create a new VOB and stream for each version each time. We have a generic stream in which we deliver the last baselines from a finished version, add a new baseline, then export the contents of the generic stream to a new VOB and Stream.
My problem is, being hasty I actually delivered into the the generic stream, not the last baseline, but a previous one. And on top of that, I added a brand new baseline to the generic stream.
I need to be able to deliver into my generic stream, the very last baseline from our previous business version of the application.
(I am mostly manipulating Clearcase project explorer, since I don't really know the cleartool command. I tried to use a few CLI solutions but could not manage to do so, but might be linked to how our Clearcase server is)
In order to do that, I tried to :
Delete the delivery activity. But there is an error when I try to do that : "Error : Cannot remove an activity with versions in its changeset". I tried to bypass this, helping myself with google, but could not manage to do so. I am afraid this is normal Clearcase behaviour, and cannot pursue this way.
Redeliver our last business version correctly, but it did not work because of my newly hastily created baseline in the generic stream.
I would take up on any clue, indication lead, since I cannot manage to find how to correctly advance upon this matter.
Thank you in advance.
It is simpler to:
deliver to the generic stream the right content (on top of the wrong one) and set a new baseline
rename the previous baseline into a "DO-NOT-USE" name
cleartool lock -obsolete the baseline, to make it invisible (rather than trying to delete it)
That way, you can resume your successive delivers/imports of each release, and forget about the wrong one.
If the baseline you created in that stream is the most recent baseline, and has not yet been used by another stream (either pulled in a rebase or delivered to another stream), you should be able to just remove it.
In any event, since your plan is to move forward by delivering a more recent baseline created in the same parent stream to this "generic" stream, you can just deliver the right baseline to this stream, make a new baseline, and optionally lock the previous baseline.
A couple of UCM gotchas you may want to be aware of:
If you deliver a baseline to another stream, the source baseline is permanently irremovable.
ALL deliver operations deliver baselines. If you don't create a baseline, the deliver operation creates a "deliverbl" baseline to deliver.
Removing streams is either non-trivial or impossible.
Removing projects where development work has been done is usually impossible.
For future reference, to remove an activity that is NOT in a baseline:
Describe the activity on the command line to get the list of versions. You may want to redirect the output into a file so you can copy and paste the version info into the next step more easily. To describe the activity, you need to use "cleartool describe activity:{id}#{project VOB tag}"
Remove all the versions in the change set using "cleartool rmver -xhlink {version ID}"
Remove the activity. Since the delivery is apparently completed, the activity should not be set.

Clearcase equivalent to hg shelve

Is there a ClearCase equivalent to hg shelve (or git stash for those of the other persuasion)? The closest I can think of is doing uncheckouts and saving keep files, but that means I'd have to hunt down the keep files afterwards, re-checkout the files and merge. I realize that ClearCase and Mercurial/Git have different philosophies behind them, but I'd be interested if there is any work in making ClearCase more "usable".
I listed a few for other version control tools, but none for ClearCase.
I explained, for ClearCase UCM, that a shelve command isn't easy to implement.
Instead of just saving the .keep files, you could save patches (unix diff between a .keep and its original version), since a patch can be re-applied later.
The other approach is to modify the config spec (easier when in a non-UCM view) in order to checking the currently modified versions in a new branch (see this config spec)
You can then decide to merge that branch later.
The philosophy is quite different.
In Clearcase, if you need to work on another branch/release, you usually have to use another Clearcase view. If you have Clearcase/UCM, it is even more true as you would use another view attached to another UCM stream. You would not be able to use the same view, whereas in Git, you would be able to stick to the same clone and perform a git stash, git checkout in order to start working on another release.
Now let's assume you need to work on another feature, for the same release. Under Clearcase/UCM, you would be able to create a new activity (cleartool mkact) and work on this new activity, using the same view. All the changes made will then be associated with this new activity. You will also be able to switch back to the previous activity using the command cleartool setact. The tricky part is if you need to deliver the activities separately. This will not necessarily possible as you might need to deliver both at the same time depending on the content of the changeset. This doc about determining dependent UCM activities is quite useful. If you need to move some changeset between activities, you can use the command cleartool chactivity with -fcset and -tcset options.
As a summary, with Clearcase UCM, if it is for different release, switch views and streams. If it is for the same release, play around with the UCM activities, knowing that it is less flexible than git stash.

UCM: How to create dynamic view (base clearcase) on arbitrary incremental baseline

Currently we use ClearCase UCM.. I am trying to evaluate possibility of using git in our project. I decided to create large repo with past three years changes from an integration stream. The pvob has 12 vobs under it. For purpose of evaluation(creating a worst case), I am putting all changes into single repository.
I want to create a base clearcase view and then adjust its spec for every baseline on the pvob. This will then synched to git repository.
Question in short: How can I create a base clearcase view given a pvob base line and keep changing its config spec to match every baseline?
(academic note : A picture of what I am trying to achieve.. )
(Approach discussed in ClearCase UCM: Is it possible to have a temporary view on any given baseline? is kind of work around in my case. I guess I can avoid the step of creating many temporary streams- not sure how!)
I am putting all changes into single repository.
This isn't the right granularity for a git repo.
Having done multiple ClearCase to Git migration, the right scale usually is one UCM component equals one Git repo.
How can I create a base clearcase view given a pvob base line and keep changing its config spec to match every baseline?
You don't have to create a base ClearCase view.
You can create a sub-stream to the Int stream, and manage the baselines you want to see there.
(cleartool rebase -bas xxx#\YourPVob)
You can then use an UCM view to that sub-stream as a source for your git import.
If that approach isn't possible (as I explained in my previous answer you mention, because for instance all baselines haven't been created in the same parent stream), then you can create a base ClearCase view and modify its config spec in order to select the baseline complete ids:
element * BaselineId1
element * BaselineId2
...
(A dynamic view here is more useful to tweak the config spec.
Once the config spec is set, you can update a snapshot view with the same config spec, and appropriate load rules, to use it as a source for your git import).
You need to make sure those baselines are:
full baselines (you can promote an incremental one to a full one)
referenced with their id (not their title, which is their visible name).
See also "Display Current Baseline with Cleartool":
cleartool describe -l baseline:aBaseline#\aPVob
cleartool descr -fmt "%[found_bls]CXp" stream:myStream#\myPVob
The second command would give you all baselines in a stream.
In both cases, you would see the baseline ids in addition of their names.
I have mention the ClearCase to Git migration aspect in :
"Migration from UCM ClearCase to GIT"
"How to integrate ClearCase development history into Git?"
"Save history from ClearCase to Git?"
"How to bridge git to ClearCase?"
"Sync GIT and ClearCase"
A good trick is to use:
git --git-dir=/path/to/git/repo/.git --work-tree=/path/to/ClearCase/view add .
That allows you to consider the ClearCase view as the working tree of your git repo (which is the destination of your import).
I generally don't try to import all baselines from all streams because it is too complex too soon (in order to get the sequence of those histories right).
I just get a few baselines from the main stream, import them and go from there (keeping the ClearCase referential as a read-only archive source for history research).

How to apply baseline for previous version?

I have done a mistake by not applying baseline for one of my release.
Now some more changes were done in the integration stream. Is it possible to apply baseline for particular past day's changes.
We are using Clearcase UCM.
You can do it... but not easily on the same branch.
You can create a non-UCM view with the files at the versions referenced by your earlier date (see "Label ClearCase Content As Seen On A Given Date)")
Then you can create and apply a label on all the versions visible in that non-UCM view
Then create a baseline by importing the label
However that will create a baseline on a separate branch, and not on the current stream.
that is not good, as you won't be able to compare that new imported baseline with all your other baselines (because they won't have any common ancestor).
The only way to easily create your baseline on your Stream (and benefit from the comparison with previous baselines) is to use your non-UCM view in order to clearfsimport -rmname the content of that view to your current view, importing all the versions (in your current UCM view) to the right content (ie the content selected by your date in your non-UCM view).
See "Best way to roll back to previous versions without baseline in CC" (and this question for more on clearfsimport).
Do it in a specific activity dedicated to record all the modifications done by that import.
Then you put your baseline.
Finally, cancel that activity, using the cset.pl script: See "Clearcase: how to rollback all changes on specific branch?".
You should get back all the versions you had before making that import.
The drawback is that your history for a given file will reflect a curious 'setback' in the list of versions on the branch of your Stream.

Is there RTC-equivalent "Suspend mode" in ClearCase?

I found "Suspend Change-set" in RTC to be very useful, and since we're working with ClearCase as well (dozens of users) I'm wondering if that feature is also available in ClearCase as well.
If not - could it be generated by script/trigger/hook ?
We use UCM, and I'd like to explain my question:
if I have to deliver and I want to skip delivering one activity, I can decide not to deliver it (if no dependencies...) , so my question is regarding working on my current stream: Is that possible to "suspend" an activity from my current stream ?
Thanks in advance
Simply put, not easily.
RTC is basically ClearCase rewritten from scratch, and the "suspend" mode (also called stashed or shelve) takes advantage of the notion of applying a changeset (to any state of a repository)
The UCM changeset are a list of versions of files. Each version is tied to its predecessor, and you cannot easily remove it (unless you do some negative or subtractive merges), and then re-apply them later.
That being said, Reuven just contacted me this morning, because he had files in checked out in a snapshot view on a Stream which he wants to rebase (similar issue to your deliver problem).
A possible way to do that is to create another view (dynamic one), which you can use for your rebase, and then go back to your snapshot view and update it: it will detect the updated config spec (following the rebase) and will not erase any of your currently checked out files.
On the checkin, those files will be merged with the updated version.

Resources