我需要动态更改 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/