检查 VBA 中是否存在 ClearCase 版本

Check ClearCase version existence in VBA

我的一个 Excel VBA 脚本循环遍历特定 ClearCase 元素的所有版本以查看它是否已合并。当使用 rmver 删除特定版本时,此操作失败(不建议使用破坏性删除,但我们确实在极少数情况下诉诸于此以使开发人员摆脱依赖)。

在 DOS 中,以下操作完美:

IF EXIST M:\View\LAMI\build.xml@@\main\lc_adhoc_dev ECHO Yes
Yes

为了在 VBA 中做到这一点,我尝试使用 Dir 方法检查是否存在特定版本:

Dim elementVersion As String
elementVersion = "M:\View\LAMI\build.xml@@\main\lc_adhoc_dev"

If Len(Dir(elementVersion)) > 0 Then
  ' Version exists
Else
  ' Version does not exist
End If

但是,这会导致错误 "Bad file name or number":

我也试过fso对象的FileExists方法:

Dim elementVersion As String
elementVersion = "M:\View\LAMI\build.xml@@\main\lc_adhoc_dev"
Dim fsoObj As Object
Set fsoObj = CreateObject("Scripting.FileSystemObject")

If fsoObj.FileExists(elementVersion) = True Then
  ' Version exists
Else
  ' Version does not exist
End If

然而,那个调用总是returns错误。似乎所有这些方法都与 ClearCase MVFS 虚拟 M: 驱动器有关。还有什么我可以尝试的吗?

I'm trying not to have to rely on the Err object, i.e. not use a cleartool command that fails when it encounters a non-existing version (such as get or descr).

那是准确地你应该依赖的东西,除非你有限制(比如每秒测试数千个元素,或其他性能瓶颈)

cleartool describe can be applied on an extended pathname 不存在则失败

by Brian Cowan, you can check if Excel VBA can call commands from the ClearCase Automation Library (CAL).
我有 used CAL in VB Script before.