workDir.mkdirs();
File baseDirectory = workDir;
File reposRoot = new File(baseDirectory, "tempRepository");
File wcRoot = new File(workDir, "working_copy");
SVNClientManager clientManager = SVNClientManager.newInstance();
SVNAdminClient adminClient = clientManager.getAdminClient();
SVNDiffClient diffClient = clientManager.getDiffClient();
DefaultSVNOptions options = (DefaultSVNOptions) diffClient.getOptions();
options.setConflictHandler(new ConflictResolverHandler());
SVNCommitClient commitClient = clientManager.getCommitClient();
boolean fileRepo = true;
String url = "svn://192.168.56.101/project6";
final SVNURL reposURL = (fileRepo? SVNURL.fromFile(reposRoot) : SVNURL.parseURIEncoded(url)),
demoURL = reposURL.appendPath("demo", false);
if (fileRepo)
adminClient.doCreateRepository(reposRoot, null, true, true, false, false);
else
{
SubversionSubmitter.setUpSVNKit();
//SVNRepository repository = SVNRepositoryFactory.create(reposURL);
ISVNAuthenticationManager m = SVNWCUtil.createDefaultAuthenticationManager("harry", "secret");
//repository.setAuthenticationManager(m);
clientManager.setAuthenticationManager(m);
}
logger.info("Repo URL = "+ reposURL);
repos = SVNRepositoryFactory.create(reposURL);
SVNCommitInfo info;
String msg;
msg = "Import of oldDMO tree";
info = clientManager.getCommitClient( ).doImport( oldDemoTree , demoURL , msg , true);
logger.info("Imported oldDemo tree: "+ info);
//final long revOldDemo = info.getNewRevision();
msg= "Copy demo to custom";
SVNCopyClient copyClient = clientManager.getCopyClient();
SVNURL customURL = reposURL.appendPath("custom", true);
SVNCopySource copySource = new SVNCopySource(SVNRevision.UNDEFINED, SVNRevision.HEAD, demoURL);
info = copyClient.doCopy(new SVNCopySource[] { copySource }, customURL, false, false, true,
msg, null);
final long revAfterCopyToCustom = info.getNewRevision();
logger.info(msg + ": " + info);
File demoDir = new File(wcRoot, "demo"),
customDir = new File(wcRoot, "custom");
SVNUpdateClient updateClient = clientManager.getUpdateClient();
updateClient.doCheckout(reposURL, wcRoot, SVNRevision.UNDEFINED, SVNRevision.HEAD, SVNDepth.INFINITY,
false);
logger.info("Checked out working copy to " + wcRoot);
overwriteTree(newDemoTree, demoDir);
/*
for (File f: dirsCreated)
clientManager.getWCClient( ).doAdd( f, false , false , false , false );
for (File f: filesCreated)
clientManager.getWCClient( ).doAdd( f, false , false , false , false );
*/
msg = "Commit of newDMO (in demo tree)";
info = commitClient.doCommit(new File[] { wcRoot }, false, msg, null, null, false,
false, SVNDepth.INFINITY);
//final long revNewDMO = info.getNewRevision();
/*
diffClient.doDiffStatus(reposURL, SVNRevision.create(revOldDemo), reposURL, SVNRevision.create(revNewDMO),
true, true, new ISVNDiffStatusHandler() {
public void handleDiffStatus(SVNDiffStatus arg0) throws SVNException {
if (arg0.getURL().toString().endsWith(".pcode"))
{
logger.info("Diff in NewDMO-OldDMO: " + arg0.getURL());
logger.info("path = " + arg0.getPath());
SVNProperties properties = SVNProperties.wrap(new HashMap());
if (repos.checkPath("/" + arg0.getPath(), revOldDemo) == SVNNodeKind.FILE
&& repos.checkPath("/" + arg0.getPath(), revNewDMO) == SVNNodeKind.FILE)
{
deltaOldDMONewDMO.add(arg0.getURL());
repos.getFile( "/" + arg0.getPath(), revOldDemo, properties, null);
String oldCheckSum = properties.getStringValue(SVNProperty.CHECKSUM);
repos.getFile("/" +arg0.getPath(), revNewDMO, properties, null);
String newCheckSum = properties.getStringValue(SVNProperty.CHECKSUM);
logger.info("Checksums: " + oldCheckSum + " " + newCheckSum);
}
}
}
});
*/
logger.info(msg + ":" + info);
dirsCreated.clear(); filesCreated.clear();
overwriteTree(oldDevTree, customDir);
/*
msg = "Commit of old DEV";
info = commitClient.doCommit(new File[] { wcRoot }, false, msg, null, null, false,
false, SVNDepth.INFINITY);
logger.info(msg + ":" + info);
long revOldDEV = info.getNewRevision();
diffClient.doDiffStatus(reposURL, SVNRevision.create(revNewDMO), reposURL, SVNRevision.create(revOldDEV),
true, true, new ISVNDiffStatusHandler() {
public void handleDiffStatus(SVNDiffStatus arg0) throws SVNException {
if (arg0.getURL().toString().endsWith(".pcode"))
{
logger.fine("Diff in DEV-oldDMO: " + arg0.getURL());
deltaOldDMODev.add(arg0.getURL());
}
}
});
*/
updateClient = clientManager.getUpdateClient();
updateClient.doCheckout(reposURL, wcRoot, SVNRevision.UNDEFINED, SVNRevision.HEAD, SVNDepth.INFINITY,
false);
logger.info("Checked out working copy to " + wcRoot);
File targetOfMerge = (mergeToDMO? demoDir: customDir);