org.antmod.scm.impl
Class SvnSystemImpl

java.lang.Object
  extended by org.antmod.scm.impl.SvnSystemImpl
All Implemented Interfaces:
ScmSystem

public class SvnSystemImpl
extends java.lang.Object
implements ScmSystem

Subversion repository provider, providing access to this compelling Source Configuration Management alternative for CVS.

This Subversion repository provider is a thin layer on top of the "svn" commandline executable, and as such requires the "svn" executable to be in the PATH of the system.

Author:
Klaas Waslander

Field Summary
static char REVISION_NAME_SEPARATOR
           
static char REVISION_VERSION_SEPARATOR
           
 
Constructor Summary
SvnSystemImpl()
          Public default onstructor.
 
Method Summary
 java.lang.String createBranchInTrunk(ScmVersion newBranchForModule)
          Creates a new branch in the trunk of the given module.
 java.lang.String createTagInBranch(ScmVersion existingBranch, ScmVersion newTag)
          Creates a new tag in the given BRANCH of the given module.
 void doAdd(java.io.File file, boolean recursive)
          Add the given directory or file to this scm system.
 void doCheckout(java.lang.String moduleName, java.io.File destDir, ScmVersion version, boolean reallyQuiet)
          Implements Subversion checkout of a module.
 void doCheckoutOrUpdate(java.lang.String packageName, java.io.File destDir, ScmVersion version, boolean reallyQuiet)
          Convenience method for doing a checkout only if needed, and otherwise updating the existing checkout.
 void doCommit(java.io.File file, java.lang.String message)
          Commit the given file or a while directory to Subversion.
 void doExport(java.lang.String moduleName, java.io.File destDir, ScmVersion version, boolean reallyQuiet)
          Implements Subversion export of a module.
 void doMerge(java.io.File moduleDir, ScmVersion version)
          Merge in changes made between current version of local module directory and given version.
 void doMerge(java.io.File moduleDir, ScmVersion version, boolean reallyQuiet)
           
 void doUpdate(java.io.File file, ScmVersion version)
          Update existing checkout locally to the given revision, or keep the same revision if null.
 ScmDifference[] getDifferences(ScmVersion version1, ScmVersion version2)
          Returns the files that have changed between the two given Subversion versions.
 java.lang.String getErrorOutput()
           
 ScmVersion getLatestVersion(java.io.File moduleDir)
          If the given module directory is not a tag, returns the latest version for that directory.
 ScmVersion getLocalVersion(java.io.File moduleDir)
          Returns the currently checked out version of the module in the given directory.
 ScmVersion getLocalVersion(java.lang.String moduleName, java.io.File moduleDir)
           
 java.lang.String getRevisionNumber(java.io.File file)
          Returns the latest file revision.
 java.lang.String getStandardOutput()
           
 ScmUrl getUrl()
          Get the URL of the repository which this ScmSystem instance is communicating with.
 ScmVersion[] getVersionsInBranch(java.io.File file, ScmVersion branch)
          Returns all available versions for the given file in the given branch, with the newest number first and the oldest number last (oldest is usually the ".0" version).
 boolean isCheckoutDir(java.io.File directory)
          Returns true if the given directory contains a checkout of content from this ScmSystem.
 boolean isUpToDate(java.io.File checkoutDir)
          Check whether the given checkout directory is up-to-date when comparing it to the repository contents.
 void setUrl(ScmUrl providerUrl)
          Set the URL this ScmSystem instance should be talking with; is only invoked from within this package.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

REVISION_NAME_SEPARATOR

public static final char REVISION_NAME_SEPARATOR
See Also:
Constant Field Values

REVISION_VERSION_SEPARATOR

public static final char REVISION_VERSION_SEPARATOR
See Also:
Constant Field Values
Constructor Detail

SvnSystemImpl

public SvnSystemImpl()
Public default onstructor.

Method Detail

getStandardOutput

public java.lang.String getStandardOutput()
Specified by:
getStandardOutput in interface ScmSystem

getErrorOutput

public java.lang.String getErrorOutput()
Specified by:
getErrorOutput in interface ScmSystem

getUrl

public ScmUrl getUrl()
Description copied from interface: ScmSystem
Get the URL of the repository which this ScmSystem instance is communicating with.

Specified by:
getUrl in interface ScmSystem
Returns:
The ScmUrl of the repository which this ScmSystem instance is communicating with.

setUrl

public void setUrl(ScmUrl providerUrl)
Description copied from interface: ScmSystem
Set the URL this ScmSystem instance should be talking with; is only invoked from within this package.

Specified by:
setUrl in interface ScmSystem
Parameters:
providerUrl - The URL this ScmSystem instance should be connecting with

doAdd

public void doAdd(java.io.File file,
                  boolean recursive)
Description copied from interface: ScmSystem
Add the given directory or file to this scm system. If it is not a file within an already added directory structure, the file/directory will be added to the root of this scm system.

Specified by:
doAdd in interface ScmSystem
Parameters:
file - The file/directory to be added
recursive - Whether to add any files under the directory recursively

