显示标签为“subversion”的博文。显示所有博文
显示标签为“subversion”的博文。显示所有博文

星期一, 五月 11, 2009

uuid of subversion

uuid of subversion

在做 subversion 迁移的时候,使用了 svnsync 来同步 repository 数据(编写的 svnsync.sh 脚本调用 svnadmin 和 svnsync init/sync 过程并日志),服务端的迁移没有什么问题,而客户端的重定位,直接使用 sw 不行:

  [root@vxy8_cfengine2 /tmp/cfengine.svn]
#svn sw http://172.22.35.10/svn/trunk/KS_CFENGINE/cfengine
svn: 'http://172.22.35.10/svn/trunk/KS_CFENGINE/cfengine'
is not the same repository as
'http://172.22.35.12/svn'

这就是说,直接使用 sw 需要在同一个主机的同一个 repository 下才行。

但 sw 有一个 --relocate 参数,可以切换 repository:

  [root@vxy8_cfengine2 /tmp/cfengine.svn]
#svn sw --relocate http://172.22.35.12/svn/trunk/KS_CFENGINE/cfengine http://172.22.35.10/svn/trunk/KS_CFENGINE/cfengine
svn: The repository at 'http://172.22.35.10/svn' has uuid '0ce980e2-6b68-4f57-841b-e7c3a84044d9', but the WC has '92f65df4-df84-11dc-ae99-89d8fa8a2030'

这个报错和 subversion 的 uuid 有关,这是由 svnsync 同步数据遗留的问题,源 repos 和新 repos 的 uuid 不一致,看看工作目录的情况:

  [root@vxy8_cfengine2 /tmp/cfengine.svn]
#svn info
Path: .
URL: http://172.22.35.12/svn/trunk/KS_CFENGINE/cfengine
Repository Root: http://172.22.35.12/svn
Repository UUID: 0ce980e2-6b68-4f57-841b-e7c3a84044d9
Revision: 2837
Node Kind: directory
Schedule: normal
Last Changed Author: roczhou.zhoup
Last Changed Rev: 2835
Last Changed Date: 2009-05-11 10:50:24 +0800 (Mon, 11 May 2009)

使用 svnlook uuid 可以查看 repos 的 uuid。下面是源 repos

  [root@vxy8_cfengine2 /tmp/cfengine.svn]
#svnlook uuid /home/admin/data/svn_repo/
0ce980e2-6b68-4f57-841b-e7c3a84044d9

下面是目标 repos

  [root@vxy7_cfengine1 /var/cfengine.svn]
#svnlook uuid /home/admin/data/svn_repo
92f65df4-df84-11dc-ae99-89d8fa8a2030

解决办法是,对于 subversion-1.5 以上,可直接在运行 svnadmin setuuid 来设置源或目标 repos 的 uuid 使其保持一致,对低于 subversion-1.5 的系统,示例如下(更改源 repos):

  [root@vxy8_cfengine2 /tmp/cfengine.svn]
#vi /tmp/x

SVN-fs-dump-format-version: 2

UUID: 92f65df4-df84-11dc-ae99-89d8fa8a2030

[root@vxy8_cfengine2 /tmp/cfengine.svn]
#cat /tmp/x | svnadmin load --force-uuid /home/admin/data/svn_repo/

#svnlook uuid /home/admin/data/svn_repo/
92f65df4-df84-11dc-ae99-89d8fa8a2030

[root@vxy8_cfengine2 /tmp/cfengine.svn]
#svn info
Path: .
URL: http://172.22.35.12/svn/trunk/KS_CFENGINE/cfengine
Repository Root: http://172.22.35.12/svn
Repository UUID: 0ce980e2-6b68-4f57-841b-e7c3a84044d9
Revision: 2837
Node Kind: directory
Schedule: normal
Last Changed Author: roczhou.zhoup
Last Changed Rev: 2835
Last Changed Date: 2009-05-11 10:50:24 +0800 (Mon, 11 May 2009)

# 此时还没变

[root@vxy8_cfengine2 /tmp/cfengine.svn]
#svn sw --relocate http://172.22.35.12/svn/trunk/KS_CFENGINE/cfengine http://172.22.35.10/svn/trunk/KS_CFENGINE/cfengine
svn: The repository at 'http://172.22.35.10/svn' has uuid '51c9629f-21a9-4eaa-825b-20ccd5c61100', but the WC has '92f65df4-df84-11dc-ae99-89d8fa8a2030'

[root@vxy8_cfengine2 /tmp/cfengine.svn]
#svn up

