net.sf.statsvn.input
Class RepositoryFileManager

java.lang.Object
  extended by net.sf.statsvn.input.RepositoryFileManager

public class RepositoryFileManager
extends java.lang.Object

Manages a checked-out repository and provides access to line number counts for repository files. New in StatSVN: Also provides a central point of access to abstract out calls to the server. Many of the methods here simply redirect to the static util/SvnXXXUtils classes. Therefore, clients don't have to know where the information is located, they can simply invoke this class.

 

Constructor Summary
RepositoryFileManager(java.lang.String pathName)
          Creates a new instance with root at pathName.
 
Method Summary
 java.lang.String absolutePathToUrl(java.lang.String absolute)
          Converts an absolute path in the repository to a URL, using the repository URL
 java.lang.String absoluteToRelativePath(java.lang.String stringData)
          Converts an absolute path in the repository to a path relative to the working folder root.
 void addDirectory(java.lang.String relativePath)
          Adds a directory to the list of known directories.
 boolean existsInWorkingCopy(java.lang.String relativePath)
          Returns true if the file exists in the working copy (according to the svn metadata, and not file system checks).
protected  ISvnDiffProcessor getDiffProcessor()
           
protected  ISvnInfoProcessor getInfoProcessor()
           
protected  int getLineCount(java.io.BufferedReader reader)
          Counts lines on a BufferedReader
 int[] getLineDiff(java.lang.String oldRevNr, java.lang.String newRevNr, java.lang.String filename)
          Returns line count differences between two revisions of a file.
 int getLinesOfCode(java.lang.String filename)
          Returns the lines of code for a repository file.
 java.lang.String getModuleName()
          Assumes #loadInfo(String) has been called.
 ISvnProcessor getProcessor()
           
protected  ISvnPropgetProcessor getPropgetProcessor()
           
 java.lang.String getRepositoryUuid()
          Assumes #loadInfo(String) has been called.
 java.lang.String getRevision(java.lang.String filename)
          Returns the revision of filename in the local working directory by reading the svn metadata.
 java.util.Vector getRevisionDiff(java.lang.String newRevNr)
          Returns line count differences for all files in a particular revision.
 java.lang.String getRootRevisionNumber()
          Assumes #loadInfo(String) has been called.
protected  ISvnVersionProcessor getVersionProcessor()
           
 boolean isBinary(java.lang.String relativePath)
          Is the given path a binary file in the working directory?
 boolean isDirectory(java.lang.String relativePath)
          Returns true if the path has been identified as a directory.
 void loadInfo()
          Initializes our representation of the repository.
 java.lang.String relativePathToUrl(java.lang.String relative)
          Converts a relative path in the working folder to a URL, using the working folder's root URL
 java.lang.String relativeToAbsolutePath(java.lang.String relative)
          Converts a relative path in the working folder to an absolute path in the repository.
 java.lang.String urlToAbsolutePath(java.lang.String url)
          Converts a url to an absolute path in the repository.
 java.lang.String urlToRelativePath(java.lang.String url)
          Converts a url to a relative path in the repository.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RepositoryFileManager

public RepositoryFileManager(java.lang.String pathName)
Creates a new instance with root at pathName.

Parameters:
pathName - the root of the checked out repository
Method Detail

absolutePathToUrl

public java.lang.String absolutePathToUrl(java.lang.String absolute)
Converts an absolute path in the repository to a URL, using the repository URL

Parameters:
absolute - Example: /trunk/statsvn/package.html
Returns:
Example: svn://svn.statsvn.org/statsvn/trunk/statsvn/package.html

absoluteToRelativePath

public java.lang.String absoluteToRelativePath(java.lang.String stringData)
Converts 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();

Parameters:
absolute - Example (assume getModuleName() returns /trunk/statsvn) /trunk/statsvn/package.html
Returns:
Example: package.html

addDirectory

public void addDirectory(java.lang.String relativePath)
Adds a directory to the list of known directories. Used when inferring implicit actions on deleted paths.

Parameters:
relativePath - the relative path.

existsInWorkingCopy

public boolean existsInWorkingCopy(java.lang.String relativePath)
Returns true if the file exists in the working copy (according to the svn metadata, and not file system checks).

Parameters:
relativePath - the path
Returns:
true if it exists

getLineCount

protected int getLineCount(java.io.BufferedReader reader)
                    throws java.io.IOException
Counts lines on a BufferedReader

