Package trac :: Package versioncontrol :: Module api :: Class Repository

Class Repository

source code

object --+
         |
        Repository
Known Subclasses:

Base class for a repository provided by a version control system.
Nested Classes
  __metaclass__
Metaclass for defining Abstract Base Classes (ABCs).
Instance Methods
 
__init__(self, name, params, log)
Initialize a repository.
source code
 
__repr__(self)
repr(x)
source code
 
can_view(self, perm)
Return True if view permission is granted on the repository.
source code
 
clear(self, youngest_rev=None)
Clear any data that may have been cached in instance properties.
source code
 
close(self)
Close the connection to the repository.
source code
 
display_rev(self, rev)
Return a string representation of a revision in the repos for displaying to the user.
source code
 
get_base(self)
Return the name of the base repository for this repository.
source code
 
get_changes(self, old_path, old_rev, new_path, new_rev, ignore_ancestry=1)
Generates changes corresponding to generalized diffs.
source code
 
get_changeset(self, rev)
Retrieve a Changeset corresponding to the given revision rev.
source code
 
get_changeset_uid(self, rev)
Return a globally unique identifier for the ''rev'' changeset.
source code
 
get_changesets(self, start, stop)
Generate Changeset belonging to the given time period (start, stop).
source code
 
get_node(self, path, rev=None)
Retrieve a Node from the repository at the given path.
source code
 
get_oldest_rev(self)
Return the oldest revision stored in the repository.
source code
 
get_path_history(self, path, rev=None, limit=None)
Retrieve all the revisions containing this path.
source code
 
get_path_url(self, path, rev)
Return the repository URL for the given path and revision.
source code
 
get_quickjump_entries(self, rev)
Generate a list of interesting places in the repository.
source code
 
get_youngest_rev(self)
Return the youngest revision in the repository.
source code
 
has_node(self, path, rev=None)
Tell if there's a node at the specified (path,rev) combination.
source code
 
is_viewable(self, perm)
Return True if view permission is granted on the repository.
source code
 
next_rev(self, rev, path='')
Return the revision immediately following the specified revision.
source code
 
normalize_path(self, path)
Return a canonical representation of path in the repos.
source code
 
normalize_rev(self, rev)
Return a (unique) canonical representation of a revision.
source code
 
parent_revs(self, rev)
Return a list of parents of the specified revision.
source code
 
previous_rev(self, rev, path='')
Return the revision immediately preceding the specified revision.
source code
 
rev_older_than(self, rev1, rev2)
Provides a total order over revisions.
source code
 
short_rev(self, rev)
Return a compact string representation of a revision in the repos.
source code
 
sync(self, rev_callback=None, clean=False)
Perform a sync of the repository cache, if relevant.
source code
 
sync_changeset(self, rev)
Resync the repository cache for the given rev, if relevant.
source code

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __setattr__, __sizeof__, __str__, __subclasshook__

