How to obtain path to changeset predecessor version of file when file is hijacked?

276 views Asked by At

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!

1

There are 1 answers

13
VonC On BEST ANSWER

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>