Throws:
java.io.IOException - error reading from reader
Parameters:
reader - the buffered reader
Returns:
the number of lines read

getLineDiff

public int[] getLineDiff(java.lang.String oldRevNr,
                         java.lang.String newRevNr,
                         java.lang.String filename)
                  throws java.io.IOException,
                         BinaryDiffException
Returns line count differences between two revisions of a file.

Throws:
java.io.IOException - problem parsing the stream
BinaryDiffException - if the error message is due to trying to diff binary files.
Parameters:
oldRevNr - old revision number
newRevNr - new revision number
filename - the filename
Returns:
A int[2] array of [lines added, lines removed] is returned.

getRevisionDiff

public java.util.Vector getRevisionDiff(java.lang.String newRevNr)
                                 throws java.io.IOException,
                                        BinaryDiffException
Returns line count differences for all files in a particular revision.

Throws:
java.io.IOException - problem parsing the stream
BinaryDiffException - if the error message is due to trying to diff binary files.
Parameters:
newRevNr - new revision number
Returns:
A vector of object[3] array of [filename, int[2](lines added, lines removed), isBinary] is returned.

getLinesOfCode

public int getLinesOfCode(java.lang.String filename)
                   throws net.sf.statcvs.input.NoLineCountException
Returns the lines of code for a repository file. (Currently checked out version)

Throws:
net.sf.statcvs.input.NoLineCountException - when the line count could not be retrieved, for example when the file was not found.
Parameters:
filename - a file in the repository
Returns:
the lines of code for a repository file

getModuleName

public java.lang.String getModuleName()
Assumes #loadInfo(String) has been called. Never ends with /, might be empty.

Returns:
The absolute path of the root of the working folder in the repository.

getRepositoryUuid

public java.lang.String getRepositoryUuid()
Assumes #loadInfo(String) has been called.

Returns:
The uuid of the repository.

getRevision

public java.lang.String getRevision(java.lang.String filename)
                             throws java.io.IOException
Returns the revision of filename in the local working directory by reading the svn metadata.

Throws:
java.io.IOException
Parameters:
filename - the filename
Returns:
the revision of filename

getRootRevisionNumber

public java.lang.String getRootRevisionNumber()
Assumes #loadInfo(String) has been called.

Returns:
the revision number of the root of the working folder (last checked out revision number)

isBinary

public boolean isBinary(java.lang.String relativePath)
Is the given path a binary file in the working directory?

Parameters:
relativePath - the directory
Returns:
true if it is marked as a binary file

isDirectory

public boolean isDirectory(java.lang.String relativePath)
Returns true if the path has been identified as a directory.

Parameters:
relativePath - the path
Returns:
true if it is a known directory.

loadInfo

public void loadInfo()
              throws net.sf.statcvs.input.LogSyntaxException,
                     java.io.IOException
Initializes our representation of the repository.

Throws:
net.sf.statcvs.input.LogSyntaxException - if the svn info --xml is malformed
java.io.IOException - if there is an error reading from the stream

relativePathToUrl

public java.lang.String relativePathToUrl(java.lang.String relative)
Converts a relative path in the working folder to a URL, using the working folder's root URL

Parameters:
relative - Example: src/Messages.java
Returns:
Example: svn://svn.statsvn.org/statsvn/trunk/statsvn/src/Messages.java

relativeToAbsolutePath

public java.lang.String relativeToAbsolutePath(java.lang.String relative)
Converts a relative path in the working folder to an absolute path in the repository.

Parameters:
relative - Example: src/Messages.java
Returns:
Example: /trunk/statsvn/src/Messages.java

urlToAbsolutePath

public java.lang.String urlToAbsolutePath(java.lang.String url)
Converts a url to an absolute path in the repository.

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

public java.lang.String urlToRelativePath(java.lang.String url)
Converts a url to a relative path in the repository.

Parameters:
url - Examples: svn://svn.statsvn.org/statsvn/trunk/statsvn, svn://svn.statsvn.org/statsvn/trunk/statsvn/package.html
Returns:
Example: ".", package.html

getProcessor

public ISvnProcessor getProcessor()

getDiffProcessor

protected ISvnDiffProcessor getDiffProcessor()

getInfoProcessor

protected ISvnInfoProcessor getInfoProcessor()

getPropgetProcessor

protected ISvnPropgetProcessor getPropgetProcessor()

getVersionProcessor

protected ISvnVersionProcessor getVersionProcessor()