net.sf.statsvn.util
public class SvnInfoUtils extends Object implements ISvnInfoProcessor
Modifier and Type | Class and Description |
---|---|
protected static class |
SvnInfoUtils.SvnInfoHandler
SAX parser for the svn info --xml command.
|
Modifier and Type | Field and Description |
---|---|
protected HashMap |
HM_REVISIONS |
protected HashSet |
HS_DIRECTORIES |
protected ISvnProcessor |
processor |
protected static String |
SVN_REPO_ROOT_NOTFOUND |
Constructor and Description |
---|
SvnInfoUtils(ISvnProcessor processor)
Invokes info using the svn info command line.
|
Modifier and Type | Method and Description |
---|---|
String |
absolutePathToUrl(String absolute)
Converts an absolute path in the repository to a URL, using the
repository URL
|
String |
absoluteToRelativePath(String absolute)
Converts an absolute path in the repository to a path relative to the
working folder root.
|
void |
addDirectory(String relativePath)
Adds a directory to the list of known directories.
|
void |
checkRepoRootAvailable()
Verifies that the "svn info" command can return the repository root
(info available in svn >= 1.3.0)
|
protected void |
clearCache() |
boolean |
existsInWorkingCopy(String relativePath)
Returns true if the file exists in the working copy (according to the svn
metadata, and not file system checks).
|
String |
getModuleName()
Assumes #loadInfo(String) has been called.
|
protected ISvnProcessor |
getProcessor() |
String |
getRepositoryUrl()
Assumes #loadInfo() has been invoked.
|
String |
getRepositoryUuid()
Assumes #loadInfo() has been invoked.
|
String |
getRevisionNumber(String relativePath)
Returns the revision number of the file in the working copy.
|
String |
getRootRevisionNumber()
Assumes #loadInfo() has been invoked.
|
String |
getRootUrl()
Assumes #loadInfo() has been invoked.
|
protected ProcessUtils |
getSvnInfo(boolean bRootOnly)
Invokes svn info.
|
boolean |
isDirectory(String relativePath)
Returns true if the path has been identified as a directory.
|
protected boolean |
isQueryNeeded(boolean bRootOnly)
Do we need to re-invoke svn info?
|
void |
loadInfo()
Initializes our representation of the repository.
|
protected void |
loadInfo(boolean bRootOnly)
Loads the information from svn info if needed.
|
void |
loadInfo(InputStream stream)
Loads the information from svn info if needed.
|
String |
relativePathToUrl(String relative)
Converts a relative path in the working folder to a URL, using the
working folder's root URL
|
String |
relativeToAbsolutePath(String relative)
Converts a relative path in the working folder to an absolute path in the
repository.
|
protected void |
setRepositoryUrl(String repositoryUrl)
Sets the project's repository URL.
|
protected void |
setRepositoryUuid(String repositoryUuid) |
protected void |
setRootUrl(String rootUrl)
Sets the project's root URL.
|
String |
urlToAbsolutePath(String url)
Converts a url to an absolute path in the repository.
|
String |
urlToRelativePath(String url)
Converts a url to a relative path in the repository.
|
protected static final String SVN_REPO_ROOT_NOTFOUND
protected ISvnProcessor processor
protected final HashMap HM_REVISIONS
protected final HashSet HS_DIRECTORIES
public SvnInfoUtils(ISvnProcessor processor)
protected ISvnProcessor getProcessor()
public String absoluteToRelativePath(String absolute)
ISvnInfoProcessor
absoluteToRelativePath
in interface ISvnInfoProcessor
absolute
- Example (assume getModuleName() returns /trunk/statsvn)
/trunk/statsvn/package.htmlpublic String absolutePathToUrl(String absolute)
ISvnInfoProcessor
absolutePathToUrl
in interface ISvnInfoProcessor
absolute
- Example: /trunk/statsvn/package.htmlpublic String relativePathToUrl(String relative)
ISvnInfoProcessor
relativePathToUrl
in interface ISvnInfoProcessor
relative
- Example: src/Messages.javapublic String relativeToAbsolutePath(String relative)
ISvnInfoProcessor
relativeToAbsolutePath
in interface ISvnInfoProcessor
relative
- Example: src/Messages.javapublic boolean existsInWorkingCopy(String relativePath)
ISvnInfoProcessor
existsInWorkingCopy
in interface ISvnInfoProcessor
relativePath
- the pathpublic String getModuleName()
ISvnInfoProcessor
getModuleName
in interface ISvnInfoProcessor
public String getRevisionNumber(String relativePath)
ISvnInfoProcessor
getRevisionNumber
in interface ISvnInfoProcessor
relativePath
- the filenamepublic String getRootRevisionNumber()
ISvnInfoProcessor
getRootRevisionNumber
in interface ISvnInfoProcessor
public String getRootUrl()
ISvnInfoProcessor
getRootUrl
in interface ISvnInfoProcessor
public String getRepositoryUuid()
ISvnInfoProcessor
getRepositoryUuid
in interface ISvnInfoProcessor
public String getRepositoryUrl()
ISvnInfoProcessor
getRepositoryUrl
in interface ISvnInfoProcessor
protected ProcessUtils getSvnInfo(boolean bRootOnly)
bRootOnly
- true if should we check for the root only or false otherwise
(recurse for all files)public boolean isDirectory(String relativePath)
ISvnInfoProcessor
isDirectory
in interface ISvnInfoProcessor
relativePath
- the pathpublic void addDirectory(String relativePath)
ISvnInfoProcessor
addDirectory
in interface ISvnInfoProcessor
relativePath
- the relative path.protected boolean isQueryNeeded(boolean bRootOnly)
bRootOnly
- true if we need the root onlyprotected void loadInfo(boolean bRootOnly) throws net.sf.statcvs.input.LogSyntaxException, IOException
bRootOnly
- load only the root?net.sf.statcvs.input.LogSyntaxException
- if the format of the svn info is invalidIOException
- if we can't read from the response stream.public void loadInfo(InputStream stream) throws net.sf.statcvs.input.LogSyntaxException, IOException
ISvnInfoProcessor
loadInfo
in interface ISvnInfoProcessor
stream
- the input stream representing
an svn info command.net.sf.statcvs.input.LogSyntaxException
- if the format of the svn info is invalidIOException
- if we can't read from the response stream.protected void clearCache()
public void loadInfo() throws net.sf.statcvs.input.LogSyntaxException, IOException
ISvnInfoProcessor
loadInfo
in interface ISvnInfoProcessor
net.sf.statcvs.input.LogSyntaxException
- if the svn info --xml is malformedIOException
- if there is an error reading from the streampublic String urlToAbsolutePath(String url)
ISvnInfoProcessor
urlToAbsolutePath
in interface ISvnInfoProcessor
url
- Examples: svn://svn.statsvn.org/statsvn/trunk/statsvn,
svn://svn.statsvn.org/statsvn/trunk/statsvn/package.htmlpublic String urlToRelativePath(String url)
ISvnInfoProcessor
urlToRelativePath
in interface ISvnInfoProcessor
url
- Examples: svn://svn.statsvn.org/statsvn/trunk/statsvn,
svn://svn.statsvn.org/statsvn/trunk/statsvn/package.htmlprotected void setRootUrl(String rootUrl)
rootUrl
- protected void setRepositoryUrl(String repositoryUrl)
repositoryUrl
- protected void setRepositoryUuid(String repositoryUuid)
public void checkRepoRootAvailable() throws SvnVersionMismatchException
checkRepoRootAvailable
in interface ISvnInfoProcessor
SvnVersionMismatchException
- if svn info failed to provide a non-empty repository root