~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/vf_repository.py

  • Committer: Jelmer Vernooij
  • Date: 2012-01-06 22:44:57 UTC
  • mfrom: (6436 +trunk)
  • mto: (6437.3.11 2.5)
  • mto: This revision was merged to the branch mainline in revision 6444.
  • Revision ID: jelmer@samba.org-20120106224457-re0pcy0fz31xob77
Merge bzr.dev.

Show diffs side-by-side

added added

removed removed

Lines of Context:
16
16
 
17
17
"""Repository formats built around versioned files."""
18
18
 
 
19
from __future__ import absolute_import
 
20
 
19
21
 
20
22
from bzrlib.lazy_import import lazy_import
21
23
lazy_import(globals(), """
23
25
 
24
26
from bzrlib import (
25
27
    check,
 
28
    config as _mod_config,
26
29
    debug,
27
30
    fetch as _mod_fetch,
28
31
    fifo_cache,
106
109
    # the default CommitBuilder does not manage trees whose root is versioned.
107
110
    _versioned_root = False
108
111
 
109
 
    def __init__(self, repository, parents, config, timestamp=None,
 
112
    def __init__(self, repository, parents, config_stack, timestamp=None,
110
113
                 timezone=None, committer=None, revprops=None,
111
114
                 revision_id=None, lossy=False):
112
115
        super(VersionedFileCommitBuilder, self).__init__(repository,
113
 
            parents, config, timestamp, timezone, committer, revprops,
 
116
            parents, config_stack, timestamp, timezone, committer, revprops,
114
117
            revision_id, lossy)
115
118
        try:
116
119
            basis_id = self.parents[0]
197
200
                       revision_id=self._new_revision_id,
198
201
                       properties=self._revprops)
199
202
        rev.parent_ids = self.parents
200
 
        self.repository.add_revision(self._new_revision_id, rev,
201
 
            self.new_inventory, self._config)
 
203
        if self._config_stack.get('create_signatures') == _mod_config.SIGN_ALWAYS:
 
204
            testament = Testament(rev, self.revision_tree())
 
205
            plaintext = testament.as_short_text()
 
206
            self.repository.store_revision_signature(
 
207
                gpg.GPGStrategy(self._config_stack), plaintext,
 
208
                self._new_revision_id)
 
209
        self.repository._add_revision(rev)
202
210
        self._ensure_fallback_inventories()
203
211
        self.repository.commit_write_group()
204
212
        return self._new_revision_id
1030
1038
        self.inventories._access.flush()
1031
1039
        return result
1032
1040
 
1033
 
    def add_revision(self, revision_id, rev, inv=None, config=None):
 
1041
    def add_revision(self, revision_id, rev, inv=None):
1034
1042
        """Add rev to the revision store as revision_id.
1035
1043
 
1036
1044
        :param revision_id: the revision id to use.
1037
1045
        :param rev: The revision object.
1038
1046
        :param inv: The inventory for the revision. if None, it will be looked
1039
1047
                    up in the inventory storer
1040
 
        :param config: If None no digital signature will be created.
1041
 
                       If supplied its signature_needed method will be used
1042
 
                       to determine if a signature should be made.
1043
1048
        """
1044
1049
        # TODO: jam 20070210 Shouldn't we check rev.revision_id and
1045
1050
        #       rev.parent_ids?
1046
1051
        _mod_revision.check_not_reserved_id(revision_id)
1047
 
        if config is not None and config.signature_needed():
1048
 
            if inv is None:
1049
 
                inv = self.get_inventory(revision_id)
1050
 
            tree = InventoryRevisionTree(self, inv, revision_id)
1051
 
            testament = Testament(rev, tree)
1052
 
            plaintext = testament.as_short_text()
1053
 
            self.store_revision_signature(
1054
 
                gpg.GPGStrategy(config), plaintext, revision_id)
1055
1052
        # check inventory present
1056
1053
        if not self.inventories.get_parent_map([(revision_id,)]):
1057
1054
            if inv is None:
1283
1280
            # result['size'] = t
1284
1281
        return result
1285
1282
 
1286
 
    def get_commit_builder(self, branch, parents, config, timestamp=None,
 
1283
    def get_commit_builder(self, branch, parents, config_stack, timestamp=None,
1287
1284
                           timezone=None, committer=None, revprops=None,
1288
1285
                           revision_id=None, lossy=False):
1289
1286
        """Obtain a CommitBuilder for this repository.
1290
1287
 
1291
1288
        :param branch: Branch to commit to.
1292
1289
        :param parents: Revision ids of the parents of the new revision.
1293
 
        :param config: Configuration to use.
 
1290
        :param config_stack: Configuration stack to use.
1294
1291
        :param timestamp: Optional timestamp recorded for commit.
1295
1292
        :param timezone: Optional timezone for timestamp.
1296
1293
        :param committer: Optional committer to set for commit.
1303
1300
            raise errors.BzrError("Cannot commit directly to a stacked branch"
1304
1301
                " in pre-2a formats. See "
1305
1302
                "https://bugs.launchpad.net/bzr/+bug/375013 for details.")
1306
 
        result = self._commit_builder_class(self, parents, config,
 
1303
        result = self._commit_builder_class(self, parents, config_stack,
1307
1304
            timestamp, timezone, committer, revprops, revision_id,
1308
1305
            lossy)
1309
1306
        self.start_write_group()