Rev 5810: (jelmer) Make Branch.fetch() no longer take a fetch_spec (Jelmer Vernooij) in file:///home/pqm/archives/thelove/bzr/%2Btrunk/
Canonical.com Patch Queue Manager
pqm at pqm.ubuntu.com
Thu Apr 28 10:30:21 UTC 2011
At file:///home/pqm/archives/thelove/bzr/%2Btrunk/
------------------------------------------------------------
revno: 5810 [merge]
revision-id: pqm at pqm.ubuntu.com-20110428103012-4mp8o2h32tluszv7
parent: pqm at pqm.ubuntu.com-20110421132208-uc7obchku13062gz
parent: jelmer at samba.org-20110427112214-zgxrm4ezwiaeel2q
committer: Canonical.com Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: +trunk
timestamp: Thu 2011-04-28 10:30:12 +0000
message:
(jelmer) Make Branch.fetch() no longer take a fetch_spec (Jelmer Vernooij)
modified:
bzrlib/branch.py branch.py-20050309040759-e4baf4e0d046576e
bzrlib/merge.py merge.py-20050513021216-953b65a438527106
bzrlib/tests/test_revisionspec.py testrevisionnamespaces.py-20050711050225-8b4af89e6b1efe84
bzrlib/workingtree_4.py workingtree_4.py-20070208044105-5fgpc5j3ljlh5q6c-1
doc/en/release-notes/bzr-2.4.txt bzr2.4.txt-20110114053217-k7ym9jfz243fddjm-1
=== modified file 'bzrlib/branch.py'
--- a/bzrlib/branch.py 2011-04-20 19:32:00 +0000
+++ b/bzrlib/branch.py 2011-04-27 10:55:49 +0000
@@ -669,20 +669,15 @@
raise errors.UnsupportedOperation(self.get_reference_info, self)
@needs_write_lock
- def fetch(self, from_branch, last_revision=None, fetch_spec=None):
+ def fetch(self, from_branch, last_revision=None):
"""Copy revisions from from_branch into this branch.
:param from_branch: Where to copy from.
:param last_revision: What revision to stop at (None for at the end
of the branch.
- :param fetch_spec: If specified, a SearchResult or
- PendingAncestryResult that describes which revisions to copy. This
- allows copying multiple heads at once. Mutually exclusive with
- last_revision.
:return: None
"""
- return InterBranch.get(from_branch, self).fetch(last_revision,
- fetch_spec)
+ return InterBranch.get(from_branch, self).fetch(last_revision)
def get_bound_location(self):
"""Return the URL of the branch we are bound to.
@@ -1000,7 +995,7 @@
return (0, _mod_revision.NULL_REVISION)
def update_revisions(self, other, stop_revision=None, overwrite=False,
- graph=None, fetch_tags=True):
+ graph=None):
"""Pull in new perfect-fit revisions.
:param other: Another Branch to pull from
@@ -1009,12 +1004,10 @@
to see if it is a proper descendant.
:param graph: A Graph object that can be used to query history
information. This can be None.
- :param fetch_tags: Flag that specifies if tags from other should be
- fetched too.
:return: None
"""
return InterBranch.get(other, self).update_revisions(stop_revision,
- overwrite, graph, fetch_tags=fetch_tags)
+ overwrite, graph)
@deprecated_method(deprecated_in((2, 4, 0)))
def import_last_revision_info(self, source_repo, revno, revid):
@@ -1045,14 +1038,7 @@
(should only be different from the arguments when lossy=True)
"""
if not self.repository.has_same_location(source.repository):
- try:
- tags_to_fetch = set(source.tags.get_reverse_tag_dict())
- except errors.TagsNotSupported:
- tags_to_fetch = set()
- fetch_spec = _mod_graph.NotInOtherForRevs(self.repository,
- source.repository, [revid],
- if_present_ids=tags_to_fetch).execute()
- self.repository.fetch(source.repository, fetch_spec=fetch_spec)
+ self.fetch(source, revid)
self.set_last_revision_info(revno, revid)
return (revno, revid)
@@ -3302,7 +3288,7 @@
@needs_write_lock
def update_revisions(self, stop_revision=None, overwrite=False,
- graph=None, fetch_tags=True):
+ graph=None):
"""Pull in new perfect-fit revisions.
:param stop_revision: Updated until the given revision
@@ -3310,8 +3296,6 @@
to see if it is a proper descendant.
:param graph: A Graph object that can be used to query history
information. This can be None.
- :param fetch_tags: Flag that specifies if tags from source should be
- fetched too.
:return: None
"""
raise NotImplementedError(self.update_revisions)
@@ -3335,11 +3319,10 @@
raise NotImplementedError(self.copy_content_into)
@needs_write_lock
- def fetch(self, stop_revision=None, fetch_spec=None):
+ def fetch(self, stop_revision=None):
"""Fetch revisions.
:param stop_revision: Last revision to fetch
- :param fetch_spec: Fetch spec.
"""
raise NotImplementedError(self.fetch)
@@ -3383,25 +3366,26 @@
self.source.tags.merge_to(self.target.tags)
@needs_write_lock
- def fetch(self, stop_revision=None, fetch_spec=None):
- if fetch_spec is not None and stop_revision is not None:
- raise AssertionError(
- "fetch_spec and last_revision are mutually exclusive.")
+ def fetch(self, stop_revision=None):
if self.target.base == self.source.base:
return (0, [])
self.source.lock_read()
try:
- if stop_revision is None and fetch_spec is None:
- stop_revision = self.source.last_revision()
- stop_revision = _mod_revision.ensure_null(stop_revision)
+ fetch_spec_factory = fetch.FetchSpecFactory()
+ fetch_spec_factory.source_branch = self.source
+ fetch_spec_factory.source_branch_stop_revision_id = stop_revision
+ fetch_spec_factory.source_repo = self.source.repository
+ fetch_spec_factory.target_repo = self.target.repository
+ fetch_spec_factory.target_repo_kind = fetch.TargetRepoKinds.PREEXISTING
+ fetch_spec = fetch_spec_factory.make_fetch_spec()
return self.target.repository.fetch(self.source.repository,
- revision_id=stop_revision, fetch_spec=fetch_spec)
+ fetch_spec=fetch_spec)
finally:
self.source.unlock()
@needs_write_lock
def update_revisions(self, stop_revision=None, overwrite=False,
- graph=None, fetch_tags=True):
+ graph=None):
"""See InterBranch.update_revisions()."""
other_revno, other_last_revision = self.source.last_revision_info()
stop_revno = None # unknown
@@ -3419,18 +3403,7 @@
# case of having something to pull, and so that the check for
# already merged can operate on the just fetched graph, which will
# be cached in memory.
- if fetch_tags:
- fetch_spec_factory = fetch.FetchSpecFactory()
- fetch_spec_factory.source_branch = self.source
- fetch_spec_factory.source_branch_stop_revision_id = stop_revision
- fetch_spec_factory.source_repo = self.source.repository
- fetch_spec_factory.target_repo = self.target.repository
- fetch_spec_factory.target_repo_kind = fetch.TargetRepoKinds.PREEXISTING
- fetch_spec = fetch_spec_factory.make_fetch_spec()
- else:
- fetch_spec = _mod_graph.NotInOtherForRevs(self.target.repository,
- self.source.repository, revision_ids=[stop_revision]).execute()
- self.target.fetch(self.source, fetch_spec=fetch_spec)
+ self.fetch(stop_revision=stop_revision)
# Check to see if one is an ancestor of the other
if not overwrite:
if graph is None:
=== modified file 'bzrlib/merge.py'
--- a/bzrlib/merge.py 2011-04-17 23:06:22 +0000
+++ b/bzrlib/merge.py 2011-04-21 00:41:42 +0000
@@ -563,14 +563,7 @@
def _maybe_fetch(self, source, target, revision_id):
if not source.repository.has_same_location(target.repository):
- try:
- tags_to_fetch = set(source.tags.get_reverse_tag_dict())
- except errors.TagsNotSupported:
- tags_to_fetch = None
- fetch_spec = _mod_graph.NotInOtherForRevs(target.repository,
- source.repository, [revision_id],
- if_present_ids=tags_to_fetch).execute()
- target.fetch(source, fetch_spec=fetch_spec)
+ target.fetch(source, revision_id)
def find_base(self):
revisions = [_mod_revision.ensure_null(self.this_basis),
=== modified file 'bzrlib/tests/test_revisionspec.py'
--- a/bzrlib/tests/test_revisionspec.py 2011-04-14 07:53:38 +0000
+++ b/bzrlib/tests/test_revisionspec.py 2011-04-21 00:41:42 +0000
@@ -397,8 +397,7 @@
"""We can get any revision id in the repository"""
# XXX: This may change in the future, but for now, it is true
self.tree2.commit('alt third', rev_id='alt_r3')
- self.tree.branch.repository.fetch(self.tree2.branch.repository,
- revision_id='alt_r3')
+ self.tree.branch.fetch(self.tree2.branch, 'alt_r3')
self.assertInHistoryIs(None, 'alt_r3', 'revid:alt_r3')
def test_unicode(self):
@@ -475,8 +474,7 @@
def test_alt_no_parents(self):
new_tree = self.make_branch_and_tree('new_tree')
new_tree.commit('first', rev_id='new_r1')
- self.tree.branch.repository.fetch(new_tree.branch.repository,
- revision_id='new_r1')
+ self.tree.branch.fetch(new_tree.branch, 'new_r1')
self.assertInHistoryIs(0, 'null:', 'before:revid:new_r1')
def test_as_revision_id(self):
=== modified file 'bzrlib/workingtree_4.py'
--- a/bzrlib/workingtree_4.py 2011-04-17 23:06:22 +0000
+++ b/bzrlib/workingtree_4.py 2011-04-21 00:41:42 +0000
@@ -2016,7 +2016,7 @@
def make_source_parent_tree(source, target):
"""Change the source tree into a parent of the target."""
revid = source.commit('record tree')
- target.branch.repository.fetch(source.branch.repository, revid)
+ target.branch.fetch(source.branch, revid)
target.set_parent_ids([revid])
return target.basis_tree(), target
=== modified file 'doc/en/release-notes/bzr-2.4.txt'
--- a/doc/en/release-notes/bzr-2.4.txt 2011-04-21 13:22:08 +0000
+++ b/doc/en/release-notes/bzr-2.4.txt 2011-04-28 10:30:12 +0000
@@ -365,9 +365,6 @@
``RepositoryFormat.supports_leaving_lock`` flags have been added.
(Jelmer Vernooij)
-* ``Branch.fetch`` implementations must now accept an optional
- ``fetch_spec`` keyword argument. (Andrew Bennetts)
-
* ``Branch.import_last_revision_info`` is deprecated. Use the
``import_last_revision_info_and_tags`` method instead.
(Andrew Bennetts)
More information about the bazaar-commits
mailing list