Distributed development using Fetch and Push

The following sections describe how you use the p4 fetch and p4 push commands to share code easily between distributed sites.

Consider the scenario described below.

The gaming company Ukko Productions has offices in France, Japan and the United States. Each site is responsible for a different part of the gaming code; each does development on the section of code or "component" for which it is responsible. This work happens on the office’s Helix Server, in a depot directory called dev. dev will contain locally submitted changes.

Let’s suppose France is working on a widget which is used by the developers in Japan and the United States. First, France makes the widget code available to Japan and the United States by dropping the code — using the p4 push into drop directories on the servers in Japan and the United States (see "1" in the figure below). (Alternatively, the Japan and United States developers could use the p4 fetch to copy France’s code into their drop directories.) The Japan and United States development teams can then merge the France widget code into their respective dev directories using p4 merge (See "2" in the figure below). They can then customize the widget for their own purposes, without sharing these customizations with the France developers.

If developers in the US and Japan have a subset of changes they do want to share with France, they use p4 push to copy this code into a special drop location on the France server — one location for Japan and one for the United States. (See "3" in the figure below). (Alternatively, France could use the p4 fetch to obtain the code and drop it into the appropriate locations.) The France developers can then merge the Japan and United States code into their dev directory using p4 merge (See "4" in the figure below).

Then the cycle repeats.

This scenario is illustrated in the following drawing:

distrib devel dvcs

The next section explains how you must define remote specs to be able to implement this scenario.

Configuring the remote specifications

In order for the p4 push and p4 fetch commands to work properly, each of the three servers — Japan’s, the United States' and France’s — must have properly configured remote specifications. Remote specifications determine which remote servers a local server can fetch from or push to and which files will be fetched and pushed. (For more information about remotes and remote specifications, see the section "Understanding Remotes" in Using Helix Core Server for Distributed Versioning.)

Because the Japan developers are fetching from or pushing to France’s server, their server’s remote spec would look as follows:

RemoteID: ServerFrance
Address: ServerFrance:1666
DepotMap:
  //depot/code-dropA/... //depot/France-dev/...
  //depot/Japan-dev/... //depot/code-dropS/...

Because the United States developers are fetching from or pushing to France’s server, their server’s remote spec would look as follows:

RemoteID: ServerFrance
Address: ServerFrance:1666
DepotMap:
  //depot/code-dropUSA/... //depot/France-dev/...
  //depot/USA-dev/... //depot/code-dropS/...

Because the France developers are fetching from or pushing to Japan, their server’s remote spec would look as follows:

RemoteID: ServerJapan
Address: ServerJapan:1666
DepotMap:
  //depot/code-dropS/... //depot/Japan-dev/...
  //depot/France-dev/... //depot/code-dropA/...

Because the France developers are also fetching from or pushing to the United States, their server would have a second remote spec that would look as follows:

RemoteID: ServerUnitedStates
Address: ServerUnitedStates:1666
DepotMap:
  //depot/code-dropS/... //depot/USA-dev/...
  //depot/France-dev/... //depot/code-dropUSA/...