以前のリビジョンをリポジトリに戻すメソッドを 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 でも使用できます。