Perforce obsolete

From ITSwiki
Revision as of 16:32, 29 November 2015 by Tsal (Talk | contribs)


Jump to: navigation, search

Gentle introduction to Perforce

If you are unfamiliar with Perforce and especially with source control systems, there is a gentle introduction on the perforce website.

Installing

Download clients

Both visual and command-line clients can be downloaded for Mac, Linux, and Windows on the perforce website:

http://www.perforce.com/downloads/helix#clients

Direct links to the most common clients are found below. The links point to R15.2 of the command line clients, and R15.1 of the visual clients. Links are last updated 2015.11.28. Due to this revision difference, it is important that you install the visual clients first, and then the command line clients.

Linux Clients

32 bit visual clients

64 bit visual clients

32 bit command line

64 bit command line

Mac Clients

visual clients for OS X 10.8+

32 bit command line

64 bit command line

Windows Clients

32 bit visual clients

62 bit visual clients

32 bit command line

64 bit command line

Basic configuration

The basic setup procedure is different for the gui and for the command line. Common for both of them is the server address and establishment of trust.

The perforce server has the address

ssl:perforce.compute.dtu.dk:1666

Authentication happens using the portalen username and password. Access to this server is administrated by Henning Christensen who can be reached at the email address at hench at dtu.dk.

Upon initial connection you are asked to approve the fingerprint of the perforce server. The fingerprint should be

#F6:7A:7A:9C:15:33:CE:16:DB:EA:6E:A9:24:05:FB:E8:63:B7:0D:2A

If another fingerprint is displayed, you are connecting to the wrong server - contact IT support.

Using the graphical interface

The graphical interface is called P4V. At first connection, you are asked to trust the server. If the fingerprint corresponds to the fingerprint above check the trust button.

As workspace, the workspace called <username>_default should be used.

Using the command line

The command line is configured using environmental variables. These variables are set using the perforce command line. Set the following options

# p4 set P4PORT=ssl:perforce.compute.dtu.dk:1666
# p4 set P4USER=<username>
# p4 set P4CLIENT=<username>_default
# p4 set P4CONFIG=.p4config

The current loaded settings can always be seen by typing p4 set in command line. Verify your installation by typing

# p4 set
P4CLIENT=tsal_pc (enviro)
P4CONFIG=.p4config (enviro) (config '/home/tsal/.p4config' )
P4EDITOR=vi (enviro)
P4IGNORE=.p4ignore (config '/home/tsal/.p4config')
P4PORT=ssl:perforce.compute.dtu.dk:1666 (enviro)
P4USER=tsal (config '/home/tsal/.p4config')

On linux/mac, these settings are stored in the file ~/.p4enviro. On Windows the settings are stored in the registry. The command line has many configurables, to see most of them, type

# p4 help environment

The documentation for perforce is built into the program. You can get help by typing

# p4 help 
# p4 help <command>

Setting up a tunnel to connect outside DTU

At this moment, the perforce server is only reachable from DTU networks - but this is subject to change soon. The easiest way to get around this is to use the OpenVPN provided by DTU compute. Alternatively you can setup a ssh tunnel. On Windows/Linux/Mac, use the following command

# ssh -L 1666:perforce.compute.dtu.dk:1666 <user>@thinlinc.compute.dtu.dk

Alternatively, use autossh with ssh keys - this will automatically restablish lost connections - e.g. on sleep/resume when using a laptop the connection is automatically established.

# autossh -i .ssh/ -L 1666:perforce.compute.dtu.dk:1666 <user>@thinlinc.compute.dtu.dk

On windows, the the two best options are putty and bitvise ssh. Bitvise supports automatic reconnections which is very useful for laptop users. This program can be downloaded here:

http://www.bitvise.com/ssh-client-download

Get the template file and insert your username and password. The bitvise client can be setup to start automatically, by inserting the following link in the startup folder

"C:\Program Files (x86)\Bitvise SSH Client\BvSsh.exe" -loginOnStartup -profile="<path to bscp file>"

If you opt for using a tunnel, you have to use ssl:localhost:1666 as P4PORT instead.

Excluding files from perforce

Usually, there are a lot of different and/or temporary files that you do not want to upload to the perforce server. Perforce implements a procedure using an ignore file that implements rules for which files to ignore. The file uses the same syntax as is known from the .gitignore format. A file called .p4ignore containing all rules for the files that should be ignored.

Archive structure

The perforce server can be accessed publicly using

https://archive.compute.dtu.dk

The general layout is as follows

//comp/ # MAIN depot with non-terabyte content

//comp/courses/ # courses
//comp/courses/02450/

//comp/common/ # common folder accessible for compute staff
//comp/common/MATLAB/extern/sgetools/ # our customizations to SGE tools
//comp/common/MATLAB/extern/sgetools/codeline.txt # information about codeline

//comp/extern/ # external libs
//comp/extern/MATLAB/gpml-matlab/MAIN # 
//comp/extern/MATLAB/sgetools/MAIN # 

//comp/sections/
//comp/sections/cogsys/projects/

//comp/projects/
//comp/projects/cosound/

//comp/users/
//comp/users/tsal/


//comp-archive/ # ARCHIVE depot - contains all publications in their entirety

//comp-data/ # DATA depot - 

Common use cases

Frequently Asked Questions

The client shows I don't have a file even though I do, how do I handle it?

This scenario can happen if you by other means move files/folders that are under Perforce source control. Perforce has a "have" database that contains which files are retrieved in which revision on each workspace, p4 have will show you the current "have list" for the chosen workspace. The p4 have list can be out of sync:

  1. You create a new workspace that points to files under perforce source control
  2. You move files by other means (e.g copy files to grid, or sync files using dropbox) to other machines and use different workspaces.
  3. Manually delete files

To resolve, run

# p4 sync -k

How do I sync a directory that does not exist on my computer yet?

If the directory exists on the perforce server but not on your computer, and you would like to do a narrow sync, do the following:

# p4 sync //complete/depot/path/...

Or from the directory you have - e.g. if you have a directory called perforce and you wish to sync a subdirectory called public, do the following:

# cd <path to perforce>
# p4 sync public/...

On Windows, I get the error "too long filename", how do I fix that?

The windows file system does per default only support path names of length up to 260. If you set the environmental variable

filesys.windows.lfn=1

both the command line and visual client can operate with long file names. If you only use the command line, this option can be set in the configuration file (p4enviro)

Further reading

External material for understanding Perforce

Perforce cheat sheet.

Perforce command line reference

Guide to the visual client

Understanding the client configuration

Understanding views

Tips for subversion users

SVN command Perforce command(s) Description Remarks
svn import p4 reconcile dd a tree of file(s) to the depot. The specified file(s) are linked to a changelist. Perforce: The files are not actually added to the depot until the changelist is sent to the server with p4 submit.
svn add p4 add Opens file(s) in a client workspace for addition to the depot. The specified file(s) are linked to a changelist. Perforce: The files are not actually added to the depot until the changelist is sent to the server with p4 submit.

SVN: The files are not actually added to the repository until the changes from your working copy are sent to the server with svn commit.

Example Example Example Example

Reference: http://answers.perforce.com/articles/KB/2953

Tips for GIT users