码迷,mamicode.com
首页 > 其他好文 > 详细

svn分支管理进行迭代开发

时间:2016-08-28 12:31:33      阅读:253      评论:0      收藏:0      [点我收藏+]

标签:

 

[root@ok svndata]# svn co svn://192.168.1.111/app01
# checkout项目到本机

开始规划我们的svn项目目录:

[root@ok svndata]# tree app01/ 
app01/ #项目根目录
├── branches #其他分支
│   ├── iterative-2 #迭代分支
│   ├── iterative-2-feature1 #基于迭代分支的特性1分支
│   └── iterative-2-feature2    #基于迭代分支的特性2分支
├── tags
└── trunk #主干分支

6 directories, 0 files

主干分支上创建第一个代码文件:

[root@ok app01]# svn mkdir trunk
A         trunk
[root@ok app01]# touch trunk/hello.py    
[root@ok app01]# svn add trunk/hello.py
A         trunk/hello.py
[root@ok app01]# svn ci -m "init"
Adding         trunk
Adding         trunk/hello.py
Transmitting file data .
Committed revision 7.
[root@ok app01]# svn update
At revision 7.

创建我们的第一个迭代分支:

[root@ok app01]# svn mkdir branches
A         branches
[root@ok app01]# svn ci -m "创建分支目录"
Adding         branches

Committed revision 8.
[root@ok app01]# svn update
At revision 8.

创建分分支的方式一:

[root@ok app01]# svn cp trunk/ branches/iterative-2
A         branches/iterative-2
[root@ok app01]# svn ci -m "创建二期迭代分支"
Adding         branches/iterative-2

Committed revision 9.

创建分分支的方式二:

[root@ok app01]# svn cp svn://192.168.1.111/app01/trunk \
> svn://192.168.1.111/app01/branches/iterative-2 \
> -m "创建二期迭代分支"
注意一定要svn update 否则可能会看不到更新log
[root@ok app01]# svn update
[root@ok app01]# svn log -v
------------------------------------------------------------------------
r11 | svnroot | 2016-08-26 12:22:45 +0800 (Fri, 26 Aug 2016) | 1 line
Changed paths:
   A /branches/iterative-2 (from /trunk:8)

创建二期迭代分支

基于迭代分支创建特性分支:
因为一次迭代开发可能包含很多新功能,面这些个功能可以由N个开发人员来并行开发。所以最佳方案是每个功能点再建一个分支出来,实现之后再合并回二期迭代分支。

[root@ok app01]# svn cp svn://192.168.1.111/app01/branches/iterative-2 \
> svn://192.168.1.111/app01/branches/iterative-2-feature-say-hi \
> -m "2期需求:say hi功能"

Committed revision 12.
[root@ok app01]# svn update
A    branches/iterative-2-feature-say-hi
A    branches/iterative-2-feature-say-hi/hello.py
Updated to revision 12.
[root@ok app01]# svn ci -m "2期需求:say hi功能"
[root@ok app01]# svn update
At revision 12.
[root@ok app01]# svn log -v
------------------------------------------------------------------------
r12 | svnroot | 2016-08-26 12:34:40 +0800 (Fri, 26 Aug 2016) | 1 line
Changed paths:
   A /branches/iterative-2-feature-say-hi (from /branches/iterative-2:11)

2期需求:say hi功能
------------------------------------------------------------------------
r11 | svnroot | 2016-08-26 12:22:45 +0800 (Fri, 26 Aug 2016) | 1 line
Changed paths:
   A /branches/iterative-2 (from /trunk:8)

创建二期迭代分支
------------------------------------------------------------------------
r10 | svnroot | 2016-08-26 12:21:48 +0800 (Fri, 26 Aug 2016) | 1 line
Changed paths:
   D /branches/iterative-2

实现特性功能:

[root@ok app01]# echo "加入代码实现一些功能!!!">branches/iterative-2-feature-say-hi/hello.py 
[root@ok app01]# svn commit -m "say hi 功能"
Sending        branches/iterative-2-feature-say-hi/hello.py
Transmitting file data .
Committed revision 13.
[root@ok app01]# svn update
At revision 13.
[root@ok app01]# svn log -v branches/iterative-2-feature-say-hi/hello.py 
------------------------------------------------------------------------
r13 | svnroot | 2016-08-26 12:38:06 +0800 (Fri, 26 Aug 2016) | 1 line
Changed paths:
   M /branches/iterative-2-feature-say-hi/hello.py

say hi 功能
------------------------------------------------------------------------
r12 | svnroot | 2016-08-26 12:34:40 +0800 (Fri, 26 Aug 2016) | 1 line
Changed paths:
   A /branches/iterative-2-feature-say-hi (from /branches/iterative-2:11)

2期需求:say hi功能
------------------------------------------------------------------------
r11 | svnroot | 2016-08-26 12:22:45 +0800 (Fri, 26 Aug 2016) | 1 line
Changed paths:
   A /branches/iterative-2 (from /trunk:8)

创建二期迭代分支

合并回迭代分支

[root@ok app01]# svn mkdir branches/{iterative-2-feature1,iterative-2-feature2}
A         branches/iterative-2-feature1
A         branches/iterative-2-feature2
[root@ok app01]# svn ci -m "基于迭代分支的特性1和2分支"
Adding         branches/iterative-2-feature1
Adding         branches/iterative-2-feature2

