tags:

views:

246

answers:

1

Using IBM Rational ClearCase: - I have only access to Snapshot Views so NO dynamic Views

I want to copy ALL versions from a certain changeset to c:\temp. I have already listed the changeset versions in a file (couple of hundred of versions, I only need the latest one), I do not have a baseline over this older set.

What I now have and does not work:

#!/usr/bin/perl -w
#
#  PROGRAM: copytest.pl
$filename = "Design test123.doc";
$view = "D:\\AdminViews\\ABC_R1_READ_2\\ABCD002\\ABC_DESIGN\\BLA Framework\\P0\\";
$version = "\\main\\ABC_R1_READ\\1";
$printhet = 'cleartool find . -name "' . $filename . '" -version version(' . $version. ') -exec "cmd /c copy %CLEARCASE_XPN% D:\temp\%CLEARCASE_PN%"';
system($printhet);

Basically because: http://www-01.ibm.com/support/docview.wss?uid=swg21150317 (XPN)

update: I read http://stackoverflow.com/questions/176858/in-clearcase-how-can-i-view-old-version-of-a-file-in-a-static-view-from-the-com again and I see that a diff with an empty file is the /hack for having no XPN. ok... but a diff with empty and a doc in the above gives me "0"

+1  A: 

I am not sure what this IBM article (you mention in your question) can mean in your situation since it only works for dynamic view (if the view does not directly select the version you need).

And my old answer for accessing an extended path file content in a snapshot view is not trivial to adapt here.


So why not aim at something equivalent but simpler?

