Creating a remote from an already existing depo


Posted by Jaime | Posted in Coding, DevOps | Posted on 30-10-2016

Tags: , ,

Today, I created a remote depo, so that I can use the DVCS functionality in P4 with one of my projects.

First, I connected to my perforce server and typed:

$p4 remotes

To see all of the remotes that were on the server. Before doing this command you have to type:

$p4 login

Which thankfully, my username on the linux server is the same as my username in the Perforce server so I didn’t have to type that again.

Once I was logged in and saw that there was no remote set up for the project I wanted to use with DVCS, I typed:


This brought up NANO (I know some of you out there are rolling your eyes) and I modified the //local/… //remote/… paths to my liking. Remember, the left side represents the local depo representation on your computer and the right side of that mapping is the remote depo representation that is on your Perforce server.

Now, in another terminal, I typed:

$p4 -u jaimerios clone -p -r PROJECT_CODE_NAME

The last command then takes the files specified in the mapping and clones it to your local filesystem.

You can check that the origin server is set up by typing:

$p4 remote -o origin

Now, in my project, I had two read-only depos in my Perforce server that was for the Boost headers and the Google gtest framework libs.

For those normally import+ folders, I created a symbolic link to those folders that were already on my local filesystem:

$ln -s /Users/jaimerios/Development/Perforce/READONLY/libs/Boost ./Boost
$ln -s /Users/jaimerios/Development/Perforce/READONLY/libs/Google ./Google

And so far, everything seems to work well … except there are a few files I want p4 status to ignore, so:

$nano .p4ignore

I added some folders and files to ignore and life is good.

So, onto happy coding 🙂

How to install Perforce DVCS


Posted by Jaime | Posted in Coding, Tools, Utility | Posted on 20-09-2016

Tags: , , , ,

For 9 years now, I’ve used Perforce; before that, it was MKD, Subversion, VisualSourceSafe, CVS and a few others.

In the past year, I used Git.

One cool thing that Git has that Perforce didn’t have was being able to save your changes while not being connected to a central server.

However, Perforce recently added native DVCS to their source control tools so, checkouts and submits are now possible while offline.

Here are the steps you need to take if you want to use Perforce DVCS on your computer. Note, I’m using macOS, so my instructions are for that platform only.

Installation steps
Step 1: download Helix server at
You will need both p4d and p4 command line utilities, so head over to and download the “Helix Server” for your machine.

Step 2: Double-click the tar file to extract it
I think this step speaks for itself; on my computer I was able to double-click the tar file and everything appeared in a new folder.

Step 3: Make a folder for the binaries to live in
I created a bin folder in ~/Perforce/. I happen to have a dedicated Perforce folder in my home directory that I use for a lot of projects and the bin directory seemed to be a logical place to store the files.

From the command line you can type the following to make the folder:
mkdir -p ~/Perforce/bin

Step 4: Copy the binaries to the bin folder
Copy the p4d and p4 command line utilities to the ~/Perforce/bin folder (or whatever folder you just created)

Step 5: Add the path to the PATH environment variable
I edited my ~/.bash_login file using emacs to add the following:
export PATH=~/Perforce/bin:$PATH

Step 6: Load the Perforce bin path
Relaunch or open a new Terminal Window or source your .bash_login via
source ~/.bash_login

Step 7: Init your offline project
Here is how I got up and running:
p4 init -C1 -xi

The extra settings after init tell p4 what case-sensitivity is should use and whether or not to enable Unicode support. If I didn’t add those, p4 would try to find a server to copy those settings from and that won’t work for me.

Step 8: Enjoy
From here, you use the and p4 to perform all of your Perforce commands and enjoy the goodness that is Perforce… like the super-large-file-support-without-choking feature 😉

Using P4Plugin with Jenkins to publish assets


Posted by Jaime | Posted in DevOps | Posted on 28-12-2015



I was previously using the Perforce Plugin in Jenkins to handle my tasks with Perforce, including adding files that needed to be released from a build, but in the past year, I’ve experienced some weirdness that lead me to evaluate the P4Plugin by Perforce.

All of the weirdness that I saw in the prior plugin went away, but I couldn’t figure out how to publish only certain files from a build.

There wasn’t anything in the documentation instructing you on how to do this feature and when I would use the Publish Assets feature, all of the extra files created in a build would be potentially added to my project, which was not the intent of the build.

It wasn’t until I found a bug report that said the following:

The shelve publish step should use a different workspace from the populate step. The view for this workspace should be very narrow (a Virtual stream, if using streams). Typically the view should be one or two files, limiting the files it will run the reconcile over.

By the way, I still haven’t figured out how to get Virtual streams to work in the P4Plugin as the plugin won’t recognize them.

So, to be able and isolate what you want published back to your Perforce server, you have to create another workspace to isolate the files, or directories, in question.

Hopefully, Perforce will include this text in their plugin documentation sometime soon.

Xcode plugin for Perforce


Posted by Jaime | Posted in Coding | Posted on 18-03-2015

Tags: , ,

