⇤ ← Revision 1 as of 2008-09-03 16:14:17
Size: 19
Comment:
|
Size: 4457
Comment:
|
Deletions are marked like this. | Additions are marked like this. |
Line 2: | Line 2: |
/* * ==================================================================== * Copyright (c) 2004-2008 TMate Software Ltd. All rights reserved. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms * are also available at http://svnkit.com/license.html. * If newer versions of this license are posted there, you may use a * newer version instead, at your option. * ==================================================================== */ package org.tmatesoft.svn.examples.wc; |
|
Line 3: | Line 15: |
import java.io.File; import java.io.IOException; import java.util.Collections; import org.tmatesoft.svn.core.SVNCommitInfo; import org.tmatesoft.svn.core.SVNDepth; import org.tmatesoft.svn.core.SVNException; import org.tmatesoft.svn.core.SVNPropertyValue; import org.tmatesoft.svn.core.SVNURL; import org.tmatesoft.svn.core.wc.SVNClientManager; import org.tmatesoft.svn.core.wc.SVNCommitClient; import org.tmatesoft.svn.core.wc.SVNCopyClient; import org.tmatesoft.svn.core.wc.SVNCopySource; import org.tmatesoft.svn.core.wc.SVNDiffClient; import org.tmatesoft.svn.core.wc.SVNRevision; import org.tmatesoft.svn.core.wc.SVNRevisionRange; import org.tmatesoft.svn.core.wc.SVNWCClient; /** * @version 1.2.0 * @author TMate Software Ltd. */ public class Merge { public static void main (String[] args) { //initialize SVNKit to work through file:/// protocol SamplesUtility.initializeFSFSprotocol(); File baseDirectory = new File(args[0]); File reposRoot = new File(baseDirectory, "exampleRepository"); File wcRoot = new File(baseDirectory, "exampleWC"); try { //first create a repository and fill it with data SamplesUtility.createRepository(reposRoot); SVNCommitInfo info = SamplesUtility.createRepositoryTree(reposRoot); //print out new revision info System.out.println(info); SVNClientManager clientManager = SVNClientManager.newInstance(); SVNURL reposURL = SVNURL.fromFile(reposRoot); //copy A to A_copy in repository (url-to-url copy) SVNCopyClient copyClient = clientManager.getCopyClient(); SVNURL A_URL = reposURL.appendPath("A", true); SVNURL copyTargetURL = reposURL.appendPath("A_copy", true); SVNCopySource copySource = new SVNCopySource(SVNRevision.UNDEFINED, SVNRevision.HEAD, A_URL); info = copyClient.doCopy(new SVNCopySource[] { copySource }, copyTargetURL, false, false, true, "copy A to A_copy", null); //print out new revision info System.out.println(info); //checkout the entire repository tree SamplesUtility.checkOutWorkingCopy(reposURL, wcRoot); //now make some changes to the working copy SamplesUtility.writeToFile(new File(wcRoot, "iota"), "New text appended to 'iota'", true); SamplesUtility.writeToFile(new File(wcRoot, "A/mu"), "New text in 'mu'", false); SVNWCClient wcClient = SVNClientManager.newInstance().getWCClient(); wcClient.doSetProperty(new File(wcRoot, "A/B"), "spam", SVNPropertyValue.create("egg"), false, SVNDepth.EMPTY, null, null); //commit local changes SVNCommitClient commitClient = clientManager.getCommitClient(); commitClient.doCommit(new File[] { wcRoot }, false, "committing changes", null, null, false, false, SVNDepth.INFINITY); //now diff the base revision of the working copy against the repository SVNDiffClient diffClient = clientManager.getDiffClient(); SVNRevisionRange rangeToMerge = new SVNRevisionRange(SVNRevision.create(1), SVNRevision.HEAD); diffClient.doMerge(A_URL, SVNRevision.HEAD, Collections.singleton(rangeToMerge), new File(wcRoot, "A_copy"), SVNDepth.UNKNOWN, true, false, false, false); } catch (SVNException svne) { System.out.println(svne.getErrorMessage()); System.exit(1); } catch (IOException ioe) { ioe.printStackTrace(); System.exit(1); } } } |