【问题标题】:ClearCase label parent folders of a fileClearCase 标签文件的父文件夹
【发布时间】:2016-01-15 10:35:43
【问题描述】:

给定文件路径,如何标记所有父文件夹直到VOB级别?

例如文件路径:\VOB1\dir1\subdir1\moredir1\file1.xml

我想用 LABEL1 标记以下元素:

\VOB1\dir1\subdir1\moredir1\file1.xml
\VOB1\dir1\subdir1\moredir1
\VOB1\dir1\subdir1
\VOB1\dir1

用mklabel命令,轻松搞定:

cleartool mklabel LABEL1 \VOB1\dir1\subdir1\moredir1\file1.xml \VOB1\dir1\subdir1\moredir1 \VOB1\dir1\subdir1 \VOB1\dir1

但是,我希望智能地计算路径。

mklabel -rec 的参数不适合这个目的,因为顶层父文件夹可能包含很多其他文件/目录。

有什么想法吗?

【问题讨论】:

    标签: batch-file clearcase


    【解决方案1】:
    @echo off
    setlocal EnableDelayedExpansion
    
    set "filePath=\VOB1\dir1\subdir1\moredir1\file1.xml"
    set "wantedParent=VOB1"
    
    set "thisPath="
    set "labelPaths="
    set "labelThisPath="
    if "%filePath:~0,1%" equ "\" set "filePath=%filePath:~1%"
    for %%a in ("%filePath:\=" "%") do (
       set "thisPath=!thisPath!\%%~a"
       if defined labelThisPath (
          set "labelPaths=!thisPath! !labelPaths!"
       ) else if "%%~a" equ "%wantedParent%" (
          set "labelThisPath=true"
       )
    )
    
    ECHO cleartool mklabel %labelPaths%
    

    输出:

    cleartool mklabel \VOB1\dir1\subdir1\moredir1\file1.xml \VOB1\dir1\subdir1\moredir1 \VOB1\dir1\subdir1 \VOB1\dir1
    

    【讨论】:

      【解决方案2】:

      由于没有获取父文件夹列表的本地方法(除非 cleartool lsfolder -ancestor 有效),您只需 'cd ..' 直到 mklabel 失败(这意味着您在 vob 之外)

      cleartool mklabel LABEL1 . || exit
      cd ..
      

      在 bash 中:

      while true; do cleartool mklabel LABEL1 . || exit; cd ..; done
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2012-09-14
        • 1970-01-01
        • 2013-10-06
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2013-04-14
        相关资源
        最近更新 更多