Can you map a file or directory multiple times in perforce?

perforce workspace mapping
perforce depot vs workspace
how to copy files from depot to workspace in perforce
perforce overlay mapping
perforce add folder to workspace

I would like to know if I can map a file or directory to multiple local copies with perforce.

I know that the P4V does allow me to do that but I encountered very weird behavior from the client and I suspect that this doesn't work.

I do not plan to modify any these files, I need this in order to recreate the same directory structure needed to build my own source tree (I do not want to create a huge branch if I know that I have to modify only few files and also I do not want to create additional workspaces because switching from them takes too much time).

You aren't allowed to do that because it leads to Bad Things. You can only map a depot file to one local location and vise versa. You can map two different depot folders to the same local folder, but you have to do it in a way that the files in the local folder will go to only one depot location (well, it will ignore the early mappings that conflict).

Branches can't be "big" because Perforce will make shadow copies until you actually make modifications. In general, you should branch the whole tree. Then you can have a workspace per branch (preferable), or one workspace that maps everything (still doable).

Mapping Multiple Directories, Reading time: about 2 minutes (453 words) The right-hand side specifies one or more files on the remote server. Although the two sides don't local side. You can use the following wildcards to specify mappings in your remote spec: To exclude a file or directory, precede the mapping with a minus sign ( - ). Whitespace  You can only map a depot file to one local location and vise versa. You can map two different depot folders to the same local folder, but you have to do it in a way that the files in the local folder will go to only one depot location (well, it will ignore the early mappings that conflict).

