org.opensolaris.opengrok.history
Class HistoryGuru

java.lang.Object
  extended by org.opensolaris.opengrok.history.HistoryGuru

public final class HistoryGuru
extends java.lang.Object

The HistoryGuru is used to implement an transparent layer to the various source control systems.


Method Summary
 void addRepositories(java.lang.String dir)
          Search through the all of the directories and add all of the source repositories found.
 Annotation annotate(java.io.File file, java.lang.String rev)
          Annotate the specified revision of a file.
 void createCache()
          Create the history cache for all of the repositories
 void createCache(java.util.List<java.lang.String> repositories)
           
 void ensureHistoryCacheExists(java.io.File file)
          Ensure that we have a directory in the cache.
 java.lang.String getCacheInfo()
          Get a string with information about the history cache.
 History getHistory(java.io.File file)
          Get the history for the specified file.
 History getHistory(java.io.File file, boolean withFiles)
          Get the history for the specified file.
 HistoryReader getHistoryReader(java.io.File file)
          Get the appropriate history reader for the file specified by parent and basename.
static HistoryGuru getInstance()
          Get the one and only instance of the HistoryGuru
protected  Repository getRepository(java.io.File path)
           
 java.io.InputStream getRevision(java.lang.String parent, java.lang.String basename, java.lang.String rev)
          Get a named revision of the specified file.
 boolean hasAnnotation(java.io.File file)
          Check if we can annotate the specified file.
 boolean hasHistory(java.io.File file)
          Does this directory contain files with source control information?
 void invalidateRepositories(java.util.List<RepositoryInfo> repos)
          Invalidate the current list of known repositories!
 void updateRepositories()
          Update the source the contents in the source repositories.
 void updateRepositories(java.util.List<java.lang.String> paths)
          Update the source the contents in the source repositories.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getInstance

public static HistoryGuru getInstance()
Get the one and only instance of the HistoryGuru

Returns:
the one and only HistoryGuru instance

getCacheInfo

public java.lang.String getCacheInfo()
                              throws HistoryException
Get a string with information about the history cache.

Returns:
a free form text string describing the history cache instance
Throws:
HistoryException - if an error occurred while getting the info

annotate

public Annotation annotate(java.io.File file,
                           java.lang.String rev)
                    throws java.io.IOException
Annotate the specified revision of a file.

Parameters:
file - the file to annotate
rev - the revision to annotate (null means BASE)
Returns:
file annotation, or null if the HistoryParser does not support annotation
Throws:
java.io.IOException

getHistoryReader

public HistoryReader getHistoryReader(java.io.File file)
                               throws HistoryException
Get the appropriate history reader for the file specified by parent and basename.

Parameters:
file - The file to get the history reader for
Returns:
A HistorReader that may be used to read out history data for a named file
Throws:
HistoryException - If an error occurs while getting the history

getHistory

public History getHistory(java.io.File file)
                   throws HistoryException
Get the history for the specified file.

Parameters:
file - the file to get the history for
Returns:
history for the file
Throws:
HistoryException - on error when accessing the history

getHistory

public History getHistory(java.io.File file,
                          boolean withFiles)
                   throws HistoryException
Get the history for the specified file.

Parameters:
file - the file to get the history for
withFiles - whether or not the returned history should contain a list of files touched by each changeset (the file list may be skipped if false, but it doesn't have to)
Returns:
history for the file
Throws:
HistoryException - on error when accessing the history

getRevision

public java.io.InputStream getRevision(java.lang.String parent,
                                       java.lang.String basename,
                                       java.lang.String rev)
                                throws java.io.IOException
Get a named revision of the specified file.

Parameters:
parent - The directory containing the file
basename - The name of the file
rev - The revision to get
Returns:
An InputStream containing the named revision of the file.
Throws:
java.io.IOException - If an error occurs while reading out the version

hasHistory

public boolean hasHistory(java.io.File file)
Does this directory contain files with source control information?

Parameters:
file - The name of the directory
Returns:
true if the files in this directory have associated revision history

hasAnnotation

public boolean hasAnnotation(java.io.File file)
Check if we can annotate the specified file.

Parameters:
file - the file to check
Returns:
true if the file is under version control and the version control system supports annotation

addRepositories

public void addRepositories(java.lang.String dir)
Search through the all of the directories and add all of the source repositories found.

Parameters:
dir - the root directory to start the search in.

updateRepositories

public void updateRepositories()
Update the source the contents in the source repositories.


updateRepositories

public void updateRepositories(java.util.List<java.lang.String> paths)
Update the source the contents in the source repositories.

Parameters:
paths - A list of files/directories to update

createCache

public void createCache()
Create the history cache for all of the repositories


createCache

public void createCache(java.util.List<java.lang.String> repositories)

ensureHistoryCacheExists

public void ensureHistoryCacheExists(java.io.File file)
                              throws HistoryException
Ensure that we have a directory in the cache. If it's not there, fetch its history and populate the cache. If it's already there, and the cache is able to tell how recent it is, attempt to update it to the most recent revision.

Parameters:
file - the root path to test
Throws:
HistoryException - if an error occurs while accessing the history cache

getRepository

protected Repository getRepository(java.io.File path)

invalidateRepositories

public void invalidateRepositories(java.util.List<RepositoryInfo> repos)
Invalidate the current list of known repositories!

Parameters:
repos - The new repositories