svn服务器管理

Svn Repository Control

--by:liy,2006/11/2

1. summary:

版本库布局:

|  

|--trunk –开发主线

|--tags  --里程碑

 |--branches  -- 维护用


  主线(trunk)一直处于开发状态,从1.0 -> 1.5 -> 2.0 .... ;
  每当要测试或发布时,将主线拷贝一份为tags/1.0b1
tags/1.0b2,tags/1.0r ;
  发布时,将主线拷贝一份为branches/branch1.0等,作为维护用
;
  在维护的版本(比如branch1.0)发现bug,出那个维护版本,修改bug,提交
;
  同时,将这个维护版本合并到主线,提交。

 

2. Branche and Merge:

2.1 set up branche:

/* First, you should mkdir /repos/calc/branches/my-calc-branch qua your branche */

<Input command:>

$ svn copy http://svn.example.com/repos/calc/trunk /

http://svn.example.com/repos/calc/branches/my-calc-branch /

-m "Creating a private branch of /calc/trunk."

2.2 work on the branche:

<Input command:>

$ svn checkout http://svn.example.com/repos/calc/branches/my-calc-branch

 

2.3 Merge branche:

The svn merge command nearly same as svn diff. But it does’nt print difference to your terminal. It direct change your local copyright.

 

<Input command:>

$ svn merge -r 343:344 http://svn.example.com/repos/calc/trunk   /* merge version 343 and 344 branche */

<Output >

U integer.c

 

<Input command:>

$ svn status

<Output :>

M integer.c

 

<Note:>

Or if you consider the merge is false decision, you only need run “svn revert”;

If you consider the merge is right, you can commit your modification by “svn commit” command.

 

2.4 Merge one branche to another

For showing your modification on your branche, you only need compare initialization and final state.

 

a)       find initialization of your branche.

 

<Input command:>

$ svn log --verbose --stop-on-copy /

http://svn.example.com/repos/calc/branches/my-calc-branch

 

<Output>

r341 | user | 2002-11-03 15:27:56 -0600 (Thu, 07 Nov 2002) | 2 lines

Changed paths:

A /calc/branches/my-calc-branch (from /calc/trunk:340)

 

b)final state is HEAD copyright.

 

2.4.1 This is merge process:

<Input command:>

$ cd calc/trunk

$ svn update

<Output>

At revision 405.

 

<Input command:>

$ svn merge -r 341:405 http://svn.example.com/repos/calc/branches/my-calc-branch

<Output>

U integer.c

U button.c

U Makefile

 

<Input command:>

$ svn status

<Output>

M integer.c

M button.c

M Makefile

# ...examine the diffs, compile, test, etc...

 

<Input command:>

$ svn commit -m "Merged my-calc-branch changes r341:405 into the trunk."

<Output>

Sending integer.c

Sending button.c

Sending Makefile

Transmitting file data ...

Committed revision 406.

 

2.4.2 Change modification:

<Input command:>     

$ svn merge -r 303:302 http://svn.example.com/repos/calc/trunk

<Output>

U integer.c

 

<Input command:>

$ svn status

<Output>

M integer.c

 

<Input command:>

$ svn diff

<Output>

# verify that the change is removed

 

<Input command:>

$ svn commit -m "Undoing change committed in r303."

<Output>

Sending integer.c

 

2.5 Tag:

2.5.1 Build a base tag

<Note:>

“svn copy” again enter. You hope upbuild a “/calc/trunk” snapshot,in fact, it is copying in the /calc/tag directory.

 

<Input command:>

$ svn copy http://svn.example.com/repos/calc/trunk /

http://svn.example.com/repos/calc/tags/release-1.0 /

-m "Tagging the 1.0 release of the 'calc' project."

 

3.repository’s directory frame

3.1 workbox of administrator

<Input command:>

$ svnlook info /path/to/repos

 

<Note:>

svnadmin – “admin’s friend”

 

<Input command:>

$ svnadmin help

 

<Output>

general usage: svnadmin SUBCOMMAND REPOS_PATH [ARGS & OPTIONS ...]

Type "svnadmin help <subcommand>" for help on a specific subcommand.

Available subcommands:

create     -- “st up a new subversion repository”

deltify   --订版本范围内,对其中修改过的路径做增量化操作。如果没有指定修订版本,这条命令会修改HEAD修订版本。

dump     -- 库修订一定版本范围内的内容,使用可移植转储格式。

hotcopy -- 做热拷贝,用这个方法你能任何时候安全的备份版本库而无需考虑是否正在使用。

 

3.2 svndumpfilter

<Input command:>

$ svndumpfilter help

 

<Output>

general usage: svndumpfilter SUBCOMMAND [ARGS & OPTIONS ...]

Type "svndumpfilter help <subcommand>" for help on a specific subcommand.

Available subcommands:

exclude

include

help (? h)

 

<Note:>

exclude

将指定路径的数据从转储数据流中排除。

include

将指定路径的数据添加到转储数据流中。

 

<Example:>

假设有一个包含三个项目的版本库: calccalendar,和 spreadsheet。它们在版本库中的布局如下:

/

calc/

trunk/

branches/

