This chapter provides details about using p4 commands in scripts and for reporting purposes. For a full description of any particular command, consult the
Perforce Command Reference, or issue the
p4 help command.
The following command-line flags enable you to specify settings on the command line and in scripts. For full details, refer to the description of global options in the
Perforce Command Reference.
If your scripts issue p4 commands that require the user to fill in a form, such as the
p4 client and
p4 submit commands, use the the
-o flag to write the form to standard output and the
-i flag to read the edited form from standard input.
1.
|
Issue the p4 job -o > temp1 command to write a blank job specification into a text file.
|
3.
|
Issue the p4 job -i < temp2 command to save the job.
|
•
|
p4 submit (use p4 change -o to create changelist, or p4 submit -d "A changelist description" to supply a description to the default changelist during changelist submission.)
|
To display information about single revisions of files, issue the p4 files command. This command displays the locations of the files in the depot, the actions (
add,
edit,
delete, and so on) performed on those files at the specified revisions, the changelists in which the specified file revisions were submitted, and the files' types. The following example shows typical output of the
p4 files command:
The p4 files command requires one or more
filespec arguments. Regardless of whether you use local, client, or depot syntax to specify the filespec arguments, the
p4 file command displays results using depot syntax. If you omit the revision number, information for the head revision is displayed. The output of
p4 files includes deleted revisions.
To display the revision history of a file, issue the p4 filelog filespec command. The following example shows how
p4 filelog displays revision history.
//depot/dev/main/jam/jam.c... #35 change 627 edit on 2001/11/13 by earl@earl-dev-yew (text) 'Handle platform variants better' ... #34 change 598 edit on 2001/10/24 by raj@raj-althea (text) 'Reverse previous attempt at fix' ... ... branch into //depot/release/jam/2.2/src/jam.c#1 ... #33 change 581 edit on 2001/10/03 by gale@gale-jam-oak (text) 'Version strings & release notes'
|
To list the files that are currently opened in a client workspace, issue the p4 opened filespec command. The following line is an example of the output displayed by the
p4 opened command:
To display the contents of a file in the depot, issue the p4 print filespec command. This command prints the contents of the file to standard output or to a specified output file, with a one-line banner that describes the file. To suppress the banner, specify the
-q flag. By default, the head revision is displayed, but you can specify a file revision.
By default, p4 annotate displays the file line by line, with each line preceded by a revision number indicating the revision that made the change. To display changelist numbers instead of revision numbers, specify the
-c flag.
The first line of file.txt has been present since revision 1, which was submitted in changelist 151. The second line has been present since revision 2, which was submitted in changelist 152.
You can combine the -a and
-c options to display all lines in the file and the changelist numbers (rather than the revision numbers) at which the lines existed.
To track changes to files as they occur, you can use the Perforce change review daemon, which enables Perforce users to specify files and directories of interest and receive email when a changelist that affects the specified files is submitted. For details about administering the review daemon, refer to the
Perforce System Administrator's Guide and to the description of the
p4 review command in the
Perforce Command Reference.
The p4 changes command
lists changelists that meet search criteria, and the
p4 describe command lists the files and jobs associated with a specified changelist. These commands are described below.
To list changelists, issue the p4 changes command. By default,
p4 changes displays one line for every changelist known to the system. The following table lists command-line flags that you can use to filter the list.
To list files and jobs affected by a specified changelist, along with the diffs of the changes, issue the
p4 describe command. To suppress display of the diffs (for shorter output), specify the
-s flag. The following table lists some useful changelist reporting commands.
To display information about labels, issue the p4 labels command. The following table lists some useful label reporting commands.
To list jobs, issue the p4 jobs command. The following table lists common job reporting commands.
Any jobs that have been linked to a changelist with p4 change,
p4 submit, or
p4 fix are referred to as
fixed (regardless of whether their status is
closed). To list jobs that were fixed by changelists, issue the
p4 fixes command.
The p4 users command displays the user name, an email address, the user's "real" name, and the date that Perforce was last accessed by that user, in the following format:
bruno <bruno@bruno_ws> (bruno) accessed 2005/03/07dai <dai@dai_ws> (Dai Sato) accessed 2005/03/04 earl <earl@earl_ws> (Earl Ashby) accessed 2005/03/07 gale <gale@gale_ws> (Gale Beal) accessed 2001/06/03 hera <hera@hera_ws> (Hera Otis) accessed 2001/10/03 ines <ines@ines_ws> (Ines Rios) accessed 2005/02/02 jack <jack@submariner> (jack) accessed 2005/03/02 mei <mei@mei_ws> (Mei Chang) accessed 2001/11/14 ona <ona@ona_ws> (Ona Birch) accessed 2001/10/23 quinn <quinn@quinn_ws> (Quinn Cass) accessed 2005/01/27 raj <raj@ran_ws> (Raj Bai) accessed 2001/07/28 vera <vera@vera_ws> (Vera Cullen) accessed 2005/01/15
|
To display information about client workspaces, issue the p4 clients command, which displays the client workspace name, the date the workspace was last updated, the workspace root, and the description of the workspace, in the following format.
Client bruno_ws 2005/03/07 root c:\bruno_ws ''Client dai-beos-locust 2002/10/03 root /boot/home/src '' Client earl-beos-aspen 2002/04/15 root /boot/src '' Client earl-dev-beech 2002/10/26 root /home/earl '' Client earl-dev-guava 2002/09/08 root /usr/earl/development '' Client earl-dev-yew 2004/11/19 root /tmp '' Client earl-mac-alder 2002/03/19 root Macintosh HD:earl '' Client earl-os2-buckeye 2002/03/21 root c:\src '' Client earl-qnx-elm 2001/01/17 root /src '' Client earl-tupelo 2001/01/05 root /usr/earl ''
|
To list depots, issue the p4 depots command. This command lists the depot's name, its creation date, its type (
local,
remote, or
spec), its host name or IP address (if
remote), the mapping to the local depot, and the system administrator's description of the depot.
The following sample script parses the output of the p4 fstat command to report files that are opened where the head revision is not in the client workspace (a potential problem).
#!/bin/sh# Usage: opened-not-head.sh files # Displays files that are open when the head revision is not # on the client workspace
if [ "$name" = "depotFile" ] then depotFile=$value
elif [ "$name" = "headRev" ] then headRev=$value
elif [ "$name" = "haveRev" ] then haveRev=$value
if [ $headRev != $haveRev ] then $echo $depotFile fi fi done
|
Copyright 2005-2009 Perforce Software.