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

Install it


The basic principles for platform-specific instructions are:

  1. Download the appropriate server for your operating system (as mentioned in the previous section)

  2. Download the zipped test repository (see link mentioned in the previous section)

  3. Unzip the repository in a local directory

  4. Initialize the Perforce repository in that directory

  5. Run the Perforce server (p4d or p4d.exe) specifying a particular port and the correct directory

The contents of the zip file

When the file is uncompressed, it creates a directory named PerforceSample. The PerforceSample directory contains the following files:

  • checkpoint (a file containing Perforce metadata)

  • checkpoint.md5 (checkpoint checksum)

  • readme.html (a description including installation instructions)

  • server.bat (a Windows batch file to run the server)

It also contains the following directories containing Perforce archive files:

  • depot

  • jam

  • spec

Detailed installation instructions for Windows

Please note that a copy of these instructions is also available at the web page linked in the previous Platform specific executables section. Use the online instructions if they are different to what is contained here:

  1. Uncompress the sampledepot.zip file using a standard compression utility such as WinZip or 7-Zip. On Windows 7 or above, Windows Explorer can open .zip files as compressed folders: right-click the folder, click on Extract All, and then follow the instructions.

  2. The PerforceSample directory where you unzipped the files, for example c:\PerforceSample, is known as the P4ROOT directory.

  3. Copy the p4d.exe executable to the P4ROOT directory using Windows Explorer.

  4. Run a command prompt window (click on Start, type Command Prompt and click on Run).

  5. Change to the P4ROOT directory:

    cd c:\PerforceSample
    
  6. To create your sample Perforce database, restore the checkpoint file by issuing the following command (from the P4ROOT directory):

    p4d -r . -jr checkpoint
    
  7. To ensure that the database format is consistent with the Perforce server version that you are using, issue the following command:

    p4d -r . -xu
    
  8. If the command is successful, you will see the message: ...upgrades done.

  9. Run the file server.bat (see the following sections for details).

Detailed installation instructions for non-Windows operating systems

Please note that a copy of these instructions is also available at the web page linked in the previous Platform specific executables section. Use the online instructions if they are different to what is contained here.

  1. Uncompress the sampledepot.tar.gz file using the following commands, we will assume in your /tmp directory:cp sampledepot.tar.gz /tmpcd /tmpgunzip sampledepot.tar.gztar xf sampledepot.tarThe PerforceSample directory where you unzipped the files, for example /tmp/PerforceSample, is known as the P4ROOT directory.

  2. Copy the p4d executable to the P4ROOT directory:cp p4d /tmp/PerforceSample

  3. Change to the P4ROOT directory:cd /tmp/PerforceSample

  4. To create your sample Perforce database, restore the checkpoint file by issuing the following command (from the P4ROOT directory):p4d -r . -jr checkpoint

  5. To ensure that the database format is consistent with the Perforce Server version that you are using, issue the following command:p4d -r . -xuIf the command is successful, you will see the message: ...upgrades done.

  6. Run the server with the following command:p4d -r . -p 1666

Windows privileges and details

The preceding installation instructions will allow you to run the test repository as an ordinary user, without requiring administrator privileges.

However, you may still have problems on locked down corporate installations of Windows. The privileges required are to:

  • Download the executables and the zipped repository

  • Being able to unzip them to a directory on your local PC

  • Being able to run a perforce server executable (p4d.exe) which uses a (configurable) port, you may need to be given permission for this

The authors have created a simple batch file (server.bat) as part of the zipped sample repository which shows you the command format and provides some simple guidance. You can just run this file from a cmd window, or by double-clicking on it from Windows Explorer:

C:\PerforceSample>server.bat

Please note that the following command will not exit and will just say:
   Perforce Server starting...

This is perfectly normal!  Just minimise this window and leave it running.
If you close this Window, or press Ctrl+C the server will stop.

C:\PerforceSample>p4d -p 1666 -r c:\PerforceSample\ -vserver=3 -L p4d.log
Perforce Server starting...

The server.bat file is located within the sample repository directory. The contents of the file are:

@setlocal
@echo off
REM Start of possible customization
REM You can change the following line to set the value
REM to a different port on the local machine if you wish
REM -----
set P4PORT=1666
REM ------
REM End of customization

REM This sets the environment variable to the path of this file
set CURR_DIR=%~dp0

set P4ROOT=%CURR_DIR%
set P4JOURNAL=%CURR_DIR%journal

REM The "title" command just sets the title of the CMD window
title Perforce server - don't stop!

@echo.
@echo Please note that the following command will not exit and will just say:
@echo    Perforce Server starting...
@echo.
@echo This is perfectly normal!  Just minimise this window and leave it running.
@echo If you close this Window, or press Ctrl+C the server will stop.

REM We assume the p4d.exe is present in this directory
@echo on
%P4ROOT%p4d.exe -p %P4PORT% -r %P4ROOT% -vserver=3 -L p4d.log

@endlocal