我正在尝试在java中创建一个方法,它会将以前的修订版本放回我的存储库中。我已经尝试了几种选择,但直到现在还没有任何成功。我认为我尝试的最佳选择是在以下Test类中:
package svntest;
import org.tmatesoft.svn.core.SVNDepth;
import org.tmatesoft.svn.core.SVNException;
import org.tmatesoft.svn.core.SVNURL;
import org.tmatesoft.svn.core.auth.ISVNAuthenticationManager;
import org.tmatesoft.svn.core.internal.io.dav.DAVRepositoryFactory;
import org.tmatesoft.svn.core.internal.io.fs.FSRepositoryFactory;
import org.tmatesoft.svn.core.internal.io.svn.SVNRepositoryFactoryImpl;
import org.tmatesoft.svn.core.internal.wc.SVNSynchronizeEditor;
import org.tmatesoft.svn.core.io.ISVNReporter;
import org.tmatesoft.svn.core.io.ISVNReporterBaton;
import org.tmatesoft.svn.core.io.SVNRepository;
import org.tmatesoft.svn.core.io.SVNRepositoryFactory;
import org.tmatesoft.svn.core.wc.SVNRevision;
import org.tmatesoft.svn.core.wc.SVNWCUtil;
public class Test {
static String url = "myhost:8080/svn/sonic76/branches/TEST/myproject";
public static void main(String[] args) {
try {
DAVRepositoryFactory.setup();
SVNRepositoryFactoryImpl.setup();
FSRepositoryFactory.setup();
ISVNAuthenticationManager authManager = SVNWCUtil.createDefaultAuthenticationManager(user, password);
SVNRepository srcRepos = SVNRepositoryFactory.create(SVNURL.parseURIEncoded(url));
srcRepos.setAuthenticationManager(authManager);
SVNRepository destRepos = SVNRepositoryFactory.create(SVNURL.parseURIEncoded(url));
destRepos.setAuthenticationManager(authManager);
SVNSynchronizeEditor syncher = new SVNSynchronizeEditor(destRepos, null, SVNRevision.BASE.getNumber(), null);
srcRepos.update(SVNURL.parseURIEncoded(url), SVNRevision.BASE.getNumber()-1, null, SVNDepth.INFINITY, new MyReporterBaton(), syncher);
} catch (Exception e) {
e.printStackTrace();
}
}
private static class MyReporterBaton implements ISVNReporterBaton {
@Override
public void report(ISVNReporter reporter) throws SVNException {
reporter.setPath("", null, 32981, false);
reporter.finishReport();
}
}
}
我得到的错误是:
org.tmatesoft.svn.core.SVNException: svn: E160024: File or directory 'xml/myfile.xml' is out of date; try updating
svn: E160024: resource out of date; try updating
xml文件夹中的文件myfile.xml正是在当前版本和上一版本之间发生变化的文件,我想放回以前的版本。有什么想法吗?
正如您所看到的,我正在使用svnkit,但任何其他API也可以。