856
856
raise NotImplementedError(self.pull)
858
def push(self, target, overwrite=False, stop_revision=None):
858
def push(self, target, overwrite=False, stop_revision=None, *args,
859
860
"""Mirror this branch into target.
861
862
This branch is considered to be 'local', having low latency.
863
raise NotImplementedError(self.push)
864
return InterBranch.get(self, target).push(overwrite, stop_revision,
865
867
def basis_tree(self):
866
868
"""Return `Tree` object for last revision."""
2232
def push(self, target, overwrite=False, stop_revision=None,
2233
_override_hook_source_branch=None):
2236
This is the basic concrete implementation of push()
2238
:param _override_hook_source_branch: If specified, run
2239
the hooks passing this Branch as the source, rather than self.
2240
This is for use of RemoteBranch, where push is delegated to the
2241
underlying vfs-based Branch.
2243
# TODO: Public option to disable running hooks - should be trivial but
2245
return _run_with_write_locked_target(
2246
target, self._push_with_bound_branches, target, overwrite,
2248
_override_hook_source_branch=_override_hook_source_branch)
2250
def _push_with_bound_branches(self, target, overwrite,
2252
_override_hook_source_branch=None):
2253
"""Push from self into target, and into target's master if any.
2255
This is on the base BzrBranch class even though it doesn't support
2256
bound branches because the *target* might be bound.
2259
if _override_hook_source_branch:
2260
result.source_branch = _override_hook_source_branch
2261
for hook in Branch.hooks['post_push']:
2264
bound_location = target.get_bound_location()
2265
if bound_location and target.base != bound_location:
2266
# there is a master branch.
2268
# XXX: Why the second check? Is it even supported for a branch to
2269
# be bound to itself? -- mbp 20070507
2270
master_branch = target.get_master_branch()
2271
master_branch.lock_write()
2273
# push into the master from this branch.
2274
self._basic_push(master_branch, overwrite, stop_revision)
2275
# and push into the target branch from this. Note that we push from
2276
# this branch again, because its considered the highest bandwidth
2278
result = self._basic_push(target, overwrite, stop_revision)
2279
result.master_branch = master_branch
2280
result.local_branch = target
2284
master_branch.unlock()
2287
result = self._basic_push(target, overwrite, stop_revision)
2288
# TODO: Why set master_branch and local_branch if there's no
2289
# binding? Maybe cleaner to just leave them unset? -- mbp
2291
result.master_branch = target
2292
result.local_branch = None
2296
2233
def _basic_push(self, target, overwrite, stop_revision):
2297
2234
"""Basic implementation of push without bound branches or hooks.
2299
Must be called with self read locked and target write locked.
2236
Must be called with source read locked and target write locked.
2301
2238
result = BranchPushResult()
2302
2239
result.source_branch = self
2307
2244
# We assume that during 'push' this repository is closer than
2309
2246
graph = self.repository.get_graph(target.repository)
2310
target.update_revisions(self, stop_revision, overwrite=overwrite,
2247
target.update_revisions(self, stop_revision,
2248
overwrite=overwrite, graph=graph)
2312
2249
if self._push_should_merge_tags():
2313
result.tag_conflicts = self.tags.merge_to(target.tags, overwrite)
2250
result.tag_conflicts = self.tags.merge_to(target.tags,
2314
2252
result.new_revno, result.new_revid = target.last_revision_info()
3017
2955
raise NotImplementedError(self.update_revisions)
2957
def push(self, overwrite=False, stop_revision=None,
2958
_override_hook_source_branch=None):
2959
"""Mirror the source branch into the target branch.
2961
The source branch is considered to be 'local', having low latency.
2963
raise NotImplementedError(self.push)
3020
2966
class GenericInterBranch(InterBranch):
3021
2967
"""InterBranch implementation that uses public Branch functions.
3069
3015
self.source.unlock()
3017
def push(self, overwrite=False, stop_revision=None,
3018
_override_hook_source_branch=None):
3019
"""See InterBranch.push.
3021
This is the basic concrete implementation of push()
3023
:param _override_hook_source_branch: If specified, run
3024
the hooks passing this Branch as the source, rather than self.
3025
This is for use of RemoteBranch, where push is delegated to the
3026
underlying vfs-based Branch.
3028
# TODO: Public option to disable running hooks - should be trivial but
3030
self.source.lock_read()
3032
return _run_with_write_locked_target(
3033
self.target, self._push_with_bound_branches, overwrite,
3035
_override_hook_source_branch=_override_hook_source_branch)
3037
self.source.unlock()
3039
def _push_with_bound_branches(self, overwrite, stop_revision,
3040
_override_hook_source_branch=None):
3041
"""Push from source into target, and into target's master if any.
3044
if _override_hook_source_branch:
3045
result.source_branch = _override_hook_source_branch
3046
for hook in Branch.hooks['post_push']:
3049
bound_location = self.target.get_bound_location()
3050
if bound_location and self.target.base != bound_location:
3051
# there is a master branch.
3053
# XXX: Why the second check? Is it even supported for a branch to
3054
# be bound to itself? -- mbp 20070507
3055
master_branch = self.target.get_master_branch()
3056
master_branch.lock_write()
3058
# push into the master from the source branch.
3059
self.source._basic_push(master_branch, overwrite, stop_revision)
3060
# and push into the target branch from the source. Note that we
3061
# push from the source branch again, because its considered the
3062
# highest bandwidth repository.
3063
result = self.source._basic_push(self.target, overwrite,
3065
result.master_branch = master_branch
3066
result.local_branch = self.target
3070
master_branch.unlock()
3073
result = self.source._basic_push(self.target, overwrite,
3075
# TODO: Why set master_branch and local_branch if there's no
3076
# binding? Maybe cleaner to just leave them unset? -- mbp
3078
result.master_branch = self.target
3079
result.local_branch = None
3072
3084
def is_compatible(self, source, target):
3073
3085
# GenericBranch uses the public API, so always compatible