I use Perforce as my version control system and Xcode as my IDE.

Unfortunately, Apple removed Perforce support from Xcode a whiles back for reasons unknown.

So, to work around the problem, I started to use of DTerm… but I wanted more.

I created AppleScripts for both Xcode4 and Xcode5 which was better, but… I wanted more.

So, I took the plung and wrote a plugin for Xcode using Swift.

The plugin is hosted on Perforce’s Swarm website, which you can download and build in Xcode. Once you build the project, the plugin is automatically installed for you.

Pay attention to the file: you will need set up files that contain the settings for your workspace, or workspaces, and those settings file are used by the plugin to do it’s work.

A big thanks to Delisa Mason for writing a Xcode plugin template. This template was a huge help in creating the plugin and the template available in the Alcatraz package manager as well as in GitHub:

If you don’t know what Alcatraz is, you should check out at

Aaaargh! Stop auto substituting my text!


Posted by Jaime | Posted in Coding, Not-so-funny | Posted on 20-03-2014

Tags: , , ,


I’ve been running into problems with my Jenkins scripts that would fail when attempting to run my p4 commands, because the three periods I inserted into the p4 command were automatically converted to an ellipsis by MacOSX, which is not a good thing: Three dots are automatically changed to an ellipsis

Perforce and Xcode4


Posted by Jaime | Posted in Coding | Posted on 14-08-2013

Tags: , , , , , ,

I created some AppleScripts that allow you to control some basic Perforce functionality in Xcode4, which was lost when Apple released the latest version of their IDE.

Perforce actually published a way of checking out files using the Behaviors functionality in Xcode (Xcode and P4), but I wanted a little more.

Note, these scripts are a work in progress. If you happen to make improvements, let me know so that those changes can be shared with the community.

You can download the AppleScripts here: xcode_p4_applescripts

The AppleScript files are also being hosted on the public Perforce swarm forum, located here: Perforce Public Swarm Server

Update 2013-11-06
I updated the AppleScripts to work with Xcode5 only and added a couple of new scripts.

The new applescript files are referenced in post Perforce and Xcode5

Checking out a file in Perforce using Xcode’s 4 behaviors


Posted by Jaime | Posted in Coding | Posted on 27-07-2012

Tags: , , ,

Perforce published a knowledge base article on how to use Xcode’s built in behaviors to check out a file: Automatically checking out files for edit in Xcode 4.3

This is nifty and similar to an article I saw posted on stackoverflow by user Mark Thalman.

I actually have AppleScripts that will do some of the functionality that Xcode3 had with Perforce on this posting: Perforce and Xcode4

Code review time


Posted by Jaime | Posted in Coding | Posted on 25-07-2012

Tags: , , ,

Right now, I’m reviewing code I copied into my own code branch (p4) and I’m finding that I’m doing something I thought I’d never do.

I’m actually lining up functions and parameters into columns. I have to admit, it’s much easier to read code this way then when code is all smushed together.

Now, I know some will say that this violates Rule 0, but I don’t care.

I don’t get enough sleep, thanks to git


Posted by Jaime | Posted in What's New | Posted on 11-05-2011

Tags: , ,

I don’t know why I do such things. I didn’t go to bed till midnight cause I was checking out git 😉

I installed git on my Mac, which was rather easy using the installer, and started to play with it.

I’m actually curious to see how this will work for me, compared to Perforce that is.

So far, it feels like any other command line version control system I have used in the past.

The real test will be how this versioning system compares to what I’m using now in a couple of months.

Xcode 3.1, Perforce and Scripts


Posted by Jaime | Posted in Coding | Posted on 09-03-2009

Tags: , ,

In my previous post, I showed how you can leverage AppleScript to check out a file or a project that resides on a Perforce server. The reason for this is that Xcode 3.x does not work well with Perforce.

Now, I figured out how to do this with the build in scripts menu in Xcode. The limitations I found so far is that you can only check out a file, can’t do a project yet, and that the cursor has to be in the file that you want to check out.

So I created a script, named it “Check out file” and put it in a section named “Gravy” since that is what I work with most. The script code is:

# This shell script checks out the current file from Perforce, so long as it has the cursor in it
# Get the file's full path
# Check to make sure it exists
if [ -f "$FULL_FILE_PATH" ]
	# Separate the filename and the path
	# Go to the folder and invoke the p4 command line app with the appropriate arguments
	cd "$FILE_PATH"
	/usr/local/bin/p4 -cjrios_My_Perforce_ClientName -PHah -ujaimer edit "$SRC_FILE"
# This is a hack to get Xcode to recognize that the file was checked out
# Notice that the code is not indented
osascript - "$1" << ENDOFSCRIPT
tell application "Xcode"
	set myFile to associated file name of front window
	save myFile
end tell
tell application "Finder"
end tell
tell application "Xcode"
end tell
	echo File not found:"$SRC_FILE"

For the output and error options, I set them to “Display in Alert”.

And that’s it. I hope this helps you and if you have any comments for improving this, post a comment and let me know.

Happy coding!

Xcode shell scripting