ClearCase:查找仅具有一个特定标签而不是更多标签的文件

发布于 2024-07-25 18:43:05 字数 343 浏览 3 评论 0原文

我想在 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

歌入人心 2024-08-01 18:43:05

假设 LBL_A 是您想要运行的(唯一)标签,

cleartool find /some/dir -version 'lbtype(LBL_A)' -print | xargs cleartool describe -fmt "%n: %l"

应将其作为输出提供

file1: (LBL_A, LBL_B)
file2: (LBL_A)

,然后您可以在 Perl 脚本中检查或通过 sed -n 's/\(.*\): (LBL_A)/\1/ 进行过滤p'(假设文件名中没有冒号)。

更新:正如 VonC 正确指出的那样,上面的命令对于包含空格的文件将失败。要处理该问题,请运行为:

cleartool find ... -print | tr '\012' '\000' | xargs -0 cleartool ....

它将换行符转换为 ascii null,然后让 xargs 使用它作为分隔符。

Assuming LBL_A is the (only) label you want running

cleartool find /some/dir -version 'lbtype(LBL_A)' -print | xargs cleartool describe -fmt "%n: %l"

should give

file1: (LBL_A, LBL_B)
file2: (LBL_A)

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:

cleartool find ... -print | tr '\012' '\000' | xargs -0 cleartool ....

which will translate newlines into ascii null and then have xargs use that as delimiter.

じее 2024-08-01 18:43:05

您可以直接执行此操作,而无需通过管道:

cleartool find . -ver "lbtype(LBL_A) && !lbtype(LBL_B)" -print

You can do this directly without having to pipe:

cleartool find . -ver "lbtype(LBL_A) && !lbtype(LBL_B)" -print
顾忌 2024-08-01 18:43:05

赫洛夫达尔的回答说明,在这种情况下,您必须找到比您需要的更多的元素,然后过滤它们(尽管所有 ClearCase 查找功能)。

注意:

 cleartool find . -type f -element 'lbtype_sub(LBL_A)' -print

可以直接为您提供元素(而不是在这种情况下可能不感兴趣的版本)。 您可以使用 -version 和格式指令找到版本,如下所述。

fmt_ccase,您可以定制输出以精确获取 Perl 脚本需要继续执行的内容:

 cleartool find . -type f -element 'lbtype_sub(LBL_A)' -exec 'cleartool describe -fmt "%En %Cl\n" \"$CLEARCASE_XPN\"' | grep -v ","
  • -fmt "%En %l\n" 将显示元素的完整路径(而不是版本:/a/b/myFile@@/main/myVersion)=> /a/b/myFile'. '\n` 确保每行一个结果。
  • -version-fmt "%n %l\n" 将显示版本
  • \"$CLEARCASE_XPN\":双引号围绕找到的版本的扩展路径,确保名称中带有空格的文件仍然有效。
  • grep -v ",":如果有逗号,则表示“多个标签”
  • %Cl:避免显示全部列表的标签。 无论如何,如果不止一个,你就不感兴趣!

因此,要查找确切的版本

 cleartool find . -type f -version 'lbtype_sub(LBL_A)' -exec 'cleartool describe -fmt "%n %Cl\n" \"$CLEARCASE_XPN\"' | grep -v ","|awk '{sub(/ \(.*/,"");print}'

注意:
上面的代码适用于 unix 语法。 Windows 语法为:

cleartool find . -type f -element "lbtype(LBL_A)" -exec "cleartool describe -fmt \"%n %Cl\n\" \"%CLEARCASE_XPN%\"" | grep -v "," | gawk "{gsub(/ \(.*,"");print}"

,它将列出仅具有一个(正确)标签的文件的版本。

  • 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:

 cleartool find . -type f -element 'lbtype_sub(LBL_A)' -print

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:

 cleartool find . -type f -element 'lbtype_sub(LBL_A)' -exec 'cleartool describe -fmt "%En %Cl\n" \"$CLEARCASE_XPN\"' | grep -v ","
  • -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:

 cleartool find . -type f -version 'lbtype_sub(LBL_A)' -exec 'cleartool describe -fmt "%n %Cl\n" \"$CLEARCASE_XPN\"' | grep -v ","|awk '{sub(/ \(.*/,"");print}'

Note:
The above works with unix syntax. The windows syntax would be:

cleartool find . -type f -element "lbtype(LBL_A)" -exec "cleartool describe -fmt \"%n %Cl\n\" \"%CLEARCASE_XPN%\"" | grep -v "," | gawk "{gsub(/ \(.*,"");print}"

, 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"
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文