94
105
self._last_revision_info_cache = None
95
106
self._master_branch_cache = None
96
107
self._merge_sorted_revisions_cache = None
108
self._open_hook(possible_transports)
98
109
hooks = Branch.hooks['open']
99
110
for hook in hooks:
102
def _open_hook(self):
113
def _open_hook(self, possible_transports):
103
114
"""Called by init to allow simpler extension of the base class."""
105
def _activate_fallback_location(self, url):
116
def _activate_fallback_location(self, url, possible_transports):
106
117
"""Activate the branch/repository from url as a fallback repository."""
107
118
for existing_fallback_repo in self.repository._fallback_repositories:
108
119
if existing_fallback_repo.user_url == url:
109
120
# This fallback is already configured. This probably only
110
# happens because BzrDir.sprout is a horrible mess. To avoid
121
# happens because ControlDir.sprout is a horrible mess. To avoid
111
122
# confusing _unstack we don't add this a second time.
112
123
mutter('duplicate activation of fallback %r on %r', url, self)
114
repo = self._get_fallback_repository(url)
125
repo = self._get_fallback_repository(url, possible_transports)
115
126
if repo.has_same_location(self.repository):
116
127
raise errors.UnstackableLocationError(self.user_url, url)
117
128
self.repository.add_fallback_repository(repo)
171
182
For instance, if the branch is at URL/.bzr/branch,
172
183
Branch.open(URL) -> a Branch instance.
174
control = bzrdir.BzrDir.open(base, _unsupported,
175
possible_transports=possible_transports)
176
return control.open_branch(unsupported=_unsupported)
185
control = controldir.ControlDir.open(base,
186
possible_transports=possible_transports, _unsupported=_unsupported)
187
return control.open_branch(unsupported=_unsupported,
188
possible_transports=possible_transports)
179
def open_from_transport(transport, name=None, _unsupported=False):
191
def open_from_transport(transport, name=None, _unsupported=False,
192
possible_transports=None):
180
193
"""Open the branch rooted at transport"""
181
control = bzrdir.BzrDir.open_from_transport(transport, _unsupported)
182
return control.open_branch(name=name, unsupported=_unsupported)
194
control = controldir.ControlDir.open_from_transport(transport, _unsupported)
195
return control.open_branch(name=name, unsupported=_unsupported,
196
possible_transports=possible_transports)
185
199
def open_containing(url, possible_transports=None):
238
253
raise NotImplementedError(self._get_config)
240
def _get_fallback_repository(self, url):
255
def store_uncommitted(self, creator, message=None):
256
"""Store uncommitted changes from a ShelfCreator.
258
:param creator: The ShelfCreator containing uncommitted changes, or
259
None to delete any stored changes.
260
:param message: The message to associate with the changes.
261
:raises: ChangesAlreadyStored if the branch already has changes.
263
raise NotImplementedError(self.store_uncommitted)
265
def get_unshelver(self, tree):
266
"""Return a shelf.Unshelver for this branch and tree.
268
:param tree: The tree to use to construct the Unshelver.
269
:return: an Unshelver or None if no changes are stored.
271
raise NotImplementedError(self.get_unshelver)
273
def _get_fallback_repository(self, url, possible_transports):
241
274
"""Get the repository we fallback to at url."""
242
275
url = urlutils.join(self.base, url)
243
a_branch = Branch.open(url,
244
possible_transports=[self.bzrdir.root_transport])
276
a_branch = Branch.open(url, possible_transports=possible_transports)
245
277
return a_branch.repository
757
785
"""Print `file` to stdout."""
758
786
raise NotImplementedError(self.print_file)
760
@deprecated_method(deprecated_in((2, 4, 0)))
761
def set_revision_history(self, rev_history):
762
"""See Branch.set_revision_history."""
763
self._set_revision_history(rev_history)
766
def _set_revision_history(self, rev_history):
767
if len(rev_history) == 0:
768
revid = _mod_revision.NULL_REVISION
770
revid = rev_history[-1]
771
if rev_history != self._lefthand_history(revid):
772
raise errors.NotLefthandHistory(rev_history)
773
self.set_last_revision_info(len(rev_history), revid)
774
self._cache_revision_history(rev_history)
775
for hook in Branch.hooks['set_rh']:
776
hook(self, rev_history)
778
788
@needs_write_lock
779
789
def set_last_revision_info(self, revno, revision_id):
780
790
"""Set the last revision of this branch.
1047
1053
def _read_last_revision_info(self):
1048
1054
raise NotImplementedError(self._read_last_revision_info)
1050
@deprecated_method(deprecated_in((2, 4, 0)))
1051
def import_last_revision_info(self, source_repo, revno, revid):
1052
"""Set the last revision info, importing from another repo if necessary.
1054
:param source_repo: Source repository to optionally fetch from
1055
:param revno: Revision number of the new tip
1056
:param revid: Revision id of the new tip
1058
if not self.repository.has_same_location(source_repo):
1059
self.repository.fetch(source_repo, revision_id=revid)
1060
self.set_last_revision_info(revno, revid)
1062
1056
def import_last_revision_info_and_tags(self, source, revno, revid,
1064
1058
"""Set the last revision info, importing from another repo if necessary.
1155
1149
def _set_config_location(self, name, url, config=None,
1156
1150
make_relative=False):
1157
1151
if config is None:
1158
config = self.get_config()
1152
config = self.get_config_stack()
1159
1153
if url is None:
1161
1155
elif make_relative:
1162
1156
url = urlutils.relative_url(self.base, url)
1163
config.set_user_option(name, url, warn_masked=True)
1157
config.set(name, url)
1165
1159
def _get_config_location(self, name, config=None):
1166
1160
if config is None:
1167
config = self.get_config()
1168
location = config.get_user_option(name)
1161
config = self.get_config_stack()
1162
location = config.get(name)
1169
1163
if location == '':
1170
1164
location = None
1171
1165
return location
1173
1167
def get_child_submit_format(self):
1174
1168
"""Return the preferred format of submissions to this branch."""
1175
return self.get_config().get_user_option("child_submit_format")
1169
return self.get_config_stack().get('child_submit_format')
1177
1171
def get_submit_branch(self):
1178
1172
"""Return the submit location of the branch.
1444
1436
t = transport.get_transport(to_location)
1445
1437
t.ensure_base()
1446
1438
format = self._get_checkout_format(lightweight=lightweight)
1440
checkout = format.initialize_on_transport(t)
1441
except errors.AlreadyControlDirError:
1442
# It's fine if the control directory already exists,
1443
# as long as there is no existing branch and working tree.
1444
checkout = controldir.ControlDir.open_from_transport(t)
1446
checkout.open_branch()
1447
except errors.NotBranchError:
1450
raise errors.AlreadyControlDirError(t.base)
1451
if checkout.control_transport.base == self.bzrdir.control_transport.base:
1452
# When checking out to the same control directory,
1453
# always create a lightweight checkout
1447
1456
if lightweight:
1448
checkout = format.initialize_on_transport(t)
1449
from_branch = BranchReferenceFormat().initialize(checkout,
1457
from_branch = checkout.set_branch_reference(target_branch=self)
1452
checkout_branch = bzrdir.BzrDir.create_branch_convenience(
1453
to_location, force_new_tree=False, format=format)
1454
checkout = checkout_branch.bzrdir
1459
policy = checkout.determine_repository_policy()
1460
repo = policy.acquire_repository()[0]
1461
checkout_branch = checkout.create_branch()
1455
1462
checkout_branch.bind(self)
1456
1463
# pull up to the specified revision_id to set the initial
1457
1464
# branch tip correctly, and seed it with history.
1458
1465
checkout_branch.pull(self, stop_revision=revision_id)
1460
1467
tree = checkout.create_workingtree(revision_id,
1461
1468
from_branch=from_branch,
1462
1469
accelerator_tree=accelerator_tree,
1592
1596
def __ne__(self, other):
1593
1597
return not (self == other)
1596
def find_format(klass, a_bzrdir, name=None):
1597
"""Return the format for the branch object in a_bzrdir."""
1599
transport = a_bzrdir.get_branch_transport(None, name=name)
1600
format_string = transport.get_bytes("format")
1601
return format_registry.get(format_string)
1602
except errors.NoSuchFile:
1603
raise errors.NotBranchError(path=transport.base, bzrdir=a_bzrdir)
1605
raise errors.UnknownFormatError(format=format_string, kind='branch')
1608
@deprecated_method(deprecated_in((2, 4, 0)))
1609
def get_default_format(klass):
1610
"""Return the current default format."""
1611
return format_registry.get_default()
1614
@deprecated_method(deprecated_in((2, 4, 0)))
1615
def get_formats(klass):
1616
"""Get all the known formats.
1618
Warning: This triggers a load of all lazy registered formats: do not
1619
use except when that is desireed.
1621
return format_registry._get_all()
1623
def get_reference(self, a_bzrdir, name=None):
1624
"""Get the target reference of the branch in a_bzrdir.
1599
def get_reference(self, controldir, name=None):
1600
"""Get the target reference of the branch in controldir.
1626
1602
format probing must have been completed before calling
1627
1603
this method - it is assumed that the format of the branch
1628
in a_bzrdir is correct.
1604
in controldir is correct.
1630
:param a_bzrdir: The bzrdir to get the branch data from.
1606
:param controldir: The controldir to get the branch data from.
1631
1607
:param name: Name of the colocated branch to fetch
1632
1608
:return: None if the branch is not a reference branch.
1637
def set_reference(self, a_bzrdir, name, to_branch):
1638
"""Set the target reference of the branch in a_bzrdir.
1613
def set_reference(self, controldir, name, to_branch):
1614
"""Set the target reference of the branch in controldir.
1640
1616
format probing must have been completed before calling
1641
1617
this method - it is assumed that the format of the branch
1642
in a_bzrdir is correct.
1618
in controldir is correct.
1644
:param a_bzrdir: The bzrdir to set the branch reference for.
1620
:param controldir: The controldir to set the branch reference for.
1645
1621
:param name: Name of colocated branch to set, None for default
1646
1622
:param to_branch: branch that the checkout is to reference
1648
1624
raise NotImplementedError(self.set_reference)
1650
def get_format_string(self):
1651
"""Return the ASCII format string that identifies this format."""
1652
raise NotImplementedError(self.get_format_string)
1654
1626
def get_format_description(self):
1655
1627
"""Return the short format description for this format."""
1656
1628
raise NotImplementedError(self.get_format_description)
1658
def _run_post_branch_init_hooks(self, a_bzrdir, name, branch):
1630
def _run_post_branch_init_hooks(self, controldir, name, branch):
1659
1631
hooks = Branch.hooks['post_branch_init']
1662
params = BranchInitHookParams(self, a_bzrdir, name, branch)
1634
params = BranchInitHookParams(self, controldir, name, branch)
1663
1635
for hook in hooks:
1666
def initialize(self, a_bzrdir, name=None, repository=None,
1638
def initialize(self, controldir, name=None, repository=None,
1667
1639
append_revisions_only=None):
1668
"""Create a branch of this format in a_bzrdir.
1640
"""Create a branch of this format in controldir.
1670
1642
:param name: Name of the colocated branch to create.
1672
1644
raise NotImplementedError(self.initialize)
2001
1947
self.revision_id)
2004
class BranchFormatMetadir(BranchFormat):
2005
"""Common logic for meta-dir based branch formats."""
1950
class BranchFormatMetadir(bzrdir.BzrFormat, BranchFormat):
1951
"""Base class for branch formats that live in meta directories.
1955
BranchFormat.__init__(self)
1956
bzrdir.BzrFormat.__init__(self)
1959
def find_format(klass, controldir, name=None):
1960
"""Return the format for the branch object in controldir."""
1962
transport = controldir.get_branch_transport(None, name=name)
1963
except errors.NoSuchFile:
1964
raise errors.NotBranchError(path=name, bzrdir=controldir)
1966
format_string = transport.get_bytes("format")
1967
except errors.NoSuchFile:
1968
raise errors.NotBranchError(path=transport.base, bzrdir=controldir)
1969
return klass._find_format(format_registry, 'branch', format_string)
2007
1971
def _branch_class(self):
2008
1972
"""What class to instantiate on open calls."""
2086
2049
def supports_leaving_lock(self):
2090
class BzrBranchFormat5(BranchFormatMetadir):
2091
"""Bzr branch format 5.
2094
- a revision-history file.
2096
- a lock dir guarding the branch itself
2097
- all of this stored in a branch/ subdirectory
2098
- works with shared repositories.
2100
This format is new in bzr 0.8.
2103
def _branch_class(self):
2106
def get_format_string(self):
2107
"""See BranchFormat.get_format_string()."""
2108
return "Bazaar-NG branch format 5\n"
2110
def get_format_description(self):
2111
"""See BranchFormat.get_format_description()."""
2112
return "Branch format 5"
2114
def initialize(self, a_bzrdir, name=None, repository=None,
2115
append_revisions_only=None):
2116
"""Create a branch of this format in a_bzrdir."""
2117
if append_revisions_only:
2118
raise errors.UpgradeRequired(a_bzrdir.user_url)
2119
utf8_files = [('revision-history', ''),
2120
('branch-name', ''),
2122
return self._initialize_helper(a_bzrdir, utf8_files, name, repository)
2124
def supports_tags(self):
2052
def check_support_status(self, allow_unsupported, recommend_upgrade=True,
2054
BranchFormat.check_support_status(self,
2055
allow_unsupported=allow_unsupported, recommend_upgrade=recommend_upgrade,
2057
bzrdir.BzrFormat.check_support_status(self, allow_unsupported=allow_unsupported,
2058
recommend_upgrade=recommend_upgrade, basedir=basedir)
2128
2061
class BzrBranchFormat6(BranchFormatMetadir):
2285
2222
mutter('creating branch reference in %s', a_bzrdir.user_url)
2286
2223
if a_bzrdir._format.fixed_components:
2287
2224
raise errors.IncompatibleFormat(self, a_bzrdir._format)
2226
name = a_bzrdir._get_selected_branch()
2288
2227
branch_transport = a_bzrdir.get_branch_transport(self, name=name)
2289
2228
branch_transport.put_bytes('location',
2290
target_branch.bzrdir.user_url)
2291
branch_transport.put_bytes('format', self.get_format_string())
2293
a_bzrdir, name, _found=True,
2229
target_branch.user_url)
2230
branch_transport.put_bytes('format', self.as_string())
2231
branch = self.open(a_bzrdir, name, _found=True,
2294
2232
possible_transports=[target_branch.bzrdir.root_transport])
2295
2233
self._run_post_branch_init_hooks(a_bzrdir, name, branch)
2299
super(BranchReferenceFormat, self).__init__()
2300
self._matchingbzrdir = bzrdir.BzrDirMetaFormat1()
2301
self._matchingbzrdir.set_branch_format(self)
2303
2236
def _make_reference_clone_function(format, a_branch):
2304
2237
"""Create a clone() routine for a branch dynamically."""
2305
2238
def clone(to_bzrdir, revision_id=None,
2328
2261
:param possible_transports: An optional reusable transports list.
2264
name = a_bzrdir._get_selected_branch()
2331
format = BranchFormat.find_format(a_bzrdir, name=name)
2266
format = BranchFormatMetadir.find_format(a_bzrdir, name=name)
2332
2267
if format.__class__ != self.__class__:
2333
2268
raise AssertionError("wrong format %r found for %r" %
2334
2269
(format, self))
2335
2270
if location is None:
2336
2271
location = self.get_reference(a_bzrdir, name)
2337
real_bzrdir = bzrdir.BzrDir.open(
2272
real_bzrdir = controldir.ControlDir.open(
2338
2273
location, possible_transports=possible_transports)
2339
result = real_bzrdir.open_branch(name=name,
2340
ignore_fallbacks=ignore_fallbacks)
2274
result = real_bzrdir.open_branch(ignore_fallbacks=ignore_fallbacks,
2275
possible_transports=possible_transports)
2341
2276
# this changes the behaviour of result.clone to create a new reference
2342
2277
# rather than a copy of the content of the branch.
2343
2278
# I did not use a proxy object because that needs much more extensive
2425
2360
def __init__(self, _format=None,
2426
2361
_control_files=None, a_bzrdir=None, name=None,
2427
_repository=None, ignore_fallbacks=False):
2362
_repository=None, ignore_fallbacks=False,
2363
possible_transports=None):
2428
2364
"""Create new branch object at a particular location."""
2429
2365
if a_bzrdir is None:
2430
2366
raise ValueError('a_bzrdir must be supplied')
2432
self.bzrdir = a_bzrdir
2433
self._base = self.bzrdir.transport.clone('..').base
2368
raise ValueError('name must be supplied')
2369
self.bzrdir = a_bzrdir
2370
self._user_transport = self.bzrdir.transport.clone('..')
2372
self._user_transport.set_segment_parameter(
2373
"branch", urlutils.escape(name))
2374
self._base = self._user_transport.base
2434
2375
self.name = name
2435
# XXX: We should be able to just do
2436
# self.base = self.bzrdir.root_transport.base
2437
# but this does not quite work yet -- mbp 20080522
2438
2376
self._format = _format
2439
2377
if _control_files is None:
2440
2378
raise ValueError('BzrBranch _control_files is None')
2441
2379
self.control_files = _control_files
2442
2380
self._transport = _control_files._transport
2443
2381
self.repository = _repository
2444
Branch.__init__(self)
2382
self.conf_store = None
2383
Branch.__init__(self, possible_transports)
2446
2385
def __str__(self):
2447
if self.name is None:
2448
return '%s(%s)' % (self.__class__.__name__, self.user_url)
2450
return '%s(%s,%s)' % (self.__class__.__name__, self.user_url,
2386
return '%s(%s)' % (self.__class__.__name__, self.user_url)
2453
2388
__repr__ = __str__
2459
2394
base = property(_get_base, doc="The URL for the root of this branch.")
2397
def user_transport(self):
2398
return self._user_transport
2461
2400
def _get_config(self):
2462
2401
return _mod_config.TransportConfig(self._transport, 'branch.conf')
2403
def _get_config_store(self):
2404
if self.conf_store is None:
2405
self.conf_store = _mod_config.BranchStore(self)
2406
return self.conf_store
2408
def _uncommitted_branch(self):
2409
"""Return the branch that may contain uncommitted changes."""
2410
master = self.get_master_branch()
2411
if master is not None:
2416
def store_uncommitted(self, creator, message=None):
2417
"""Store uncommitted changes from a ShelfCreator.
2419
:param creator: The ShelfCreator containing uncommitted changes, or
2420
None to delete any stored changes.
2421
:param message: The message to associate with the changes.
2422
:raises: ChangesAlreadyStored if the branch already has changes.
2424
branch = self._uncommitted_branch()
2426
branch._transport.delete('stored-transform')
2428
if branch._transport.has('stored-transform'):
2429
raise errors.ChangesAlreadyStored
2430
transform = StringIO()
2431
creator.write_shelf(transform, message)
2433
branch._transport.put_file('stored-transform', transform)
2435
def get_unshelver(self, tree):
2436
"""Return a shelf.Unshelver for this branch and tree.
2438
:param tree: The tree to use to construct the Unshelver.
2439
:return: an Unshelver or None if no changes are stored.
2441
branch = self._uncommitted_branch()
2443
transform = branch._transport.get('stored-transform')
2444
except errors.NoSuchFile:
2446
return shelf.Unshelver.from_tree_and_shelf(tree, transform)
2464
2448
def is_locked(self):
2465
2449
return self.control_files.is_locked()
2695
2671
self._transport.put_bytes('last-revision', out_string,
2696
2672
mode=self.bzrdir._get_file_mode())
2699
class FullHistoryBzrBranch(BzrBranch):
2700
"""Bzr branch which contains the full revision history."""
2703
def set_last_revision_info(self, revno, revision_id):
2704
if not revision_id or not isinstance(revision_id, basestring):
2705
raise errors.InvalidRevisionId(revision_id=revision_id, branch=self)
2706
revision_id = _mod_revision.ensure_null(revision_id)
2707
# this old format stores the full history, but this api doesn't
2708
# provide it, so we must generate, and might as well check it's
2710
history = self._lefthand_history(revision_id)
2711
if len(history) != revno:
2712
raise AssertionError('%d != %d' % (len(history), revno))
2713
self._set_revision_history(history)
2715
def _read_last_revision_info(self):
2716
rh = self.revision_history()
2719
return (revno, rh[-1])
2721
return (0, _mod_revision.NULL_REVISION)
2723
@deprecated_method(deprecated_in((2, 4, 0)))
2725
def set_revision_history(self, rev_history):
2726
"""See Branch.set_revision_history."""
2727
self._set_revision_history(rev_history)
2729
def _set_revision_history(self, rev_history):
2730
if 'evil' in debug.debug_flags:
2731
mutter_callsite(3, "set_revision_history scales with history.")
2732
check_not_reserved_id = _mod_revision.check_not_reserved_id
2733
for rev_id in rev_history:
2734
check_not_reserved_id(rev_id)
2735
if Branch.hooks['post_change_branch_tip']:
2736
# Don't calculate the last_revision_info() if there are no hooks
2738
old_revno, old_revid = self.last_revision_info()
2739
if len(rev_history) == 0:
2740
revid = _mod_revision.NULL_REVISION
2742
revid = rev_history[-1]
2743
self._run_pre_change_branch_tip_hooks(len(rev_history), revid)
2744
self._write_revision_history(rev_history)
2745
self._clear_cached_state()
2746
self._cache_revision_history(rev_history)
2747
for hook in Branch.hooks['set_rh']:
2748
hook(self, rev_history)
2749
if Branch.hooks['post_change_branch_tip']:
2750
self._run_post_change_branch_tip_hooks(old_revno, old_revid)
2752
def _write_revision_history(self, history):
2753
"""Factored out of set_revision_history.
2755
This performs the actual writing to disk.
2756
It is intended to be called by set_revision_history."""
2757
self._transport.put_bytes(
2758
'revision-history', '\n'.join(history),
2759
mode=self.bzrdir._get_file_mode())
2761
def _gen_revision_history(self):
2762
history = self._transport.get_bytes('revision-history').split('\n')
2763
if history[-1:] == ['']:
2764
# There shouldn't be a trailing newline, but just in case.
2768
def _synchronize_history(self, destination, revision_id):
2769
if not isinstance(destination, FullHistoryBzrBranch):
2770
super(BzrBranch, self)._synchronize_history(
2771
destination, revision_id)
2773
if revision_id == _mod_revision.NULL_REVISION:
2776
new_history = self.revision_history()
2777
if revision_id is not None and new_history != []:
2779
new_history = new_history[:new_history.index(revision_id) + 1]
2781
rev = self.repository.get_revision(revision_id)
2782
new_history = rev.get_history(self.repository)[1:]
2783
destination._set_revision_history(new_history)
2786
def generate_revision_history(self, revision_id, last_rev=None,
2788
"""Create a new revision history that will finish with revision_id.
2790
:param revision_id: the new tip to use.
2791
:param last_rev: The previous last_revision. If not None, then this
2792
must be a ancestory of revision_id, or DivergedBranches is raised.
2793
:param other_branch: The other branch that DivergedBranches should
2794
raise with respect to.
2675
def update_feature_flags(self, updated_flags):
2676
"""Update the feature flags for this branch.
2678
:param updated_flags: Dictionary mapping feature names to necessities
2679
A necessity can be None to indicate the feature should be removed
2796
self._set_revision_history(self._lefthand_history(revision_id,
2797
last_rev, other_branch))
2800
class BzrBranch5(FullHistoryBzrBranch):
2801
"""A format 5 branch. This supports new features over plain branches.
2803
It has support for a master_branch which is the data for bound branches.
2681
self._format._update_feature_flags(updated_flags)
2682
self.control_transport.put_bytes('format', self._format.as_string())
2807
2685
class BzrBranch8(BzrBranch):
2808
2686
"""A branch that stores tree-reference locations."""
2810
def _open_hook(self):
2688
def _open_hook(self, possible_transports=None):
2811
2689
if self._ignore_fallbacks:
2691
if possible_transports is None:
2692
possible_transports = [self.bzrdir.root_transport]
2814
2694
url = self.get_stacked_on_url()
2815
2695
except (errors.UnstackableRepositoryFormat, errors.NotStacked,
2947
2828
"""See Branch.set_push_location."""
2948
2829
self._master_branch_cache = None
2950
config = self.get_config()
2831
conf = self.get_config_stack()
2951
2832
if location is None:
2952
if config.get_user_option('bound') != 'True':
2833
if not conf.get('bound'):
2955
config.set_user_option('bound', 'False', warn_masked=True)
2836
conf.set('bound', 'False')
2958
2839
self._set_config_location('bound_location', location,
2960
config.set_user_option('bound', 'True', warn_masked=True)
2841
conf.set('bound', 'True')
2963
2844
def _get_bound_location(self, bound):
2964
2845
"""Return the bound location in the config file.
2966
2847
Return None if the bound parameter does not match"""
2967
config = self.get_config()
2968
config_bound = (config.get_user_option('bound') == 'True')
2969
if config_bound != bound:
2848
conf = self.get_config_stack()
2849
if conf.get('bound') != bound:
2971
return self._get_config_location('bound_location', config=config)
2851
return self._get_config_location('bound_location', config=conf)
2973
2853
def get_bound_location(self):
2974
"""See Branch.set_push_location."""
2854
"""See Branch.get_bound_location."""
2975
2855
return self._get_bound_location(True)
2977
2857
def get_old_bound_location(self):
3189
3055
# Copy source data into target
3190
3056
new_branch._write_last_revision_info(*branch.last_revision_info())
3191
new_branch.set_parent(branch.get_parent())
3192
new_branch.set_bound_location(branch.get_bound_location())
3193
new_branch.set_push_location(branch.get_push_location())
3057
new_branch.lock_write()
3059
new_branch.set_parent(branch.get_parent())
3060
new_branch.set_bound_location(branch.get_bound_location())
3061
new_branch.set_push_location(branch.get_push_location())
3195
3065
# New branch has no tags by default
3196
3066
new_branch.tags._set_tag_dict({})
3198
3068
# Copying done; now update target format
3199
3069
new_branch._transport.put_bytes('format',
3200
format.get_format_string(),
3201
3071
mode=new_branch.bzrdir._get_file_mode())
3203
3073
# Clean up old files
3204
3074
new_branch._transport.delete('revision-history')
3206
branch.set_parent(None)
3207
except errors.NoSuchFile:
3209
branch.set_bound_location(None)
3078
branch.set_parent(None)
3079
except errors.NoSuchFile:
3081
branch.set_bound_location(None)
3212
3086
class Converter6to7(object):
3459
3342
result.target_branch = self.target
3460
3343
result.old_revno, result.old_revid = self.target.last_revision_info()
3461
3344
self.source.update_references(self.target)
3345
overwrite = _fix_overwrite_type(overwrite)
3462
3346
if result.old_revid != stop_revision:
3463
3347
# We assume that during 'push' this repository is closer than
3465
3349
graph = self.source.repository.get_graph(self.target.repository)
3466
self._update_revisions(stop_revision, overwrite=overwrite,
3350
self._update_revisions(stop_revision,
3351
overwrite=("history" in overwrite),
3468
3353
if self.source._push_should_merge_tags():
3469
3354
result.tag_updates, result.tag_conflicts = (
3470
self.source.tags.merge_to(self.target.tags, overwrite))
3355
self.source.tags.merge_to(
3356
self.target.tags, "tags" in overwrite))
3471
3357
result.new_revno, result.new_revid = self.target.last_revision_info()
3551
3437
# -- JRV20090506
3552
3438
result.old_revno, result.old_revid = \
3553
3439
self.target.last_revision_info()
3554
self._update_revisions(stop_revision, overwrite=overwrite,
3440
overwrite = _fix_overwrite_type(overwrite)
3441
self._update_revisions(stop_revision,
3442
overwrite=("history" in overwrite),
3556
3444
# TODO: The old revid should be specified when merging tags,
3557
3445
# so a tags implementation that versions tags can only
3558
3446
# pull in the most recent changes. -- JRV20090506
3559
3447
result.tag_updates, result.tag_conflicts = (
3560
self.source.tags.merge_to(self.target.tags, overwrite,
3448
self.source.tags.merge_to(self.target.tags,
3449
"tags" in overwrite,
3561
3450
ignore_master=not merge_tags_to_master))
3562
3451
result.new_revno, result.new_revid = self.target.last_revision_info()
3563
3452
if _hook_master: