Class SvnInfoUtils
java.lang.Object
net.sf.statsvn.util.SvnInfoUtils
- All Implemented Interfaces:
ISvnInfoProcessor
- Direct Known Subclasses:
SvnKitInfo
Utilities class that manages calls to svn info. Used to find repository
information, latest revision numbers, and directories.
- Version:
- $Id: SvnInfoUtils.java 394 2009-08-10 20:08:46Z jkealey $
- Author:
- Jason Kealey invalid input: '<'jkealey@shade.ca>
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected static classSAX parser for the svn info --xml command. -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final HashMapprotected final HashSetprotected ISvnProcessorprotected static final String -
Constructor Summary
ConstructorsConstructorDescriptionSvnInfoUtils(ISvnProcessor processor) Invokes info using the svn info command line. -
Method Summary
Modifier and TypeMethodDescriptionabsolutePathToUrl(String absolute) Converts an absolute path in the repository to a URL, using the repository URLabsoluteToRelativePath(String absolute) Converts an absolute path in the repository to a path relative to the working folder root.voidaddDirectory(String relativePath) Adds a directory to the list of known directories.voidVerifies that the "svn info" command can return the repository root (info available in svn >= 1.3.0)protected voidbooleanexistsInWorkingCopy(String relativePath) Returns true if the file exists in the working copy (according to the svn metadata, and not file system checks).Assumes #loadInfo(String) has been called.protected ISvnProcessorAssumes #loadInfo() has been invoked.Assumes #loadInfo() has been invoked.getRevisionNumber(String relativePath) Returns the revision number of the file in the working copy.Assumes #loadInfo() has been invoked.Assumes #loadInfo() has been invoked.protected ProcessUtilsgetSvnInfo(boolean bRootOnly) Invokes svn info.booleanisDirectory(String relativePath) Returns true if the path has been identified as a directory.protected booleanisQueryNeeded(boolean bRootOnly) Do we need to re-invoke svn info?voidloadInfo()Initializes our representation of the repository.protected voidloadInfo(boolean bRootOnly) Loads the information from svn info if needed.voidloadInfo(InputStream stream) Loads the information from svn info if needed.relativePathToUrl(String relative) Converts a relative path in the working folder to a URL, using the working folder's root URLrelativeToAbsolutePath(String relative) Converts a relative path in the working folder to an absolute path in the repository.protected voidsetRepositoryUrl(String repositoryUrl) Sets the project's repository URL.protected voidsetRepositoryUuid(String repositoryUuid) protected voidsetRootUrl(String rootUrl) Sets the project's root URL.urlToAbsolutePath(String url) Converts a url to an absolute path in the repository.urlToRelativePath(String url) Converts a url to a relative path in the repository.
-
Field Details
-
SVN_REPO_ROOT_NOTFOUND
- See Also:
-
processor
-
HM_REVISIONS
-
HS_DIRECTORIES
-
-
Constructor Details
-
SvnInfoUtils
Invokes info using the svn info command line.
-
-
Method Details
-
getProcessor
-
absoluteToRelativePath
Description copied from interface:ISvnInfoProcessorConverts an absolute path in the repository to a path relative to the working folder root. Will return null if absolute path does not start with getModuleName();- Specified by:
absoluteToRelativePathin interfaceISvnInfoProcessor- Parameters:
absolute- Example (assume getModuleName() returns /trunk/statsvn) /trunk/statsvn/package.html- Returns:
- Example: package.html
-
absolutePathToUrl
Description copied from interface:ISvnInfoProcessorConverts an absolute path in the repository to a URL, using the repository URL- Specified by:
absolutePathToUrlin interfaceISvnInfoProcessor- Parameters:
absolute- Example: /trunk/statsvn/package.html- Returns:
- Example: svn://svn.statsvn.org/statsvn/trunk/statsvn/package.html
-
relativePathToUrl
Description copied from interface:ISvnInfoProcessorConverts a relative path in the working folder to a URL, using the working folder's root URL- Specified by:
relativePathToUrlin interfaceISvnInfoProcessor- Parameters:
relative- Example: src/Messages.java- Returns:
- Example: svn://svn.statsvn.org/statsvn/trunk/statsvn/src/Messages.java
-
relativeToAbsolutePath
Description copied from interface:ISvnInfoProcessorConverts a relative path in the working folder to an absolute path in the repository.- Specified by:
relativeToAbsolutePathin interfaceISvnInfoProcessor- Parameters:
relative- Example: src/Messages.java- Returns:
- Example: /trunk/statsvn/src/Messages.java
-
existsInWorkingCopy
Description copied from interface:ISvnInfoProcessorReturns true if the file exists in the working copy (according to the svn metadata, and not file system checks).- Specified by:
existsInWorkingCopyin interfaceISvnInfoProcessor- Parameters:
relativePath- the path- Returns:
- true if it exists
-
getModuleName
Description copied from interface:ISvnInfoProcessorAssumes #loadInfo(String) has been called. Never ends with /, might be empty.- Specified by:
getModuleNamein interfaceISvnInfoProcessor- Returns:
- The absolute path of the root of the working folder in the repository.
-
getRevisionNumber
Description copied from interface:ISvnInfoProcessorReturns the revision number of the file in the working copy.- Specified by:
getRevisionNumberin interfaceISvnInfoProcessor- Parameters:
relativePath- the filename- Returns:
- the revision number if it exists in the working copy, null otherwise.
-
getRootRevisionNumber
Description copied from interface:ISvnInfoProcessorAssumes #loadInfo() has been invoked.- Specified by:
getRootRevisionNumberin interfaceISvnInfoProcessor- Returns:
- the root of the working folder's revision number (last checked out revision number)
-
getRootUrl
Description copied from interface:ISvnInfoProcessorAssumes #loadInfo() has been invoked.- Specified by:
getRootUrlin interfaceISvnInfoProcessor- Returns:
- the root of the working folder's url (example: svn://svn.statsvn.org/statsvn/trunk/statsvn)
-
getRepositoryUuid
Description copied from interface:ISvnInfoProcessorAssumes #loadInfo() has been invoked.- Specified by:
getRepositoryUuidin interfaceISvnInfoProcessor- Returns:
- the uuid of the repository
-
getRepositoryUrl
Description copied from interface:ISvnInfoProcessorAssumes #loadInfo() has been invoked.- Specified by:
getRepositoryUrlin interfaceISvnInfoProcessor- Returns:
- the repository url (example: svn://svn.statsvn.org/statsvn)
-
getSvnInfo
Invokes svn info.- Parameters:
bRootOnly- true if should we check for the root only or false otherwise (recurse for all files)- Returns:
- the response.
-
isDirectory
Description copied from interface:ISvnInfoProcessorReturns true if the path has been identified as a directory.- Specified by:
isDirectoryin interfaceISvnInfoProcessor- Parameters:
relativePath- the path- Returns:
- true if it is a known directory.
-
addDirectory
Description copied from interface:ISvnInfoProcessorAdds a directory to the list of known directories. Used when inferring implicit actions on deleted paths.- Specified by:
addDirectoryin interfaceISvnInfoProcessor- Parameters:
relativePath- the relative path.
-
isQueryNeeded
protected boolean isQueryNeeded(boolean bRootOnly) Do we need to re-invoke svn info?- Parameters:
bRootOnly- true if we need the root only- Returns:
- true if we it needs to be re-invoked.
-
loadInfo
protected void loadInfo(boolean bRootOnly) throws net.sf.statcvs.input.LogSyntaxException, IOException Loads the information from svn info if needed.- Parameters:
bRootOnly- load only the root?- Throws:
net.sf.statcvs.input.LogSyntaxException- if the format of the svn info is invalidIOException- if we can't read from the response stream.
-
loadInfo
public void loadInfo(InputStream stream) throws net.sf.statcvs.input.LogSyntaxException, IOException Description copied from interface:ISvnInfoProcessorLoads the information from svn info if needed.- Specified by:
loadInfoin interfaceISvnInfoProcessor- Parameters:
stream- the input stream representing an svn info command.- Throws:
net.sf.statcvs.input.LogSyntaxException- if the format of the svn info is invalidIOException- if we can't read from the response stream.
-
clearCache
protected void clearCache() -
loadInfo
Description copied from interface:ISvnInfoProcessorInitializes our representation of the repository.- Specified by:
loadInfoin interfaceISvnInfoProcessor- Throws:
net.sf.statcvs.input.LogSyntaxException- if the svn info --xml is malformedIOException- if there is an error reading from the stream
-
urlToAbsolutePath
Description copied from interface:ISvnInfoProcessorConverts a url to an absolute path in the repository.- Specified by:
urlToAbsolutePathin interfaceISvnInfoProcessor- Parameters:
url- Examples: svn://svn.statsvn.org/statsvn/trunk/statsvn, svn://svn.statsvn.org/statsvn/trunk/statsvn/package.html- Returns:
- Example: /trunk/statsvn, /trunk/statsvn/package.html
-
urlToRelativePath
Description copied from interface:ISvnInfoProcessorConverts a url to a relative path in the repository.- Specified by:
urlToRelativePathin interfaceISvnInfoProcessor- Parameters:
url- Examples: svn://svn.statsvn.org/statsvn/trunk/statsvn, svn://svn.statsvn.org/statsvn/trunk/statsvn/package.html- Returns:
- Example: ".", package.html
-
setRootUrl
-
setRepositoryUrl
Sets the project's repository URL.- Parameters:
repositoryUrl-
-
setRepositoryUuid
-
checkRepoRootAvailable
Verifies that the "svn info" command can return the repository root (info available in svn >= 1.3.0)- Specified by:
checkRepoRootAvailablein interfaceISvnInfoProcessor- Throws:
SvnVersionMismatchException- if svn info failed to provide a non-empty repository root
-