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.
        """
        self.db_branch = db_branch

        self.last_scanned_id = self.db_branch.last_scanned_id

        if committer is None:
            committer = db_branch.owner
        self.committer = committer
        self.committer_id = committer_id

        self.no_race_check = no_race_check

        # Directories we create on the branch, and their ids.
        self.path_ids = {}

        self.bzrbranch = self.db_branch.getBzrBranch()

        self.bzrbranch.lock_write()
        self.is_locked = True
        try:
            self.revision_tree = self.bzrbranch.basis_tree()
            self.transform_preview = TransformPreview(self.revision_tree)
            assert self.transform_preview.find_conflicts() == [], "TransformPreview is not in a consistent state."
            if not no_race_check:
                last_revision = self.bzrbranch.last_revision()
                if not self._matchingLastMirrored(last_revision):
                    raise StaleLastMirrored(db_branch, get_branch_info(self.bzrbranch))

            self.is_open = True
        except:
            self.unlock()
            raise

        self.files = set()
        self.merge_parents = merge_parents
Пример #2
0
 def got_path_info((transport_type, data, trailing_path)):
     if transport_type != BRANCH_TRANSPORT:
         raise NotABranchPath(virtual_url_fragment)
     transport, _ = self._transport_dispatch.makeTransport((transport_type, data, trailing_path))
     if jail_info.transports:
         jail_info.transports.append(transport)
     try:
         branch = BzrDir.open_from_transport(transport).open_branch(ignore_fallbacks=True)
         info = get_branch_info(branch)
         info["stacked_on_url"] = self._normalize_stacked_on_url(branch)
     finally:
         if jail_info.transports:
             jail_info.transports.remove(transport)
     if info["stacked_on_url"] is None:
         info["stacked_on_url"] = ""
     return self._branchfs_client.branchChanged(data["id"], **info)
Пример #3
0
 def got_path_info((transport_type, data, trailing_path)):
     if transport_type != BRANCH_TRANSPORT:
         raise NotABranchPath(virtual_url_fragment)
     transport, _ = self._transport_dispatch.makeTransport(
         (transport_type, data, trailing_path))
     if jail_info.transports:
         jail_info.transports.append(transport)
     try:
         branch = BzrDir.open_from_transport(transport).open_branch(
             ignore_fallbacks=True)
         info = get_branch_info(branch)
         info['stacked_on_url'] = (
             self._normalize_stacked_on_url(branch))
     finally:
         if jail_info.transports:
             jail_info.transports.remove(transport)
     if info['stacked_on_url'] is None:
         info['stacked_on_url'] = ''
     return self._branchfs_client.branchChanged(data['id'], **info)
    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.
        """
        self.db_branch = db_branch

        self.last_scanned_id = self.db_branch.last_scanned_id

        if committer is None:
            committer = db_branch.owner
        self.committer = committer
        self.committer_id = committer_id

        self.no_race_check = no_race_check

        # Directories we create on the branch, and their ids.
        self.path_ids = {}

        self.bzrbranch = self.db_branch.getBzrBranch()

        self.bzrbranch.lock_write()
        self.is_locked = True
        try:
            self.revision_tree = self.bzrbranch.basis_tree()
            self.transform_preview = TransformPreview(self.revision_tree)
            assert self.transform_preview.find_conflicts() == [], (
                "TransformPreview is not in a consistent state.")
            if not no_race_check:
                last_revision = self.bzrbranch.last_revision()
                if not self._matchingLastMirrored(last_revision):
                    raise StaleLastMirrored(
                        db_branch, get_branch_info(self.bzrbranch))

            self.is_open = True
        except:
            self.unlock()
            raise

        self.files = set()
        self.merge_parents = merge_parents