In ClearCase, how can I view the old version of a file in a static view from the command line?

In a static view, how can I view an old version of a file?

Given an empty file (called empty in this example), I can undermine diff to show me the old version:

     % cleartool diff -ser empty File @@ / main / 28

This seems like a pretty ugly hack. Am I missing a more basic command? Is there an easier way to do this?

(I don’t want to edit the configuration specification - this is rather tedious, and I'm trying to look at a bunch of old versions.)

Explanation . I want to send a version of the file to stdout, so I can use it with the rest of Unix (grep, sed, etc.). If you found this question because you are looking for a way to save the version of an element in a file, see Brian's answer .

+15
clearcase
Oct 07 '08 at 1:02
source share
5 answers

I'm trying to look at a bunch of old versions

I'm not sure what you are talking about is a bunch of old versions of a single file, a bunch of old versions of several files.

To visualize several old versions of a single file, the simplest is to display its version tree ( ct lsvtree -graph File ), and then select the version, right-click it and " Send To ", which accepts several files (for example, Notepad ++) . In a few clicks you will see these old versions.
Note: you must have CC6.0 or 7.0.1. IFix01 (7.0.0 and 7.0.1 cannot "send" to a file with the following error message " Access to unnamed file was denied ")

But for visualizing several old versions of different files, I would recommend dynamically presenting and editing the configuration specification of this view (rather than the snapshot that you are currently working on) to quickly select all these old files (I hope with a simple selection rule, for example " element * aLabel ")




[From comments:]

what is the idiomatic way to "cat" an earlier version of a file?

The idiomatic way is to present a dynamic view (which you configure using the same configuration configuration as the existing existing snapshot).

Then you can view (as in the "change directory" section) various extended file paths .

If you want to quote all versions of a file branch, you go to:

 cd /view/MyView/vobs/myVobs/myPath/myFile@@/main/[...]/maBranch cat 1 cat 2 ... cat x 

' 1 ', ' 2 ', ... ' x ' is version 1, 2, ... x of your file in this thread.




An extended path is not available for presenting a snapshot , so your "hacking" is the way to go.

However, 2 comments here:

  • to quickly display all previous versions of the snapshot file in this branch, you can enter:

(single line version for copy-paste, Unix syntax :)

 cleartool find addon.xml -ver 'brtype (aBranch) &&! version (... / aBranch / LATEST) &&!  version (... / aBranch / 0) '-exec' cleartool diff -ser empty "$ CLEARCASE_XPN" '

(multi-line version for reading :)

 cleartool find addon.xml -ver 'brtype (aBranch) && 
                                ! version (... / aBranch / LATEST) && 
                                !  version (... / aBranch / 0) ' 
           -exec 'cleartool diff -ser empty "$ CLEARCASE_XPN"'
  • you can quickly get out a little better with

(single line version for copy-paste, Unix syntax :)

 cleartool find addon.xml -ver 'brtype (aBranch) &&! version (... / aBranch / LATEST) &&!  version (... / aBranch / 0) '-exec' cleartool diff -ser empty "$ CLEARCASE_XPN" '|  ccperl -nle '$ a = $ _;  $ b = $ a;  $ b = ~ s / ^> + \ s (?: file \ s + \ d +: \ s +)? // g; print $ b if $ a = ~ / ^> / '

(multi-line version for reading :)

 cleartool find addon.xml -ver 'brtype (aBranch) && 
                                ! version (... / aBranch / LATEST) && 
                                !  version (... / aBranch / 0) ' 
          -exec 'cleartool diff -ser empty "$ CLEARCASE_XPN"'
 |  ccperl -nle '$ a = $ _;  $ b = $ a; 
                $ b = ~ s / ^> + \ s (?: file \ s + \ d +: \ s +)? // g;
                print $ b if $ a = ~ / ^> / '

Thus, the result is better.




The " cleartool get " command (man page) mentioned below by Brian does not do stdout:

The get command only copies the elements of the file to the view.

On a UNIX or Linux system, copy /dev/hello_world/foo.c@@/main/2 to the current directory.

 cmd-context get –to foo.c.temp /dev/hello_world/foo.c@@/main/2 

On a Windows system, copy \dev\hello_world\foo.c@@\main\2 to the C:\build directory.

 cmd-context get –to C:\build\foo.c.temp \dev\hello_world\foo.c@@\main\2 

Thus, it is possible if, by passing the result to cat (or type in windows), you can do something with the output of the specified cat ( type ) command.

 cmd-context get –to C:\build\foo.c.temp \dev\hello_world\foo.c@@\main\2 | type C:\build\foo.c.temp 
+13
Oct 07 '08 at 6:03
source share

I know that this is an old thread ... but I could not allow this to fall on unauthorized ....

Static views have the "ct get" command, which does exactly what you are looking for.

 cleartool get -to ~/foo File@@/main/28 

saves this version of the file to ~/foo .

+12
Feb 10 2018-11-21T00:
source share

[Rewritten based on the first comment]

All files in Clearcase, including versions, are available in the virtual directory structure. I don't have much acquaintance with static views, but I believe that they still go through virtual fs; they just update in different ways.

In this case, you can simply do:

  cat File@@/main/28 

This can become ugly if you also need to find the correct version of the directory containing this file element. We have a PERL script at work that uses this approach to analyze historical changes made to files, and we quickly ran out of command line space on Windows to actually run commands!

+2
Oct 07 '08 at 4:58
source share

If the file is a Clearcase element and cat File working and the view is installed correctly, try:

 cat File@@/main/28 

(note: without ct shell - you do not need this if you are already in the view.)

Try entering:

 ct ls -l File 

If it shows a file with an extended name similar to the one above, then you should be able to roll the file using the extended name.

+1
05 Oct '10 at 21:50
source share

ct shell cat File @@ version

-one
Dec 28 '09 at 5:27
source share



All Articles