[root@vxy8_cfengine2 /tmp/cfengine.svn]
#svn info
Path: .
URL: http://172.22.35.12/svn/trunk/KS_CFENGINE/cfengine
Repository Root: http://172.22.35.12/svn
Repository UUID: 92f65df4-df84-11dc-ae99-89d8fa8a2030
Revision: 2837
Node Kind: directory
Schedule: normal
Last Changed Author: roczhou.zhoup
Last Changed Rev: 2835
Last Changed Date: 2009-05-11 10:50:24 +0800 (Mon, 11 May 2009)

# 此时已经改变

[root@vxy8_cfengine2 /tmp/cfengine.svn]
#svn sw --relocate http://172.22.35.12/svn/trunk/KS_CFENGINE/cfengine http://172.22.35.10/svn/trunk/KS_CFENGINE/cfengine
svn: The repository at 'http://172.22.35.10/svn' has uuid '51c9629f-21a9-4eaa-825b-20ccd5c61100', but the WC has '92f65df4-df84-11dc-ae99-89d8fa8a2030'

但运行还是出错,这说明,更改源 repos 的 uuid 无效!

那么尝试更改目标的 uuid(下面让 vxy8_cfengine2 作为目标,vxy7_cfengine1 作为源)

  [root@vxy8_cfengine2 /tmp/cfengine.svn]
#!286
cat /tmp/y | svnadmin load --force-uuid /home/admin/data/svn_repo/

[root@vxy8_cfengine2 /tmp/cfengine.svn]
#svnlook uuid /home/admin/data/svn_repo/
0ce980e2-6b68-4f57-841b-e7c3a84044d9

[root@vxy7_cfengine1 /tmp/cfengine.svn]
#svn info
Path: .
URL: http://172.22.35.10/svn/trunk/KS_CFENGINE/cfengine
Repository Root: http://172.22.35.10/svn
Repository UUID: 92f65df4-df84-11dc-ae99-89d8fa8a2030
Revision: 2842
Node Kind: directory
Schedule: normal
Last Changed Author: roczhou.zhoup
Last Changed Rev: 2842
Last Changed Date: 2009-05-11 14:52:36 +0800 (Mon, 11 May 2009)

[root@vxy7_cfengine1 /tmp/cfengine.svn]
#svn sw --relocate http://172.22.35.10/svn/trunk/KS_CFENGINE/cfengine http://172.22.35.12/svn/trunk/KS_CFENGINE/cfengine
svn: The repository at 'http://172.22.35.12/svn' has uuid '92f65df4-df84-11dc-ae99-89d8fa8a2030', but the WC has '0ce980e2-6b68-4f57-841b-e7c3a84044d9'

[root@vxy8_cfengine2 /tmp/cfengine.svn]
#cat /tmp/x | svnadmin load --force-uuid /home/admin/data/svn_repo/

[root@vxy8_cfengine2 /tmp/cfengine.svn]
#svnlook uuid /home/admin/data/svn_repo/
92f65df4-df84-11dc-ae99-89d8fa8a2030

[root@vxy7_cfengine1 /tmp/cfengine.svn]
#svn sw --relocate http://172.22.35.10/svn/trunk/KS_CFENGINE/cfengine http://172.22.35.12/svn/trunk/KS_CFENGINE/cfengine

[root@vxy7_cfengine1 /tmp/cfengine.svn]
#svn info
Path: .
URL: http://172.22.35.12/svn/trunk/KS_CFENGINE/cfengine
Repository Root: http://172.22.35.12/svn
Repository UUID: 92f65df4-df84-11dc-ae99-89d8fa8a2030
Revision: 2848
Node Kind: directory
Schedule: normal
Last Changed Author: roczhou.zhoup
Last Changed Rev: 2847
Last Changed Date: 2009-05-11 16:15:01 +0800 (Mon, 11 May 2009)

这里已经完成了切换。所以,要统一 uuid,需要更改目标 repos 的 uuid。

另外,从上面的例子可以看出,修改了 repos 的 uuid 之后,对于已经检查(checkout/co)的工作目录不会有影响,当其下一次 svn up 之后,其 info 中的 uuid 即进行了更新。

星期一, 四月 02, 2007

sourceforge svn

现在需要使用 sourceforge 的 subversion,并将以前的版本库导入到里面。这涉及几个方面的问题,可以参考 sourceforge 的文档。
http://sourceforge.net/docs/E09

首先是需要启用 subversion。我的项目创建时默认使用的是 CVS,可以进入 "Admin"->"CVS" 禁止掉,在进入 "Admin"->"subversion" enable。

