Contents

15 Articles

Search

8 years Ago

Backup, Recovery & Optimization Scripts

Published by Marco on

Perforce servers have a checkpointing mechanism in order to back up the server metadata. That checkpoint, along with the depot data and a journal file (for changes made since the checkpoint was taken) are enough to restore a Perforce database.

Here at Encodo, we take a checkpoint every evening right before the depot files are backed up. We retain a few days worth of these checkpoints, just in case. Since our server runs on Debian Etch (Linux), we have a Bash script to do all of this (included... [More]

9 years Ago

Missing Menu Entries in P4V

Published by Marco on

The P4V client for Perforce gets better with each version and is in many ways much better than its predecessor on Windows, P4Win. However, if you’ve upgraded through several versions – possibly including beta versions – you may not be seeing the full client. On both Windows Vista and Windows XP, we’ve noticed that shortcut menu entries are missing on some clients. That is, a user on one machine sees ten commands available when right-clicking on a file whereas another user sees only five.
... [More]

Perforce Branching Specification Typo

Published by Marco on

At Encodo, we use the Perforce source control system. Recently, I created a branch specification in order to maintain bug fixes in a released product. See below:

//depot/branches/customername/versionnumber/projects/encodo/quino... //depot/projects/encodo/quino/...

Naturally, the next thing I did was to branch the files under //depot/projects/encodo/quino/ to the branch, using the P4V client. It displayed the new changelist, but did not update the statuses of the files therein (there were... [More]

11 years Ago

Rolling Back a File

Published by Marco on

How to you revert in Perforce? If you want to roll back to a previous version, use the following instructions.

The following instructions apply to the Windows client (P4WIN) only.

  1. Select the file you wish to roll back (If you want to recover a deleted file, select Show deleted depot files from the View menu).
  2. Right-click and select Revision History.
  3. Select the file revision version you want to recover.
  4. Click the Sync button at the top of the dialog.
  5. Exit the revision history dialog.
  6. Open the... [More]

Labelling an Old Release

Published by Marco on

With Perforce, it’s not the end of the world if you forget to label a release before checking in more changes. As long as you know the last changelist number that belonged to the release, you can always make the label anyway. In fact, you can follow the instructions for Creating a Label, but alter them in the following way:

  1. Once you have the final dialog open (After step 4), do not click Ok immediately.
  2. Instead, click the radio button at the top for Add/Replace only the following files.
  3. Click... [More]

Working Offline

Published by Marco on

What happens when changes are made to files that need to applied to a Perforce depot? This usually happens for one of the following reasons:

  • You have been working offline—on a notebook without an internet connection.
  • You have a new version of third-party code that must be uploaded.

The following instructions apply to the Windows client (P4WIN) only; other clients and operation systems will have to use the longer instructions located at How do you work disconnected from the Perforce Server?... [More]

Excluding Files

Published by Marco on

Perforce maps files in the depot to a workspace using a view. The view is composed of single lines, each of which has a depot path and a workspace path (see Using Wildcards for some examples). You can also exclude files from the mapping by prepending a ‘-’ to the line.

Here are some handy excludes to use:

Windows

-//depot/…/Thumbs.db //marco-sten/…/Thumbs.db

Delphi

-//depot/…/*.~* //marco-sten/…/*.~*
-//depot/…/*.dcu //marco-sten/…/*.dcu 
-//depot/…/*.ddp... [More]

Syncing with a Label

Published by Marco on

Sometimes you need to go back and fix a bug in older release. This means you need to somehow get to the source code you had when that version was released and download it. With Perforce, you don’t need to make zip files or other backups — you only need to have made a label or to know which changelist you’d like to sync with.

The following instructions apply to the Windows client (P4WIN) only.

The easiest way to get an old version back is to use a label:

  1. Select the label from the... [More]

Creating a Label

Published by Marco on

Labels are separate objects in Perforce and contain a list of files at specific revisions. You can use a label to revert to previous release (See Syncing with a Label for more information).

The following instructions apply to the Windows client (P4WIN) only.

  1. Click the label toolbar button to show the labels page.
  2. Make a new label (right-click in the list); Give it a useful description.
  3. Restrict the View to that needed by the project being labelled (See Using Wildcards and Excluding Files for... [More]

Using Wildcards

Published by Marco on

Perforce can interpret a rich wildcard syntax, but it can only be specified from the command line. An easy way to get to the correct directory is to do the following:

The following instructions apply to the Windows client (P4WIN) only.

  1. Right-click the desired starting folder
  2. Select Command Prompt from the shortcut menu

Now that you’re at a command prompt, you can use wildcards to open files for edit (or delete/revert, etc.). All of the standard symbols are interpreted as expected, with one... [More]

Settings Default File Types

Published by Marco on

Each file in Perforce has a type, which includes the type of contents and special flags for handling the file on the server. The content types are usually binary or text (OS X users will notice the apple type being used for binary files with resource forks). The flags control things like compression, header expansion (+k) or which revisions are stored on a server.

To set the default file types, use the Perforce typemap command.

  1. Open a command window.
  2. Type “p4 typemap” (it will open in the... [More]

Changing a File Type

Published by Marco on

Each file in Perforce has a type, which includes the type of contents and special flags for handling the file on the server. The content types are usually binary or text (OS X users will notice the apple type being used for binary files with resource forks). The flags control things like compression, header expansion (+k) or which revisions are stored on a server. See Setting Default File Types to find out how to control the initial file type when a file is added.

You have to check out the... [More]

Adding Files

Published by Marco on

Adding files to Perforce is easy; adding a folder with all sub-folders is less obvious. Often, you want to “check” a folder to see whether there are any local files that should be in Perforce.

The following instructions apply to the Windows client (P4WIN) only; other operating systems will have to use the command line executable, P4.

  1. Drag the desired folder from the Windows Explorer to an open changelist.
  2. Perforce displays a dialog to add the files.
  3. Select the Add only radio button. (see... [More]

Hidden Files in Perforce

Published by Marco on

We keep our source code in Perforce, an extremely powerful SCM (source control manager). It retains multiple revisions of files and manages integrations between “branches”, or diverging streams of similar code. Read/write permissions for paths within the depot can be restricted per user.

Recently, we needed to get the history of a particular file to see which changes had been applied to it over the course of the last year. Instead of the approximately 20 revisions we expected, we saw only one.... [More]

Synchronize Perforce depots

Published by Marco on

Here’s a script that replicates one Perforce depot (or portions thereof) to another. It performs the following steps:

  1. Synchronize with Company B’s depot (forcing the sync if -f is specified)
  2. Opens new files for add in the Company A’s default changelist
  3. Opens missing files for delete in Company A’s default changelist
  4. Opens modified files for edit in Company A’s default changelist
  5. If there are any files in Company A’s default changeslist, it submits them with a standard message

All script... [More]