~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/branch.py

  • Committer: Patch Queue Manager
  • Date: 2011-12-22 18:52:58 UTC
  • mfrom: (6213.1.55 feature-flags)
  • Revision ID: pqm@pqm.ubuntu.com-20111222185258-wgcba8590pbw5sf1
(jelmer) Add support for feature flags in bzr formats. (Jelmer Vernooij)

Show diffs side-by-side

added added

removed removed

Lines of Context:
53
53
import bzrlib.bzrdir
54
54
 
55
55
from bzrlib import (
 
56
    bzrdir,
56
57
    controldir,
57
58
    )
58
59
from bzrlib.decorators import (
1587
1588
 
1588
1589
    Formats provide three things:
1589
1590
     * An initialization routine,
1590
 
     * a format string,
 
1591
     * a format description
1591
1592
     * an open routine.
1592
1593
 
1593
1594
    Formats are placed in an dict by their format string for reference
1999
2000
            self.revision_id)
2000
2001
 
2001
2002
 
2002
 
class BranchFormatMetadir(bzrdir.BzrDirMetaComponentFormat, BranchFormat):
 
2003
class BranchFormatMetadir(bzrdir.BzrFormat, BranchFormat):
2003
2004
    """Base class for branch formats that live in meta directories.
2004
2005
    """
2005
2006
 
2006
2007
    def __init__(self):
2007
2008
        BranchFormat.__init__(self)
2008
 
        bzrdir.BzrDirMetaComponentFormat.__init__(self)
 
2009
        bzrdir.BzrFormat.__init__(self)
2009
2010
 
2010
2011
    @classmethod
2011
2012
    def find_format(klass, controldir, name=None):
2049
2050
        control_files.create_lock()
2050
2051
        control_files.lock_write()
2051
2052
        try:
2052
 
            utf8_files += [('format', self.get_format_string())]
 
2053
            utf8_files += [('format', self.as_string())]
2053
2054
            for (filename, content) in utf8_files:
2054
2055
                branch_transport.put_bytes(
2055
2056
                    filename, content,
2097
2098
    def supports_leaving_lock(self):
2098
2099
        return True
2099
2100
 
 
2101
    def check_support_status(self, allow_unsupported, recommend_upgrade=True,
 
2102
            basedir=None):
 
2103
        BranchFormat.check_support_status(self,
 
2104
            allow_unsupported=allow_unsupported, recommend_upgrade=recommend_upgrade,
 
2105
            basedir=basedir)
 
2106
        bzrdir.BzrFormat.check_support_status(self, allow_unsupported=allow_unsupported,
 
2107
            recommend_upgrade=recommend_upgrade, basedir=basedir)
 
2108
 
2100
2109
 
2101
2110
class BzrBranchFormat5(BranchFormatMetadir):
2102
2111
    """Bzr branch format 5.
2304
2313
        branch_transport = a_bzrdir.get_branch_transport(self, name=name)
2305
2314
        branch_transport.put_bytes('location',
2306
2315
            target_branch.user_url)
2307
 
        branch_transport.put_bytes('format', self.get_format_string())
 
2316
        branch_transport.put_bytes('format', self.as_string())
2308
2317
        branch = self.open(
2309
2318
            a_bzrdir, name, _found=True,
2310
2319
            possible_transports=[target_branch.bzrdir.root_transport])
3218
3227
 
3219
3228
        # Copying done; now update target format
3220
3229
        new_branch._transport.put_bytes('format',
3221
 
            format.get_format_string(),
 
3230
            format.as_string(),
3222
3231
            mode=new_branch.bzrdir._get_file_mode())
3223
3232
 
3224
3233
        # Clean up old files
3237
3246
        format = BzrBranchFormat7()
3238
3247
        branch._set_config_location('stacked_on_location', '')
3239
3248
        # update target format
3240
 
        branch._transport.put_bytes('format', format.get_format_string())
 
3249
        branch._transport.put_bytes('format', format.as_string())
3241
3250
 
3242
3251
 
3243
3252
class Converter7to8(object):
3247
3256
        format = BzrBranchFormat8()
3248
3257
        branch._transport.put_bytes('references', '')
3249
3258
        # update target format
3250
 
        branch._transport.put_bytes('format', format.get_format_string())
 
3259
        branch._transport.put_bytes('format', format.as_string())
3251
3260
 
3252
3261
 
3253
3262
class InterBranch(InterObject):