Saturday, January 8, 2011

A solution for sharing Perforce workspaces using AltRoots

Perforce lets you share workspaces between Cygwin and Windows. The same technique can be used to share between Linux and Windows, when sharing the data via Samba – but there’s a pretty big catch.

If you run p4 sync in Linux from outside the AltRoot location, p4 will sync to a new directory with the name of the p4 Root. Say you accidentally run p4 sync from the /etc dir – you’ll end up with a directory like /etc/S:\workspace, and your real workspace directory will now be out of sync. (This isn’t a problem with p4 for cygwin, since cygwin can interpret Windows paths.)

Here’s a workaround:
1) Remove the base directory from the Root and AltRoot paths
2) Add the base directory to all paths in the workspace mapping
3) Add / as a second AltRoot
4) Create a symlink in / with the name of the base directory, pointing to the real location.

By using / as a second AltRoot, every linux directory will match, and the default root will never be used.

Here's a simpler workaround that instead just results in a an error message when running p4 outside of the workspace root.

1) Set P4CLIENT to something invalid like `XXXXX - Running from invalid root`
2) Set P4CONFIG to `.p4config`
3) Create a file called `.p4config` in your workspace root. Inside add the line `P4CLIENT=[Name]` substituting [Name] with your real client name

No comments:

Post a Comment