669
669
raise errors.UnsupportedOperation(self.get_reference_info, self)
671
671
@needs_write_lock
672
def fetch(self, from_branch, last_revision=None, fetch_spec=None):
672
def fetch(self, from_branch, last_revision=None):
673
673
"""Copy revisions from from_branch into this branch.
675
675
:param from_branch: Where to copy from.
676
676
:param last_revision: What revision to stop at (None for at the end
678
:param fetch_spec: If specified, a SearchResult or
679
PendingAncestryResult that describes which revisions to copy. This
680
allows copying multiple heads at once. Mutually exclusive with
684
return InterBranch.get(from_branch, self).fetch(last_revision,
680
return InterBranch.get(from_branch, self).fetch(last_revision)
687
682
def get_bound_location(self):
688
683
"""Return the URL of the branch we are bound to.
1000
995
return (0, _mod_revision.NULL_REVISION)
1002
997
def update_revisions(self, other, stop_revision=None, overwrite=False,
1003
graph=None, fetch_tags=True):
1004
999
"""Pull in new perfect-fit revisions.
1006
1001
:param other: Another Branch to pull from
1009
1004
to see if it is a proper descendant.
1010
1005
:param graph: A Graph object that can be used to query history
1011
1006
information. This can be None.
1012
:param fetch_tags: Flag that specifies if tags from other should be
1016
1009
return InterBranch.get(other, self).update_revisions(stop_revision,
1017
overwrite, graph, fetch_tags=fetch_tags)
1019
1012
@deprecated_method(deprecated_in((2, 4, 0)))
1020
1013
def import_last_revision_info(self, source_repo, revno, revid):
1045
1038
(should only be different from the arguments when lossy=True)
1047
1040
if not self.repository.has_same_location(source.repository):
1049
tags_to_fetch = set(source.tags.get_reverse_tag_dict())
1050
except errors.TagsNotSupported:
1051
tags_to_fetch = set()
1052
fetch_spec = _mod_graph.NotInOtherForRevs(self.repository,
1053
source.repository, [revid],
1054
if_present_ids=tags_to_fetch).execute()
1055
self.repository.fetch(source.repository, fetch_spec=fetch_spec)
1041
self.fetch(source, revid)
1056
1042
self.set_last_revision_info(revno, revid)
1057
1043
return (revno, revid)
3303
3289
@needs_write_lock
3304
3290
def update_revisions(self, stop_revision=None, overwrite=False,
3305
graph=None, fetch_tags=True):
3306
3292
"""Pull in new perfect-fit revisions.
3308
3294
:param stop_revision: Updated until the given revision
3310
3296
to see if it is a proper descendant.
3311
3297
:param graph: A Graph object that can be used to query history
3312
3298
information. This can be None.
3313
:param fetch_tags: Flag that specifies if tags from source should be
3317
3301
raise NotImplementedError(self.update_revisions)
3335
3319
raise NotImplementedError(self.copy_content_into)
3337
3321
@needs_write_lock
3338
def fetch(self, stop_revision=None, fetch_spec=None):
3322
def fetch(self, stop_revision=None):
3339
3323
"""Fetch revisions.
3341
3325
:param stop_revision: Last revision to fetch
3342
:param fetch_spec: Fetch spec.
3344
3327
raise NotImplementedError(self.fetch)
3383
3366
self.source.tags.merge_to(self.target.tags)
3385
3368
@needs_write_lock
3386
def fetch(self, stop_revision=None, fetch_spec=None):
3387
if fetch_spec is not None and stop_revision is not None:
3388
raise AssertionError(
3389
"fetch_spec and last_revision are mutually exclusive.")
3369
def fetch(self, stop_revision=None):
3390
3370
if self.target.base == self.source.base:
3392
3372
self.source.lock_read()
3394
if stop_revision is None and fetch_spec is None:
3395
stop_revision = self.source.last_revision()
3396
stop_revision = _mod_revision.ensure_null(stop_revision)
3374
fetch_spec_factory = fetch.FetchSpecFactory()
3375
fetch_spec_factory.source_branch = self.source
3376
fetch_spec_factory.source_branch_stop_revision_id = stop_revision
3377
fetch_spec_factory.source_repo = self.source.repository
3378
fetch_spec_factory.target_repo = self.target.repository
3379
fetch_spec_factory.target_repo_kind = fetch.TargetRepoKinds.PREEXISTING
3380
fetch_spec = fetch_spec_factory.make_fetch_spec()
3397
3381
return self.target.repository.fetch(self.source.repository,
3398
revision_id=stop_revision, fetch_spec=fetch_spec)
3382
fetch_spec=fetch_spec)
3400
3384
self.source.unlock()
3402
3386
@needs_write_lock
3403
3387
def update_revisions(self, stop_revision=None, overwrite=False,
3404
graph=None, fetch_tags=True):
3405
3389
"""See InterBranch.update_revisions()."""
3406
3390
other_revno, other_last_revision = self.source.last_revision_info()
3407
3391
stop_revno = None # unknown
3419
3403
# case of having something to pull, and so that the check for
3420
3404
# already merged can operate on the just fetched graph, which will
3421
3405
# be cached in memory.
3423
fetch_spec_factory = fetch.FetchSpecFactory()
3424
fetch_spec_factory.source_branch = self.source
3425
fetch_spec_factory.source_branch_stop_revision_id = stop_revision
3426
fetch_spec_factory.source_repo = self.source.repository
3427
fetch_spec_factory.target_repo = self.target.repository
3428
fetch_spec_factory.target_repo_kind = fetch.TargetRepoKinds.PREEXISTING
3429
fetch_spec = fetch_spec_factory.make_fetch_spec()
3431
fetch_spec = _mod_graph.NotInOtherForRevs(self.target.repository,
3432
self.source.repository, revision_ids=[stop_revision]).execute()
3433
self.target.fetch(self.source, fetch_spec=fetch_spec)
3406
self.fetch(stop_revision=stop_revision)
3434
3407
# Check to see if one is an ancestor of the other
3435
3408
if not overwrite:
3436
3409
if graph is None: