我的一个 Excel VBA 脚本循环遍历特定 ClearCase 元素的所有版本,以查看它是否已合并。当使用 rmver 删除特定版本时,此操作失败(不建议使用破坏性删除,但我们确实在极少数情况下求助于此以使开发人员摆脱依赖)。
在 DOS 中,下面的代码完美运行:
IF EXIST M:\View\LAMI\build.xml@@\main\lc_adhoc_dev\3 ECHO Yes
Yes
为了在 VBA 中执行此操作,我尝试使用 Dir 方法检查是否存在特定版本:
Dim elementVersion As String
elementVersion = "M:\View\LAMI\build.xml@@\main\lc_adhoc_dev\3"
If Len(Dir(elementVersion)) > 0 Then
' Version exists
Else
' Version does not exist
End If
但是,这会导致错误“文件名或编号错误”:
我也试过fso对象的FileExists方法:
Dim elementVersion As String
elementVersion = "M:\View\LAMI\build.xml@@\main\lc_adhoc_dev\3"
Dim fsoObj As Object
Set fsoObj = CreateObject("Scripting.FileSystemObject")
If fsoObj.FileExists(elementVersion) = True Then
' Version exists
Else
' Version does not exist
End If
但是,该调用始终返回 False。似乎所有这些方法都与 ClearCase MVFS 虚拟 M: 驱动器有关。还有什么我可以尝试的吗?
最佳答案
I'm trying not to have to rely on the
Err
object, i.e. not use acleartool
command that fails when it encounters a non-existing version (such as get or descr).
这正是你应该依赖的东西,除非你有约束(比如每秒测试数千个元素,或其他性能瓶颈)
cleartool describe
可以应用于 extended pathname如果它不存在,将会失败。
作为commented通过 Brian Cowan ,您可以检查 Excel VBA 是否可以从 ClearCase Automation Library (CAL) 调用命令.
我有 used CAL in VB Script before .
关于vba - 检查 VBA 中是否存在 ClearCase 版本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43348071/