Backends

Implemented Backends

Base Backend

Created on Apr 8, 2010

author:marcink,lukaszb
class vcs.backends.base.BaseChangeset

Each backend should implement it’s changeset representation.

Attribute :repository: repository object within which changeset exists
Attribute :id: may be raw_id or i.e. for mercurial’s tip just tip
Attribute :raw_id: raw changeset representation (i.e. full 40 length sha for git backend) as string
Attribute :short_id: shortened (if needed) version of raw_id; it would be simple shortcut for raw_id[:12]
Attribute :revision: revision number as integer
Attribute :files: list of Node objects with NodeKind.FILE
Attribute :dirs: list of Node objects with NodeKind.DIR
Attribute :nodes: combined list of Node objects
Attribute :author: author of the changeset
Attribute :message: message of the changeset
Attribute :size: integer size in bytes
Attribute :last: True if this is last changeset in repository, False otherwise; ChangesetError is raised if not related with repository object
get_file_changeset(path)

Returns last commit of the file at the given path.

get_file_content(path)

Returns content of the file at the given path.

get_file_history(path)

Returns history of file as reversed list of Changeset objects for which file at given path has been modified.

get_file_message(path)

Returns message of the last commit related to file at the given path.

get_file_size(path)

Returns size of the file at the given path.

get_node(path)

Returns Node object from the given path. If there is no node at the given path, ChangesetError would be raised.

get_nodes(path)

Returns combined DirNode and FileNode objects list representing state of changeset at the given path. If node at the given path is not instance of DirNode, ChangesetError would be raised.

walk(topurl='')

Similar to os.walk method. Insted of filesystem it walks through changeset starting at given topurl. Returns generator of tuples (topnode, dirnodes, filenodes).

class vcs.backends.base.BaseInMemoryChangeset(repository)

Represents differences between repository’s state (most recent head) and changes made in place.

Attribute :repository: repository object of working directory
Attribute :added: list of new FileNode objects going to be committed
Attribute :changed: list of changed FileNode objects going to be committed
Attribute :removed: list of RemovedFileNode objects marked to be removed
add(*filenodes)

Marks given FileNode objects as to be committed.

Raises:
  • NodeAlreadyExistsError – if node with same path exists at latest changeset
  • NodeAlreadyAddedError – if node with same path is already marked as new
change(*filenodes)

Marks given FileNode objects to be changed in next commit.

Raises:
  • ChangesetError – if node doesn’t exist in latest changeset or node with same path is already marked as changed.
  • RepositoryError – if there are no changesets yet
commit(message, **kwargs)

Commits local (from working directory) changes and returns newly created Changeset. Updates repository’s revisions list.

Raises CommitError:
 if any error occurs while committing
get_ipaths()

Returns generator of paths from nodes marked as added, changed or removed.

get_paths()

Returns list of paths from nodes marked as added, changed or removed.

remove(*filenodes)

Marks given FileNode (or RemovedFileNode) objects to be removed in next commit. If FileNode doesn’t exists

Raises:
  • ChangesetError – if node does not exist in latest changeset
  • RepositoryError – if there are no changesets yet
  • NodeAlreadyRemovedError – if node has been already marked to be removed
reset()

Resets this instance to initial state (cleans added, changed and removed lists).

class vcs.backends.base.BaseRepository(repo_path, create=False, **kwargs)

Base Repository for final backends

Attribute :repo object from external api
Attribute :revisions: list of all available revisions’ ids, in ascending order
Attribute :changesets: storage dict caching returned changesets
Attribute :path: absolute local path to the repository
Attribute :branches: branches as list of changesets
Attribute :tags: tags as list of changesets

Initializes repository. Raises RepositoryError if repository could not be find at the given repo_path.

Parameters:
  • repo_path – local path of the repository
  • create=False – if set to True, would try to craete repository if it does not exist rather than raising exception
add(filenode, **kwargs)

Commit api function that will add given FileNode into this repository. If there is a file with same path already in repository, NodeAlreadyExistsError is raised.

commit(message, **kwargs)

Persists current changes made on this repository and returns newly created changeset. If no changed has been made, NothingChangedError is raised.

get_changeset(revision=None)

Returns instance of Changeset class. If revision is None, most recenent changeset is returned.

get_changesets(limit=10, offset=None)

Return last n number of Changeset objects specified by limit attribute if None is given whole list of revisions is returned

@param limit: int limit or None @param offset: int offset

get_state()

Returns dictionary with added, changed and removed lists containing FileNode objects.

is_valid()

Validates repository.

remove(filenode, **kwargs)

Commit api function that will remove given FileNode into this repository. If there is no file with given path, NodeDoesNotExistError is raised.

class vcs.backends.base.BaseWorkdir(repository)

Working directory representation of single repository.

Attribute :repository: repository object of working directory
commit(message, **kwargs)

Commits local (from working directory) changes and returns newly created Changeset. Updates repository’s revisions list.

Raises CommitError:
 if any error occurs while committing
get_added()

Returns list of FileNode objects marked as new in working directory.

get_changed()

Returns list of FileNode objects changed in working directory.

get_removed()

Returns list of RemovedFileNode objects marked as removed in working directory.

get_untracked()

Returns list of FileNode objects which are present within working directory however are not tracked by repository.

update(revision=None)

Fetches content of the given revision and populates it within working directory.

Table Of Contents

Previous topic

Nodes

Next topic

Git Backend

This Page