在ClearCase中,如何从命令行在静态视图中查看文件的旧版本? [英] In ClearCase, how can I view old version of a file in a static view, from the command line?

查看:93
本文介绍了在ClearCase中,如何从命令行在静态视图中查看文件的旧版本?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在静态视图中,如何查看文件的旧版本?



给出一个空文件(称为 empty 在此示例中)我可以颠覆 diff 向我展示旧版本:

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

这感觉很丑陋。我错过了更基本的命令吗?有没有更整洁的方法呢?



(我不想编辑配置规范-太繁琐了,我试图看看一堆

说明:我想将该文件的版本发送到stdout,因此我可以将其与其他版本一起使用Unix(grep,sed等)。如果由于正在寻找将元素版本保存到文件中的方式而发现此问题,请参见


我正在尝试查看一堆旧版本


我不确定您是否在谈论一堆旧版本。 一个文件,一堆旧版本;


要显示一个文件的多个旧版本,最简单的方法是显示其版本树( ct lsvtree-图形文件),然后选择一个版本,右键单击它,然后使用 发送到一个接受多个文件的编辑器(例如Notepad ++) 。只需单击几下,您便可以查看那些旧版本。

注意:您必须具有CC6.0或7.0.1 IFix01(7.0.0和7.0.1无法发送到带有以下错误消息的文件 拒绝访问未命名文件


但是要可视化不同文件的多个旧版本,我建议使用动态视图并编辑该视图的配置规范(而不是当前正在使用的快照视图),以便快速选择所有那些旧文件(希望通过简单的选择规则,例如' element * aLabel ')




[来自评论:]


猫的惯用方式是什么文件的较早版本?


惯用的方式是通过动态视图(您使用完全相同的配置进行配置规范,而不是现有的快照视图。


然后,您可以浏览文件(如在将目录更改为中一样)各种扩展路径

>

如果要显示文件分支的所有版本,请进入:

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

' 1 ',' 2 ',...' x '是该分支中文件的版本1、2,... x。




对于快照视图扩展路径不可访问,因此您的 hack


不过,这里有2条评论:



  • 可快速显示快照的所有先前版本给定分支中的文件,您可以键入:


(复制粘贴的一线版本,Unix语法:)

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

(多行版本,以提高可读性: )

 
cleartool查找addon.xml -ver'brtype(aBranch)&&
!version(... / aBranch / LATEST)&&
!版本(... / aBranch / 0)'
-exec'cleartool diff -ser空 $ CLEARCASE_XPN'



  • 使用$ li

(复制粘贴的一线版本,Unix语法:)

$,您可以很快得到更好的输出。 b $ b

 
cleartool查找addon.xml -ver'brtype(aBranch)&&!version(... / aBranch / LATEST)&&!版本(... / aBranch / 0)’-exec‘cleartool diff -ser空 $ CLEARCASE_XPN’| ccperl -nle’$ a = $ _; $ b = $ a; $ b =〜s / ^> + \s(?:file\s + \d +:\s +)?// g;如果$ a =〜/ ^> /'

(多行版本,以提高可读性:)

 
cleartool find addon.xml -ver'brtype( aBranch)&&
!version(... / aBranch / LATEST)&&
!版本(... / aBranch / 0)’
-exec‘cleartool diff -ser空 $ CLEARCASE_XPN’
| ccperl -nle’$ a = $ _; $ b = $ a;
$ b =〜s / ^> + \s(?:file\s + \d +:\s +)?// g;
如果$ a =〜/ ^> /'

则打印$ b这样,输出会更好。




> cleartool get 命令(手册页) Brian 的下面提到的a-static-view-from-the-com / 4962643#4962643> 't do stdout:


get命令仅将文件元素复制到视图中。


在UNIX或Linux上系统,将 /dev/hello_world/foo.c @@ / main / 2 复制到当前目录。



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



在Windows系统上,复制 \dev\hello_world\foo.c @@ \main\ 2 进入 C:\build 目录。



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

因此,也许可以通过将结果传递给 cat (或在Windows中输入),然后用 cat type )命令的输出执行某些操作。

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


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 subvert diff to show me the old version:

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

This feels like a pretty ugly hack. Have I missed a more basic command? Is there a neater way to do this?

(I don't want to edit the config spec - that's pretty tedious, and I'm trying to look at a bunch of old versions.)

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

解决方案

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

I am not sure if you are speaking about "a bunch of old versions" of one file, "a bunch of old versions" from several files.

To visualize several old versions of one file, the simplest mean is to display its version tree (ct lsvtree -graph File), and then select a version, right-click on it and 'Send To' an editor which accepts multiple files (like Notepad++). In a few click you will have a view of those old versions.
Note: you must have CC6.0 or 7.0.1 IFix01 (7.0.0 and 7.0.1 fail to 'sent to' a file with the following error message "Access to unnamed file was denied")

But to visualize several old versions of different files, I would recommend a dynamic view and editing the config spec of that view (and not the snapshot view you are currently working with), in order to quickly select all those old files (hopefully through a simple select rule like 'element * aLabel')


[From the comments:]

what's the idiomatic way to "cat" an earlier revision of a file?

The idiomatic way is through a dynamic view (that you configure with the exact same config spec than your existing snapshot view).

You can then browse (as in 'change directory to') the various extended paths of a file.

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

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

'1', '2', ... 'x' being the version 1, 2, ... x of your file within that branch.


For a snapshot view, the extended path is not accessible, so your "hack" is the way to go.

However, 2 remarks here:

  • to quickly display all previous revisions of a snapshot file in a given branch, you can type:

(one 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 readability:)

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

  • you can quickly have an output a little nicer with

(one 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 readability:)

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 =~/^>/'

That way, the output is nicer.


The "cleartool get" command (man page) mentioned below by Brian don't do stdout:

The get command copies only file elements into a view.

On a UNIX or Linux system, copy /dev/hello_world/foo.c@@/main/2 into 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 into the C:\build directory.

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

So maybe than, by piping the result to a cat (or type in windows), you can then do something with the output of said 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 

这篇关于在ClearCase中,如何从命令行在静态视图中查看文件的旧版本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