[p4] perforce "svn:externals" equivalent

Johan Nilsson r.johan.nilsson at gmail.com
Tue Aug 24 23:31:51 PDT 2010


Ilya Kazakevich wrote:
> Hello,
>
> I have several libraries I want to share between my projects. All
> they are in //myDepo/myLibraries/
>
> So, I want to have folder "myLibraries" in my projects. In SVN I
> could do so using "svn:external" attribute that makes my folder
> content to be fetched from another folder each time I do "update"
> ("sync" in perfoce terms).
>
> Is it possible to achieve same functionality in perforce?

No, unfortunately. But please tell Perforce Support - they should have an 
enhancement request logged for this which they can add your name to. The 
more the better ...

> I was
> thinking about workspace mapping:
>
> //myDepo/myProject/...  //myWorkSpace/myProject/...
>
> //myDepo/myLibraries/...  //myWorkSpace/myProject/libraries/...
>
>
> But I really do not like this idea because I believe this info should
> be part of depo, not workspace.

Agreed.

> Additionally I am not sure it will
> work fine.

It will work.

>So, is it possible to solve it on VCS layer?

I tend to use branching for this purpose, e.g.:

p4 integrate //myDepo/myLibraries/... //myDepo/myProject/myLibraries/...

It is a bit heavier than using workspace mapping (can create quite a bit of 
metadata depending on complexity of "myLibrary") but is easier to maintain, 
IMHO of course. Single-line workspace/client definitions are a Good 
Thing(tm).

An issue with both of the approaches is that it doesn't protect 
"myLibraries" from getting edited through the target workspace "out of the 
box". As for the latter approach it would be possible to put permissions for 
"integrate only" to paths matching e.g. "//.../readonly-deps/..." and change 
the above integration to:

p4 integrate //myDepo/myLibraries/... 
//myDepo/myProject/readonly-deps/myLibraries/...

I would also recommend you to use versioning in the depot paths, especially 
if you need to maintain separate versions of the libraries/other projects, 
e.g:

p4 integrate //myDepo/myLibraries/REL1.0/... 
//myDepo/myProject/MAIN/readonly-deps/myLibraries/...

Regards,
Johan





More information about the perforce-user mailing list