java - 使用 svnkit 即时更改 svn 文件属性

标签 java svn svnkit

我需要动态更改 svn 存储库中文件的版本化自定义属性的值。 我不想更改任何内容,只需更改现有文件的属性值即可。 我在java中使用svnkit。

我该怎么做?

example: 
http:://svnserver.com/example/directorya/file1.txt   ... has svn property: myproperty = abc

after the operation:
http:://svnserver.com/example/directorya/file1.txt   ... has svn property: myproperty = def

这是我尝试过的,但它不起作用。它没有更改文件属性,而是添加了对整个存储库的提交,而不触及文件 file1.txt。

    SVNRepository repository = SVNRepositoryFactory.create(url);       

    ISVNAuthenticationManager authManager = SVNWCUtil.createDefaultAuthenticationManager(user,password);
    repository.setAuthenticationManager(authManager);

    ISVNEditor editor = repository.getCommitEditor("comment" , null);
    editor.openRoot(-1);
    editor.openFile("file1.txt", -1);
    editor.changeFileProperty("file1.txt", "mypropertyname", SVNPropertyValue.create("myvalue"));
    editor.closeEdit();

最佳答案

我没有调用 closeFile(),并且我需要在文件名前加一个“/”,现在它可以工作了

SVNRepository repository = SVNRepositoryFactory.create(url);       

ISVNAuthenticationManager authManager = SVNWCUtil.createDefaultAuthenticationManager(user,password);
repository.setAuthenticationManager(authManager);

ISVNEditor editor = repository.getCommitEditor("comment" , null);
editor.openRoot(-1);
editor.openFile("/file1.txt", -1);
editor.changeFileProperty("/file1.txt", "mypropertyname", SVNPropertyValue.create("myvalue"));
editor.closeFile("/file1.txt",null);
editor.closeEdit();

关于java - 使用 svnkit 即时更改 svn 文件属性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7607511/

相关文章:

java - Android - 如何在 setColor 中更改颜色

java - 如何匹配多个对象

windows - 如何使用 "svn export"命令从存储库中获取单个文件?

asp.net - Tortoise SVN 操作后文件丢失 IIS_IUSRS 权限

eclipse - 在 Eclipse 中安装 ADT 23.0.3 时出现 SVNKit 错误?

实现接口(interface)的java方法泛型

java - 生成一个唯一的 id 以存储在缓存中

svn - 从 SVN 存储库创建 'stable' 版本

java - 在没有 Atlassian Fisheye 的情况下以编程方式检索 SVN 提交

java - svnkit:如何从 SVN DB 获取最新的修订号?