Add a branch

The Branches tab enables you to add a branch, which is the prerequisite for Edit a branch.

To learn how to create branches for a P4 Code Review project, watch this video or review the instructions following the video.

Add a branch

To add a new project branch:

  1. Click the Add new branch button. This opens an Add new branch dialog.

  2. Enter a short Name for your branch.

  3. Enter one or more branch paths in the Depot paths field using depot syntax, one path per line. For more information on branch paths, see Example branch paths.

    Branch paths are case sensitive.
  4. Click the Confirm button.

A new branch is created.

Example branch paths

If you have entered multiple branch paths into the Depot paths field, these paths are processed in order, starting with the first path in the list.

Branch paths, and files can be excluded by putting a minus symbol - at the start of the path. In the following example:

  • The first path includes all of the directories and files under //depot/main/swarm/ in the project branch.

  • The second path excludes all of the files in -//depot/main/swarm/test/ from the project branch.

  • The third path includes the ResultSummary.html file from the previously excluded //depot/main/swarm/test/ directory.

Copy
//depot/main/swarm/...
-//depot/main/swarm/test/...
//depot/main/swarm/test/ResultSummary.html

Use wildcards in branch paths

Two kinds of wildcards that are supported in project branch paths: ... and *.

... wildcard

The ... wildcard matches all files in a folder and all of its subfolders. Use ... at the end of a branch path:

//depot/Jam/src/...

If the path does not exist yet, it is not shown in the project file browser until it is created. This allows you to define paths before they exist.

* wildcard

The * wildcard matches file names in one folder only (it does not include subfolders).

You can use * inside a branch path to match parts of file names or folder names.

For example, VersionA and VersionB could be replaced with the wildcard * in the following paths:

//ProjectY/UserZ/VersionA/LibA/SubLib1/Data1/...
//ProjectY/UserZ/VersionA/LibA/SubLib2/...
//ProjectY/UserZ/VersionB/LibA/SubLib1/Data1/...
//ProjectY/UserZ/VersionB/LibA/SubLib2/...

Resulting in the following fllepaths with wildcards.

//ProjectY/UserZ/*/LibA/SubLib1/Data1/...
//ProjectY/UserZ/*/LibA/SubLib2/...  

You cannot use * at the start of a branch path. For example, the following is invalid:

*//depot/Jam/src/...

Branch paths are not checked when you save them. If a path includes a file that does not exist, P4 Code Review shows a 404 error when you try to open it in the project file browser.

Supported wildcard formats

Examples using the ... wildcard:

  • //depot/project/...

  • //depot/project/src/...

  • //depot/project/main/...

  • //depot/*/src/...

Examples using the * wildcards:

  • //depot/Project/*/src/...

  • //depot/Project/*

  • //depot/Project/MA*

  • //depot/Project/REL*/src

  • //depot/Project/R*/src

  • //depot/Project/R*EL/src

  • //depot/Project/*HEL/src

  • //depot/Project/*/src

  • //depot/*/*/src

  • //depot/*/*/*

  • //depot/*/MAIN/*

  • //depot/Project/REL*/s*

  • //depot/str1_*_str2/src

Examples using both the * and ... wildcards:

  • Match all src folders across all projects and include all subfolders:

    • //depot/*/src/...

  • Match all versions (VersionA, VersionB, etc) and include everything under src:

    • //ProjectY/UserZ/*/src/...

  • Match all release folders (REL1, REL2, etc) and include all contents:

    • //depot/Project/REL*/...

  • Match any module name under a project, then include everything inside it:

    • //depot/Project/*/modules/...

  • Match patterns in the folder name and include all subfolders:

    • //depot/*/R*/src/...

Handling new sub-directories

If new sub-directories are added or removed after the initial branch paths have been created, you can update branch paths by clicking the Expand wildcards button. This will expand all * wildcard paths to the matching single level sub-directories path.

Alternatively, you can expand the wildcards by editing and re-saving a branch.

The expand wildcards feature can match a large set of directories, including subdirectories. We have tested performance when expanding up to 30,000 paths and found no issues.