1

I have a file foo.c and I quickly want to access it's BASE version. How can I do it?

For example I have foo.c@@/main/2

$ENV{'CLEARCASE_PN'} gives me the current file path: L:/user/vob/dir/foo.c

$ENV{'CLEARCASE_XPN'} gives me the next version number L:/user/vob/dir/foo.c@@/main/3

How can I quickly open the current base version on the current view foo.c@@/main/2?

nowox
  • 25,978
  • 39
  • 143
  • 293

1 Answers1

1

$ENV{'CLEARCASE_XPN'} should give you the extended path name of the current version, as selected by the current view, not the "next" version.

Here "base" is for the current version before a CI trigger allows a new one to be created.

In that case, cleartool descr -l $ENV{'CLEARCASE_PN'} should still display the one selected by the current view foo.c@@/main/2.

If not, using '-pred' would help (to get the previous version): cleartool descr -pred -l $ENV{'CLEARCASE_PN'}

The OP coin confirms in the comments:

my $desc = 'cleartool descr $ENV{'CLEARCASE_PN'}'; 
if($desc =~ /predecessor version:\s*(.+)$/) { 
    die "Predecessor: $ENV{'CLEARCASE_PN'}\@\@$1"; 
}

"base" could be interpreted as the base contributor version for a merge (see "How to perform a 'merge' using clearcase?")

In that case, you can check:

  • cleartool findmerge -print, which can list the names of the versions that require a merge. The default listing includes the version IDs of the to-versions and from-versions and the version ID of the base contributor (common ancestor)
  • cleartool describe -anc, which is able to desribe the closest common ancestor version of all the pname arguments.
Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • Unfortunately in a CI trigger, `CLEARCASE_XPN` seems different. I guess another "pre-op" trigger already did the check-in. – nowox Nov 12 '14 at 09:00
  • @coin right, in that context, that make sense. But a `cleartool descr $ENV{'CLEARCASE_PN'}` should display the current version (are we talking about a pre-op or post-op trigger though?) – VonC Nov 12 '14 at 09:02
  • I am always getting confused with pre-op and post-op triggers. Do you have documentation on it? – nowox Nov 12 '14 at 09:19
  • @coin no, it is just part of the mktrtrype you must have used (an option) – VonC Nov 12 '14 at 09:20
  • @coin in the meantime, what does a `cleartool descr $ENV{'CLEARCASE_PN'}` would return in your script called by your trigger? – VonC Nov 12 '14 at 09:22
  • Actually this gives me what I need: `my $desc = 'cleartool descr $ENV{'CLEARCASE_PN'}'; if($desc =~ /predecessor version:\s*(.+)$/) { die "Predecessor: $ENV{'CLEARCASE_PN'}\@\@$1"; }` – nowox Nov 12 '14 at 09:36
  • 1
    @coin Excellent. I have included your conclusion in the answer for more visibility. – VonC Nov 12 '14 at 09:40
  • @nowox Remember, I am here every. single. day: https://meta.stackexchange.com/questions/122976/anyone-with-a-visited-3333-days-3333-consecutive-in-their-profile#comment1065955_122976 – VonC Apr 11 '19 at 15:44
  • Among everything I learned from SO, this was a comment you made that I will never forget. I’ll never stop to amaze me. – nowox Apr 11 '19 at 15:46