# # read in -Ztag output. # # Note that this is a very simple-minded implementation # that only reads in the first line of a field - multiline # fields (descriptions, etc) require more code here. # # Copyright 2004 Perforce Corporation, Inc. All rights reserved. sub readinZtag { my ($str) = @_; my (@retval); my ($oldIFS) = $/; $/ = ''; # set IFS to double-newline print "running \"$str\"\n"; open(FD, "$str|") || die "cannot run \"$str\""; while (<FD>) { my (%h); @fields = split("\n", $_); # # input is "... fieldname fieldvalue", # so we parse it and put into assoc. array # foreach $f (@fields) { if ($f =~ /^\.\.\.\s+(\S+)\s+(.*)/) { local($key, $val) = ($1,$2); $h{$key} = $val; } } push(@retval, \%h) if length(keys(%h)) > 0; } close(FD); $/ = $oldIFS; # reset IFS return @retval; } sub readInfo { my ($str) = "$p4 info"; my (%retval); open(FD, "$str|") || die "cannot run \"$str\""; while (<FD>) { if (/^\.\.\.\s+(\S+)\s+(.*)/) { local($key, $val) = ($1,$2); $retval{$key} = $val; } } close(FD); return %retval; } 1;
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#2 | 5286 | Jeff Bowles |
fixing some incompatibilities with newer 'p4 info' behavior. (Okay, and fixing some earlier coding error!) |
||
#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. |