Committed revision 14.
[root@ok app01]# cd branches/iterative-2-feature1/
[root@ok iterative-2-feature1]# svn merge svn://192.168.1.111/app01/branches/iterative-2
[root@ok iterative-2-feature1]# svn commit -m "合并迭代分支的修改"
Sending        iterative-2-feature1

Committed revision 15.
//自测,没问是后,合并回迭代分支
[root@ok branches]# cd iterative-2
[root@ok iterative-2]# svn merge --reintegrate svn://192.168.1.111/app01/branches/iterative-2-feature-say-hi
--- Merging differences between repository URLs into .:
U    hello.py
[root@ok iterative-2]# svn status
 M      .
M       hello.py
[root@ok iterative-2]# svn diff

Property changes on: .
___________________________________________________________________
Added: svn:mergeinfo
   Merged /branches/iterative-2-feature-say-hi:r12-15

Index: hello.py
===================================================================
--- hello.py    (revision 13)
+++ hello.py    (working copy)
@@ -0,0 +1 @@
+加入代码实现一些功能!!!
[root@ok iterative-2]# svn ci -m "合并回迭代分支"
Sending        iterative-2
Sending        iterative-2/hello.py
Transmitting file data .
Committed revision 16.

使用reintegrate合并后,迭代分支并没有保存特 性分支的提交历史(但是在branches目录下,能看到完整的提交历史)

迭代分支合并到 trunk 中

[root@ok trunk]# svn merge --reintegrate svn://192.168.1.111/app01/branches/iterative-2
--- Merging differences between repository URLs into ‘.‘:
U    hello.py
 U   .
[root@ok iterative-2]# svn diff

Property changes on: .
___________________________________________________________________
Added: svn:mergeinfo
   Merged /branches/iterative-2-feature-say-hi:r30-33

Index: hello.py
===================================================================
--- hello.py    (revision 31)
+++ hello.py    (working copy)
@@ -0,0 +1 @@
+进行了一些修改 实现了要求达到的功能!!
[root@ok trunk]# svn ci -m "合并到turnk"
Sending        trunk
Sending        trunk/hello.py
Transmitting file data .
Committed revision 36.
[root@ok trunk]# svn update
At revision 36.
[root@ok trunk]# svn log
------------------------------------------------------------------------
r36 | svnroot | 2016-08-26 19:16:30 +0800 (Fri, 26 Aug 2016) | 1 line

合并到turnk
------------------------------------------------------------------------
r27 | svnroot | 2016-08-26 18:40:48 +0800 (Fri, 26 Aug 2016) | 1 line

init
------------------------------------------------------------------------

删除特性分支

[root@ok iterative-2]# svn rm svn://192.168.1.111/app01/branches/iterative-2-feature-say-hi -m ""

 

------------------------------------------

创建分支:

[root@ok branches]# svn cp -m "create branch" svn://192.168.1.111/app01/trunk svn://192.168.1.111/app01/branches/br_feature001

获得分支:

[root@ok branches]# svn co svn://192.168.1.111/app01/branches/br_feature001
A    br_feature001/hello.py
Checked out revision 17.

合并主干上的最新代码到分支上

[root@ok br_feature001]# svn merge svn://192.168.1.111/app01/trunk

测试如下:

[root@ok br_feature001]# cat hello.py 
[root@ok br_feature001]# svn merge svn://192.168.1.111/app01/trunk
--- Merging r18 into .:
U    hello.py 
[root@ok br_feature001]# cat hello.py 
12k

 

如果需要预览该刷新操做,可以使用svn mergeinfo:

[root@ok trunk]# svn mergeinfo svn://192.168.1.111/app01/trunk --show-revs eligible
r18

在分支上的开发结束,分支上的代码需要合并到主干,如下步骤:

[root@ok br_feature001]# cat hello.py 
12k
[root@ok br_feature001]# svn status
 M      .
M       hello.py
#末把分支合并到主干之前,查看代码:
[root@ok br_feature001]# cat ../../trunk/hello.py 
12k
[root@ok trunk]# cat hello.py 
12k
更新主干内容!!!
[root@ok trunk]# svn merge --reintegrate svn://192.168.1.111/app01/branches/br_feature001

分支合并到主干中完成后应当删该分支,因为在svn中该分支已经不能进行刷新也不能合并到主干。

[root@ok trunk]# svn log
------------------------------------------------------------------------
r19 | svnroot | 2016-08-26 16:10:20 +0800 (Fri, 26 Aug 2016) | 1 line


------------------------------------------------------------------------
r18 | svnroot | 2016-08-26 15:57:32 +0800 (Fri, 26 Aug 2016) | 1 line

12k
------------------------------------------------------------------------
r7 | svnroot | 2016-08-26 12:05:49 +0800 (Fri, 26 Aug 2016) | 1 line

init
------------------------------------------------------------------------
[root@ok trunk]# svn -r 18:19 merge svn://192.168.1.111/app01/trunk

建立tags

产品开发已经基本完成,并且通过很严格的测试,这时候我们就想发布给客户使用,发布为1.0版本

[root@ok app01]# svn copy svn://192.168.1.111/app01/trunk svn://192.168.1.111/app01/1.0 -m "Release 1.0"

Committed revision 20.

可以看出,就是简单的复制动做。

 

svn分支管理进行迭代开发

标签:

原文地址:http://www.cnblogs.com/bass6/p/5813399.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!