09 May 2014

1 Introduction

  • In this article, I'll introduce following svn command:
    • svn switch
    • svn log
    • svn merge
  • and finally combines these command into one svn workflow.

2 Usage of svn command

2.1 svn log

  • list svn logs
kimim@kimi.im codedojo$svn log -l 5 -g
------------------------------------------------------------------------
r595 | kimim | 2014-04-29 11:11:22 +0800 (Tue, 29 Apr 2014) | 6 lines

merge from my branch

------------------------------------------------------------------------
r594 | kimim | 2014-04-29 10:50:27 +0800 (Tue, 29 Apr 2014) | 2 lines
Merged via: r595

add handles
  • more info: svn help log

2.2 svn switch

  • switch current folder to a branch
kimim@kimi.im codedojo$svn sw ^/branches/codedojo
U    Makefile
U    jekyll.el
 U   .
Updated to revision 595.
  • more info: "svn help switch"

2.3 svn merge

  • merge from one branch to another
kimim@kimi.im codedojo$svn merge ^/trunk/codedojo
--- Merging differences between repository URLs into '.':
U    jekyll.el
U    ox-reveal.el
--- Recording mergeinfo for merge between repository URLs into '.':
 U   .
  • more info: "svn help merge"

3 SVN graph of merge operation

    branches/codedojo  +-----------------------------+-------+----------->
                      /                             /         \
                     /                             (merge)    (merge)
                    /       r598                  /             \
trunk ------+------+----------o------------------+---------------+------->
             \                 \                /
              \                 \_(merge)___   (merge)
               \                            \ /
branches/code2  +----------------------------+--------------------------->

4 SVN workflow

4.1 Create a branch of sub-folder

kimim@kimi.im codedojo$svn copy ^/trunk/codedojo ^/branches/codedojo

Committed revision 598.

4.2 Switch the sub-folder to the branch

  • switch to branch
kimim@kimi.im codedojo$svn switch ^/branches/codedojo
U    Makefile
U    jekyll.el
 U   .
  • branch info: ^/branches/codedojo
kimim@kimi.im codedojo$svn info
Path: .
Working Copy Root Path: /home/kimim/codedojo
URL: http://kimi.im/svn/lily/branches/codedojo
Relative URL: ^/branches/codedojo
Repository Root: http://kimi.im/svn/lily
Repository UUID: 740ae2fa-c468-104b-b514-ad5a56475b1e
Revision: 598
Node Kind: directory
Schedule: normal
Last Changed Author: kimim
Last Changed Rev: 598
Last Changed Date: 2014-04-29 16:00:35 +0800 (Tue, 29 Apr 2014)

4.3 Commit the daily modification to the branch

  • commit code as soon as you need
kimim@kimi.im codedojo$svn ci

4.4 Merge trunk changes to branch, compile and test

kimim@kimi.im codedojo$svn merge ^/trunk/codedojo
--- Recording mergeinfo for merge of r598 into '.':
 U   .
  • after you merged trunk to your branch, you'd better to compile and test with the branch
  • if any error, fix and commit, remember to commit the fix to the branch
  • when all the test passed, you will need to merge the code back to trunk

4.5 Merge back the branch to trunk, compile and test

  • switch to trunk
kimim@kimi.im codedojo$svn switch ^/trunk/codedojo
At revision 598.
  • merge branch to trunk
kimim@kimi.im codedojo$svn merge ^/branches/codedojo
--- Recording mergeinfo for merge of r598 into '.':
 G   .
  • finally, you need to test the merged trunk and commit the changes merged from branch to trunk
  • be reminded that the branch already contains the code merged from trunk