Академический Документы
Профессиональный Документы
Культура Документы
A definitive guide
Chapter 1: Installing P4
a) To check if perforce is installed properly: P4 info
Chapter 2: Configuring P4
Client workspace:
Client workspace is a set of directories on the client machine where you work on file revisions that are
managed by Perforce
Client: bruno_ws
Root: c:\bruno_ws
View:
//depot/... //bruno_ws/...
View:
//depot/dev/... //bruno_ws/depot/dev/...
//testing/... //bruno_ws/testing/...
//archive/... //bruno_ws/archive/...
The second mapping //depot/proj2/... maps to //joe/project and conflicts with the
first mapping. Because these mappings conflict, the first mapping is ignored; no files in //depot/proj1 are
mapped into the workspace: //depot/proj1/file.c is not mapped,even if //depot/proj2/file.c does not exist
Revertunchanged: Only those files with content or type changes are submitted to the depot. Unchanged files
are reverted.
p4 sync ...#none
Syncing
Syncing (retrieving) files
C:\bruno_ws>p4 sync <workspace>\…
Adding
p4 add -f -c 1 c:\pws\1.txt c:\pws\2.txt c:\pws\3.txt
3 files opened for add
p4 submit -f submitunchanged –i
Editing
P4 edit //depot/proj1/a.txt ( The blue tick mark on the p4v client symbolizes the file is opened for edit)
Revert
P4 revert //depot/proj1/a.txt
Changelists
A changelist contains a list of files, their revision numbers,and the operations to be performed on the files.
Unsubmitted changelists are referred to as pending changelists.
• p4 add
• p4 delete
• p4 edit
• p4 integrate
• p4 reopen
• p4 revert
p4 change is used to issue a numbered changelist,
Diffing a file:
Diff:
First open the file for edit
C:\pws>p4 edit //depot/1.txt
//depot/1.txt#1 - opened for edit
Then use;
C:\pws>p4 diff 1.txt
==== //depot/1.txt#1 - C:\pws\1.txt ====
Diff2: Its used to find out the diff between two different revision of files:
p4 diff2 file file#134
The difference between p4 lock and +l is that p4 lock allows anyone to open a file for
edit, but only the person who locked the file can submit it. By contrast, a file of type +l
prevents more than one user from opening the file.
Creating a branch using a file specification Version 2.2 of Jam has just been released, and work on version
3.0 is starting. Version 2.2 must be branched to //depot/release/jam/2.2/... for maintenance.Bruno uses p4
client to add the following mapping to his \
client view:
//depot/release/jam/2.2/... //bruno_ws/release/jam/2.2/...
He issues the following command to create the branch:
p4 integrate //depot/dev/main/jam/... //bruno_ws/release/jam/2.2/...
Finally, he issues the p4 submit command, which adds the newly branched files to the depot.
p4 integrate –b branchname
p4 submit
Untagging files
You can untag revisions with:
p4 tag -d -l labelname filepattern
Deleting labels
To delete a label, use the following command:
p4 label -d labelname
Jobs: A job is a numbered (or named) work request managed by the Perforce server. Perforce jobs enable
you to track the status of bugs and enhancement requests and associate them with change lists that
implement fixes and enhancements
Creating job:
p4 job jobname
Example:
P4 jobs –e use*
P4 jobs –e \*use*
Linking manually
To link a job to a changelist manually, issue the p4 fix -c changenum jobname command. If the changelist
has already been submitted, the value of the job’s Status:field is changed to closed. Otherwise, the status is
not changed.
p4 fix -c 18 options-bug
p4 job -i
p4 fix -c 1 Proj1
p4 files //depot/...
The files currently synced to the specified client workspace
p4 files @clientname
p4 files //clientname/...
p4 files filespec
Specified files at the time a changelist was submitted, regardless of whether the files were submitted in the
changelist
p4 files filespec@changenum
p4 filelog filespec
Example:
p4 filelog //depot/dev/main/jam/jam.c
Changelist reporting
With the first 31 characters of the changelist descriptions: p4 changes
With full descriptions p4 changes -l
The last n changelists p4 changes -m n
With a specified status p4 changes -s pending
or
p4 changes -s submitted
From a specified user p4 changes -u user
From a specified workspace p4 changes -c workspace
That affect specified files p4 changes filespec
That affect specified files, including changelists that affect files that were later integrated with the named
files
p4 changes -i filespec
That affect specified files, including only those changelists between revisions m and n of these files
p4 changes filespec#m,#n
That affect specified files at each revision between the revisions specified in labels lab1 and lab2
p4 changes filespec@lab1,@lab2
Submitted between two dates p4 changes @date1,@date2
Submitted on or after a specified date p4 changes @date1,@now
Label reporting
To display information about labels, issue the p4 labels command. The following table
lists some useful label reporting commands.
To list Use this command
Files in a pending changelist p4 opened -c changenum
Files submitted and jobs fixed by a particular
changelist, including diffs
p4 describe changenum
Files submitted and jobs fixed by a particular
changelist, suppressing diffs
p4 describe -s changenum
Files and jobs affected by a particular changelist,
passing the context diff flag to the underlying diff
program
p4 describe -dc changenum
The state of particular files at a particular
changelist, regardless of whether these files were
affected by the changelist
p4 files filespec@changenum
To list Use this command
All labels, with creation date and owner p4 labels
All labels containing a specific file revision (or range) p4 labels file#revrange
Files tagged with a specified label p4 files @labelname
A preview of the results of syncing to a label p4 sync -n @labelname
Chapter 8: Scripting and Reporting
Job reporting
Listing jobs
To list jobs, issue the p4 jobs command. The following table lists common job reporting commands.
Displaying users
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:
To list Use this command
all changelists linked to jobs p4 fixes
all changelists linked to a specified job p4 fixes -j jobname
all jobs linked to a specified changelist p4 fixes -c changenum
all fixes associated with specified files p4 fixes filespec
all fixes associated with specified files, including changelists that contain files that were later integrated
with the specified files
p4 fixes -i filespec
bruno <bruno@bruno_ws> (bruno) accessed 2005/03/07
dai <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
Perforce administration:
Database files store metadata, including changelists, opened files, client workspace specifications, branch
mappings, and other data concerning the history and present state of the versioned files.
Creating a checkpoint:
P4d –r $P4ROOT –jc
p4d -r D:\perforce\depots –jc
D:\perforce\depots>p4d -r D:\perforce\depots -jc
Checkpointing to checkpoint.1...
Rotating journal to journal.0...
Disabling journaling
To disable journaling, stop the server, remove the existing journal file (if it exists), set the environment
variable P4JOURNAL to off, and restart p4d without the -J flag.
p4 admin stop
There can be no db.* files in the $P4ROOT directory when you start recovery from a checkpoint. Although
the old db.* files are never used during recovery, it's good practice not to delete them until you're certain
your restoration was successful.
3. Invoke p4d with the -jr (journal-restore) flag, specifying your most recent checkpoint and current
journal. If you explicitly specify the server root ($P4ROOT), the -r $P4ROOT argument must precede the
-jr flag:
This recovers the database as it existed when the last checkpoint was taken, and then applies the changes
recorded in the journal file since the checkpoint was taken.
p4 admin stop
mv your_root_dir/db.* /tmp
The corrupt db.* files aren't actually used in the restoration process, but it's safe practice not to delete
them until you're certain your restoration was successful.
3. Invoke p4d with the -jr (journal-restore) flag, specifying only your most recent checkpoint:
This recovers the database as it existed when the last checkpoint was taken, but does not apply any of the
changes in the journal file. (The -r $P4ROOT argument must precede the -jr flag.)
The database recovery without the roll-forward of changes in the journal file brings the database up to date
as of the time of your last backup. In this scenario, you do not want to apply the changes in the journal
file, because the versioned files you restored reflect only the depot as it existed as of the last checkpoint.
Your restoration is complete. See "Ensuring system integrity after any restoration" on page 37 to make sure
your restoration was successful.
Files submitted to the depot between the time of the last system backup and the disk crash will not be present
in the restored depot.
User maintenance tasks, including resetting passwords, creating users, disabling the automatic creation of
users, and cleaning up files left open by former users
Administrative operations, including setting the server security level, obliterating files to reclaim disk
space, editing submitted changelists, verifying server integrity, defining file types to control Perforce’s file
type detection mechanism, and the use of the -f flag to force operations
Logging in to Perforce
p4 login
p4 login -a
Logging out of Perforce
p4 logout
p4 logout –a
p4 tickets
Creating Users
p4 user -f username
To prevent Perforce from automatically creating users, all users must be defined in the protections table.
The easiest way to do this is to include all users in a Perforce group, and to configure Perforce to grant
access only to members of that group.
p4 obliterate -y filename
p4 obliterate -y file#5
p4 obliterate -y file#5,7
p4 counter -f monitor 1
p4 counter -f monitor 2
p4 monitor show
To obtain more information about user environment, use the -e flag. The -e flag produces output of the
form
pid client IP-address status owner workspace hh:mm:ss command [args]
//depot/... //workspace/...
//depot/main/srv/devA/... //workspace/main/srv/devA/...
//depot/main/drv/lport/... //workspace/main/dvr/lport/...
//depot/rel2.0/srv/devA/bin/... //workspace/rel2.0/srv/devA/bin/...
//depot/qa/s6test/dvr/... //workspace/qa/s6test/dvr/...
@list = `p4 changes -s submitted`;
foreach $chg (@list)
{
$chgnbr = (split /s+/, $chg)[1];
print `p4 change -d -f $chgnbr`;
}
exit 0;zbuiv