# This progam is used to automatically version # label contents. # # Create the directory stucture specified by 'labelpath' # first before running script for the first time. # # Gerry Thompson Python Class Perforce Software 2002 # Version 1.0 # This imports p4s.py module. import marshal, os, string, p4s p4path = 'p4' # Path to p4 executable labelpath = '//depot/versions/labels/' # Path to label files in depot admin = 'gerry+label@perforce.com' # My 'From' address for email to = 'gerry@perforce.com' # My email address p4 = p4path def checklabel(alabel): oneline = os.popen(p4 + ' -s files ' + labelpath + alabel, 'r').readline() check = string.split(oneline, ) if len(check) == 0: print 'An error has occured in p4l.py' else: if check[0] == 'error:': # The label name is a new label name to be versioned. os.popen(p4 + ' label '+ alabel ,'r') os.popen(p4 + ' add ' + labelpath + alabel) else: os.popen(p4 + ' sync ' + labelpath + alabel) os.popen(p4 + ' edit ' + labelpath + alabel) # The label already exits. def makefile(labelname): checklabel(labelname) newline = [] for aline in os.popen(p4 + ' files //...@'+labelname, 'r').readlines(): if aline[0] != '#': if aline[0] != '\n': newline.append(aline) alist = os.popen(p4 + ' -G fstat ' + labelpath + labelname, 'rb') dict = marshal.load(alist) path = dict['clientFile'] open(path, 'w').writelines(newline) p4s.tryit(admin, to) def getlabel(aname): makefile(aname)