سؤال

In the context of a dynamic "default view" when I issue the following commands:

$ cd Dir_A/Dir_B

$ ct find . -all -nvi -type f -ele 'brtype(my_branch)' -print

For each line I get strange output that looks like this:

/vobs/vob_name/Dir_A/Dir_B@@/main/Branch_A/Branch_B/n1/Dir_C/main/Branch_C/n2/Dir_D/main/Branch_D/n3/Filename@@

How do I get the find command to simply print the standard operating system pathname without all the intermediate version information for each directory?

I have tried -exec 'ct des -fmt' to no avail.

هل كانت مفيدة؟

المحلول

That strange format is called an extended path name.
As explained here, a result like:

\proj_vob\foo.c@@\main\bugfix\4

is actually called a version-extended path name.

In your case:

/vobs/vob_name/Dir_A/Dir_B@@/main/Branch_A/Dir_C/[...]/n3/Filename@@

is a vob extended path name.

It references elements (file or directory) which are no longer visible in the view (because they have been rmnamed, that is removed).

You can access any version of an element by using its version ID, which specifies its exact version-tree location.

That allows to access versions which aren't visible in the view (i.e. selected by the config spec of the view) in which you are executing a cleartool find (since a view is a requirement for a find).


Try also the -nxname option:

ct find . -all -nvi -nxname -type f -ele "brtype(my_branch)" -print

(but that would remove only the final @@)


fmt_ccase has some way to format it, but you can also try (as in here):

-exec "echo %CLEARCASE_PN%"

(Here it doesn't work, since there is no "path name" available for the version found: the view doesn't select it directly, so that version isn't visible, and %CLEARCASE_PN% is set to %CLEARCASE_XPN%, the extended path name).

Check also what the Leaf name returns:

-exec "cleartool  descr -fmt \"%Ln\" \"%CLEARCASE_XPN%\""

But that only returns the file name, not its path.


If you need a simple path (which won't represent an "actual" path, because those elements are not all visible in the view), you would need to process each line in order to remove /main/.../n1, leaving only Dir_C\dir_D\element.

Here is one library which is suppose to do that: ClearCase-Tools

 $explicitPath = '/vobTag/users/.@@/main/1/llf/main/12/install/main/1/README/main/2';
 $canonPath = ClearCase::Vob::CanonPath->parse( $explicitPath );
 $canonPath = $cpathObj->parse( $explicitPath );

Where $canonPath will, in this example, contain the following string:

 /vobTag/users/llf/install/README

You can find the sources in those rpm, in usr/lib/perl5/vendor_perl/5.6.1/ClearCase/Vob/CanonPath.pm.

The implementation isn't trivial, but it is doable: very small extract:

push @branches, "main";
while (@leaves && !(($leaves[0] =~ "^[0-9]+\$") || ($leaves[0] =~ "^CHECKEDOUT\.[0-9]+\$"))) {
  $leaf = shift(@leaves);
  push @branches, $leaf if defined($leaf);
  $self->dpr("dump(3) $leaf")     if defined($leaf);
}
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top