17

I noticed that when doing code view, people here in my company usually just give the branch in which his work is done, and nothing else. So I guess there must be a easy way to find out all the files that has a version in the given branch which is the same thing to find all the files that has been changed.

Yes, I don't know the expected "easy way" to find files in certain branch, so need your help and thanks in advance.

Haiyuan Zhang
  • 40,802
  • 41
  • 107
  • 134
  • more info also here http://stackoverflow.com/questions/5800926/how-to-find-the-files-modified-under-a-clearcase-branch – x29a Mar 03 '14 at 15:03

2 Answers2

28

You can quickly list all files from a particular branch:

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

I would recommend combining that with:

  • -user to limit to a particular user, in case several users use the same branch.
    cleartool find . -type f -branch "brtype(abranch)" -user aloginname -print
  • -created_since filter, to find all elements created since a certain date, in case their is incremental review for a work done on the same branch.
    cleartool find . -type f -branch "brtype(abranch)" -element "{created_since(10-Jan)}" -user aloginname -print
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • what is the difference between the created_since filter in -version (as stated in http://stackoverflow.com/questions/22300632/cleartool-finding-changes-from-specific-date) and the -element used here? the results surely differ. – x29a Jan 15 '15 at 09:02
  • @x29a it is just on what item the created_since apply: the element (meaning when a file has been "added to source control" or the versions of that element (meaning all the versions checked in since a certain date) – VonC Jan 15 '15 at 09:08
  • i created a new question for this: http://stackoverflow.com/questions/27959952/cleartool-difference-between-element-and-version - sorry for the confusion. editlimit of 5min got me ;/ – x29a Jan 15 '15 at 09:09
1

Here is a python script that does the trick. It may look a lot more complicated but it's copy paste and go. Feel free to swap out the cmd with VonC's.

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)
Benjamin Castor
  • 234
  • 3
  • 9
  • If you are using Windows ClearCase 'Report Builder' can be used to find all elements with a given branch name, as well as the option to find the latest version number (explicit element). – Benjamin Castor Feb 23 '16 at 22:29