1000
1000
# (push_result)
1001
1001
# containing the members
1002
1002
# (source, local, master, old_revno, old_revid, new_revno, new_revid)
1003
# where local is the local branch or None, master is the target
1003
# where local is the local target branch or None, master is the target
1004
1004
# master branch, and the rest should be self explanatory. The source
1005
1005
# is read locked and the target branches write locked. Source will
1006
1006
# be the local low-latency branch.
1477
1477
@needs_write_lock
1478
1478
def pull(self, source, overwrite=False, stop_revision=None,
1479
_hook_master=None, _run_hooks=True):
1479
_hook_master=None, run_hooks=True):
1480
1480
"""See Branch.pull.
1482
1482
:param _hook_master: Private parameter - set the branch to
1483
1483
be supplied as the master to push hooks.
1484
:param _run_hooks: Private parameter - allow disabling of
1485
hooks, used when pushing to a master branch.
1484
:param run_hooks: Private parameter - if false, this branch
1485
is being called because it's the master of the primary branch,
1486
so it should not run its hooks.
1487
1488
result = PullResult()
1488
1489
result.source_branch = source
1526
1527
@needs_read_lock
1527
1528
def push(self, target, overwrite=False, stop_revision=None,
1528
_hook_master=None, _run_hooks=True):
1529
_hook_master=None, run_hooks=True):
1529
1530
"""See Branch.push.
1532
This is the basic concrete implementation of push()
1531
1534
:param _hook_master: Private parameter - set the branch to
1532
1535
be supplied as the master to push hooks.
1533
:param _run_hooks: Private parameter - allow disabling of
1534
hooks, used when pushing to a master branch.
1536
:param run_hooks: Private parameter - if false, this branch
1537
is being called because it's the master of the primary branch,
1538
so it should not run its hooks.
1540
return self._push_with_bound_branches(target, overwrite,
1541
stop_revision, _hook_master, run_hooks)
1543
def _push_with_bound_branches(self, target, overwrite,
1544
stop_revision, _hook_master, run_hooks):
1545
"""Updates branch.push to be bound branch aware
1547
This is on the base BzrBranch class even though it doesn't support
1548
bound branches because the *target* might be bound.
1550
bound_location = target.get_bound_location()
1551
master_branch = None
1552
if bound_location and target.base != bound_location:
1553
# not pushing to master, so we need to update master.
1554
master_branch = target.get_master_branch()
1555
master_branch.lock_write()
1558
# push into the master from this branch.
1559
self._basic_push(master_branch, overwrite, stop_revision,
1560
stop_revision, run_hooks=False)
1561
# and push into the target branch from this. Note that we push from
1562
# this branch again, because its considered the highest bandwidth
1564
return self._basic_push(target, overwrite, stop_revision,
1565
_hook_master=master_branch, run_hooks=run_hooks)
1568
master_branch.unlock()
1570
def _basic_push(self, target, overwrite, stop_revision, _hook_master,
1572
"""Basic implementation of push without considering bound branches."""
1536
1573
result = PushResult()
1537
1574
result.source_branch = self
1538
1575
result.target_branch = target
1635
1672
@needs_write_lock
1636
1673
def pull(self, source, overwrite=False, stop_revision=None,
1638
1675
"""Extends branch.pull to be bound branch aware.
1640
:param _run_hooks: Private parameter used to force hook running
1641
off during bound branch double-pushing.
1677
:param run_hooks: Private parameter - if false, this branch
1678
is being called because it's the master of the primary branch,
1679
so it should not run its hooks.
1643
1681
bound_location = self.get_bound_location()
1644
1682
master_branch = None
1650
1688
if master_branch:
1651
1689
# pull from source into master.
1652
1690
master_branch.pull(source, overwrite, stop_revision,
1654
1692
return super(BzrBranch5, self).pull(source, overwrite,
1655
1693
stop_revision, _hook_master=master_branch,
1656
_run_hooks=_run_hooks)
1659
master_branch.unlock()
1662
def push(self, target, overwrite=False, stop_revision=None):
1663
"""Updates branch.push to be bound branch aware."""
1664
bound_location = target.get_bound_location()
1665
master_branch = None
1666
if bound_location and target.base != bound_location:
1667
# not pushing to master, so we need to update master.
1668
master_branch = target.get_master_branch()
1669
master_branch.lock_write()
1672
# push into the master from this branch.
1673
super(BzrBranch5, self).push(master_branch, overwrite,
1674
stop_revision, _run_hooks=False)
1675
# and push into the target branch from this. Note that we push from
1676
# this branch again, because its considered the highest bandwidth
1678
return super(BzrBranch5, self).push(target, overwrite,
1679
stop_revision, _hook_master=master_branch)
1694
run_hooks=run_hooks)
1681
1696
if master_branch:
1682
1697
master_branch.unlock()