Library for tools that need to interact with ROS-support version control systems.
creates a logger ‘vcstools’
bzr vcs support.
Bases: vcstools.vcs_base.VcsClientBase
Raises : | VcsError if bzr not detected |
---|
Returns: | BZR URL of the branch (output of bzr info command), |
---|
or None if it cannot be determined
Parameters: | spec – (optional) revisionspec of desired version. May be any revisionspec as returned by ‘bzr help revisionspec’, e.g. a tagname or ‘revno:<number>’ |
---|---|
Returns: | the current revision number of the repository. Or if spec is provided, the number of a revision specified by some token. |
Looks up bzr version by calling bzr –version. :raises: VcsError if bzr is not installed
git vcs support.
refnames in git can be branchnames, hashes, partial hashes, tags. On checkout, git will disambiguate by checking them in that order, taking the first that applies
This class aims to provide git for linear centralized workflows. This means in case of ambiguity, we assume that the only relevant remote is the one named “origin”, and we assume that commits once on origin remain on origin.
A challenge with git is that it has strong reasonable conventions, but is very allowing for breaking them. E.g. it is possible to name remotes and branches with names like “refs/heads/master”, give branches and tags the same name, or a valid SHA-ID as name, etc. Similarly git allows plenty of ways to reference any object, in case of ambiguities, git attempts to take the most reasonable disambiguation, and in some cases warns.
Bases: vcstools.vcs_base.VcsClientBase
Raises : | VcsError if git not detected |
---|
meaning git checkout, not vcstools checkout. This works for local branches, remote branches, tagnames, hashes, etc. git will create local branch of same name when no such local branch exists, and also setup tracking. Git decides with own rules whether local changes would cause conflicts, and refuses to checkout else.
Raises GitError: | |
---|---|
when checkout fails |
Execute git fetch if necessary, and if we can fast-foward, do so to the last fetched version using git rebase.
Parameters: |
|
---|---|
Returns: | True if up-to-date or after succesful fast-forward |
Raises : | GitError when git fetch fails |
calls git fetch :raises: GitError when call fails
updates without fetching, thus any necessary fetching must be done before allows arguments to reduce unnecessary steps after checkout
Parameters: |
|
---|
Parameters: |
|
---|---|
Returns: | (branch, remote) the name of the branch this branch tracks and its remote |
Raises : | GitError if fetch fails |
in order to support users who name their default origin something else than origin, read remote name.
checks git log –all (the list of all commits reached by references, meaning branches or tags) for version. If it shows up, that means git garbage collection will not remove the commit. Else it would eventually be deleted.
Parameters: |
|
---|---|
Returns: | True if version is not recursively referenced by a branch or tag |
Raises : | GitError if git fetch fails |
checks list of remote branches for match. Set fetch to False if you just fetched already.
Returns: | True if branch_name exists for remote <remote_name> (or ‘origin’ if None) |
---|---|
Raises : | GitError when git fetch fails |
calls git rev-list with refname and returns True if version can be found in rev-list result
Parameters: |
|
---|---|
Returns: | True if version is an ancestor commit from refname |
Raises : | GitError when call to git fetch fails |
calls git clone and then, if version was given, update(version)
For git we change the label to clarify when a different remote is configured.
Returns: | git URL of the directory path (output of git info command), or None if it cannot be determined |
---|
Parameters: |
|
---|---|
Returns: | current SHA-ID of the repository. Or if spec is provided, the SHA-ID of a commit specified by some token if found, else None |
checks list of tags for match. Set fetch to False if you just fetched already.
Returns: | True if tag_name among known tags |
---|---|
Raises : | GitError when call to git fetch fails |
if version is None, attempts fast-forwarding current branch, if any.
Else interprets version as a local branch, remote branch, tagname, hash, etc.
If it is a branch, attempts to move to it unless already on it, and to fast-forward, unless not a tracking branch. Else go untracked on tag or whatever version is. Does not leave if current commit would become dangling.
Returns: | True if already up-to-date with remote or after successful fast_foward |
---|
Bases: exceptions.Exception
Looks up git version by calling git –version.
Raises : | VcsError if git is not installed or returns |
---|
something unexpected
Parses git diff result and changes the filename prefixes.
hg vcs support.
using ui object to redirect output into a string
Bases: vcstools.vcs_base.VcsClientBase
Raises : | VcsError if hg not detected |
---|
Parameters: | spec – (optional) spec can be what ‘svn info –help’ allows, meaning a revnumber, {date}, HEAD, BASE, PREV, or COMMITTED. |
---|---|
Returns: | current revision number of the repository. Or if spec provided, the number of a revision specified by some token. |
Returns: | HG URL of the directory path. (output of hg paths |
---|
command), or None if it cannot be determined
Parameters: | spec – (optional) token for identifying version. spec can be a whatever is allowed by ‘hg log -r’, e.g. a tagname, sha-ID, revision-number |
---|---|
Returns: | the current SHA-ID of the repository. Or if spec is provided, the SHA-ID of a revision specified by some token. |
Looks up hg version by calling hg –version. :raises: VcsError if hg is not installed
Parses hg diff result and changes the filename prefixes.
svn vcs support.
Bases: vcstools.vcs_base.VcsClientBase
Raises : | VcsError if python-svn not detected |
---|
Parameters: |
|
---|---|
Returns: | current revision number of the repository. Or if spec provided, the number of a revision specified by some token. |
Returns: | SVN URL of the directory path (output of svn info command), |
---|
or None if it cannot be determined
Parameters: |
|
---|---|
Returns: | current revision number of the repository. Or if spec provided, the number of a revision specified by some token. |
Looks up svn version by calling svn –version. :raises: VcsError if svn is not installed
checks url for traces of canonical svn structure, and return root, type, name (of tag or branch), subfolder, query and fragment (see urllib urlparse) This should allow creating a different url for switching to a different tag or branch
Parameters: | url – location of central repo, str |
---|---|
Returns: | dict {root, type, name, subfolder, query, fragment} |
with type one of “trunk”, “tags”, “branches”
tar vcs support.
The implementation uses the “version” argument to indicate a subfolder within a tarfile. Hence one can organize sources by creating one tarfile with a folder inside for each version.
Bases: vcstools.vcs_base.VcsClientBase
@raise VcsError if tar not detected
untars tar at url to self.path. If version was given, only the subdirectory ‘version’ of the tar will end up in self.path. Also creates a file next to the checkout named *.tar which is a yaml file listing origin url and version arguments.
Returns: | TAR URL of the directory path (output of tar info |
---|
command), or None if it cannot be determined
Does nothing except returning true if tar exists in same “version” as checked out with vcstools.
undoc-members: | |
---|---|
show-inheritance: | |
Bases: object
DEPRECATED API for interacting with source-controlled paths independent of actual version-control implementation.
Returns: | list of valid key to use as vcs_type |
---|
Returns the class interfacing with vcs of given type
Parameters: | vcs_type – id of the tpye, e.g. git, svn, hg, bzr |
---|---|
Returns: | class extending VcsClientBase |
Raises : | ValueError for unknown vcs_type |
Returns a client with which to interact with the vcs at given path
Parameters: | vcs_type – id of the tpye, e.g. git, svn, hg, bzr |
---|---|
Returns: | instance of VcsClientBase |
Raises : | ValueError for unknown vcs_type |
Parameters: |
|
---|
vcs support library base class.
undoc-members: | |
---|---|
show-inheritance: | |
Bases: object
parent class for all vcs clients, provides their public API
subclasses may raise VcsError when a dependency is missing
Attempts to create a local repository given a remote url. Fails if a target path exists, unless it’s an empty directory. If a version is provided, the local repository will be updated to that revision. It is possible that after a failed call to checkout, a repository still exists, e.g. if an invalid revision was given. If shallow is provided, the scm client may checkout less than the full repository history to save time / disk space. If a timeout is specified, any pending operation will fail after the specified amount (in seconds). NOTE: this parameter might or might not be honored, depending on VCS client implementation. :param url: where to checkout from :type url: str :param version: token for identifying repository revision :type version: str :param shallow: hint to checkout less than a full repository :type shallow: bool :param timeout: maximum allocated time to perform operation :type shallow: int :returns: True if successful
For auto detection
Calls scm equivalent to svn export, removing scm meta information and tar gzip’ing the repository at a given version to the given basepath.
Parameters: | version – version of the repository to export. This can |
---|
be a branch, tag, or path (svn). When specifying the version as a path for svn, the path should be relative to the root of the svn repository, i.e. ‘trunk’, or ‘tags/1.2.3’, or ‘./’ for the root. :param basepath: this is the path to the tar gzip, excluding the extension which will be .tar.gz :returns: True on success, False otherwise.
Get the files that were affected by a specific revision :param revision: SHA or revision number. :returns: A list of strings with the files affected by a specific commit
Returns a list of all branches in the vcs repository.
Parameters: | local_only – if True it will only list local branches |
---|---|
Returns: | list of branches in the repository, [] if none exist |
Find an description for the current local version. Token spec might be a branchname, version-id, SHA-ID, ... depending on the VCS implementation.
Returns: | short description of local version (e.g. branchname, tagename). |
---|---|
Return type: | str |
Find a label for the default branch on remote, meaning the one that would be checked out on a clean checkout.
Returns: | a label or None (if not applicable) |
---|---|
Return type: | str |
Parameters: | basepath – diff paths will be relative to this, if any |
---|---|
Returns: | A string showing local differences |
Return type: | str |
For debugging purposes, returns a dict containing information about the environment, like the version of the SCM client, or version of libraries involved. Suggest considering keywords “version”, “dependency”, “features” first. :returns: a dict containing relevant information :rtype: dict
Calls scm log command.
Parameters: | relpath – (optional) restrict logs to events on this |
---|
resource path (folder or file) relative to the root of the repository. If None (default), this is the root of the repository. :param limit: (optional) the maximum number of log entries that should be retrieved. If None (default), there is no limit.
returns the path this client was configured for
Find an identifier for the current revision on remote. Token spec might be a tagname, version-id, SHA-ID, ... depending on the VCS implementation.
Parameters: | fetch – if False, only local information may be used |
---|---|
Returns: | current revision number of the remote repository. |
Return type: | str |
Calls scm status command. Output must be terminated by newline unless empty.
Semantics of untracked are difficult to generalize. In SVN, this would be new files only. In git, hg, bzr, this would be changes that have not been added for commit.
Extra keyword arguments are passed along to the underlying vcs code. See the specific implementations of get_status() for extra options.
Parameters: |
|
---|---|
Returns: | A string summarizing locally modified files |
Return type: | str |
Returns: | The source control url for the path or None if not set |
---|---|
Return type: | str |
used when auto detected
Find an identifier for a the current or a specified revision. Token spec might be a tagname, branchname, version-id, SHA-ID, ... depending on the VCS implementation.
Parameters: | spec (str) – token for identifying repository revision |
---|---|
Returns: | current revision number of the repository. Or if spec is provided, the respective revision number. |
Return type: | str |
helper function
For auto detection
Sets the local copy of the repository to a version matching the version parameter. Fails when there are uncommited changes. On failures (also e.g. network failure) grants the checked out files are in the same state as before the call. If a timeout is specified, any pending operation will fail after the specified amount (in seconds)
Parameters: |
|
---|---|
Returns: | True on success, False else |
client can decide whether the url and the other url are equivalent. Checks string equality by default :param url_or_shortcut: url or shortcut (e.g. bzr launchpad url) :returns: bool if params are equivalent
Bases: exceptions.Exception
To be thrown when an SCM Client faces a situation because of a violated assumption