148
148
def get_config(self):
149
149
return BranchConfig(self)
151
def _get_nick(self, possible_transports=None):
151
def _get_nick(self, local=False, possible_transports=None):
152
152
config = self.get_config()
153
if not config.has_explicit_nickname(): # explicit overrides master
153
# explicit overrides master, but don't look for master if local is True
154
if not local and not config.has_explicit_nickname():
155
156
master = self.get_master_branch(possible_transports)
156
157
if master is not None:
157
158
# return the master branch value
158
config = master.get_config()
159
160
except errors.BzrError, e:
160
161
# Silently fall back to local implicit nick if the master is
709
710
"""Synchronize last revision and revision history between branches.
711
712
This version is most efficient when the destination is also a
712
BzrBranch5, but works for BzrBranch6 as long as the revision
713
history is the true lefthand parent history, and all of the revisions
714
are in the destination's repository. If not, set_revision_history
713
BzrBranch6, but works for BzrBranch5, as long as the destination's
714
repository contains all the lefthand ancestors of the intended
715
last_revision. If not, set_last_revision_info will fail.
717
717
:param destination: The branch to copy the history into
718
718
:param revision_id: The revision-id to truncate history at. May
719
719
be None to copy complete history.
721
if revision_id == _mod_revision.NULL_REVISION:
721
source_revno, source_revision_id = self.last_revision_info()
722
if revision_id is None:
723
revno, revision_id = source_revno, source_revision_id
724
elif source_revision_id == revision_id:
725
# we know the revno without needing to walk all of history
724
new_history = self.revision_history()
725
if revision_id is not None and new_history != []:
727
new_history = new_history[:new_history.index(revision_id) + 1]
729
rev = self.repository.get_revision(revision_id)
730
new_history = rev.get_history(self.repository)[1:]
731
destination.set_revision_history(new_history)
728
# To figure out the revno for a random revision, we need to build
729
# the revision history, and count its length.
730
# We don't care about the order, just how long it is.
731
# Alternatively, we could start at the current location, and count
732
# backwards. But there is no guarantee that we will find it since
733
# it may be a merged revision.
734
revno = len(list(self.repository.iter_reverse_revision_history(
736
destination.set_last_revision_info(revno, revision_id)
734
739
def copy_content_into(self, destination, revision_id=None):
735
740
"""Copy the content of self into destination.
1419
1425
def __init__(self):
1420
1426
super(BranchReferenceFormat, self).__init__()
1421
1427
self._matchingbzrdir = bzrdir.BzrDirMetaFormat1()
1428
self._matchingbzrdir.set_branch_format(self)
1423
1430
def _make_reference_clone_function(format, a_branch):
1424
1431
"""Create a clone() routine for a branch dynamically."""
1594
1601
if Branch.hooks['post_change_branch_tip']:
1595
1602
self._run_post_change_branch_tip_hooks(old_revno, old_revid)
1604
def _synchronize_history(self, destination, revision_id):
1605
"""Synchronize last revision and revision history between branches.
1607
This version is most efficient when the destination is also a
1608
BzrBranch5, but works for BzrBranch6 as long as the revision
1609
history is the true lefthand parent history, and all of the revisions
1610
are in the destination's repository. If not, set_revision_history
1613
:param destination: The branch to copy the history into
1614
:param revision_id: The revision-id to truncate history at. May
1615
be None to copy complete history.
1617
if revision_id == _mod_revision.NULL_REVISION:
1620
new_history = self.revision_history()
1621
if revision_id is not None and new_history != []:
1623
new_history = new_history[:new_history.index(revision_id) + 1]
1625
rev = self.repository.get_revision(revision_id)
1626
new_history = rev.get_history(self.repository)[1:]
1627
destination.set_revision_history(new_history)
1597
1629
def _run_pre_change_branch_tip_hooks(self, new_revno, new_revid):
1598
1630
"""Run the pre_change_branch_tip hooks."""
1599
1631
hooks = Branch.hooks['pre_change_branch_tip']
2098
2130
self._last_revision_info_cache = revno, revision_id
2099
2131
self._run_post_change_branch_tip_hooks(old_revno, old_revid)
2133
def _synchronize_history(self, destination, revision_id):
2134
"""Synchronize last revision and revision history between branches.
2136
:see: Branch._synchronize_history
2138
# XXX: The base Branch has a fast implementation of this method based
2139
# on set_last_revision_info, but BzrBranch/BzrBranch5 have a slower one
2140
# that uses set_revision_history. This class inherits from BzrBranch5,
2141
# but wants the fast implementation, so it calls
2142
# Branch._synchronize_history directly.
2143
Branch._synchronize_history(self, destination, revision_id)
2101
2145
def _check_history_violation(self, revision_id):
2102
2146
last_revision = _mod_revision.ensure_null(self.last_revision())
2103
2147
if _mod_revision.is_null(last_revision):
2252
2296
value = self.get_config().get_user_option('append_revisions_only')
2253
2297
return value == 'True'
2255
def _synchronize_history(self, destination, revision_id):
2256
"""Synchronize last revision and revision history between branches.
2258
This version is most efficient when the destination is also a
2259
BzrBranch6, but works for BzrBranch5, as long as the destination's
2260
repository contains all the lefthand ancestors of the intended
2261
last_revision. If not, set_last_revision_info will fail.
2263
:param destination: The branch to copy the history into
2264
:param revision_id: The revision-id to truncate history at. May
2265
be None to copy complete history.
2267
source_revno, source_revision_id = self.last_revision_info()
2268
if revision_id is None:
2269
revno, revision_id = source_revno, source_revision_id
2270
elif source_revision_id == revision_id:
2271
# we know the revno without needing to walk all of history
2272
revno = source_revno
2274
# To figure out the revno for a random revision, we need to build
2275
# the revision history, and count its length.
2276
# We don't care about the order, just how long it is.
2277
# Alternatively, we could start at the current location, and count
2278
# backwards. But there is no guarantee that we will find it since
2279
# it may be a merged revision.
2280
revno = len(list(self.repository.iter_reverse_revision_history(
2282
destination.set_last_revision_info(revno, revision_id)
2284
2299
def _make_tags(self):
2285
2300
return BasicTags(self)