mozversioncontrol package

Submodules

mozversioncontrol.repoupdate module

mozversioncontrol.repoupdate.update_git_repo(git, repo, path, revision=u'origin/master')

Ensure a Git repository exists at a path and is up to date.

mozversioncontrol.repoupdate.update_mercurial_repo(hg, repo, path, revision=u'default', hostfingerprints=None, global_args=None)

Ensure a HG repository exists at a path and is up to date.

Module contents

class mozversioncontrol.GitRepository(path, git=u'git')

Bases: mozversioncontrol.Repository

An implementation of Repository for Git repositories.

add_remove_files(path)
base_ref
forget_add_remove_files(path)
get_changed_files(diff_filter=u'ADM', mode=u'unstaged')
get_files_in_working_directory()
get_outgoing_files(diff_filter=u'ADM', upstream=u'default')
get_upstream()
head_ref
name
sparse_checkout_present()
working_directory_clean(untracked=False, ignored=False)
class mozversioncontrol.HgRepository(path, hg=u'hg')

Bases: mozversioncontrol.Repository

An implementation of Repository for Mercurial repositories.

add_remove_files(path)
base_ref
forget_add_remove_files(path)
get_changed_files(diff_filter=u'ADM', mode=u'unstaged')
get_files_in_working_directory()
get_outgoing_files(diff_filter=u'ADM', upstream=u'default')
get_upstream()
head_ref
name
sparse_checkout_present()
working_directory_clean(untracked=False, ignored=False)
exception mozversioncontrol.InvalidRepoPath

Bases: exceptions.Exception

Represents a failure to find a VCS repo at a specified path.

exception mozversioncontrol.MissingConfigureInfo

Bases: mozversioncontrol.MissingVCSInfo

Represents error finding VCS info from configure data.

exception mozversioncontrol.MissingUpstreamRepo

Bases: exceptions.Exception

Represents a failure to automatically detect an upstream repo.

exception mozversioncontrol.MissingVCSInfo

Bases: exceptions.Exception

Represents a general failure to resolve a VCS interface.

exception mozversioncontrol.MissingVCSTool

Bases: exceptions.Exception

Represents a failure to find a version control tool binary.

class mozversioncontrol.Repository(path, tool)

Bases: object

A class wrapping utility methods around version control repositories.

This class is abstract and never instantiated. Obtain an instance by calling a get_repository_*() helper function.

Clients are recommended to use the object as a context manager. But not all methods require this.

add_remove_files(path)

Add and remove files under path in this repository’s working copy.

base_ref

Hash of revision the current topic branch is based on.

forget_add_remove_files(path)

Undo the effects of a previous add_remove_files call for path.

get_changed_files(diff_filter, mode=u'unstaged')

Return a list of files that are changed in this repository’s working copy.

diff_filter controls which kinds of modifications are returned. It is a string which may only contain the following characters:

A - Include files that were added D - Include files that were deleted M - Include files that were modified

By default, all three will be included.

mode can be one of ‘unstaged’, ‘staged’ or ‘all’. Only has an affect on git. Defaults to ‘unstaged’.

get_files_in_working_directory()

Obtain a list of managed files in the working directory.

get_outgoing_files(diff_filter, upstream=u'default')

Return a list of changed files compared to upstream.

diff_filter works the same as get_changed_files. upstream is a remote ref to compare against. If unspecified, this will be determined automatically. If there is no remote ref, a MissingUpstreamRepo exception will be raised.

get_upstream()

Reference to the upstream remote.

head_ref

Hash of HEAD revision.

name

Name of the tool.

sparse_checkout_present()

Whether the working directory is using a sparse checkout.

A sparse checkout is defined as a working directory that only materializes a subset of files in a given revision.

Returns a bool.

tool_version

Return the version of the VCS tool in use as a LooseVersion.

working_directory_clean(untracked=False, ignored=False)

Determine if the working directory is free of modifications.

Returns True if the working directory does not have any file modifications. False otherwise.

By default, untracked and ignored files are not considered. If untracked or ignored are set, they influence the clean check to factor these file classes into consideration.

mozversioncontrol.get_repository_from_build_config(config)

Obtain a repository from the build configuration.

Accepts an object that has a topsrcdir and subst attribute.

mozversioncontrol.get_repository_from_env()

Obtain a repository object by looking at the environment.

If inside a build environment (denoted by presence of a buildconfig module), VCS info is obtained from it, as found via configure. This allows us to respect what was passed into configure. Otherwise, we fall back to scanning the filesystem.

mozversioncontrol.get_repository_object(path, hg=u'hg', git=u'git')

Get a repository object for the repository at path. If path is not a known VCS repository, raise an exception.

mozversioncontrol.get_tool_path(tool)

Obtain the path of tool.