Can you map a file or directory multiple times in perforce?
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).
(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.
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.
Preforce supports it now.
Map a single depot path to multiple locations in a workspace.
https://www.perforce.com/perforce/doc.current/manuals/p4guide/Content/P4Guide/configuration.workspace_view.one-to-many.html?TocPath=Configure%20clients%7CConfigure%20workspace%20views%7C_____8
To enable the one-to-many mapping feature, prepend & to the mapping line for each additional client location you want to map to:
View:
//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.
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.
精彩评论