Class Variables
  __abstractmethods__ = frozenset(['close', 'get_changes', 'get_...
  has_linear_changesets = False
  realm = 'repository'
  scope = '/'
Properties
  oldest_rev
  resource
  youngest_rev

Inherited from object: __class__

Method Details

__init__(self, name, params, log)
(Constructor)

source code 
Initialize a repository.
Parameters:
  • name - a unique name identifying the repository, usually a type-specific prefix followed by the path to the repository.
  • params - a dict of parameters for the repository. Contains the name of the repository under the key "name" and the surrogate key that identifies the repository in the database under the key "id".
  • log - a logger instance.
Raises:
Overrides: object.__init__

__repr__(self)
(Representation operator)

source code 
repr(x)
Overrides: object.__repr__
(inherited documentation)

clear(self, youngest_rev=None)

source code 

Clear any data that may have been cached in instance properties.

youngest_rev can be specified as a way to force the value of the youngest_rev property (''will change in 0.12'').

close(self)

source code 
Close the connection to the repository.
Decorators:
  • @abstractmethod

display_rev(self, rev)

source code 

Return a string representation of a revision in the repos for displaying to the user.

This can be a shortened revision string, e.g. for repositories using long hashes.

Raises:

get_base(self)

source code 

Return the name of the base repository for this repository.

This function returns the name of the base repository to which scoped repositories belong. For non-scoped repositories, it returns the repository name.

get_changes(self, old_path, old_rev, new_path, new_rev, ignore_ancestry=1)

source code 

Generates changes corresponding to generalized diffs.

Generator that yields change tuples (old_node, new_node, kind, change) for each node change between the two arbitrary (path,rev) pairs.

The old_node is assumed to be None when the change is an ADD, the new_node is assumed to be None when the change is a DELETE.

Decorators:
  • @abstractmethod

get_changeset(self, rev)

source code 
Retrieve a Changeset corresponding to the given revision rev.
Decorators:
  • @abstractmethod

get_changeset_uid(self, rev)

source code 

Return a globally unique identifier for the ''rev'' changeset.

Two changesets from different repositories can sometimes refer to the ''very same'' changeset (e.g. the repositories are clones).

get_node(self, path, rev=None)

source code 

Retrieve a Node from the repository at the given path.

A Node represents a directory or a file at a given revision in the repository. If the rev parameter is specified, the Node corresponding to that revision is returned, otherwise the Node corresponding to the youngest revision is returned.

Decorators:
  • @abstractmethod

get_oldest_rev(self)

source code 
Return the oldest revision stored in the repository.
Decorators:
  • @abstractmethod

get_path_history(self, path, rev=None, limit=None)

source code 

Retrieve all the revisions containing this path.

If given, rev is used as a starting point (i.e. no revision ''newer'' than rev should be returned). The result format should be the same as the one of Node.get_history()

Decorators:
  • @abstractmethod

get_path_url(self, path, rev)

source code 

Return the repository URL for the given path and revision.

The returned URL can be None, meaning that no URL has been specified for the repository, an absolute URL, or a scheme-relative URL starting with //, in which case the scheme of the request should be prepended.

get_quickjump_entries(self, rev)

source code 

Generate a list of interesting places in the repository.

rev might be used to restrict the list of available locations, but in general it's best to produce all known locations.

The generated results must be of the form (category, name, path, rev).

get_youngest_rev(self)

source code 
Return the youngest revision in the repository.
Decorators:
  • @abstractmethod

has_node(self, path, rev=None)

source code 

Tell if there's a node at the specified (path,rev) combination.

When rev is None, the latest revision is implied.

next_rev(self, rev, path='')

source code 

Return the revision immediately following the specified revision.

If path is given, filter out descendant revisions having no changes below path.

In presence of multiple children, this follows the first child.

Decorators:
  • @abstractmethod

normalize_path(self, path)

source code 
Return a canonical representation of path in the repos.
Decorators:
  • @abstractmethod

normalize_rev(self, rev)

source code 

Return a (unique) canonical representation of a revision.

It's up to the backend to decide which string values of rev (usually provided by the user) should be accepted, and how they should be normalized. Some backends may for instance want to match against known tags or branch names.

In addition, if rev is None or '', the youngest revision should be returned.

Decorators:
  • @abstractmethod
Raises:

previous_rev(self, rev, path='')

source code 

Return the revision immediately preceding the specified revision.

If path is given, filter out ancestor revisions having no changes below path.

In presence of multiple parents, this follows the first parent.

Decorators:
  • @abstractmethod

rev_older_than(self, rev1, rev2)

source code 

Provides a total order over revisions.

Return True if rev1 is an ancestor of rev2.

Decorators:
  • @abstractmethod

short_rev(self, rev)

source code 
Return a compact string representation of a revision in the repos.
Raises:

sync(self, rev_callback=None, clean=False)

source code 

Perform a sync of the repository cache, if relevant.

If given, rev_callback must be a callable taking a rev parameter. The backend will call this function for each rev it decided to synchronize, once the synchronization changes are committed to the cache. When clean is True, the cache is cleaned first.

sync_changeset(self, rev)

source code 

Resync the repository cache for the given rev, if relevant.

Returns a "metadata-only" changeset containing the metadata prior to the resync, or None if the old values cannot be retrieved (typically when the repository is not cached).


Class Variable Details

__abstractmethods__

Value:
frozenset(['close',
           'get_changes',
           'get_changeset',
           'get_node',
           'get_oldest_rev',
           'get_path_history',
           'get_youngest_rev',
           'next_rev',
...

Property Details

oldest_rev

Get Method:
unreachable(self)

resource

Get Method:
unreachable.resource(self)

youngest_rev

Get Method:
unreachable(self)