http://www.secnetix.de/olli/FreeBSD/perforce-ref.txt Perforce (p4) FreeBSD Howto / Reference Copyright (C) 2007-2009 Oliver Fromme, Munich. All rights reserved. Note, this is not a tutorial and not an introduction to p4 or to revision control systems in general. This is only a reference of typical actions and "daily doing", especially when using the FreeBSD Perforce repository. ================================================================ Prerequisites: $ mkdir ~/p4 $ cd ~/p4 $ $EDITOR ~/.p4config P4PORT=perforce.freebsd.org:1666 P4USER= P4PASSWD= P4CLIENT= $ chmod 600 ~/.p4config ================================================================ Get server and client info: $ p4 info View help page about p4 command (e.g. p4 "sync" command): $ p4 help sync View list of commonly used commands: $ p4 help simple Viel list of all commands: $ p4 help commands Show where I am, relative to depot, client and local host: $ p4 where Make sure sure to have up-to-date files from server: $ p4 sync ================================================================ View abbreviated revision history of a file: $ p4 filelog myfile.c View complete commit messages: $ p4 filelog -l myfile.c List all {users, clients, branches} known to the server: $ p4 {clients, users, branches} View a {user, client, branch} definition: $ p4 {user, client, branch} -o myname Create or edit a {user, client, branch} definition: $ p4 {user, client, branch} myname ================================================================ Please see note #3 below regarding the "p4 submit" command. Add a new file: $ $EDITOR newfile.c $ p4 add newfile.c $ p4 submit Edit an existing file: $ p4 edit myfile.c $ $EDITOR myfile.c $ p4 submit List files opened for editing by this client: $ p4 opened View unified diffs of all unsubmitted local changes: $ p4 diff -du View unified diff of a particular file: $ p4 diff -du myfile.c Rename a file: $ p4 integrate -i oldname.c newname.c $ p4 resolve $ p4 delete oldname.c $ p4 submit List the files that were modified in this branch: $ p4 diff2 -q -b my_branch Merge changes from current into my branch (called "IFC", see note #1 below): $ p4 integrate -b my_branch $ p4 resolve -as $ p4 resolve -du $ p4 diff -du (review changes) $ p4 submit Generate patch of my_branch against branch integrated from (only right after a fresh IFC, otherwise see note #2 below): $ p4 diff2 -u -b my_branch Note that the patch does not contain new files, i.e. files that did not exist in the branch integrated from! You'll have to add these separately. Another possibility is to omit the -u option and use the following post processing script: http://people.freebsd.org/~scottl/awkdiff ================================================================ Additional notes: 1. When doing an IFC (integrate from current), it is customary to include the change number against which you integrate in the commit message: "IFC @xxxxxx" In order to find that number, use this command: $ p4 changes -m 20 and look for the latest change made by "importer". Use that change number in the commit message. 2. If you want to provide a patch set for public consumption, make the patch against that change number (note that the default of diff2 is to use the current head revision, which is probably not what you want): $ p4 diff2 -u -b my_branch @xxxxxx #head That means: Produce a patch set of my_branch at its head revision against the branch it was integrated from (presumably the FreeBSD vendor branch) when it was at change level xxxxxx. You can omit "@xxxxxx #head" only if you did a fresh IFC right before, and you're sure there haven't been any commits since then. (Note: Some shells treat the "#" character specially, therefore you might have to quote it, i.e. write '#head' in single quotes.) 3. When doing a "p4 submit" and you stay in the editor for too long, a network time-out might occur, aborting the commit halfway through. This is not disaster, but it's annoying and somewhat non-intuitive to recover from. Therefore, if you intend to write a long commit message, it might be a good idea to prepare the message in advance, then fire up "p4 submit" and copy the prepared text into the template. ================================================================