Git Backend

Git backend implementation.

GitRepository

class vcs.backends.git.GitRepository(repo_path, create=False, clone_url=None)

Git repository backend

get_changeset(revision=None)

Returns GitChangeset object representing commit from git repository at the given revision or head (most recent commit) if None given.

get_changesets(limit=10, offset=None)

Return last n number of MercurialChangeset specified by limit attribute if None is given whole list of revisions is returned :param limit: int limit or None

pull(url)

Tries to pull changes from external location.

run_git_command(cmd)

Runs given cmd as git command and returns tuple (returncode, stdout, stderr).

Note

This method exists only until log/blame functionality is implemented at Dulwich (see https://bugs.launchpad.net/bugs/645142). Parsing os command’s output is road to hell...

Parameters:
  • cmd – git command
  • repo_path – if given, command would be prefixed with –git-dir=repo_path/.git (note that “.git” is always appended

GitChangeset

class vcs.backends.git.GitChangeset(repository, revision)

Bases: vcs.backends.base.BaseChangeset

Represents state of the repository at single revision.

id

Returns same as raw_id attribute.

raw_id

Returns raw string identifing this changeset (40-length sha)

short_id

Returns shortened version of raw_id (first 12 characters)

revision

Returns integer representing changeset.

parents

Returns list of parents changesets.

added

Returns list of added FileNode objects.

changed

Returns list of changed FileNode objects.

removed

Returns list of removed RemovedFileNode objects.

Note

Remember that those RemovedFileNode instances are only dummy FileNode objects and trying to access most of it’s attributes or methods would raise NodeError exception.

get_file_annotate(path)

Returns a list of three element tuples with lineno,changeset and line

TODO: This function now uses os underlying ‘git’ command which is generally not good. Should be replaced with algorithm iterating commits.

get_file_changeset(path)

Returns last commit of the file at the given path.

get_file_content(path)

Returns content of the file at 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.

TODO: This function now uses os underlying ‘git’ and ‘grep’ commands which is generally not good. Should be replaced with algorithm iterating commits.

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 given path.

get_node(path)
get_nodes(path)
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).

Table Of Contents

Previous topic

Backends

Next topic

Mercurial Backend

This Page