_docsweeper.version_control#
Module for version control functions.
- class _docsweeper.version_control.VCSCommandSetConfig#
Bases:
NamedTupleConfiguration values for
VCSCommandSet.Holds configuration values that are customizable by clients.
Note
This class is exported publicly as
docsweeper.VCSCommandSetConfig.- executable: Optional[pathlib.Path]#
The path of the executable of the version used.
- merge(other)#
Return a new config with merged values of this config and other.
- Parameters
other (VCSCommandSetConfig) – entries that are not
Nonein this config are merged into the new one- Returns
the merged config
- Return type
- class _docsweeper.version_control.FileRenamedError#
Bases:
ValueErrorRaised when a file was unexpectedly detected to have been renamed.
- class _docsweeper.version_control.VCSCommandSet#
Bases:
ABCEncapsulates all commands needed for a complete version control command set.
Note
This class is exported publicly as
docsweeper.VCSCommandSet.
- class _docsweeper.version_control.GitCommandSet#
Bases:
VCSCommandSetAn implementation of a version control command set for git.
Note
This class is exported publicly as
docsweeper.GitCommandSet.
- class _docsweeper.version_control.MercurialCommandSet#
Bases:
VCSCommandSetAn implementation of a version control command set for mercurial.
Note
This class is exported publicly as
docsweeper.MercurialCommandSet.
- class _docsweeper.version_control.VCSShim#
A shim between the output of a version control command set and clients.
Encapsulates the low-level commands of a
VCSCommandSetinto a more user-friendly interface.- __init__(vcs_command_set, vcs_command_set_config)#
Instantiate a
VCSShim.- Parameters
vcs_command_set (Type[VCSCommandSet]) – the
VCSCommandSetthat is to be usedvcs_command_set_config (VCSCommandSetConfig) – configuration dictionary for the version control command set
- Return type
None
- get_all_revisions(path)#
Return a list of revision identifiers in which the file path was changed.
- Parameters
path (Path) – the path of a file in the repository
- Returns
a list of revision identifiers
- Raises
ValueError – if path is not under version control
- Return type
- get_file_from_repo(path, revision)#
Return the contents of path under revision.
- Parameters
- Raises
RuntimeError – if the underlying version control command fails unexpectedly
ValueError – if path or revision is the empty string
- Returns
the file content
- Return type
- get_old_name(path, revision)#
If a file has been renamed to path in revision, return this files’ old name.
- _docsweeper.version_control.command_sets: Dict[str, Tuple[Type[_docsweeper.version_control.VCSCommandSet], _docsweeper.version_control.VCSCommandSetConfig]] = {'git': (<class '_docsweeper.version_control.GitCommandSet'>, VCSCommandSetConfig(executable=PosixPath('/usr/bin/git'), follow_rename=True)), 'hg': (<class '_docsweeper.version_control.MercurialCommandSet'>, VCSCommandSetConfig(executable=PosixPath('/usr/bin/hg'), follow_rename=True))}#
Dictionary of all supported command sets and their default configuration.
Note
This object is exported publicly as
docsweeper.command_sets.