Branch Views

Branching of the source tree allows multiple sets of files to evolve along different paths. The creation of a branch view allows Perforce to automatically manage the file copying and edit propagation tasks associated with branching.

Branch views map existing areas of the depot (the source files) onto new areas of the depot (the target files). They are defined in a manner similar to that used for defining client views, but rather than mapping files directly into a client workspace, they merely set up mappings within the depot. Because integration can take place in either direction, every line in a branch view must be unambiguous in both directions; overlay mappings are therefore not permitted in branch views.

Branch View Sample Mapping

New code branching off from the main codeline

//depot/main/...   //depot/1.1dev/...

Rearranging directories in the new release

//depot/main/...   //depot/1.1dev/...
//depot/main/*.c   //depot/1.1dev/src/*.c
//depot/main/*.txt //depot/1.1dev/doc/*.txt

To create a branch view, use p4 branch newbranch. This will bring up a screen (similar to the one associated with p4 client) and allow you to map the donor files from the main source tree onto the target files of the new branch.

No files are copied when a branch view is first created. To copy the files, you must ensure that the newly-created files are included in any client view intending to use those files. You can do this by adding the newly-mapped branch of the depot to your current client view and performing a p4 sync command.