【问题标题】:ClearCase : list the content of a directory (ls) using CALClearCase : 使用 CAL 列出目录 (ls) 的内容
【发布时间】:2010-11-03 17:45:30
【问题描述】:

在 ClearCase 中,您可以使用“cleartool ls”列出目录的内容。

我的问题是如何使用 CAL(ClearCase 自动化层)来做同样的事情。我更喜欢 COM API 的原因是我不必解析“ls”的输出。

到目前为止,我能够成功获取VOB和View,但是我没有找到任何列出内容的方法。

到目前为止我的代码:

IClearCase cc = new ApplicationClass();
CCVOB vob = cc.get_VOB("\\VOB-name");
CCView view = cc.get_View("ViewTag");

感谢您的帮助。

我用 C# 为感兴趣的人写了 VonC 的答案。

string[] files = Directory.GetFiles("View path here", "*.*", SearchOption.AllDirectories);
foreach (string file in files)
{
    try
    {
            CCVersion ver = cc.get_Version(file);
            Console.WriteLine(ver.Path);
    }
    catch(Exception) {/*the file is not versioned*/}
}

【问题讨论】:

  • 完成了我对“rmname”部分的回答。
  • 完成了我关于你的“ICCElement”问题的cmets。

标签: com list automation directory clearcase


【解决方案1】:

也许这是一个好的开始:

Set CC = Wscript.CreateObject("ClearCase.Application") 
Set DirVer = CC.Version(".") 
Set FSO = CreateObject("Scripting.FileSystemObject") 
Set Folder = FSO.GetFolder(DirVer.Path) 
Wscript.Echo "Files under source control: " 
For Each File in Folder.Files 
     On Error Resume Next 
     Set Ver = CC.Version(File.Name) 
     If Err.Number = 0 Then 
           Wscript.Echo Ver.ExtendedPath 
     End If 
Next

这个想法是使用ICCVersion 方法来尝试访问文件的版本。如果不返回错误,则确实是版本化文件。


现在我知道文件是版本控制的,我该如何删除它(rmname)。

不要使用 RemoveVersion():
无法恢复地删除版本(相当于cleartool rmver)
警告!这是一个潜在的破坏性操作。因为CAL在任何情况下都不会提示用户输入,所以调用RemoveVersion时没有确认步骤。调用 RemoveVersion 等同于使用 -force 选项运行 cleartool rmver。

改为使用ICCElement接口中的RemoveName。

【讨论】:

  • CC.Version(".") 仅在将当前目录设置为视图路径(通过 C# 中的 Environement.CurrentDirectory)时才有效。如果是这种情况,不能只删除第二行,然后执行 "Set Folder = FSO.GetFolder("-- your view path here --")" 吗?换句话说,第二行是必要的吗?泰。
  • 在你提到的情况下,这第二行确实是不必要的。但我还没有完全测试。
  • 好吧,又来了。如果我敢再补充一个小问题。现在我知道该文件是版本控制的,我该如何删除它(rmname)。有 RemoveVersion(...),但我不确定它是否等同于 rmname。
  • 警告:ClearCase 中有两个“删除版本”:rmver 是最危险的一个,因为它明确从 VOB 中删除版本。 rmname 只是从其父目录引用的文件列表中取消引用版本。
  • 改用 ICCElement 界面中的 RemoveName。
猜你喜欢
  • 2022-06-17
  • 1970-01-01
  • 1970-01-01
  • 2011-07-07
  • 2019-09-05
  • 2012-12-30
  • 2010-11-04
  • 2011-06-10
  • 1970-01-01
相关资源
最近更新 更多