Replies: 7 - Pages: 1 -
Last Post: Nov 26, 2010 5:42 PM Last Post By: 314 Threads: [ Previous |
Next ]
Posts: 41
Registered: Nov 24, 2004 09:18:18 AM
Retrieve rmnamed elements and rmelem them
Posted: Nov 25, 2010 08:24:14 AM I need 2 answers.
1) Is there a quick way to retrieve the list of all elements removed (via rmname, NOT rmelem) from a VOB? I tried this command:
cleartool lshistory -fmt "%Nd#%En#%c\n" -r Luca_vob
In fact, I found in the output some lines like Uncataloged directory element "...", but the format does not satisfy me, as I would like to have, on a single line, the complete path of the removed element.
2) Provided that I succeeded in retrieving the removed elements list, how could I perform the rmelem of those elements? I mean, the problem is that they are no longer visible in the current configuration on the VOB, so I should create many views on past configurations (i.e. baselines).
Is there a quicker way to perform that?
Thanks in advance.
Posts: 419
Registered: Mar 15, 2005 04:40:07 AM
Re: Retrieve rmnamed elements and rmelem them
Posted: Nov 25, 2010 09:29:23 AM
in response to:
Lumart's post Lumart wrote:
> 1) I tried this command:
> cleartool lshistory -fmt "%Nd#%En#%c\n" -r Luca_vob
Several problems...
you recurse in your view, so you miss elements themselves not reachablethis recusion will miss the root directoryactually, you rely upon the default comments of the checkin events of directory objects...This comment is no guaranteed to be preserved, especially if the user gives a comment at checkin!
- it gets scrubbed for one thing;
- for an other, after you'll have removed the elements, the history of their parents won't change.
I doubt you are on a steady path, there.
Marc
Posts: 419
Registered: Mar 15, 2005 04:40:07 AM
Re: Retrieve rmnamed elements and rmelem them
Posted: Nov 25, 2010 09:55:02 AM
in response to:
314's post Marc wrote:
> - actually, you rely upon the default comments of the checkin events of directory objects...
Sorry: I have to take this back. It is also in the comment of the rmname events, and it is at least harder to prevent it from getting there.
foo> ct co -nc .
Checked out "." from version "/main/mg/16".
foo> ct rm -c 'aaa bbb' a.c d
Removed "a.c".
Removed "d".
foo> ct ci -c 'foo bar' .
Checked in "." version "/main/mg/20".
foo> ct lshis -fmt "%o %Nc\n" -minor -since today -dir .
checkin foo bar
rmname Uncataloged directory element "d".
aaa bbb
rmname Uncataloged file element "a.c".
aaa bbb
All in all, you get something with:
ct lshis -a -fmt "%o %n %Nc\n" -minor -since 14:45 | egrep ^rmname
At least this doesn't depend on your view, and cannot be altered by the user comments.
The next this for your 2nd question would be to edit this into an element path, and to use it to get the oid (des -fmt %On). This, you could rmelem... assuming you master it, and got rid of the other checks (labels, locks, hyperlinks,...)
Some job for Perl.
Marc
Posts: 41
Registered: Nov 24, 2004 09:18:18 AM
Re: Retrieve rmnamed elements and rmelem them
Posted: Nov 26, 2010 08:09:27 AM
in response to:
314's post I think the command you suggested is good enough for the customer's purposes.
The removed elements list can be extracted from the output manually or automatically (i.e with a Perl script).
What about the second question?
I mean, any idea on how to rmelem all those elements that are no longer visible in the views?
I read the reference for the rmelem command, and it looks like an element can be "rmelem-ed" by specifying an extended pathname, i.e. one of its versions.
Thanks in advance.
Posts: 297
Registered: Jan 11, 2007 06:46:38 AM
Re: Retrieve rmnamed elements and rmelem them
Posted: Nov 26, 2010 08:30:27 AM
in response to:
Lumart's post Luca,
Before you take this to the end, you are 100% sure that you understand that rmelem will permanently remove the element, including its history and wrecking any prior releases already made containing said element?
Just want make sure you really, really grasp that you could be in a world of hurt unless you are completely certain this is the way to go.
ken1
Posts: 41
Registered: Nov 24, 2004 09:18:18 AM
Re: Retrieve rmnamed elements and rmelem them
Posted: Nov 26, 2010 08:40:12 AM
in response to:
keolw's post Keolw, don't worry, I have been working with ClearCase for years, I know the pros and the cons of rmelem.
In my opinion, the customer is going to perform a wrong operation, as the purpose of rmname is to "clean" the current configuration without losing historical data.
We tried to convince the customer that rmelem is, at best, useless for them, but they said that those elements were added by mistake, so they asked us to support them for rmelem.
Anyway, I performed some tests on local vobs and I verified that I can rmelem an element by just specifying one of its versions with an extended pathname.
Thank you for all.
Posts: 419
Registered: Mar 15, 2005 04:40:07 AM
Re: Retrieve rmnamed elements and rmelem them
Posted: Nov 26, 2010 10:09:44 AM
in response to:
Lumart's post Lumart wrote:
> I think the command you suggested is good enough for the customer's purposes.
OK.
> What about the second question?
I thought I replied...
OK, not clearly enough, and with a detail error. Here is an example: atcctest> ct lshis -a -fmt "%o %En@@%PVn %Nc\n" -minor -since today | egrep ^rmnamermname /vobs/atcctest/.@@/main/mg/2 Uncataloged file element "bar".atcctest> ct des -fmt "%On\n" /vobs/atcctest/.@@/main/mg/2/bar831185be.71e44c50.b472.70:23:ef:8b:57:5batcctest> ct rmelem -f oid:831185be.71e44c50.b472.70:23:ef:8b:57:5bRemoved element "/vobs/atcctest/.@@/main/mg/2/bar".
So, using Perl, and ClearCase::Argv from CPAN (I leave the '-since today'):
use ClearCase::Argv;my $ct =
new ClearCase::Argv({autochomp=>1, ipc=>1);
for ($ct->lshis([qw(-a -fmt), q(%o %En@@%PVn %Nc\n), qw(-minor -since today)])->qx) {
if (/^rmname (.*) Uncataloged .* element "(.*)"\.$/) { my $oid = $ct->des([qw(-fmt %On)], join('/', $1, $2))->qx; $ct->rmelem([qw(-f)], 'oid:' . $oid)->system; }}
I didn't run it, but as far as I can tell, this should be portable (the '/' will be accepted on input), and take care of spaces and '$'s in file names.
It will fail verbosely on mastership errors.
The week link IMHO is the 'previous version'... It won't work in every branching case...
I also suspect the result after letting the forum mash this... Hopefully all the characters go through!
Marc
Posts: 419
Registered: Mar 15, 2005 04:40:07 AM
Re: Retrieve rmnamed elements and rmelem them
Posted: Nov 26, 2010 05:42:22 PM
in response to:
314's post Marc wrote:
> > my $ct =
new ClearCase::Argv({autochomp=>1, ipc=>1); } >
One missing brace, at least.
Marc
Use the search field to find all types of content in My developerWorks with that tag.
Use the slider bar to see more or fewer tags.
Popular tags shows the top tags for this particular type of content or application that you're viewing.
My tags shows your tags for this particular type of content or application that you're viewing.
Use the search field to find all types of content in My developerWorks with that tag. Use the slider bar to see more or fewer tags. Popular tags shows the top tags for this particular type of content or application that you're viewing. My tags shows your tags for this particular type of content or application that you're viewing.
More
Less
View the original article here