Part of lp.code.model.directbranchcommit View In Hierarchy
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. |
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.
If you write a file multiple times, the first one is used and the rest ignored.
If it does, raise ConcurrentUpdateError
.