Perforce Public Knowledge Base - VSS "Shared" Files and Perforce
Reset Search
 

 

Article

VSS "Shared" Files and Perforce

« Go Back

Information

 
Problem

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 mapping otherwise provides.


Solution

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/
      and then only work 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. Often, a build system can be reworked slightly to accomplish this.

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

      Related Links

      Feedback

       

      Was this article helpful?


         

      Feedback

      Please tell us how we can make this article more useful.

      Characters Remaining: 255