~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/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:
14
14
# along with this program; if not, write to the Free Software
15
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16
16
 
 
17
from __future__ import absolute_import
 
18
 
17
19
from bzrlib.lazy_import import lazy_import
18
20
lazy_import(globals(), """
19
21
import itertools
20
22
import time
21
23
 
22
24
from bzrlib import (
23
 
    bzrdir,
24
25
    config,
25
26
    controldir,
26
27
    debug,
39
40
""")
40
41
 
41
42
from bzrlib import (
 
43
    bzrdir,
42
44
    errors,
43
45
    registry,
44
46
    symbol_versioning,
78
80
    # being committed to
79
81
    updates_branch = False
80
82
 
81
 
    def __init__(self, repository, parents, config, timestamp=None,
 
83
    def __init__(self, repository, parents, config_stack, timestamp=None,
82
84
                 timezone=None, committer=None, revprops=None,
83
85
                 revision_id=None, lossy=False):
84
86
        """Initiate a CommitBuilder.
93
95
        :param lossy: Whether to discard data that can not be natively
94
96
            represented, when pushing to a foreign VCS 
95
97
        """
96
 
        self._config = config
 
98
        self._config_stack = config_stack
97
99
        self._lossy = lossy
98
100
 
99
101
        if committer is None:
100
 
            self._committer = self._config.username()
 
102
            self._committer = self._config_stack.get('email')
101
103
        elif not isinstance(committer, unicode):
102
104
            self._committer = committer.decode() # throw if non-ascii
103
105
        else:
711
713
    def create_bundle(self, target, base, fileobj, format=None):
712
714
        return serializer.write_bundle(self, target, base, fileobj, format)
713
715
 
714
 
    def get_commit_builder(self, branch, parents, config, timestamp=None,
 
716
    def get_commit_builder(self, branch, parents, config_stack, timestamp=None,
715
717
                           timezone=None, committer=None, revprops=None,
716
718
                           revision_id=None, lossy=False):
717
719
        """Obtain a CommitBuilder for this repository.
718
720
 
719
721
        :param branch: Branch to commit to.
720
722
        :param parents: Revision ids of the parents of the new revision.
721
 
        :param config: Configuration to use.
 
723
        :param config_stack: Configuration stack to use.
722
724
        :param timestamp: Optional timestamp recorded for commit.
723
725
        :param timezone: Optional timezone for timestamp.
724
726
        :param committer: Optional committer to set for commit.
1291
1293
        """Returns the policy for making working trees on new branches."""
1292
1294
        return not self._transport.has('no-working-trees')
1293
1295
 
 
1296
    @needs_write_lock
 
1297
    def update_feature_flags(self, updated_flags):
 
1298
        """Update the feature flags for this branch.
 
1299
 
 
1300
        :param updated_flags: Dictionary mapping feature names to necessities
 
1301
            A necessity can be None to indicate the feature should be removed
 
1302
        """
 
1303
        self._format._update_feature_flags(updated_flags)
 
1304
        self.control_transport.put_bytes('format', self._format.as_string())
 
1305
 
1294
1306
 
1295
1307
class RepositoryFormatRegistry(controldir.ControlComponentFormatRegistry):
1296
1308
    """Repository format registry."""
1495
1507
            hook(params)
1496
1508
 
1497
1509
 
1498
 
class RepositoryFormatMetaDir(bzrdir.BzrDirMetaComponentFormat, RepositoryFormat):
 
1510
class RepositoryFormatMetaDir(bzrdir.BzrFormat, RepositoryFormat):
1499
1511
    """Common base class for the new repositories using the metadir layout."""
1500
1512
 
1501
1513
    rich_root_data = False
1512
1524
 
1513
1525
    def __init__(self):
1514
1526
        RepositoryFormat.__init__(self)
1515
 
        bzrdir.BzrDirMetaComponentFormat.__init__(self)
 
1527
        bzrdir.BzrFormat.__init__(self)
1516
1528
 
1517
1529
    def _create_control_files(self, a_bzrdir):
1518
1530
        """Create the required files and the initial control_files object."""
1557
1569
            raise errors.NoRepositoryPresent(a_bzrdir)
1558
1570
        return klass._find_format(format_registry, 'repository', format_string)
1559
1571
 
 
1572
    def check_support_status(self, allow_unsupported, recommend_upgrade=True,
 
1573
            basedir=None):
 
1574
        RepositoryFormat.check_support_status(self,
 
1575
            allow_unsupported=allow_unsupported, recommend_upgrade=recommend_upgrade,
 
1576
            basedir=basedir)
 
1577
        bzrdir.BzrFormat.check_support_status(self, allow_unsupported=allow_unsupported,
 
1578
            recommend_upgrade=recommend_upgrade, basedir=basedir)
 
1579
 
1560
1580
 
1561
1581
# formats which have no format string are not discoverable or independently
1562
1582
# creatable on disk, so are not registered in format_registry.  They're