Bazaar for Perforce users

The following is a basic introduction to equivalences between Bazaar and Perforce. For further information, refer to the Bazaar documentation online or use Bazaar’s built-in help facilities by doing bzr help COMMAND. For further details, get started with bzr help topics.

Core tasks

Checking out a project

Perforce requires that you create a “client specification” or “workspace”, describing a “view”, before getting the source of a project. Using Bazaar, creating a “view” isn’t necessary.

To get the source of a project located at path:

P4PORT=host:port P4CLIENT=clientname p4 client
# Edit the client specification to add a view:
#   ...
#   Root:     working_directory
#   ...
#   View:
#     path/... clientname/...
p4 sync
bzr co --lightweight protocol://host:port/path

Note that Bazaar cannot check out subdirectories of a working tree, so where Perforce accepts both path/... clientname/... and path/a/sub/directory/... clientname/... as views, it is only possible to do bzr co protocol://host:port/path.

Adding new files

To put file1 and file2 under version control:

p4 add file1 file2
bzr add file1 file2

Note that bzr add will automatically add all unversioned, non-ignored files under the current directory.

Checking the status

To check the status of the current directory:

p4 opened
bzr st -S .

Note that Bazaar gives pathnames relative to the top of the working tree while Perforce gives pathnames relative to the current directory.

Committing changes

To commit the current state of the working tree:

p4 submit -d 'this is a commit message'
bzr ci -m 'this is a commit message'

You can specify certain files to commit in the same way as in Perforce: bzr ci -m 'dont save all things' file1 file2.

Bazaar does not have a concept analogous to Perforce changelists, which allow you to organize uncommitted changes in the working tree.

Viewing history

To see the history of the current project:

p4 changes
bzr log --line

or to give verbose information including all of the files changed by each revision use the -v flag. To see the log for a limited range of revisions:

p4 changes @10,25
bzr log -r 10..25

Updating to the latest version

When other people have made a change to the project, your working copy may be out of date. To update your working copy:

p4 sync
bzr up

This update may result in conflicts which need to be manually resolved.

Note that the update (up) command in Bazaar is not used to put the working copy in the state of a previous revision as the sync command is in Perforce.

Changing to a previous revision

To change the working tree to the state that it had in a previous revision:

p4 sync @25
bzr revert -r 25

Note that both of these commands try not to lose uncommitted information in the working tree, but they may do so in different ways. In both cases, use of the respective “status” command after the change is recommended.

Network protocols

Perforce typically identifies network resources using a combination of a “P4PORT” and a “depot path”. Bazaar uses an URL. Both programs have a native server program that runs remotely. The Perforce protocol is implicit. The Bazaar protocol is selected by using an URL that starts with bzr://. Perforce users typically use its native protocol to access its always-running native server program p4d, though Perforce also supports starting the server program on demand by using a P4PORT value that starts with rsh:. Bazaar users commonly tunnel its native protocol over SSH by using an URL that starts with bzr+ssh://. The bzr help urlspec command lists the full range of protocols Bazaar can use.


Perforce refers to revisions by appending a revision value to a file path, with @ or # depending on the type of revision value. Bazaar commands use a -r option to accept a revision value.

In both systems, the most common way to refer to revisions is as numbers starting from 1 and counting up with subsequent commits. Perforce interprets a number prefixed by # as a file revision number, and by @ as a changelist number. Bazaar treats a number, absent any prefix, as a change set revision number.

Both Perforce and Bazaar provide ways to refer to revisions in other terms as well. The table below should serve as a preliminary guide to the equivalences.

Revision desired Perforce Bazaar
Change Revision Range @ARG1,ARG2 ARG1..ARG2
File Revision Range #ARG1,ARG2 ARG1..ARG2
Specific Date @2009/06/04 date:2009-06-04
Latest Revision #head -1
Next-to-last Revision (not supported) -2

Due to the distributed nature of Bazaar, sequential revision numbers are not authoritative in Bazaar as they are in Perforce. Due to merging with other branches, Bazaar’s revision numbers can change. The most consistent way to refer to a revision in Bazaar is a revision id such as

bzr revert -r

These ids can be seen using bzr log --show-ids. There are even more ways to refer to related revisions in Bazaar. See bzr help revspec for further possibilities. For the Perforce equivalences, see p4 help revisions.

Other commands

“How are the more advanced p4 commands done in Bazaar?”

To be completed ...


“What else is worth knowing to get up to speed?”

To be completed ...

Feedback and edits

See Improving these documents.