sourceforge svn 的 repos URL 是:
http://PROJECTNAME.svn.sourceforge.net/svnroot/PROJECTNAME
所以我的项目将是:
http://crablfs.svn.sourceforge.net/svnroot/crablfs
但是如果要写入,则需要使用 https。

先试试检出:
sh$ svn co https://crablfs.svn.sourceforge.net/svnroot/crablfs
svn: Unrecognized URL scheme https
要检查 svn 支持哪些 scheme,使用 svn --version 命令:
sh$ svn --version
...
he following repository access (RA) modules are available:

* ra_dav : Module for accessing a repository via WebDAV (DeltaV) protocol.
- handles 'http' scheme
* ra_svn : Module for accessing a repository using the svn network protocol.
- handles 'svn' scheme
* ra_local : Module for accessing a repository on local disk.
- handles 'file' scheme
从 google search 的情况来看,必须添加 ssl 支持,而这个支持是由 neon 库来完成的。另外还需要 apr/apr-util。我之前使用的是 1.1.4 版,neon 和 apr 都包含在 source 里了,但编译添加 --with-ssl,或单独编译 neon-0.26.3 再在 svn ./configure 时添加参数 --with-neon 都无效。

换用 subversion-1.4.3,neon 和 apr 都不再包括在源代码中了,只能自己编译。但似乎这次必须使用 apache(必须指定 apxs),即使使用 --disable-mod-activative,否则连 http scheme 都没有了。

不想为了一个 svn client 装一个 apache server,结果找了一个 1.3.2 解决这个问题,也是包含 neon 和 apr 的,
The following repository access (RA) modules are available:

* ra_dav : Module for accessing a repository via WebDAV (DeltaV) protocol.
- handles 'http' scheme
- handles 'https' scheme
* ra_svn : Module for accessing a repository using the svn network protocol.
- handles 'svn' scheme
* ra_local : Module for accessing a repository on local disk.
- handles 'file' scheme
添加 --with-ssl 编译。

然后需要将以前的版本库导入。不可能直接使用 svn import 导入,因为需要保留以前的所有信息。可以参考:
http://sourceforge.net/docs/E09#import
的指导。大体上,就是先使用 svnadmin dump 得到当前版本库的备份,再利用 sourceforge 的机制导入。
sh$ svnadmin dump /mnt/file/data/gears | gzip >/tmp/gears.gz
sh$ cp /tmp/gears.gz chowroc@crablfs.sourceforge.net:/home/groups/c/cr/crablfs/
这里 /home/groups/p/pr/project 就是相关文档的 DocumentRoot。

然后进入 "Admin"->"Subversion"->"Migration Instructions"->"migrate"进入:
http://sourceforge.net/project/admin/svn_migration.php?group_id=180695
填写刚才的 .gz 文件并提交即可。

