Subversion若干问题小记

1. Subversion 1.6升级到1.7提交错误:'svn/!svn/me'path not found
在网上搜了一下,找到这样一条留言,
引用
Subversion E160013: '/svn/xxx/!svn/me' path not found* error(http://stackoverflow.com/questions/9928285/subversion-e160013-svn-xxx-svn-me-path-not-found-error)

I recently upgraded the bitnami trac stack (from 0.12.2-5 to 0.12.3) on our server and after reconfiguring all the scripts and repositories all seemed well. I was able to login and view the source code and browse through the repository using trac. I tested checking out the source code and I could browse the repository via both visualsvn and tortoise. But when it came to commiting changes made there was a problem. I got a path not found exception. Looking into the error log on the server all I could see was all get requests were fine, but posts had an incorrect url (!svn/me was appended at the end). After spending a couple of hours going through logs and configurations, since subversion was upgraded from 1.6 to 1.7, this include the new HttpV2 protocol. This protocol somehow affected access to the svn repositores, but only seems to affect posts and not gets. The way to disable the new features is by changes to the mod_dav_snv configuration locations as follows:

DAV svn
...
SVNAdvertiseV2Protocol Off
The issue was then resolved and we could check in our changes again.


这段话大意是说:
引用
他最近升级了他服务器上的Trac,可以登录和看到版本库里的源代码,他可以通过visualsvn和totoise对版本库checkout, 但是当他commiting changes的时候,却得到path not found的错误,(跟我遇到的问题一模一样)。他看了错误日志,发现日志里面所有的request请求都是正常的,但post请求却都跟着一个错误的 url,所有的url在最末尾都被错误地附加上了!svn/me。他花了几个小时查看日志和配置文件,发现subversion在从1.6升级到1.7的 时候,包含了新的HttpV2 protocol,这个协议影响到了对svn版本库的访问,但仅仅影响到了posts,而gets并没有受到影响。禁用这个新特性的方法就是更改mod_dav_svn的本地配置,如下:

DAV svn
...
SVNAdvertiseV2Protocol Off

照此方法改了我的httpd.conf文件后,问题也得到了解决。非常感谢这位无私的问题贡献者。

2.解决svn "cannot set LC_CTYPE locale"的问题

在Linux下的svn命令执行时,出现错误警告:
svn :  warning :  cannot set LC_CTYPE locale
svn :  warning :  environment variable LANG is en_US . UTF - 8
svn :  warning :  please check that your locale name is correct
Type  ' svn help '   for  usage .

  
解决方法:修改/etc/profile:
sudo vi  /etc/profile
加入一行:export LC_ALL = C
然后执行:source  /etc/profile

3.php网页中执行exec一例--svn update
<?php
$username = 'abc';
$password = '123456';
$target_dir = '/var/my_work_folder';
$arg_file = '/var/args';

exec("sudo svn up --username $username --password $password $target_dir 2>&1 <$arg_file", $output);
print_r($output);


/var/args文件内容如下:
p
yes

这是因为第一次执行svn up时可能要求交互确认信息(如,svn密码是否永久保存确认等),需要通过管道输入。

本以为以上的写法天衣无缝,其实不然,因为sudo配置信息必须保证php网页执行用户(我这里是apache)具备合适的权限执行svn 命令。

为此,修改sudo配置文件,直接键如visudo命令编辑配置文件:

1. 注释Defaults requiretty
Defaults requiretty修改为 #Defaults requiretty, 表示不需要控制终端。
否则会出现sudo: sorry, you must have a tty to run sudo

2. 增加行 Defaults visiblepw
否则会出现 sudo: no tty present and no askpass program specified

3. 赋予apache用户执行svn权限
如,增加行:apache ALL=(ALL) NOPASSWD: /usr/bin/svn
注:NOPASSWD可以使在命令执行时不需要交互输入apache用户的密码

猜你喜欢

转载自koda.iteye.com/blog/1841394
今日推荐