Perforce Depot Renamer
This tool can be used against a checkpoint file to perform a "deep rename" of a depot.
This code is provided as-is, with no warranty. The author(s) take no responsbility for any damage it may do. Always take a back up of your Perforce instance before running this, and test the results thoroughly before going live!
- This was developed and tested against p4d 2018.1 checkpoints. YMMV for other versions.
- This tool has only been tested against standard depots. Graph, Stream, and Remote depots will likely not work!
- It has only been tested against a full checkpoint. It may not work against journal data.
- It has only been tested against a depot with the standard mapping. If your depot's Map is not the default ie.
<depotname>/..., you may wish to change it before proceeding.
go install github.com/rpetti/p4-depot-renamer
How to Use
- Do a full
p4 verify -q //...and fix any issues.
- Take a full checkpoint and backup of your server.
- Stop p4d.
- Remove db.* files.
- If the latest checkpoint is compressed, uncompress it.
- Run the tool against the checkpoint file with the necessary options. (outlined below)
- Restore the checkpoint.
p4d -r . -jr checkpoint.renamed
- Run database verification tests.
p4d -r . -xv
- Move the lbr/versioned files for the renamed depot. For example, if you renamed
myproduct, then rename the
depotdirectory in the P4ROOT to
- Bring the server back online.
p4d -r . -p <port>
- Run a full lbr verification.
p4 verify -q //...
Note: It's likely that verify will encounter "BAD" files at this point. This is likely because of
$Id$ tags in the files messing up the calculated checksum since the path has changed. In order to fix these, you'll need to run
p4 verify -qv //newdepotname/....
p4-depot-renamer -cp checkpoint.100 -depot mydepot -rename-to -mynewdepot -o checkpoint.100.renamed
-cp <checkpoint file>- Which checkpoint file to process.
-depot <depot name>- The name of the depot to be renamed.
-rename-to <depot name>- The new name of the depot.
-o <new checkpoint file>- The new checkpoint file to write.
-f- Forces overwriting the new checkpoint file if it already exists.
-batch- Batch mode - allows to batching multiple renames in one pass, also enables including/excluding certain transforms.
The batch argument allows to replace -depot/-rename-to with a YAML file that defines multiple transforms. Additionally, the batch argument allows specifying either an inclusion list (only transforms in the list are applied) or an exclusion list (transforms in the list are not applied).
For example, the following YAML allows to move multiple depots under a single one:
- path_from: old_depot_first path_to: new_depot/first excluded_transforms: - db.depot:0 - db.depot:3 - db.domain:0 - path_from: old_depot_second path_to: new_depot/second excluded_transforms: - db.depot:0 - db.depot:3 - db.domain:0
Note that in this case we want to exclude changes to domains/depots - we should instead manually create the new depots prior to the rename.
Running a demo example locally
go run . -batch demo_batch.yaml -cp demo_checkpoint -o new_checkpoint -f