Jump to content


Single depot, multiple projects- branching

p4v branch depot

  • Please log in to reply
2 replies to this topic

#1 rdrummond

rdrummond

    Newbie

  • Members
  • Pip
  • 2 posts

Posted 18 November 2019 - 02:15 AM

This is Perforce branching&workspaces 101 I'm sure- apologies.

We have a large depot with multiple project/folders. Each project has a folder for hardware, software, etc.  I want to branch the software folders for each project, like I'd do with git, where I'd create a new branch on a folder, and everything stays the same, except all the files are now on the new branch.

Whatever I have tried so far always results in the source code in a separate local folder, which can't be used by the dev tools (they expect the same local folder of course). I've mucked around for a while trying to get this to behave as I want (which is, the folder content changes but the folder structure doesn't).  

A lot of my way of thinking comes from using tortoise svn/git, and I understand my understanding may need to be 'extended' to suit perforce's way of doing things.  

It seems to be so basic that I can't find any specifics on this scenario. I'd be so grateful if someone could please help me understand what I'm missing and how I can rectify it.  I'm sure perforce is exceptionally powerful, but without branching, it severely limits how we manage our development.

I use P4V exclusively. Whatever command line things I need to do I'd like to mirror in P4V if possible.


Thanks in advance.
Rhys Drummond

#2 Sambwise

Sambwise

    Advanced Member

  • Members
  • PipPipPip
  • 976 posts

Posted 18 November 2019 - 03:31 PM

First -- if you can make your dev tools use relative paths instead of absolute paths, that will make life easier in general.  I always liked having all my branches on my filesystem (within a single workspace) and just being able to hop between them by changing directories.  :)  But you can definitely have multiple branches and map them all to one spot (just not all at the same time).

If you use streams, it works almost exactly like git:

p4 switch -c my-new-stream

Presto, you have a new stream, and it's mapped to your workspace in the same place as the stream you just branched it from.  When you p4 switch back to the original stream, your workspace gets switched around so that once again that stream is in the same spot.  (If you use P4V, I think this mostly works as well, although I remember there being some bugs around switching streams with old versions of P4V; that might work better now.)

If you aren't using streams, and you want to change which branch your workspace maps, you have to manage the workspace manually by modifying the View.  The basic idea is that when you're working in branch //depot/main your View maps //depot/main to your client, like this:

//depot/main/... //your-workspace-name/...

If you want to work in a different branch but map it to the same place in the workspace, you change the View:

//depot/dev/your-name/... //your-workspace-name/...

and the next time you sync the workspace, all the files will be replaced with the ones from the new branch.

#3 rdrummond

rdrummond

    Newbie

  • Members
  • Pip
  • 2 posts

Posted 18 November 2019 - 10:34 PM



Sambwise, thank you, I really appreciate your detailed and helpful response.
The second part where you mention remapping of branches is exactly the trick I was after; I'm not surprised I didn't grasp it before. It's a shame it's not quite as straightforward as stream depot usage, which I'm sure is exactly where I'll be heading from this point on.
Time for some restructuring!
Cheers :)





Also tagged with one or more of these keywords: p4v, branch, depot

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users