1169
1170
def _set_config_location(self, name, url, config=None,
1170
1171
make_relative=False):
1171
1172
if config is None:
1172
config = self.get_config()
1173
config = self.get_config_stack()
1173
1174
if url is None:
1175
1176
elif make_relative:
1176
1177
url = urlutils.relative_url(self.base, url)
1177
config.set_user_option(name, url, warn_masked=True)
1178
config.set(name, url)
1179
1180
def _get_config_location(self, name, config=None):
1180
1181
if config is None:
1181
config = self.get_config()
1182
location = config.get_user_option(name)
1182
config = self.get_config_stack()
1183
location = config.get(name)
1183
1184
if location == '':
1184
1185
location = None
1185
1186
return location
1999
2000
self.revision_id)
2002
class BranchFormatMetadir(bzrdir.BzrDirMetaComponentFormat, BranchFormat):
2003
class BranchFormatMetadir(bzrdir.BzrFormat, BranchFormat):
2003
2004
"""Base class for branch formats that live in meta directories.
2006
2007
def __init__(self):
2007
2008
BranchFormat.__init__(self)
2008
bzrdir.BzrDirMetaComponentFormat.__init__(self)
2009
bzrdir.BzrFormat.__init__(self)
2011
2012
def find_format(klass, controldir, name=None):
2049
2050
control_files.create_lock()
2050
2051
control_files.lock_write()
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):
2101
def check_support_status(self, allow_unsupported, recommend_upgrade=True,
2103
BranchFormat.check_support_status(self,
2104
allow_unsupported=allow_unsupported, recommend_upgrade=recommend_upgrade,
2106
bzrdir.BzrFormat.check_support_status(self, allow_unsupported=allow_unsupported,
2107
recommend_upgrade=recommend_upgrade, basedir=basedir)
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])
2967
2976
"""See Branch.set_push_location."""
2968
2977
self._master_branch_cache = None
2970
config = self.get_config()
2979
conf = self.get_config_stack()
2971
2980
if location is None:
2972
if config.get_user_option('bound') != 'True':
2981
if not conf.get('bound'):
2975
config.set_user_option('bound', 'False', warn_masked=True)
2984
conf.set('bound', 'False')
2978
2987
self._set_config_location('bound_location', location,
2980
config.set_user_option('bound', 'True', warn_masked=True)
2989
conf.set('bound', 'True')
2983
2992
def _get_bound_location(self, bound):
2984
2993
"""Return the bound location in the config file.
2986
2995
Return None if the bound parameter does not match"""
2987
config = self.get_config()
2988
config_bound = (config.get_user_option('bound') == 'True')
2989
if config_bound != bound:
2996
conf = self.get_config_stack()
2997
if conf.get('bound') != bound:
2991
return self._get_config_location('bound_location', config=config)
2999
return self._get_config_location('bound_location', config=conf)
2993
3001
def get_bound_location(self):
2994
3002
"""See Branch.set_push_location."""
3004
3012
## self._check_stackable_repo()
3005
3013
# stacked_on_location is only ever defined in branch.conf, so don't
3006
3014
# waste effort reading the whole stack of config files.
3007
config = self.get_config()._get_branch_data_config()
3015
conf = _mod_config.BranchOnlyStack(self)
3008
3016
stacked_url = self._get_config_location('stacked_on_location',
3010
3018
if stacked_url is None:
3011
3019
raise errors.NotStacked(self)
3012
3020
return stacked_url
3220
3228
# Copying done; now update target format
3221
3229
new_branch._transport.put_bytes('format',
3222
format.get_format_string(),
3223
3231
mode=new_branch.bzrdir._get_file_mode())
3225
3233
# Clean up old files
3238
3246
format = BzrBranchFormat7()
3239
3247
branch._set_config_location('stacked_on_location', '')
3240
3248
# update target format
3241
branch._transport.put_bytes('format', format.get_format_string())
3249
branch._transport.put_bytes('format', format.as_string())
3244
3252
class Converter7to8(object):
3248
3256
format = BzrBranchFormat8()
3249
3257
branch._transport.put_bytes('references', '')
3250
3258
# update target format
3251
branch._transport.put_bytes('format', format.get_format_string())
3259
branch._transport.put_bytes('format', format.as_string())
3254
3262
class InterBranch(InterObject):