- 浏览: 128515 次
- 性别:
- 来自: Singapore
-
文章分类
- 全部博客 (112)
- Tiger Thread (18)
- Perforce (6)
- Spring (5)
- maven (3)
- log4j (3)
- Quartz Scheduler (4)
- unix and linux (12)
- hibernate (3)
- Enum (1)
- Futures and Options (1)
- Market Making (2)
- Java Basic (11)
- Tibco EMS (3)
- F I X message (5)
- equity derivative (2)
- Sybase (3)
- XML (1)
- JUnit (2)
- J A X B 2.0 (1)
- N I O (1)
- windows batch file (1)
- Cruise Control (1)
- util Class (5)
- ant (1)
- JMS (1)
- profiling (0)
- Sql Server (6)
- GXT (2)
- eclipse (1)
- Generics (1)
- Tibco RV (3)
- Autosys (0)
- Message (1)
最新评论
-
houzhe11:
<property name="proxyTa ...
AOP usage -- BeanNameAutoProxyCreator usage
by Robert Cowham, Perforce Consulting Partner
http://www.vaccaperna.co.uk/scm/branching.html
Introduction
This web page gives an introduction to Perforce branching mechanisms and explains some aspects that may not be obvious at first sight (well they weren't to me anyway!).
This page gives some additional information to Perforce branching mechanisms.
Other references are given at the bottom of this page.
Branching introduction
Perforce's basic mechanism, Inter-File Branching is described on their web page. The main feature is that branches of files are indicated by changing one or more elements of the depot pathname (or location in the Perforce repository), and this change is done by creating a virtual copy of the file using the integrate command.
Examples of this are:
//depot/main/jam/jam.c
//depot/r1.0/jam/jam.c
or
//depot/main/jam/...
//depot/r1.0/jam/...
for complete trees of files.
The component of the depot path that has been modified is "main" and "r1.0" respectively. In this example, we deduce ("elementary my dear Watson") that the version of jam.c in r1.0 is related to a specific version of the same file in main, and indeed that the r1.0 version was released as part of Release 1.0 for the Jam product.
This brings up a key point - you can branch a file from anywhere in the repository to anywhere else. Perforce is clever - it will keep track of what is related to what however complex that relationship. But to keep our lives simpler we need to come up with appropriate conventions so that we can easily "see" the relationships when we are browsing the repository (the KISS principle). Like most computer programs Perforce is stupid enough to do exactly what we tell it to do as opposed to what we meant it to do.
Terminology Warning...
There are some words that Perforce uses somewhat (!) ambiguously (most notably using the word "client" when "workspace" is meant (please change this Perforce even though it's a pain to do - it will make training and support much easier...), and "branch" is one of them. This means any one of:
- a codeline (most likely meaning when used as a noun)
- a branch view specification (as in the entity created by "p4 branch" command - also a noun) - these are talked about below
- when used as a verb ("to branch") it means to use the "p4 integrate" command to create a new codeline (or branch!) of one or more files
Usually it is fairly obvious what is meant once you are comfortable with the 3 alternatives, and to test your understanding I will use them interchangeably below...
Noddy1 creates his first branch --- Very good and important example!!!!
Noddy has some code sitting in //depot/main/jam/... which he wants to branch into a release codeline for maintenance purposes. During the creation of his new branch the files in //depot/main/jam/... are the "source" files and the "target" files are somewhere else in the repository (//depot/r1.0/jam/... in this instance).
So he does the following:
- Use "p4 client" and checks that his client workspace view mapping includes the "source" and "target" of his intended branch.
- Runs "p4 integrate <source files> <target files>"
- Runs "p4 submit" to submit changes to the repository after which point they become visible to other people.
E.g.
1. p4 client shows:
View: //depot/main/jam/... //client/main/...
so he changes this to:
View: //depot/main/jam/... //client/main/... //depot/r1.0/jam/... //client/r1.0/...
There is a gotcha in this example - what happens if your mapping originally had //client/... on the right hand side (no "main"). Well remember that if you change the mapping and do a "p4 sync" Perforce will delete all the old files and move them down one level to underneath "main". Make sure you do not have any files opened for editing or similar when you do this.
2. He runs the integrate command which actually does most of the work:
p4 integrate //depot/main/jam/... //depot/r1.0/jam/...
Note that this also copies all the files into his client workspace.
3. He submits his changes and the new branch is visible in the repository to everyone.
p4 submit
Behind the Scenes
Remember that when you branch a set of files, although it appears that Perforce is copying all the files, (e.g. there are 1,000 files in //depot/main/... and it appears as if there are now another 1,000 files in //depot/r1.0/..., giving 2,000 in total), that the newly branched files are just virtual copies. Perforce has duplicated the metadata in its database to say that all the //depot/r1.0/... files now exist, but they are just pointers to specific version of the real files in //depot/main/....
Behind the scenes, the //depot/main/... files actually have RCS format archives (for text files) to store all the details about the contents of each revision (binary files are normally stored as a compressed version of each revision - see "p4 help filetypes" for more information). The files in //depot/r1.0/... only acquire their own archive file on the server when they are modified (p4 edit and then submit). Thus for typical situations where you branch 1,000 files and yet change less than 100, you only get less than 100 new archive files on the server.
Branch Specs
Branch specs are created using the p4 branch command. --- Very important paragraph!!!
The key thing to remember about them is that they are only a shorthand - creating a branch spec does not branch files from its source to its target. Files are actually branched when you use a branch spec with the integrate command - it's the integrate command which does the work (not the branch command).
Branch specs are particularly useful when you have multi-line views - they save lots of typing, getting things wrong, forgetting about things etc.
Remember that you can always delete branch specs and yet the work that was done with them (using the integrate command) remains done, even after the branch spec has been deleted (they are similar to client workspace specs in this regard). I recommend that people do delete the branch specs when they are no longer needed because if they aren't there, people can't accidentally use the wrong ones - it's always wise to remove temptation from your users...
Branch Spec Directions
Branch specs have a direction (source -> target). You can use the branch spec and reverse the direction with the -r flag (see below).
One thing lots of people do is to create a branch spec for a release branch such as:
Branch: r1.0 View: //depot/main/jam/... //depot/r1.0/jam/...
They then normally only make bug fixes to the r1.0 branch and propagate them back to main and almost never in the reverse direction. This means that they always need to use the -r flag:
p4 integrate -r -b r1.0
Why not create the branch spec the "wrong" way round for its first usage (to create the branch):
View: //depot/r1.0/jam/... //depot/main/jam/...
and then you will not need to use the -r flag in most subsequent uses because you are always going from r1.0 back to main.
Don't forget the branch
component in depot path!
It is generally a good idea to have at least one component of the depot pathname as your "branch indicator". In the examples above the "main" or "r1.0" components were the indicator.
Sometimes people rush in and add a whole set of files to the depot without thinking about branching in future. For example adding source files to //depot/jam/... instead of //depot/jam/main/... (or similar). If you do this then you may have problems in the future when it comes to creating new branches for these files - what should the naming convention be?
Some Standard Depot Structures --- branch naming standard
So at this point we have covered some of the basics of the details of branching. The thing we haven't touched on is some of the alternative depot structures that are possible and why one might be better than another (in some situations at least).
Standard Release Branches - Indicator first
As already covered above, there are some very simple and yet effective structures for basic release purposes. E.g.
//depot/main/jam/...
is branched to:
//depot/r1.0/jam/...
//depot/r1.1/jam/...
This is very straight forward and easy to understand. One potential drawback, is what happens if we have many releases - well we would tend to clutter up the directory naming convention under //depot. An option might be:
//depot/main/jam/...
is branched to:
//depot/release/r1.0/jam/...
//depot/release/r1.1/jam/...
Standard Release Branches - Indicator Second
If we have many products each of which we want to branch independently, then we could do something like:
//depot/productA/main/...
is branched to:
//depot/productA/r1.0/...
//depot/productA/r1.1/...
or:
//depot/productA/release/r1.0/...
//depot/productA/release/r1.1/...
as we prefer.
There is no particular difference, but it might make things easier if we distinguish between the different products and don't mix them up (as they might be when indicator came first).
Indicator first (again) --- 2008-12-18 reading to here..
Another alternative which is useful when people have development branches (either team or personal) is:
//depot/main/productA/...
//depot/release/productA/r1.0/...
//depot/release/productA/r1.1/...
//depot/dev/personal/Fred/productA/...
//depot/dev/team/blue_team/productA/...
One advantage of this is that the first component of the path indicates the basic use (main, release, etc.). The depths become slightly more complex but this sort of things works rather well. Notice the components in the /dev/personal and /dev/team to make sure people understand what's going on and who "owns" the branch.
Weaving strands together
If we have a number of products each of which has associated documents and tests etc, then one structure is (assume that all paths are rooted under //depot):
/main/src/ |
All source files |
productA/... |
Sources for Product A |
productB/... |
Sources for Product B |
productC/... |
etc |
/main/doc/ |
All documentation files |
productA/... |
Docs for Product A |
productB/... |
etc |
/main/test/ |
All test files and documentation |
productA/... |
Sources for Product A |
productB/... |
etc |
Now we can branch "Product A" for release 1.0 as:
/release |
All source files |
/productA/1.0/ |
Release 1.0 of Product A |
src/... |
Sources |
doc/... |
Documentation |
test/... |
Test |
The problem with the above is that when you branch either to create the release branch in the first place or to propagate changes back, you need multiple lines in your view - an excellent time to use branch view specs mind.
As a general guideline, I prefer to have as simple a branch spec as possible to avoid "forgetting" things. I would try to go for one of the examples shown earlier. However, this is not always possible or indeed desirable.
Protections, Triggers
and Other Paraphernalia
If you have structured your repository thoughtfully, it is very straight forward (as an administrator) to use the protect command to create different protections for different branches. For example you can allow all developers write access to the main line, but only a small group to have write access to a particular release branch for bug fixing. Indeed there might be older "frozen" releases which are no longer being supported from which you could remove all write access.
You can also write triggers which monitor submits to specific branches and for example will not allow direct edits to files in that branch but only integrates from other related branches.
(How to implement this is left as an exercise for the reader...)
Conclusion
Perforce offers a very flexible and powerful mechanism for branches with which you can easily shoot yourself in the foot if you are not careful. Think first, think again, plan, and only then start adding, submitting and branching and remember to KISS and you will be OK (and waste less time restructuring your depot later).
This page has shown a few examples and given a few guidelines as to things to think about. The possibilities of course are endless and as long as you have good reasons for doing things and you (and your colleagues) can understand what is going on then branch away - have fun!
I have made no attempt to look at some of the more complex aspects of branching:
- sibling branches
- the nitty gritty of propagating changes and partial integrations and the like
- integration histories
- scripting branch stuff
These will be covered at a later point.
References
For more examples of uses of branching and the principles involved I suggest you read:
Software Life-Cycle Modelling in Perforce - a good overview
High-level Best Practices in Software Configuration Management - in particular the description of the mainline branching model.
Please send feedback and comments on this page to <script type="text/javascript"></script> web@vaccaperna.co.uk
Footnotes
1) For the non-Brits amongst you, Noddy is a character in Enid Blyton's children's books - whole generations of us came across them. Q: Why do elephants have Big Ears? A: Because Noddy wouldn't pay the ransom!
发表评论
-
Perforce tagging -- P4V GUI usage steps
2009-02-26 17:05 1507Perforce tagging is something d ... -
branching and merging
2009-02-26 16:07 624from : http://www.perforce.com/ ... -
Perforce usage examples
2009-02-11 14:35 898If you want to look up a single ... -
Perforce client command line usage start up
2009-01-12 14:57 1424Step 1) Find where perforce is ... -
Chapter 1. Files in the Depot
2008-07-23 12:15 872P4 Command-line client is more ...
相关推荐
$ cd directory-that-has-space-to-build-in $ bran worker -n WORKER_1 -p 7777 -m MASTER.DNS.NAME:7777 这将在端口7777上启动一个“工作程序”节点,并指定它应侦听MASTER.DNS.NAME:7777上来自主服务器的指令。 ...
国际上,IEEE 802.11、IEEE 802.16、IEEE 802.20和欧洲电信标准化学会(ETSI)广播无线电接入网络(BRAN)委员会等标准化组织已建立或正在建立使用OFDM技术的高速无线通信标准。 为了应对高PAPR问题,OFDM系统需要...
《Bran的内核开发指南》是一份专为学习操作系统内核开发的资源,主要针对Bran这个虚构的操作系统。这份指南以HTML格式提供,便于在线阅读或离线浏览,并且包含了源代码,使得读者能够深入理解并实践内核开发过程。...
"castle-bran.github.io" 是一个GitHub Pages站点的名称,通常用于个人或项目网页的托管。GitHub Pages是GitHub提供的一项服务,允许用户免费发布静态网站。这个特定的站点可能属于一个名为"castle-bran"的用户或...
Modeling and Analysis of Real-Time and Embedded Systems with UML and MARTE explains how to apply the complex MARTE standard in practical situations. This approachable reference provides a handy user ...
7. bran - 麸;糠:谷物加工后的外皮,富含纤维,常用于动物饲料和健康食品。 8. flour, meal - 粗磨谷粉:通过研磨谷物得到,用于烘焙和烹饪。 9. spring wheat - 春小麦:春季播种的硬质小麦品种。 10. maize - ...
自己写的PDMS PML 管道模块宏,可以自动BRAN收头收尾并重新链接头尾目标。 可以做一个按钮方便使用。
Bran提供用于序列化和反序列化以及编码的代码转换器。 目的是为本机Python类型(例如嵌套字典)提供序列化格式,其序列化是明确且稳定的。 那就是两个具有相同内容的值序列化到相同的字节字符串。 这样就可以创建...
麸 一种在 Erlang VM 上运行的具有... $ ln -s /home/yourname/bran /opt/local/bran 将bin目录的路径添加到命令行路径。 (环境变量PATH等) # .bashrc, etc. export PATH=/opt/local/bran/bin:$PATH 将环境变量BR
在企业级软件开发与管理领域,SAP(Systems, Applications, and Products in Data Processing)系统占据着举足轻重的地位。其中,SAP Business Intelligence (BI)模块是数据分析和决策支持的重要组成部分。本文将...
ETSI TR 102 742 V1.1.1 ...in the 3 400 MHz to 3 800 MHz Frequency Band 官网下载 需要凑够五十个字,在写一些吧。 V2X从2019年火了,看下载量,就看出来了。 全体降价为1,希望大家给一些留言,不胜感激额
Drupal项目加载器 下载所有Drupal项目的整个代码库。 安装 npm install -g drupal-project-loader 用法 选项: 长 短的 默认值 ... Drupal API分支(6.x,7.x,8.x等)。...drupal-project-loader --bran
目前,包括IEEE 802.11、IEEE 802.16、IEEE 802.20以及欧洲电信标准协会(European Telecommunications Standards Institute, ETSI)广播无线电接入网络(Broadcast Radio Access Network, BRAN)委员会等在内的多个...
TouchThing js-TTjs JavaScript实体/组件游戏框架TTjs的主要工作是在游戏环境中加载,管理和更新对象。 检出包含以下库: Sylvester-JavaScript的矢量和矩阵数学模块...) gl-matrix,(MIT,版权所有(c)2013,Bran
2. **智能特性**:具备完整的自诊断功能和通讯能力,支持与BRAN手操器BT200/100、HART手操器YHC4100或PRM等系统进行通讯,便于远程设定和监控。 3. **长期稳定性**:能够保持零点的长期稳定性,确保测量结果的一致性...
laravel-debugbar, Laravel Debugbar ( 集成了PHP调试栏) Laravel Debugbar 的注释: 现在,Debugbar需要包来启用,但默认情况下仍然需要 APP_DEBUG=true !请使用 branch branch branch branch branch bran
乙、对聚丙烯腈(PAN),聚α-氯代丙烯腈(Pα-ClAN)及聚α-溴代丙烯腈(Pα-BrAN)的热处理试样进行了红外光谱分析。对PAN及Pα-ClAN在热处理过程中试样的失重、含氮量的变化及热解气体进行了分析测定,测定了Pα-ClAN热...
GithubDemogit 操作实例1.利用Android studio 创建一个工程2.创建远程代码仓库VCS->Import into Version Control->Share Project on Github3.添加项目成员setting->Contributors...新建分支右键->Git->Repository->Bran
JavaGuru:Java 1在线-冬季-一月-星期三-课程组存储库 欢迎! :waving_hand: 本文档包含有关课程的最重要信息。 先决条件 意志和电脑的力量! :winking_face: 工具箱 -广泛使用的集成开发环境,可帮助... > Remote Bran
discordjs-bot discordjs-bot是服务器的discord机器人。 该机器人用于节制,欢迎,角色和练级。 先决条件 开始之前,请确保您满足以下要求: 您已经安装了最新版本的 安装discordjs-bot ...bran