1

Working with cleartool under UNIX, if I have a file in a snapshot view that is unmodified (e.g. still checked in, not checked out, not hijacked), I can successfully get its predecessor version with this:

$ cleartool describe -predecessor -short file.c
/main/ABC_int/ABC_STAGING/user_ABC_STAGING_dev1/9

No problem in that case.

However, if the file happens to be hijacked (which happens very often with the way I work), cleartool describe refuses to give me its predecessor version:

a) The following two lines simulate an hijack:

$ chmod 666 file.c
$ touch file.c

b) Then at that point if I try the same command line again on the same file:

$ cleartool describe -predecessor -short file.c
cleartool: Error: -predecessor invalid for non file system objects: "file.c".

How can I get the changeset predecessor version path of the file when it is hijacked?

Is there a different way to do this than:

  1. Take a backup of the hijacked file ("cp file.c file.c.backup"),
  2. Run "cleartool update -overwrite <file>" to un-hijack it,
  3. Re-run the cleartool describe command line on it to get the predecessor on the un-hijacked file ("cleartool describe -predecessor -short file.c"),
  4. Then re-hijack it again ("chmod 666 file.c"),
  5. And finally move the backup on top of it ("mv file.c.backup file.c")?

Thanks!

user972301
  • 137
  • 8

1 Answers1

0

One simple solution is to have a dynamic view with the same config spec as your current snapshot view.

While the file state in the snapshot view might not allow to get its predecessor version, the same file referenced in the dynamic view will.

cleartool descr -pred -short /view/yourDynamicView/vobs/AVob/path/to/files.c

You would still work as usual in the snapshot view, but you would rely on the dynamic view to get the information you need.


The OP confirms in the comments:

it works!

  1. Create temporary dynamic view with:
cleartool mkview -tag <dynview_tagname> -stream <mystream@/myPVOB> -stg -auto
  1. Obtain predecessor of hijacked file with:
cleartool describe -predecessor -short /view/<dynview_tagname>/vobs/<path>/file.c
  1. Destroy temporary dynamic view with:
cleartool rmview -tag <dynview_tagname>
Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • Interesting idea. I'd be willing to script this to make it easier however. Would you mind indicating the commandline to create a dynamic view, and also to destroy a dynamic view? – user972301 Nov 14 '14 at 22:41
  • @user972301: http://stackoverflow.com/a/1367656/6309 for `cleartool mkview` example. `cleartool rmview` to delete it (http://www-01.ibm.com/support/knowledgecenter/SSSH27_7.1.2/com.ibm.rational.clearcase.cc_ref.doc/topics/ct_rmview.htm?cp=SSSH27_7.1.2%2F8-0-0-1-63). – VonC Nov 14 '14 at 22:42
  • Thanks VonC, will give this a shot when I get access to clearcase this week. – user972301 Nov 16 '14 at 01:51
  • Ok - it works! 1) Create temporary dynamic view with `cleartool mkview -tag -stream -stg -auto` 2) Obtain predecessor of hijacked file with `cleartool describe -predecessor -short /view//vobs//file.c` 3) Destroy temporary dynamic view with `cleartool rmview -tag `. Thanks VonC! – user972301 Nov 18 '14 at 16:59
  • @user972301 great feedback! I have included your solution in the answer for more visibility. – VonC Nov 18 '14 at 17:50
  • No problem. Next time I have tough ClearCase questions I'll know where to go... :-) – user972301 Dec 06 '14 at 04:11
  • Hi! Could someone explain what yo substitute with? given that my snapshot view has the following path c:/CC// – Henrik Feb 19 '18 at 12:08
  • @Henrik In your snapshot view, type `cleartool lsstream -cview`; you will have the name of the stream associated to your snapshot view, provided it is an UCM View: so replace it with `@\thePVob`, withthePvob being the name of the pvob in which the stream is defined. – VonC Feb 19 '18 at 12:16
  • @VonC, thanks for your reply. My goal is to setup a temporarely dynamic view for the same reasons as stated in this question. I am currently experimenting on how to create a dynamic view with tag "DynView_tmp" that should act like a mirror to my snapshot view. i.e I want to run the following command: – Henrik Feb 19 '18 at 13:00
  • cleartool mkview -tag DynView_tmp -stream $(cleartool lsstream -cview)@C:/CC/ -stg -auto. but it seems like I dont have any "streams" connected to my vob. i.e I get the following errors: cleartool: Error: Unable to find stream "@C:/CC/". cleartool: Error: Cannot attach view to stream "@C:/CC/". Do you have any idea on how to fix this? – Henrik Feb 19 '18 at 13:00
  • @Henrik Are you sure that `@C:/CC/` is a valid pvob tag? You need to pvob (not vob, pvob) tag, referenced as `\myPvobTag`. – VonC Feb 19 '18 at 13:02
  • @VonC you may be onto something. I thought "PVob" implied my personal vob i.e the snapshot vob. Any idea on how to find the corresponding PVob? Is there any other way to obtain the predecessor of a hijacked file? – Henrik Feb 19 '18 at 19:15
  • @Henrik As for hijacked, have a look at my old answer: https://stackoverflow.com/a/26923152/6309 – VonC Feb 19 '18 at 20:01