ClearCase:查找仅具有一个特定标签而不是更多标签的文件
我想在 ClearCase 中查找标有特定标签但没有设置任何其他标签的文件。
例如,如果我有这样标记的文件:
file1 LBL_A, LBL_B
file2 LBL_A
我希望有一个查询只提供 file2 而不是 file1。
有没有办法用cleartool find 来做到这一点? 如果这不可能通过单个查询来完成,我也很乐意了解如何分几步完成此操作的任何想法(我将从 perl 脚本调用cleartool,因此可以轻松保存文件列表暂时并对其运行进一步的命令)。
预先非常感谢!
扬
I'd like to find files in ClearCase that are labeled with a specific label but that do not have any other labels set.
For example, if I have files labeled like this:
file1 LBL_A, LBL_B
file2 LBL_A
I'd like to have a query that gives me just file2 and not file1.
Is there a way to do this with cleartool find? If this is not possible to do with a single query, I'd also be happy for any ideas how to do this in several steps (I'll be calling cleartool from a perl script, so it will be easy to save lists of files temporarily and run further commands on them).
Thanks a lot in advance!
Jan
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
假设 LBL_A 是您想要运行的(唯一)标签,
应将其作为输出提供
,然后您可以在 Perl 脚本中检查或通过 sed -n 's/\(.*\): (LBL_A)/\1/ 进行过滤p'(假设文件名中没有冒号)。
更新:正如 VonC 正确指出的那样,上面的命令对于包含空格的文件将失败。要处理该问题,请运行为:
它将换行符转换为 ascii null,然后让 xargs 使用它作为分隔符。
Assuming LBL_A is the (only) label you want running
should give
as output which you then can check in your perl script or filter through
sed -n 's/\(.*\): (LBL_A)/\1/p'
(assuming no colons in filenames).Update: As VonC correctly points out, the command above will fail for files with spaces in. To handle that run as:
which will translate newlines into ascii null and then have xargs use that as delimiter.
您可以直接执行此操作,而无需通过管道:
You can do this directly without having to pipe:
赫洛夫达尔的回答说明,在这种情况下,您必须找到比您需要的更多的元素,然后过滤它们(尽管所有 ClearCase 查找功能)。
注意:
可以直接为您提供元素(而不是在这种情况下可能不感兴趣的版本)。 您可以使用
-version
和格式指令找到版本,如下所述。在 fmt_ccase,您可以定制输出以精确获取 Perl 脚本需要继续执行的内容:
-fmt "%En %l\n"
将显示元素的完整路径(而不是版本:/a/b/myFile@@/main/myVersion)=> /a/b/myFile'. '
\n` 确保每行一个结果。-version
和-fmt "%n %l\n"
将显示版本\"$CLEARCASE_XPN\"
:双引号围绕找到的版本的扩展路径,确保名称中带有空格的文件仍然有效。grep -v ","
:如果有逗号,则表示“多个标签”%Cl
:避免显示全部列表的标签。 无论如何,如果不止一个,你就不感兴趣!因此,要查找确切的版本:
注意:
上面的代码适用于 unix 语法。 Windows 语法为:
,它将列出仅具有一个(正确)标签的文件的版本。
awk '{sub(/ \(.*/,"");print}'
会将“myFile@@/main/myVersion (LBL_A)
”转换为“myFile @@/main/myVersion"hlovdal's answer illustrates that, in this case, you have to find more elements than you need, and then filter them (despite all the ClearCase find features).
Note:
could give you directly the elements (and not the version which may not be interesting in this case). You can find the version with
-version
and a format directive as explained below.With the help of fmt_ccase, you can tailor the output to get precisely what your perl script will need to go on:
-fmt "%En %l\n"
will display the full path of the element (instead of the version: /a/b/myFile@@/main/myVersion)=> /a/b/myFile'. the '
\n` ensure one result per line.-version
and-fmt "%n %l\n"
would display the version\"$CLEARCASE_XPN\"
: the double quotes arount the extended path of the version found ensure a file with spaces in its name will still work.grep -v ","
: if there is any comma, that means "more than one label"%Cl
: avoid displaying the all list of labels. Anyway, if there are more than one, you are not interested!So, for finding the exact version:
Note:
The above works with unix syntax. The windows syntax would be:
, which would list the version of files with only one (correct) label.
awk '{sub(/ \(.*/,"");print}'
will transform "myFile@@/main/myVersion (LBL_A)
" into "myFile@@/main/myVersion"