doCheckout

public void doCheckout(java.lang.String moduleName,
                       java.io.File destDir,
                       ScmVersion version,
                       boolean reallyQuiet)
Implements Subversion checkout of a module.

Specified by:
doCheckout in interface ScmSystem
Parameters:
moduleName - The top-level module to be checked out from the SCM repository
destDir - The destination directory for the locally checked out module contents, usually you set this to a directory with the name equal to the moduleName
version - The module version you want to checkout.
reallyQuiet - Whether console output should be suppressed

doExport

public void doExport(java.lang.String moduleName,
                     java.io.File destDir,
                     ScmVersion version,
                     boolean reallyQuiet)
Implements Subversion export of a module.

Specified by:
doExport in interface ScmSystem

doCheckoutOrUpdate

public void doCheckoutOrUpdate(java.lang.String packageName,
                               java.io.File destDir,
                               ScmVersion version,
                               boolean reallyQuiet)
Description copied from interface: ScmSystem
Convenience method for doing a checkout only if needed, and otherwise updating the existing checkout.

Specified by:
doCheckoutOrUpdate in interface ScmSystem

doMerge

public void doMerge(java.io.File moduleDir,
                    ScmVersion version)
Description copied from interface: ScmSystem
Merge in changes made between current version of local module directory and given version.

Specified by:
doMerge in interface ScmSystem
Parameters:
moduleDir - The module directory which should receive the changes compared to the given version
version - The version containing the changes to be merged into the locally checked module directory

doMerge

public void doMerge(java.io.File moduleDir,
                    ScmVersion version,
                    boolean reallyQuiet)

doUpdate

public void doUpdate(java.io.File file,
                     ScmVersion version)
Description copied from interface: ScmSystem
Update existing checkout locally to the given revision, or keep the same revision if null.

Specified by:
doUpdate in interface ScmSystem
Parameters:
file - The directory or file to be updated
version - If null, revision of checkout is not changed

doCommit

public void doCommit(java.io.File file,
                     java.lang.String message)
Commit the given file or a while directory to Subversion.

Specified by:
doCommit in interface ScmSystem
Parameters:
file -

getRevisionNumber

public java.lang.String getRevisionNumber(java.io.File file)
Returns the latest file revision.

Specified by:
getRevisionNumber in interface ScmSystem

getLatestVersion

public ScmVersion getLatestVersion(java.io.File moduleDir)
If the given module directory is not a tag, returns the latest version for that directory.

Specified by:
getLatestVersion in interface ScmSystem
Returns:
null if no latest version is found

getLocalVersion

public ScmVersion getLocalVersion(java.io.File moduleDir)
                           throws org.apache.tools.ant.BuildException
Returns the currently checked out version of the module in the given directory.

Specified by:
getLocalVersion in interface ScmSystem
Parameters:
moduleDir - The directory where the module is currently checked out
Returns:
The current local version of the module
Throws:
org.apache.tools.ant.BuildException

getLocalVersion

public ScmVersion getLocalVersion(java.lang.String moduleName,
                                  java.io.File moduleDir)
                           throws org.apache.tools.ant.BuildException
Throws:
org.apache.tools.ant.BuildException

getVersionsInBranch

public ScmVersion[] getVersionsInBranch(java.io.File file,
                                        ScmVersion branch)
Returns all available versions for the given file in the given branch, with the newest number first and the oldest number last (oldest is usually the ".0" version).

Specified by:
getVersionsInBranch in interface ScmSystem

isUpToDate

public boolean isUpToDate(java.io.File checkoutDir)
Check whether the given checkout directory is up-to-date when comparing it to the repository contents.

Specified by:
isUpToDate in interface ScmSystem
Parameters:
checkoutDir - The directory with locally checked out contents
Returns:
Whether the checkoutDir is up-to-date

getDifferences

public ScmDifference[] getDifferences(ScmVersion version1,
                                      ScmVersion version2)
Returns the files that have changed between the two given Subversion versions.

Specified by:
getDifferences in interface ScmSystem
Parameters:
version1 - The 'old' version to use as base
version2 - The 'new' version, which should be compared against the 'old' version
Returns:
The changes between the given versions.

createBranchInTrunk

public java.lang.String createBranchInTrunk(ScmVersion newBranchForModule)
Creates a new branch in the trunk of the given module.

Specified by:
createBranchInTrunk in interface ScmSystem

createTagInBranch

public java.lang.String createTagInBranch(ScmVersion existingBranch,
                                          ScmVersion newTag)
Creates a new tag in the given BRANCH of the given module.

Specified by:
createTagInBranch in interface ScmSystem

isCheckoutDir

public boolean isCheckoutDir(java.io.File directory)
Description copied from interface: ScmSystem
Returns true if the given directory contains a checkout of content from this ScmSystem.

Specified by:
isCheckoutDir in interface ScmSystem
Parameters:
directory - The directory which does or does not contain a checkout
Returns:
Whether the given directory contains a checkout