May 16, 2016
Introducing Ditto Mappings
Email sign up
In today's blog post I'll be talking about a brand new trick you can do with client views: ditto mappings!
To begin with an explanation of terminology: much like we here usually say "+ mapping" in conversation rather than the more cumbersome term "overlay mapping", during development we've been exclusively been calling this feature "& (pronounced 'and') mapping". That looks pretty weird on the page, though, so "ditto mapping" is what we've come up with as a more grammatically pleasing alternative for written usage. If you hear somebody say "and mapping" this is what they're talking about.
The "p4 help views" entry explains the relationship between "ditto" and "overlay" mappings like this:
A mapping line that begins with a + overlays the later mapping on an earlier one: if files match both the earlier and later mappings, then the file matching the later mapping is used. Overlay mappings are supported only for client views, and enable you to map multiple server directories to the same client directory. A mapping line that begins with a & does not override earlier mappings for the same depot path, allowing multiple 'ditto' versions of the same depot file to be synced to one workspace. Ditto mappings are supported only for client views, and files mapped in this way are read-only.
Like overlay mappings, ditto mappings allow you to break the usual rule of client mappings being "one to one", but whereas overlay mappings let you map multiple depot paths to one client path, ditto mappings let you map one depot path to multiple client paths!
Supporting this feature is the ability to set a ChangeView based on client path rather than depot path:
#1315758 (Bug #81357) ** Entries in the client spec field 'ChangeView' may now be provided in client syntax as well as depot syntax.
For one-to-one mappings this would provide no significant benefit, but client-syntax ChangeViews combined with ditto mappings permit you to have different versions of a particular file in your workspace. Here's a small example of the two working together:
View: //depot/... //sams-client/... &//depot/and/foo //sams-client/and/bar &//depot/and/foo //sams-client/and/ola ChangeView: //sams-client/and/ola@9310 C:\test\local\and>p4 sync ... //depot/and/foo#2 - added as c:\test\local\and\bar //depot/and/foo#2 - added as c:\test\local\and\foo //depot/and/foo#1 - added as c:\test\local\and\ola
While this may seem like an esoteric feature, it's a long-standing request from users who are trying to build projects with components that each require a particular common file (or group of files) to be in their own workspace location. Previously you couldn't do this within a single workspace unless the files were also duplicated within the depot, but this new mapping syntax makes it possible.
Check out the 2016.1 release notes for more exciting new features!