tags/

calendar/

trunk/

branches/

tags/

spreadsheet/

trunk/

branches/

tags/


 

现在要把这三个项目转移到三个独立的版本库中。首先,转储整个版本库:

<Input command:>

$ svnadmin dump /path/to/repos > repos-dumpfile

<Output>

* Dumped revision 0.

* Dumped revision 1.

* Dumped revision 2.

* Dumped revision 3.

然后,将转储文件三次送入过滤器,每次仅保留一个顶级目录,就可以得到三个转储文件:

<Input command:>

$ cat repos-dumpfile | svndumpfilter include calc > calc-dumpfile

$ cat repos-dumpfile | svndumpfilter include calendar > cal-dumpfile

$ cat repos-dumpfile | svndumpfilter include spreadsheet > ss-dumpfile

 

3.3 svnshell.py

<Input command:>

$tools/examples/svnshell.py  /path/to/repos

<Output>

<rev: 2 />$ help

Available commands:

cat FILE : dump the contents of FILE

cd DIR : change the current working directory to DIR

exit : exit the shell

ls [PATH] : list the contents of the current directory

lstxns : list the transactions available for browsing

setrev REV : set the current revision to browse

settxn TXN : set the current transaction to browse

youngest : list the youngest browsable revision number

<rev: 2 />$

3.4版本库清理

<Note:> txn-info.sh(异常事务报告)

<Input command:>

$vi txn-info.sh

<Output>

#!/bin/sh

### Generate informational output for all outstanding transactions in

### a Subversion repository.

REPOS="${1}"

if [ "x$REPOS" = x ] ; then

echo "usage: $0 REPOS_PATH"

exit

fi

for TXN in `svnadmin lstxns ${REPOS}`; do

echo "---[ Transaction ${TXN} ]-------------------------------------------"

svnlook info "${REPOS}" --transaction "${TXN}"

done

可以用下面的命令使用上例中脚本: /path/to/txn-info.sh /path/to/repos

<Input command:>

$ txn-info.sh myrepos

<Output>

---[ Transaction 19 ]-------------------------------------------

sally

2001-09-04 11:57:19 -0500 (Tue 04 Sep 2001)

0

---[ Transaction 3a1 ]-------------------------------------------

harry

2001-09-10 16:50:30 -0500 (Mon 10 Sep 2001)

39

Trying to commit over a faulty network.

---[ Transaction a45 ]-------------------------------------------

sally

2001-09-12 11:09:28 -0500 (Wed 12 Sep 2001)

0

3.5 管理磁盘空间

<Note:>删除硬盘杀手 日志文件;

<Input command:>

$ svnadmin list-unused-dblogs /path/to/repos

<Output>

/path/to/repos/log.0000000031

/path/to/repos/log.0000000032

/path/to/repos/log.0000000033

 

<Input command:>

$ svnadmin list-unused-dblogs /path/to/repos | xargs rm

 

3.6 版本库的恢复

使用下面的方法试着恢复你的版本库:

  1. 确保没有其它进程访问(或者试图访问)版本库。对于网络版本库,关闭Apache HTTP服务器是个好办法。

  2. 成为版本库的拥有者和管理员。这一点很重要,如果以其它用户的身份恢复版本库,可能会改变版本库文件的访问权限,导致在版本库恢复后依旧无法访问。

  3. 运行命令svnadmin recover /path/to/repos 


 

  4. Repository lock acquired

  5. Please wait; recovering the repository may take some time...

  6. Recovery completed.

  7. The latest repos revision is 19.

  8. 重新启动Subversion服务器。

3.7 版本库的移植

把所有的数据(或者一部分数据)保存在一个独立的、可移植的、普通格式的文件中。Subversion通过svnadmin的两个子命令dumpload提供了类似的功能。

$ svnadmin create newrepos

$ svnadmin dump myrepos | svnadmin load newrepos

or:

$ svnadmin dump myrepos --revision 0:1000 > dumpfile1

$ svnadmin dump myrepos --revision 1001:2000 --incremental > dumpfile2

$ svnadmin dump myrepos --revision 2001:3000 --incremental > dumpfile3

这些转储文件可以使用下列命令装载到一个新的版本库中:

$ svnadmin load newrepos < dumpfile1

$ svnadmin load newrepos < dumpfile2

$ svnadmin load newrepos < dumpfile3

3.8 版本库备份

1.tools/backup/目录有一个hot-backup.py文件。只要给定了版本库路径和备份路径,hot-backup.py一个包裹了svnadmin hotcopy但更加智能的命令将会执行必要的步骤来备份你的活动的版本库不需要你首先禁止公共的版本库访问而且之后会从你的版本库清理死掉的伯克利日志文件。

2.全备份可以使用svnadmin hotcopysvnsync来做;

3.热备份:

Svnadmin hotcopy REPOS-PATH  NEW-REPOS—PATH
我用的命令: usr/local/subversion/bin/svnadmin hotcopy /home/svnroot/r /home/bak

4.增量备份可以通过svnadmin dump--incremental选项来实现;

至于自动备份,可以写一个批处理加到定时任务中;

 

 

 

 

 

 

 
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值