javasvnsvnkit

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

Solution

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