Perforce:Need some introduction on Perforce streams

耗尽温柔 提交于 2020-01-05 04:09:05

问题


I am new to perforce streams. I have gone though some docs over net and not clearly understood what is the main use of perforce streams. Can any one please help me giving brief intro on perforce streams. what is the main purpose ? when it is useful ?


回答1:


It would be easier to answer this question if you gave some hint of your context -- do you already understand the general concepts of branching and merging as they're used in other tools, or better yet, are you already familiar with how branching works in Perforce without streams? If so I could give you some specifics on what the benefits of streams are relative to manually managing branch and client views.

For this answer though I'm going to assume you're new to branching in general and will simply direct you to the 2006 Google Tech Talk "The Flow of Change", which was given by Laura Wingerd, one of the chief architects of Perforce streams. This is from about 5 years before streams were actually implemented in Perforce (the 2011.1 release), but the core ideas around what it means to manage the flow of change between variants of software are all there. Hopefully with the additional context of the stream docs you've already read it'll be more clear why this is useful in the real world.

https://www.youtube.com/watch?v=AJ-CpGsCpM0




回答2:


If you're already familiar with branching in Perforce, you're aware that a branch can be any arbitrary collection of files, managed by two types of view:

  1. One or more client views, which define the set of files you need to map to your workspace in order to sync the branch
  2. One or more branch views, which define how to merge changes between this branch and other branches. (Even if you don't define permanent branch specs, if you run p4 integrate src... dst... that's an ad hoc branch view.)

The main purpose of streams from a technical standpoint is to eliminate the work of maintaining these views. With "classic" Perforce branching, you might declare the file path //depot/main/... is your mainline and //depot/rel1/... is your rel1 release branch, and then define views like this:

Branch: rel1
View:
     //depot/main/... //depot/rel1/...

Client: main-ws
View:
    //depot/main/... //main-ws/...

Client: rel1-ws
View:
    //depot/rel1/... //rel1-ws/...

If you wanted to have one workspace and switch between the two branches you'd do something like:

p4 client -t rel1-ws
p4 sync
(do work in rel1)
p4 submit
p4 client -t main-ws
p4 sync
p4 integ -r -b rel1

This is a very simple example of course -- if you decide you want to unmap some files from the branch, then you have to make that change in both client specs and possibly the branch view, if you create more branches that's more client specs and more branch specs, etc.


With streams the same simple two-branch setup is represented by two streams:

Stream: //depot/main
Parent: none
Type: mainline
Paths:
    share ...

Stream: //depot/rel1
Parent: //depot/main
Type: release
Paths:
    share ...

To do work in both streams you'd do:

p4 switch rel1
(do work in rel1)
p4 submit
p4 switch main
p4 merge --from rel1

All tasks around managing branch and client views are handled automatically -- the switch command generates a client view appropriate to the named stream and syncs it (it also shelves your work in progress, or optionally relocates it to the new stream similar to a git checkout command), and the merge command generates a branch view that maps between the current stream and the named source stream.

More complex views are also handled; for example, if you want to ignore all .o files in all workspaces associated with either of these streams, just add this to the //depot/main stream:

Ignored:
    .o

This is automatically inherited by all child streams and is reflected in all automatically generated client and branch views (it's like adding a -//depot/branch/....o //client/... line to all your client views at once).

There's a lot more that you can do with stream definitions but hopefully that gives you the general idea -- the point is to take all the work that people do to manage views associated with codelines and centralize/automate it for ease of use, as well as provide nice syntactic sugar like p4 switch and p4 merge --from.



来源:https://stackoverflow.com/questions/48623273/perforceneed-some-introduction-on-perforce-streams

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!