l.c.m.d.DirectBranchCommit : class documentation

Part of lp.code.model.directbranchcommit View In Hierarchy

Commit a set of files straight into a branch.

Use this to write a set of files into a branch efficiently, without caring what was in there before. The files may be new to the branch or they may exist there already; in the latter case they will be overwritten.

The branch is write-locked for the entire lifetime of this object. Be sure to call unlock() when done. This will be done for you as part of a successful commit, but unlocking more than once will do no harm.

The trick for this was invented by Aaron Bentley. It saves having to do a full checkout of the branch.

Method __init__ Create context for direct commit to branch.
Method writeFile Write file to branch; may be an update or a new file.
Method getBzrCommitterID Find the committer id to pass to bzr.
Method commit Commit to branch.
Method unlock Release commit lock, if held.
Method _matchingLastMirrored Undocumented
Method _getDir Get trans_id for directory "path." Create if necessary.
Method _checkForRace Check if bzrbranch has any changes waiting to be scanned.
def __init__(self, db_branch, committer=None, no_race_check=False, merge_parents=None, committer_id=None):
Create context for direct commit to branch.

Before constructing a `DirectBranchCommit`, set up a server that
allows write access to lp-internal:/// URLs:

bzrserver = get_rw_server()
bzrserver.start_server()
try:
    branchcommit = DirectBranchCommit(branch)
    # ...
finally:
    bzrserver.stop_server()

Or in tests, just call `useBzrBranches` before creating a
`DirectBranchCommit`.

:param db_branch: a Launchpad `Branch` object.
:param committer: the `Person` writing to the branch.  Defaults to
    the branch owner.
:param no_race_check: don't check for other commits before committing
    our changes, for use in tests.
:param committer_id: Optional identification (typically with email
    address) of the person doing the commit, for use in bzr.  If not
    given, the `committer`'s email address will be used instead.
def _matchingLastMirrored(self, revision_id):
Undocumented
def _getDir(self, path):
Get trans_id for directory "path." Create if necessary.
def writeFile(self, path, contents):
Write file to branch; may be an update or a new file.

If you write a file multiple times, the first one is used and the rest ignored.

def _checkForRace(self):
Check if bzrbranch has any changes waiting to be scanned.

If it does, raise ConcurrentUpdateError.

def getBzrCommitterID(self):
Find the committer id to pass to bzr.
def commit(self, commit_message, txn=None):
Commit to branch.
Parameterscommit_messageMessage for branch's commit log.
txnTransaction to commit. Can be helpful in avoiding long idle times in database transactions. May be committed more than once.
def unlock(self):
Release commit lock, if held.
API Documentation for Launchpad, generated by pydoctor at 2022-06-16 00:00:12.