2012-05-11 72 views
3

我需要在发生提交后编辑文件的svn属性。因此,我想使用提交后脚本。svn propedit在非交互式脚本中

例子:

我有一个名为export设置为test时,我犯了一个名为example.ex 我提交成功我有一个post-commit钩子,也做了一些聪明的事情(即没有按后文件中的值属性对我的问题无关紧要),并在完成后需要将export的属性更改(或删除)为succeeded等新值。

在命令行中我这样做:

svn propedit "export" file:///svn/repositoryName/path/to/file/in/repository/example.ex 

这将打开我的系统编辑器vi,我会看到价值test。我可以将其更改为任何我想要保存并退出用vi命令的文件像:wq

颠覆还给这样

"svn-prop.tmp" 1L, 10C written 
Set new value for property 'export' on file:///svn/repositoryName/path/to/file/in/repository/example.ex' 
Committed revision 67. 

消息正因如此精细。但正如我所说,我需要在一个后提交脚本中,我无法控制vi(或者我错了吗?)。

所以Subversion使我可以添加一个文件到命令propedit。该文件仅包含新值succeeded

新的命令应该是这样的:

svn propedit "export" file:///svn/repositoryName/path/to/file/in/repository/example.ex --file /path/to/propertyValueFile/propValue.file 

而这里的问题:最后一个命令不起作用。 再次打开,我需要手动更改我的值。为什么?我究竟做错了什么?

+0

好吧,同时我已经意识到--file将使用此文件作为日志信息的内容。 不过,同样的问题:我需要一个脚本。 – derroman

回答

2

我找到了适合我的解决方案。

svn propedit "export" file:///svn/repositoryName/path/to/file/in/repository/example.ex --file /data/svn/intranet/hooks/fileWithLogMessage --editor-cmd "echo succeeded >" 

--editor-cmd给出了另一个编辑器,我可以echo newValueForProp智取propedit。

现在它像一个魅力。

-

0

尝试使用svn propset而不是svn propedit。使用propedit总是打开一个外部编辑器...这就是它的用途。

+0

不是。这不是一个解决方案,因为如果该属性已经设置,svn propset也不起作用。但我自己找到了解决方案。不过谢谢。 – derroman