Book Image

Learning Perforce SCM

By : Neal Ralph Firth, Robert Cowham
Book Image

Learning Perforce SCM

By: Neal Ralph Firth, Robert Cowham

Overview of this book

<p>Learning Perforce SCM is a pragmatic how-to guide, explaining the key concepts and usage of Perforce. Based on the authors' experiences training thousands of users around the globe, it explains those key concepts in a clear, incremental manner, combining sound theory with the pragmatic application of principles.<br /><br />Learning Perforce SCM provides practical knowledge which will transform you into confident and competent Perforce users in your day-to-day operations.<br /><br />You'll start by learning how to use Perforce to track your day-to-day coding activities. Once a solid foundation is established you'll learn how to apply the data mining features to evaluate current and past activities. Then you'll learn how to configure Perforce so that it adapts to support your specific development needs. All the while you'll be learning how to deal with conflicts and use the tool to communicate with other team members. Finally, you'll learn about using branches and streams to provide seamless support for concurrent development. Along the way, pragmatic hints and tips will help you avoid issues and identify areas for further personal exploration.</p> <p><em>"It's wonderful to see a new book about Perforce, especially one written by Robert Cowham and Neal Firth. No one can teach Perforce better than these seasoned subject matter experts"</em><br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;&nbsp; -&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <em>Laura Wingerd, author of Practical Perforce.</em></p>
Table of Contents (19 chapters)
Learning Perforce SCM
Credits
About the Authors
About the Reviewers
www.PacktPub.com
Preface
Index

Command-line help is always available


There are two options for getting help on the Perforce command line.

P4 Command Reference Guide

This is available from the Perforce website in two formats:

Notice that the URLs are not version specific, so you will get the latest version of the particular files.

As shown previously, the HTML version of the help includes a complete list of all Perforce commands. The specific page for each command explains command line flags and cross links to other related commands.

Setting environment variables

This is fully discussed in the command reference manual, towards the bottom of the table of contents:

Note the crucial variables which define the Perforce server you are communicating with (P4PORT), your username (P4USER), and your current workspace (P4CLIENT).

These will be set automatically if you use the Open Command Window Here option from P4V's right-click menu as discussed previously. Note that P4V itself does not take account of environment variables. Instead, it uses the settings defined by the Connection menu and Edit | Preferences options.

Run the p4 set command:

C:\work\bruno_jam_main\depot\Jam\MAIN\src>p4 set
P4CLIENT=bruno_jam_main
P4CONFIG=p4config.txt (set) (config 'noconfig')
P4EDITOR=C:\Windows\notepad.exe (set)
P4PORT=1666
P4USER=bruno

The output shows us the key environment variables already set up in the command window: P4PORT (1666 is a port on the local machine), P4USER, and P4CLIENT.

The info command also shows us basic server information:

C:\work\bruno_jam_main\depot\Jam\MAIN\src>p4 info
User name: bruno
Client name: bruno_jam_main
Client host: Robert-Laptop
Client root: C:\work\bruno_jam_main
Current directory: c:\work\bruno_jam_main\depot\Jam\MAIN\src
Peer address: 127.0.0.1:52808
Client address: 127.0.0.1
Server address: Robert-Laptop:1666
Server root: C:\perforce\p4book\
Server date: 2013/08/26 09:42:58 +0100 GMT Daylight Time
Server uptime: 155:31:02
Server version: P4D/NTX64/2013.2.BETA/663432 (2013/06/25)
Server license: none
Case Handling: insensitive

A commonly seen error message for the info command is:

Perforce client error:
        Connect to server failed; check $P4PORT.
        TCP connect to 1248 failed.
        connect: 127.0.0.1:1248: WSAECONNREFUSED

This suggests that either we have configured the wrong value for P4PORT, or perhaps that the server is not running, or there is a network issue. Check with your administrator to resolve this.

Tip

If you do much work at the command line then we recommend reading up on the P4CONFIG environment variable. It makes life much more convenient!

P4 help

Help is always available when running at the command line:

C:\work\bruno_jam_main>p4 help

    Perforce -- the Fast Software Configuration Management System.

    p4 is Perforce's client tool for the command line.  Try:

        p4 help simple          list most common commands
        p4 help commands        list all standard commands
        p4 help command         help on a specific command

        p4 help administration  help on specialized administration topics
        p4 help charset         help on character set translation
        p4 help configurables   list server configuration variables
        p4 help environment     list environment and registry variables
        p4 help filetypes       list supported file types
        p4 help jobview         help on jobview syntax
        p4 help networkaddress  help on network address syntax
        p4 help revisions       help on specifying file revisions
        p4 help streamintro     introduction to streams
        p4 help usage           generic command line arguments
        p4 help views           help on view syntax

        p4 help legal           legal and license information

    The full user manual is available at http://www.perforce.com/manual.

It is often useful to refer to help on specific commands, a list of which is available:

C:\work\bruno_jam_main>p4 help commands

    Perforce client commands:

        add          Open a new file to add it to the depot
        annotate     Print file lines along with their revisions
        attribute    Set per-revision attributes on revisions
        branch       Create or edit a branch specification
        branches     Display list of branches
        change       Create or edit a changelist description
        changes      Display list of pending and submitted changelists
        changelist   Create or edit a changelist description
        changelists  Display list of pending and submitted changelists
        client       Create or edit a client specification and its view
        clients      Display list of known clients
        :