开发者

change svn file property on the fly with svnkit

I need to change the value of a versioned custom property of a file in an svn repository on the fly. I do not want to alter any content, just change the value of the property of the already existing file. I am using svnkit in java.

How would i go about it?

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

This is what i tried, but it doesnt work. Instead of changing the file property it adds a commit to the whole repo, without touching the file file1.txt.

    SVNRepository repository = SVNRepositoryFactory.create(url);       

    ISVNAuthenticationManager authManager = SVNWCUtil.createDefaultAuthenticationManager(user,password);
  开发者_JS百科  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();


i had not called closeFile(), and i needed an "/" before the filename, now it works

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();


We can use SVNDeltaGenerator and use sendDelta method.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