VSS "Shared" Files and Perforce

One to many file mappings

Info & Tags

Article #:
239
Created:
10/19/06
Modified:
11/06/08
Tags:
mapping, shared files, vss

Related Articles

Links

SUMMARY

Perforce enforces a 1:1 mapping between server and client files. Perforce does not support 1:many file mappings, such as the "shared" files" feature in Visual Source Safe (VSS). There are both client and server methods of achieving the same results that 1:many file indirection otherwise provides.


DETAILS

If you have one file that you want updated in several places in the depot, you have a few options.

  • Have a master copy of the file and use p4 integrate to push its content to each of the other places. Update only the master copy.

    For example:
    You can put a master file in a shared directory:

      //depot/sharedfiles/COPYRIGHT.TXT

    ...and then propagate changes to the various branches using the following commands:
    p4 integ //depot/sharedfiles/COPYRIGHT.TXT //depot/r1.0/COPYRIGHT.TXT
    p4 integ //depot/sharedfiles/COPYRIGHT.TXT //depot/r1.2/COPYRIGHT.TXT
    p4 integ //depot/sharedfiles/COPYRIGHT.TXT //depot/r2.0/COPYRIGHT.TXT
    

    The process above can be scripted. See Submitting Files Non-interactively for more information on scripting submit operations.

  • If the workspaces do not need to have more than one code line mapped in, you can create separate client specifications, and map the shared code into each workspace along with a single unshared codeline that uses it. Map the shared common file(s) or codeline as a separate line in the client spec "View" category.

    For example:
    If you have multiple branches:

      //depot/r1.0/
      //depot/r1.2/
      //depot/r2.0/

    but only worked on one at a time. In this case, the client spec "View" you use for the /r1.0 codeline appears as follows:
    View:
        //depot/r1.0/... //clientname/r1.0/...
        //depot/sharedfiles/COPYRIGHT.TXT //clientname/r1.0/COPYRIGHT.TXT
  • Reorganize your code to avoid this construct. Many times, the build system can be reworked slightly to get out of this situation.

For more information on Codelines and Branching see Chapter 6 of the Perforce User's Guide