(sorry - just saw that you don't want to switch workspaces...can you clarify why you think that takes too much time? You can, in p4v, set up "favorite connections" under the connections menu that makes switching a snap. I suppose that hotkeys might make it faster. You also have the option of having mutliple p4v instances open).

Can you simply create a new workspace to do the mapping for you? If you don't intent to modify the files, seems like the easiest way to go. Just create a new workspace and then apply whatever changes you need inside of the workspace mapping. An example:

//depot/src/... //my-test-workspace/src_from_depot/...
//depot/doc/... //my-test-workspace/doc_from_depot/...

That will put the src and doc folders in a src_from_depot and doc_from_depot folder in our workspace root. I'd just put the workspace root somewhere different than you normally work - then you will have copy isolated from where you normally work with a directory structure that has changed to suit your needs.

Specify mappings // Using Perforce for Distributed Versioning, Helix server includes a "one-to-many" mapping feature, with which you can of the locations in the workspace must contain the same image file for the logo. Browse for the branch mapping you want to use. Select the branch mapping and click OK. In the Target field, specify where you want the source files integrated. The target must be a path that contains some or all of the paths identified in the branch mapping. In other words, the target can be a subset of the path specified by the branch mapping.

It sounds like the real problem may be the time it takes to switch workspaces. If that was fast, then you could maintain separate workspaces per branch.

In the next release, it will be easier to do in-place branch switching. In other words, you can maintain one workspace, and switch it from branch to branch as you work. The p4 sync command adds a new option to only update the files in the workspace that actually differ. So even if your branches are huge (> 500k files, > 30GB data), if only 10 files differ between two branches, moving your workspace from one branch to the other will only update those 10 files. That should be a big time saver.

I'm not sure if this will help or not, but I thought it was worth mentioning.

Map a single depot path to multiple locations in a workspace, Reading time: about 5 minutes (1,117 words) If more than one mapping line refers to the same file(s), the earlier mappings are overridden. the entire depot is mapped to the client workspace, but the file //depot/dir/file.c is mapped to  You can delete lines from the Files: field. Any files deleted from this list are moved to the next default changelist, and are listed the next time you submit the default changelist. If you are adding a file to a directory that does not exist in the depot, the depot directory is created when you successfully submit the changelist.

I have encountered this problem as well. I have files/directories that are common to multiple branches. The common files/directories need to be present in a certain structure in each branch for compilation.

The solution that worked for me was to place the common files/directories in a location separate of the branches. This maintains the perforce 1:1 mapping requirement.

Then, symbolically link the common file/directories to each branch for compilation purposes.

Client views, If you configure multiple workspaces on the same machine, keep workspace config files, you avoid the inconvenience of changing system settings every time you You can define a client workspace view to map only files and directories of​  Depending on the number of files being transferred, the p4 sync command might take a long time to execute. You can speed up processing by having this command transfer files using multiple threads. You do this by setting the net.parallel.max configuration variable to a value greater than one and by using the --parallel option to the p4 sync

Preforce supports it now.

Map a single depot path to multiple locations in a workspace.

To enable the one-to-many mapping feature, prepend & to the mapping line for each additional client location you want to map to:


//Acme/images/logo.png  //bruno_ws/products/images/logo.png
&//Acme/images/logo.png  //bruno_ws/documentation/images/logo.png
&//Acme/images/logo.png  //bruno_ws/support/images/logo.png

When you sync the client, the depot file maps to all three locations.

Important All mapping lines prepended with & are read-only, so in the example above //bruno_ws/documentation and //bruno_ws/support are read only.

Configuring P4 // P4 User's Guide, A computer can contain multiple workspaces. Classic depots: You can configure the workspace view (mappings) in the Build your workspace mapping by selecting a depot, folder, or file and using Modtime: Modification time for files edited in the client workspace is set to the time when the file is submitted to the depot. If p4 changes is called with multiple file arguments, the sets of changelists that affect each argument are evaluated individually. The final output is neither combined nor sorted. The effect is the same as calling p4 changes multiple times, once for each file argument.

Creating and managing workspaces // P4V User Guide, The left-hand side specifies one or more files or directories in the depot, Views can consist of multiple mappings, which are used to map portions of the If nomodtime is set, the modification date is the date and time of sync,  The tiny.db. file itself is stored in the P4ROOT folder, but the full path to the the file revision is stored inside 'tiny.db', using the directory structure present prior to changes to the depot spec's 'map' field or 'server.depot.root'. Take a checkpoint of 'tiny.db', correct the content, and restore using this manually-updated tiny.db

Perforce Basics: The Details, Reading time: about 2 minutes (453 words) To map groups of files in remote specs, you use Helix wildcards ( * , . Remote specs can consist of multiple mappings; these map portions of the shared server file tree to different notes in the remote p4-doc folder reside in the personal server in a top-level folder called doc: To make a single duplicate of a file you probably know that you can use cp: cp file file-001 Now, to make more duplicates to a file, you can combine cp with xargs. In your case: echo file-{001..200} | xargs -n 1 cp file. will copy file to file-001, file-002, ,file-200. See man xargs for more info.

Specify mappings // Using Helix for Distributed Versioning, Perforce does not support 1:many file mappings, such as the "shared files" feature in Visual Source Safe (VSS). There are both client Perforce enforces a 1:1 mapping between server and client files. Perforce does not You can put a master file in a shared directory: and then only work on one at a time. The following list of tasks summarizes the process of transporting a database using an export dump file. Details for each task are provided in the subsequent example. At the source database, place each of the user-defined tablespaces in read-only mode and export the database.

  • Can you add an excerpt from your client-spec and describe what 'weird behavior' you saw?
  • Probably Perforce team didn't seriously considered huge repositories with >500.000 files and >30GB.
  • They have considered that. And there are multiple problems you would run into. If a depot file is in two different local locations, and you sync one of them, then Perforce now thinks they are both synced. If you add a file, and the client mapping shows two possible depot locations, where should Perforce put the file?
  • It seems that Perforce people are not so used to the concept of symlink and hardlink ;)
  • If perforce still in business? Nobody told them to close the lights?
  • This is a borderline link-only answer. You should expand your answer to include as much information here, and use the link only for reference.