最后还有一个问题,就是备份。虽然 svn 版本库保存在网络上了,但是还是需要以防万一,且不说如果 sourceforge 本身出问题如何,如果出现象地震或 GFW 等问题导致不能连接,至少还可以使用本地拷贝,如果可能还可以使用前面的 migrate 方法重新导入。用如下方法备份:
sh$ mkdir gears
sh$ cd gears
sh$ rsync -av crablfs.svn.sourceforge.net::svn/crablfs/* .
注意需要使用 svn/crablfs/* 而不是 svn/crablfs,因为 svn/crablfs 实际上是到 /home/groups/c/cr/crablfs/svnroot 的一个符号链接。

其他一些问题:
如何查询某个特定版本与另一个特定版本相比修改了哪些文件?
目前不知道如何直接利用 svn 的命令来做到,但是可以使用 --diff-cmd -x 来调用 diff,从而可以得到一个简要清单:
sh$ svn diff --diff-cmd -x --breif
因此也可以利用这一点做一些其他形式的比较,比如我比较喜欢使用 diff 的 -y --suppress-common-lines:
sh$ svn diff --diff-cmd diff -x '-y --suppress-common-lines' utilsea/trunk/fs_backup  | less

星期二, 二月 27, 2007

svn over http

sh$ cat /usr/src/apache/.config
command = "./configure --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr --with-mpm=prefork --enable-so --enable-rewrite=static --enable-track-vars --enable-dav=shared --enable-dav-fs=shared --enable-dav-lock=shared";

sh$ cat /usr/src/subversion/.config
command = "./configure --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr";
command = "make";
command = "sed -i 's@MKDIR = /usr/bin/install -c -d@MKDIR = mkdir -p@g' Makefile";
command = "make install";

sh$ cat httpd.conf
......
NameVirtualHost *:80

"<"VirtualHost *:80">"
ServerName docs.shopex.cn
DocumentRoot "/var/www/html/docs"
"<"Directory "/var/www/html/docs"">"
Options Indexes FollowSymLinks
AllowOverride None

Order allow,deny
Allow from all
"<"/Directory">"
"<"Location /repos">"
DAV svn
SVNParentPath /var/www/html/docs/repos
"<"/Location">"
"<"/VirtualHost">"

sh$ svnadmin create --fs-type fsfs http://docs.shopex.cn/
svnadmin: 'http://docs.shopex.cn' is an URL when it should be a path
svnadmin 直接访问版本库(因此只可以在存放版本库的机器上使用),它通过路径访问版本库,而不是 URL。
sh$ svnadmin create --fs-type fsfs /var/www/html/docs/repos/sysadm

sh$ svn list http://docs.shopex.cn/docs
svn: Unrecognized URL scheme for 'http://docs.shopex.cn/docs'

这是因为没有 ra_dav 这个库。
sh$ upm files subversion-1.4.3 | grep ra_dav

故障解决
但是编译没有成功将 ra_dav 编译进来,这是因为 neon 不存在或版本不够。可以从 ./configure 的输出中找到相应的说明。

sh$ rpm -qi neon
neon is an HTTP and WebDAV client library, with a C interface;
providing a high-level interface to HTTP and WebDAV methods along
with a low-level interface for HTTP request handling. neon
supports persistent connections, proxy servers, basic, digest and
Kerberos authentication, and has complete SSL support.


换用一个较低版本的 subversion,保证可以成功编译 ra_dav,然后运行:
sh$ svn list file:///var/www/html/docs/repos/sysadm/
sh$ svn list http://docs.shopex.cn/repos/sysadm
svn: PROPFIND request failed on '/repos/sysadm'
svn: PROPFIND of '/repos/sysadm': 301 Moved Permanently (http://docs.shopex.cn)
从页面上访问 docs.shopex.cn/repos:
Forbidden
You don't have permission to access /repos/ on this server. 然后访问 http://docs.shopex.cn/repos/index.html:
"<"D:error">"
"<"C:error/">"
"<"m:human-readable errcode="2"">"
Could not open the requested SVN filesystem
"<"/m:human-readable">"
"<"/D:error">"
这个问题参考这些页面:
Subversion 出現 301 Moved Permanently 的解決方法
subversion 301-error
SVN 基本的 Apache 配置
也就是说,不能将 DocumentRoot 和 SVN 的 repos Location 定义为同样的路径,因为如果一个请求的 URI 是/repos/foo.py,Apache不知道是直接到 repos/foo.py 访问这个文件还是让 mod_dav_svn 代理从 Subversion 版本库返回 foo.py。这里只需要注释上面的 DocumentRoot 即可!

星期一, 十一月 20, 2006

svn simple tagging

$ svn copy file:///file/project/data/ea/crablfs/trunk file:///file/project/data/ea/crablfs/tags/v0.1.1alpha -m "tagging v0.1.1alpha"
Committed revision 59.
$ svn update

其中 $repos=/file/project/data/

星期四, 十月 05, 2006

subversion 修改 log

[roc@chowroc trunk]$ svnadmin setlog /mnt/file/data/ea/ -r 25 ~/tmp
svn: Repository has not been enabled to accept revision propchanges;
ask the administrator to create a pre-revprop-change hook
[roc@chowroc trunk]$ svnadmin setlog /mnt/file/data/ea/ -r 25 ~/tmp --bypass-hooks

星期六, 九月 30, 2006

subversion 的简单使用

如果是本地使用,如下即可:
$ svnadmin create --fs-type fsfs /mnt/file/data/ea
$ mkdir tmp
$ cd tmp
$ mkdir crablfs/{trunk,tags} -p
$ svn import . file:///mnt/file/data/ea
$ cd /mnt/file/work/project
$ svn checkout /mnt/file/data/ea/crablfs
$ cd !$
$ cp /path/to/userpack .
$ svn add userpack
$ svn commit
$ vi userpack
$ svn commit

服务器形式:
$ svnserve -d -r /mnt/file/data/ea
$ svn list svn://localhost/
$ svn checkout svn://localhost/crablfs

$ svnserve -t
$ svn checkout svn+ssh://localhost/mnt/file/data/ea/crablfs

注意:
svn 针对的是工作拷贝
svnadmin/svnlook 针对的是版本库本身,随意只能在本地操作,不能远程操作!

备份和恢复:
svnadmin dum /mnt/file/data/ea >dumpfile
svnadmin create --fs-type fsfs /tmp/ea
svnadmin load /tmp/ea "<"dumpfile