0

I want to commit one server directory contents (all versioned contents of versioned dir already present on server dir) to a new dir on same server using SVNKit (version 1.7).

This new dir can be already present; or have to add/make it at appropriate location based on abs path. (adding new dir to server i can do)

but i am not able to commit source path contents to dest path (already present or newly created).

i understand since I want Server to server commit , Here, there will not be any working copy.

I checked solution mentioned in Committing changed file via SVNKit without local checkout? but couldnt make it work as I am not getting what should source path and what should be dest path.

As a work around, I tried copy functionality, but as u know, with copy, earlier history of files will be retained... I was looking for creating a fresh version of all contents at source path to dest path.

Another thing i tried is making a temp local working copy at c:// drive, checking out code from source to this local dir and then committing it to dest path. but this is not approprriate way :( also, i can not delete the local temp working coopy; it says it contains root so cant be deleted.

Can anybody help me in server to server commit using SVNKit ?

Thanks. -Aditya

Community
  • 1
  • 1
adityag
  • 603
  • 3
  • 8
  • 24

1 Answers1

0

That's not that difficult. If you wanted to retain copy history, you could run the following code

ISVNCommitEditor editor = svnRepository.getCommitEditor("", null);

editor.openRoot(latestRevision);
editor.openDir("path", latestRevision); //or use addDir if it doesn't exist
editor.openDir("path/to", latestRevision); //or use addDir if it doesn't exist
editor.openDir("path/to/new", latestRevision); //or use addDir if it doesn't exist
editor.addDir("path/to/new/directory", "/path/to/old/directory", copySourceRevision); 
editor.closeDir();
editor.closeDir();
editor.closeDir();
editor.closeDir();
editor.closeDir();
editor.closeEdit();

But if you don't want to retain the history, you can create editor with

ISVNCommitEditor editor = svnRepository.getCommitEditor("", null);

and then call

anotherSvnRepository.setLocation(copySourceUrl, true);
anotherSvnRepository.update(copySourceRevision, "", SVNDepth.INFINITY, false, reporter, customEditor);

Instead of reporter use this code:

    ISVNReporterBaton reporter = new ISVNReporterBaton() {
        @Override
        public void report(ISVNReporter reporter) throws SVNException {
            reporter.setPath("", null, copySourceRevision, SVNDepth.INFINITY, true);
            reporter.finishReport();
        }
    }; 

customEditor should be a wrapper for editor constructed above, that would call editor with correct paths (maybe you should add some openDir/closeDir calls to make editor calls correct).

As an example, you can have a look at the sources of my svnkitfilter project that does similar things.

To understand if the directory/file exists or not use SVNRepository#checkPath method.

Dmitry Pavlenko
  • 8,530
  • 3
  • 30
  • 38