Why not create another snapshot view directly within c:\temp (c:\temp\myview_snap), with a config spec along the lines of (you can keep '/' instead of '\'):

element * CHECKEDOUT
element "/ABC_R1_READ_2/ABCD002/ABC_DESIGN/BLA Framework/P0/..." /main/ABC_R1_READ/1
element -directory "/ABC_R1_READ_2/ABCD002/ABC_DESIGN/BLA Framework/P0/..." /main/ABC_R1_READ/LATEST
element -directory "/ABC_R1_READ_2/ABCD002/ABC_DESIGN/BLA Framework/P0/..." /main/LATEST
element "/ABC_R1_READ_2/ABCD002/ABC_DESIGN/BLA Framework/P0/..." -none
element /ABC_R1_READ_2/ABCD002 /main/ABC_R1_READ/1
element /ABC_R1_READ_2/ABCD002 /main/LATEST
element /ABC_R1_READ_2/ABCD002/ABC_DESIGN /main/ABC_R1_READ/1
element /ABC_R1_READ_2/ABCD002/ABC_DESIGN /main/LATEST
element "/ABC_R1_READ_2/ABCD002/ABC_DESIGN/BLA Framework" /main/ABC_R1_READ/1
element "/ABC_R1_READ_2/ABCD002/ABC_DESIGN/BLA Framework" /main/LATEST
element * -none
load /ABC_R1_READ_2

That way, you should select:

  • any element under /ABC_R1_READ_2/ABCD002/ABC_DESIGN/BLA Framework/P0 (P0 included) with the right version
  • any directory which had not the exact version will try first to load itself as the LATEST on ABC_R1_READ, else as /main/LATEST as fallback (always exists)
  • if an element (file) has not that version, it won't be selected at all and not loaded.
  • any parent element (/ABC_R1_READ_2/ABCD002/ABC_DESIGN/BLA Framework), if it has not the right version, will be selected as /main/LATEST (always exist)
  • any other element (outside of the relevant tree) will be ignored, non-selected

Just tested it: it works fine.


Notes:

  • "BLA Framework" is a directory with a space in it, so you need to add the double quotes where it is used.
  • the load rule can just load the vob ABC_R1_READ_2: since the '-none' rules will not select what you don't need, they won't be loaded anyway.
VonC
Thanks, Im trying it
edelwater
I had not thought on producing a config spec. thanks. Superb. Kudos. I'm just rounding up the last things. I have now added about 580 different element lines in there selecting the files and dirs. It now gives some last errors on some documents which ARE in the component but... should not be in the view it somehow wants them in there:ClearCase CM Server: Error: Unable to load "Detail Design bla.doc": no version selected in configuration specification.ClearCase CM Server: Error: Unable to load "Detail Design bla.doc".And some dirs that it somehow want to have in there (and I do not)
edelwater
@cogmios: I do confirm any config spec with `-none` "non-selection rules" in it will generate some Error "Unable to load, no version selected". That is expected (and to be ignored). You also will end up with extra directory, because I have no way of knowing of those old directories (which have not the right version) might or might not contain files which *do* have the right version.
VonC
@cogmios: note, those extra directories should be empty, and should then be safely removed in order to get a final "clean" result.
VonC
I have made a base cc view, labeled all elements as "D", imported that set as baseline... and now I want to deliver that baseline ... unfortunately it does not show me that baseline. So kicked off a copy-merge script (http://www.abs-consulting.com/ftp/TOOLS/COPY_MERGE.txt) to copy everything with label "D", seems to work great. I'm left with a little problem that system ("$COPY \"$SRC_FILE\" \"$DEST_FILE\""); will not output "" around the long-file-names-with-spaces but that seems to be my long lost perl-dos knowledge ... might be interesting to ask here also.
edelwater
@cogmios: I confirm each time you are using `%CLEARCASE_PN%` without adding double quotes around (`\\\"` if you are within a string, or just `\"`), you will risk failing on file names with spaces in them.
VonC
uhm... will this copymerge script work with snapshot views....
edelwater
@cogmios: it should work, if executed *within* the view. What error do you have?
VonC
I am standing inside the target snapshot view. It does all the first merges (producing 0kb files). When it want to "copy" (exactly the line above) it says path not found. I've tried performing a copy from the command line from within the snapshot view that also says path not found.
edelwater
@cogmios: exact: the copy would try to access extended pathname, which is not available through the destination snapshot view. The script should be changed in your case to try and copy the same file from a *source* snapshot view, with a config spec reflecting the source labels to be copy-merged.
VonC
offtopic: bothered by a "internal error detected in "\atria\lib\sum\sum_vob_object.cxx" line 577" in the meanwhile..
edelwater
@cogmios: try setting in the registry: [HKEY_LOCAL_MACHINE\SOFTWARE\Atria\ClearCase\CurrentVersion]"LookupOnlyFqNames"=dword:00000001
VonC
Could well be... We have MVFS disabled but its still running as a service on my machine..... Unfortunately I have no rights to edit the registry...nor to edit control panel... so that will be a RFC.
edelwater
ok...update.... using $SRC_FILE =~ s/\.\\/D:\\temp\\VIEWNAME\\VOBNAME\\COMPONENTNAME\\/g;$SRC_FILE =~ s/@.*//; before the copy action now indeed does all the copying. Great! Now the last part (to make it supertidy): drawing the "arrow" :)
edelwater
@cogmios: a red merge arrow is a `ct merge -ndata -to /my/file/in/dest/view /my/file@@/main/.../version` : but I am not sure the extended path will be accepted in this command used *within a snapshot* view. It is worth a try though.
VonC
update: its running now including merge arrows. So... this will be the end of this thread. I noted in the copymerge script that the error routine does not handle files with spaces well. A nice idea might be to add all these steps in one script, would be handy. The input would be a list of activities, the output a copymerged set. For some time when there is time :)
edelwater
thanks for all your Tips VonC if you ever need a favor be sure to mail me.
edelwater
@cogmios: glad you made it work in the end ;) Out of curiosity, did the `ct merge -ndata` worked with an extended path name, when executed in your snapshot view?
VonC
y: system ("cleartool merge -rep -to \"$DEST_FILE\" -ndata -version $F_ID"); so I did not change abs-consulting.com/ftp/TOOLS/COPY_MERGE.txt one bit in that respect.
edelwater