2

我需要动态更改 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();
4

2 回答 2

4

我没有调用 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();
于 2011-10-05T11:21:53.737 回答
-1

我们可以使用 SVNDeltaGenerator 并使用 sendDelta 方法。

于 2021-11-10T13:47:23.177 回答