# Copyright 2004 Perforce Corporation, Inc. All rights reserved. import os import marshal def runp4cmd(p4cmd): """ Return the output from the Perforce command, and assume that the user put the '-G' in the options to get us marshall output. We always return an array for the results.""" fd = os.popen(p4cmd, 'rb') results = [] while 1: try: d = marshal.load(fd) results.append(d) except EOFError: break fd.close() return results def SubtractTwoHashes(list1, list2): '''find the things in list1 that aren't in list2, those in list2 (but not list1), and in common. Return those three results as a three-tuple. ''' OnlyList1res = [] OnlyList2res = [] Duplicates = [] for l in list1.keys(): if list2.has_key(l) and list2[l]: Duplicates.append(l) else: OnlyList1res.append(l) for l in list2.keys(): if list1.has_key(l) and list1[l]: pass # no need to duplicate the above entirely else: OnlyList2res.append(l) return [OnlyList1res, OnlyList2res, Duplicates]
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#2 | 6419 | Jeff Bowles |
binary reads. Oops. |
||
#1 | 4312 | Jeff Bowles |
Adding a number of example scripts that show how to get to Perforce data for a variety of scripting languages and variety of simple tasks. Note that Perl/Python/Ruby (and variants) are included, but shell/batch/DCL/applescript are not. (Am trying to stick with somewhat-portable approaches, to make comparisons easier.) Each program is written in the following languages/configurations: 1. Perl, calling "p4 -Ztag" for data 2. Perl, calling Tony Smith's "P4Perl" module 3. Python, calling "p4 -G" for data 4. Ruby, calling "p4 -R" for data 5. Ruby, calling Tony Smith's "P4Ruby" module The programs do the following: a. compare client specs to users (find old clients) b. compare two labels c. determine which client specs use compression. d. determine which files need to be "p4 add'ed." e. output list of 'opened' files, using local pathnames. |