repoman package¶
Subpackages¶
Submodules¶
repoman.changeset module¶
repoman.commitmessage module¶
- class repoman.commitmessage.CommitMessage(message, values={})¶
Bases: object
- class repoman.commitmessage.DefaultCommitMessageBuilder¶
Bases: object
- CLOSE_BRANCH = 'Closing branch %(branch)s'¶
- MERGE = 'Merging %(other_branch)s@%(other_revision)s into %(local_branch)s@%(local_revision)s'¶
- close_branch(branch)¶
- commit(message, values={})¶
- commit_message(message, values={})¶
- merge(local_branch=None, local_revision=None, other_branch=None, other_revision=None)¶
repoman.depot module¶
- class repoman.depot.Depot(path, parent, dvcs)¶
Bases: object
Manages a depot.
- grab_changesets_from_upstream(requirements)¶
Copy the specified requirements from their origins, add them to this repo.
Parameters: requirements (dict) – {‘repository_path’: [changeset1, changeset2, ...],...}
- repo_kind¶
- repository¶
- request_refresh(requirements)¶
Refresh a clon with the required changesets from upstream cache.
Parameters: requirements (dict) – requirements with the following type: {‘repository_path’: [changeset1, changeset2,...],...} Returns: True is successfull.
- set_source(source)¶
Set the default source in the dvcs
repoman.depot_manager module¶
- exception repoman.depot_manager.CloneProvisionError¶
Bases: exceptions.Exception
Raised when a repo cannot be provisioned.
- class repoman.depot_manager.DepotManager(main_workspace='~/.repo', repo_kind='hg', main_source=None)¶
Bases: object
Acts as an public facing API for working with managed clones.
Parameters: - main_workspace (string) – directory where all the workspaces will be created.
- repo_kind (string) – Repository type
- main_source (string) – FIXME
- cache_name = 'main_cache'¶
- free_depot(depot, task_guid)¶
Frees a repository for new uses.
Parameters: - clone – a RepoWorkspace to be freed from use.
- task_guid – Identifier of the task reserving the clone.
Raises RepoFreeError: When a repo cannot be freed.
- get_available_clone(path)¶
Returns: a clone with the available clone specified by path Return type: RepoWorkspace
- get_not_available_clone(path)¶
Returns: a clone with the not available clone specified by path Return type: RepoWorkspace
- give_me_depot(task_guid, task_name, requirements=None, default_source=None)¶
Reserves or prepares a new repository workspace.
Parameters: - task_guid – Identifier of the task reserving the clone.
- task_name – Name of the task for information purposes
- requirements – requirements to pull
- default_source – default clone source
Returns: a free repo.
Return type: Raises RepoProvisionError: When a new repo cannot be provisioned.
- give_me_depot_from_path(path)¶
Gets a repository from the current path without checking its state, no matter if it’s FREE or INUSE
Parameters: path (string) – depot path to get
- squadron_roster_name = 'squadron_roster.db'¶
- workspaces_prefix = 'workspace'¶
repoman.depot_operations module¶
- class repoman.depot_operations.DepotOperations¶
Bases: object
- KIND = None¶
- check_changeset_availability(path, changesets)¶
Check for changesets are already in the specified depot path. Always request all changesets from all sources. This means that the changesets will always be missing.
Parameters: - path – Path to the depot.
- changesets – List of strings specifying the changesets.
Returns: List of changesets missing
- clear_depot(path, parent=None)¶
Clear a depot just in case a previous usage let it dirty This should also reset configuration
Parameters: - path – Path of the depot
- parent –
- get_depot_from_path(path, parent=None)¶
Factory method that creates Depots from a given path
Parameters: path – Path of the depot Returns: Depot class corresponding to the path.
- classmethod get_depot_operations(repo_kind)¶
- grab_changesets(path, url, changesets)¶
Copies changesets from the remote url to the specified path.
Parameters: - path – target depot for the changesets.
- url – depot to copy the changesets from.
- changesets – List of changesets ids.
Returns: True.
- init_depot(path, parent=None, source=None)¶
Initializes a new depot
Parameters: path – path to the main depot Returns: Depot class corresponding to the path. False otherwise.
- is_a_depot(path)¶
Check if the given path corresponds to a depot.
Parameters: path – path to the supposed depot Returns: True if a depot. False otherwise.
- set_source(path, source)¶
Set the default remote source.
Parameters: - path – Path of the depot
- source – Remote URI of the source repo
repoman.reference module¶
repoman.repo_indexer module¶
- class repoman.repo_indexer.MultiRepoIndexer(repository_name_matrix, indexers_list=None)¶
Bases: object
MultiRepoIndexer is a repo indexer that search in multiple sources ordered by priority. If one doesn’t find the data, it will search in the next one. You can register as many repository indexers as you want
Parameters: - repository_name_matrix (dict) – is a dict that represent each repository name for the registered indexers, the dict key is the repository id
- indexers_list (list of indexers) – Every item in the list is a tuple that contains: priority, indexer path, indexer id and another tuple with the auth credentials
- get_branch_log(branch_name, limit=None)¶
Returns the log for the given brancha and limit
Parameters: - branch_name (string) –
- limit (int) –
Returns: list of tuples with the log information
- get_branches(limit=None)¶
Returns the branches in the repository, it look for them in all the registered repositories by priority
Parameters: limit (int) – Returns: list of strings with the name of the branches
- register_indexer(priority, indexer, id, auth)¶
This method register a new indexer
Parameters: - priority (int) – indexer priority
- indexer (string) – module plus class name to instantiate, having this form: module1.module2.ClassName
- id (string) – repository
- auth (tuple) – tuple that contains 3 elements: url, user and password
- exception repoman.repo_indexer.RepoIndexerError¶
Bases: exceptions.Exception
repoman.repository module¶
- exception repoman.repository.MergeConflictError(exception)¶
Bases: repoman.repository.RepositoryError
There was any conflict while merging.
- class repoman.repository.Repository(repo_path, repo_indexer=None, message_builder=None, signature=None)¶
Bases: object
Models a repo and provides changesets, operations and such.
ABSTRACT class. Do not create instances of this class. Use repository_factory() to get the proper Repository implementation.
- add(files)¶
Adds a file or a list of files to the repo to be tracked
Parameters: files (string or list of strings) – file or files to add Raises: RepositoryError
- branch(branch_name)¶
Creates a branch in the repository.
- branch_exists(branch_name)¶
Return if the given branch exists in the repository
Parameters: branch_name (string) – name of the branch
- commit(message, custom_parent=None, allow_empty=False)¶
Commits changes in current working copy. This will implement a git commit -a behaviour.
Parameters: - message (string) – commit message
- custom_parent (pygit2.Oid) – by default the commit parent is the repo head with this parameter you can specify a custom one like when there was a fastforward merge and you want to perform a commit anyway
- allow_empty (bool) – allows empty commits
- compare_branches(revision_to_check, branch_base)¶
This function returns the changesets that would be included in branch_base_name if you merge revision_to_check_hash into branch_base_name. The first param must be a changeset hash and the second a branch name.
Parameters: - revision_to_check_hash (string) –
- branch_base_name (string) –
- do_as(signature)¶
Convenience methods to do operations with an specific signature.
To be used like:
repository.do_as(other_signature).tag(‘foo’)Parameters: signature (repoman.signature.Signature()) – Signature to use for the operation.
- exterminate_branch(branch_name, repo_origin, repo_dest)¶
Exterminating the branch, apart from terminate it, this also removes it from remote
Parameters: - branch_name (string) – name of the branch
- repo_origin (string) – repository source
- repo_dest (string) – repository destination
- message (string) – Message used in commit message (ignored)
- full_merge_and_push(base_branch, changeset_to_merge_hash, branch_to_merge_name, origin, destination, ref_name=None)¶
Perform a full merge and push.
Parameters: - base_branch (string) – branch where the changeset will be merged into
- changeset_to_merge_hash (string) – changeset to merge into base_branch
- branch_to_merge_name (string) – name of the branch to merge
- origin (string) – repository origin
- destination (string) – repository destination
- ref_name (string) – reference name to push
- get_ancestor(cs1, cs2)¶
Returns a changeset being the first ancestor of both changesets provided
Parameters: - cs1 (string) – First changeset
- cs2 (string) – Second changeset
Returns: ancestor changeset
Return type: string
- get_branch(branch_name=None)¶
Get Branch object. If no branch_provided, current branch is returned Does not need to swith to the branch
Parameters: branch_name (string) – name of the branch Returns: Branch object Return type: repoman.reference.Reference()
- get_branch_tip(branch_name)¶
Returns the changeset being the branch tip checking the indexers first and then the repository itself
Parameters: branch_name (string) – name of the branch
- get_branches(active=False, closed=False)¶
Returns the list of branches. Firstly, it tries to do so using the included repo indexer, if not possible, it tries to retrieve them from repository itself. If either active or closed are true, it directly search in the repository.
Parameters: - active (bool) – indicates to get active branches
- closed (bool) – indicates to get closed branches
- get_changeset_branches(changeset)¶
Gets the branches associated to the given changeset
Parameters: changeset – Changeset to look for
Gets the tags of the given changeset
Parameters: changeset_hash (string) – Returns: the tags of the given changeset Return type: list of strings
- get_parents(changeset_hash)¶
Returns the list of parents of the given changeset
Parameters: changeset_hash (string) – hash identifying the changeset
- static get_repository(repo_path, repo_kind=None, repo_indexer=None, commit_message_builder=None)¶
Deprecated since version 0.5.1: Use repository_factory() instead.
- get_revset(cs_from=None, cs_to=None, branch=None, keyword=None, date=None)¶
Returns an iterator for the changesets in the repository that correspond to the given parameters
Parameters: - cs_from (string) – starting changeset. If this is the only parameter, a list with just this changeset will be returned
- cs_to (string) – ending changeset. If specified, all changesets between cs_from and cs_to will be returned, both included
- branch – branch that returned changesets should belong to. Filter out changesets not belonging to that branch
Returns: Return type:
- is_merge(changeset_hash)¶
Returns if the changeset is a merge.
Parameters: changeset_hash (string) – hash identifying the changeset
- merge(local_branch=None, other_rev=None, other_branch_name=None, dry_run=False)¶
Merges two revision and commits the result
Parameters: - local_branch – branch object to merge to - optional, if None, it takes current branch
- other_rev – changeset object to merge with - mandatory
- other_branch_name (string) – name of the branch the other_rev changeset belongs to
- dry_run (bool) – option to simulate the merge, it assuer the repository is restored to the previous state
- parents()¶
Returns a list of the parents of current working copy revision
- pull(remote=None, revision=None, branch=None)¶
Gets changesets from remote repo into local repo If neither branch nor revision are specified, everything will be pulled.
Parameters: - remote (string) – URL of the remote repo, where to pull from
- revision (string) – revision to pull
- branch (string) – branch to pull
Raises:
- push(orig, dest, rev=None, ref_name=None)¶
- Pushes changesets to remote repo from local repo. It will also pull,
- merge and commit if two remote heads are found
Parameters: - orig (string) – URL of repo to pull from if two heads found
- dest (string) – URL of the remote repo, where to push to
- rev (changeset object) – changeset object to push
- ref_name (string) – reference name to push
Raises:
- rawcommand(command)¶
- signature¶
- strip(changeset)¶
Strips the given changeset
Parameters: changesets (list of Changeset) – list of changeset objects
- tag(tag_name, revision=None, message=None)¶
Creates a tag in the repository
- tag_exists(tag_name)¶
Return if the given tag exists in the repository
Parameters: tag_name (string) – name of the tag
Just returns the tags
- terminate_branch(branch_name, repo_origin, repo_dest)¶
Remove the branch locally and remotely
Parameters: - branch_name (string) – name of the branch
- repo_origin (string) – repository source
- repo_dest (string) – repository destination
- tip()¶
- update(branch)¶
Updates working copy to the specified branch.
Parameters: branch (string) – ref to update working copy to, a branch name or a revision hash
- exception repoman.repository.RepositoryError(exception)¶
Bases: exceptions.Exception
Any error relative to repositories.
- repoman.repository.repository_factory(repo_path, repo_kind=None, repo_indexer=None, commit_message_builder=None)¶
Factory to create Repository objects. It will try to choose the correct repository kind.
Parameters: - repo_path (string) – Path to the repository working copy.
- repo_kind (string) – Repository class to be used.It will be determined automatically if None.
- repo_indexer (string) – Indexer to be used, if any. See repoman.repo_indexers package.
- commit_message_builder (repoman.commitmessage) – Constructor to generate the commit message. It will use repoman.commitmessage.DefaultCommitMessageBuilder if None.
repoman.roster module¶
- class repoman.roster.Clone(path, status, task, task_name, timestamp)¶
Bases: object
- FREE = 'FREE'¶
- INUSE = 'INUSE'¶
- exception repoman.roster.MaxClonesLimitReached¶
Bases: repoman.roster.RosterError
- class repoman.roster.Roster(location, max_clones=12, clone_timeout=datetime.timedelta(0, 1800))¶
Bases: _abcoll.MutableMapping
Manages the file used as a roster. Provides dict API to it.
- class DBCursor(connection)¶
Bases: object
- Roster.add(path, task, task_name)¶
- Roster.free_clone(clone, task)¶
- Roster.get_available()¶
- Roster.get_not_available()¶
- Roster.reserve_clone(task, task_name)¶
- exception repoman.roster.RosterError¶
Bases: exceptions.Exception
- repoman.roster.marshall(clone)¶
Adapter for serializing the object into a string for db storage.
Parameters: clone – Clone class to be serialized.
- repoman.roster.unmarshall(db_str)¶
Creates a Python Clone object from the result of a db query.
Parameters: db_str – String from the database.