【问题标题】:how to find files in a given branch如何在给定分支中查找文件
【发布时间】:2011-02-16 15:59:02
【问题描述】:

我注意到,在进行代码查看时,我公司的人们通常只给出他工作所在的分支,而不是其他。所以我想必须有一种简单的方法来找出给定分支中具有版本的所有文件,这与查找所有文件相同 那已经改变了。

是的,我不知道在某些分支中查找文件的预期“简单方法”,因此需要您的帮助并提前致谢。

【问题讨论】:

标签: clearcase


【解决方案1】:

您可以快速列出来自特定分支的所有文件:

cleartool find . -type f -branch "brtype(abranch)" -print

我建议将其与:

  • -user 限制为特定用户,以防多个用户使用同一个分支。
清除工具找到 . -type f -branch "brtype(abranch)" -user aloginname -print
  • -created_since 过滤器,用于查找自特定日期以来创建的所有元素,以防它们对同一分支上的工作进行增量审查。
清除工具找到 . -type f -branch "brtype(abranch)" -element "{created_since(10-Jan)}" -user aloginname -print

【讨论】:

  • -version 中的 created_since 过滤器(如stackoverflow.com/questions/22300632/… 中所述)和这里使用的-element 有什么区别?结果肯定不同。
  • @x29a 它只是在 created_since 应用的项目上:元素(意味着文件已“添加到源代码管理”或该元素的版本(意味着自特定日期)
  • 我为此创建了一个新问题:stackoverflow.com/questions/27959952/… - 很抱歉造成混淆。 5分钟的editlimit让我;/
【解决方案2】:

这是一个可以解决问题的 python 脚本。它可能看起来要复杂得多,但它是复制粘贴即可。随意用 VonC 替换 cmd。

import subprocess
import os
import sys
from   optparse import OptionParser

def pipeCmd(Cmd):
    pipe = subprocess.Popen(Cmd,
        shell = True,
        stdout = subprocess.PIPE,
        stderr = subprocess.PIPE )
    (stdout_data,stderr_data) = pipe.communicate()
    return (pipe,stdout_data,stderr_data)

def main(br_name):                         
        cmd = "cleartool find -vis -avobs -element 'brtype(" + br_name + ")' -exec 'cleartool describe -short $CLEARCASE_PN'"
        pipe,data,err = pipeCmd(cmd)
        if 0 == pipe.returncode:
            print data
        else:
            print err                           

# Process cmd arguments
if (1):
    if (len(sys.argv) <= 1):
        print "Finds all branches in your view."
        print "\nExamples:\n"\
            "allBranches.py -b $BRANCH_NAME \n"\
            "allBranches.py --branch=$BRANCH_NAME\n"

    parser = OptionParser()
    branchName = "Example: 'rs__BRANCH_NAME_int'"
        parser.add_option("-b", "--branch", dest="BRANCH_NAME", help=branchName, metavar="BRANCH_NAME")       
    (options, args) = parser.parse_args()

if (options.BRANCH_NAME):
        print "\nFinding " + options.BRANCH_NAME + " elements...\n" 
        main(options.BRANCH_NAME)

sys.exit(0)

【讨论】:

  • 如果您使用的是 Windows ClearCase,“报表生成器”可用于查找具有给定分支名称的所有元素,以及查找最新版本号(显式元素)的选项。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2012-02-16
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2014-02-10
相关资源
最近更新 更多