Rev 3569: Defer decision to reconcile to the repository being fetched into. in http://people.ubuntu.com/~robertc/baz2.0/btree-graphindex
Robert Collins
robertc at robertcollins.net
Mon Jul 28 10:12:33 BST 2008
At http://people.ubuntu.com/~robertc/baz2.0/btree-graphindex
------------------------------------------------------------
revno: 3569
revision-id: robertc at robertcollins.net-20080728091228-jyx4832utkwztez3
parent: robertc at robertcollins.net-20080728083915-7p1w6504b661e31g
committer: Robert Collins <robertc at robertcollins.net>
branch nick: btree-graphindex
timestamp: Mon 2008-07-28 19:12:28 +1000
message:
Defer decision to reconcile to the repository being fetched into.
modified:
NEWS NEWS-20050323055033-4e00b5db738777ff
bzrlib/fetch.py fetch.py-20050818234941-26fea6105696365d
bzrlib/remote.py remote.py-20060720103555-yeeg2x51vn0rbtdp-1
bzrlib/repofmt/weaverepo.py presplitout.py-20070125045333-wfav3tsh73oxu3zk-1
bzrlib/repository.py rev_storage.py-20051111201905-119e9401e46257e3
bzrlib/tests/repository_implementations/test_repository.py test_repository.py-20060131092128-ad07f494f5c9d26c
bzrlib/tests/test_repository.py test_repository.py-20060131075918-65c555b881612f4d
=== modified file 'NEWS'
--- a/NEWS 2008-07-28 08:39:15 +0000
+++ b/NEWS 2008-07-28 09:12:28 +0000
@@ -54,10 +54,12 @@
API CHANGES:
- * The generic fetch code now uses two attributes on Repository objects
- to control the requested streams: ``_fetch_order`` and
- ``_fetch_uses_deltas``. Setting these appropriately allows different
- repository implementations to recieve data in their optimial form.
+ * The generic fetch code now uses three attributes on Repository objects
+ to control fetch. The streams requested are controlled via :
+ ``_fetch_order`` and ``_fetch_uses_deltas``. Setting these
+ appropriately allows different repository implementations to recieve
+ data in their optimial form. If the ``_fetch_reconcile`` is set then
+ a reconcile operation is triggered at the end of the fetch.
(Robert Collins)
INTERNALS:
=== modified file 'bzrlib/fetch.py'
--- a/bzrlib/fetch.py 2008-07-28 08:39:15 +0000
+++ b/bzrlib/fetch.py 2008-07-28 09:12:28 +0000
@@ -199,6 +199,8 @@
self._fetch_revision_texts(revs, pb)
else:
raise AssertionError("Unknown knit kind %r" % knit_kind)
+ if self.to_repository._fetch_reconcile:
+ self.to_repository.reconcile()
finally:
if pb is not None:
pb.finished()
@@ -274,17 +276,6 @@
pass
-class GenericRepoFetcher(RepoFetcher):
- """This is a generic repo to repo fetcher.
-
- This triggers a reconciliation after fetching to ensure integrity.
- """
-
- def _fetch_revision_texts(self, revs, pb):
- RepoFetcher._fetch_revision_texts(self, revs, pb)
- self.to_repository.reconcile()
-
-
class Inter1and2Helper(object):
"""Helper for operations that convert data from model 1 and 2
@@ -422,12 +413,6 @@
pass
self._copy_revision(rev)
count += 1
- # fixup inventory if needed:
- # this is expensive because we have no inverse index to current ghosts.
- # but on local disk its a few seconds and sftp push is already insane.
- # so we just-do-it.
- # FIXME: repository should inform if this is needed.
- self.to_repository.reconcile()
def _copy_revision(self, rev):
self.helper.fetch_revisions([rev])
=== modified file 'bzrlib/remote.py'
--- a/bzrlib/remote.py 2008-07-28 06:08:42 +0000
+++ b/bzrlib/remote.py 2008-07-28 09:12:28 +0000
@@ -836,6 +836,16 @@
self._ensure_real()
return self._real_repository._fetch_uses_deltas
+ @property
+ def _fetch_reconcile(self):
+ """Decorate the real repository for now.
+
+ In the long term getting this back from the remote repository as part
+ of open would be more efficient.
+ """
+ self._ensure_real()
+ return self._real_repository._fetch_reconcile
+
def get_parent_map(self, keys):
"""See bzrlib.Graph.get_parent_map()."""
# Hack to build up the caching logic.
=== modified file 'bzrlib/repofmt/weaverepo.py'
--- a/bzrlib/repofmt/weaverepo.py 2008-07-28 05:09:54 +0000
+++ b/bzrlib/repofmt/weaverepo.py 2008-07-28 09:12:28 +0000
@@ -86,6 +86,7 @@
self._text_store = get_store('text-store')
super(AllInOneRepository, self).__init__(_format, a_bzrdir, a_bzrdir._control_files)
self._fetch_order = 'topological'
+ self._fetch_reconcile = True
@needs_read_lock
def _all_possible_ids(self):
@@ -182,6 +183,7 @@
def __init__(self, _format, a_bzrdir, control_files):
super(WeaveMetaDirRepository, self).__init__(_format, a_bzrdir, control_files)
self._fetch_order = 'topological'
+ self._fetch_reconcile = True
@needs_read_lock
def _all_possible_ids(self):
@@ -323,6 +325,7 @@
def __init__(self):
super(RepositoryFormat4, self).__init__()
self._fetch_order = 'topological'
+ self._fetch_reconcile = True
def get_format_description(self):
"""See RepositoryFormat.get_format_description()."""
@@ -375,6 +378,7 @@
def __init__(self):
super(RepositoryFormat5, self).__init__()
self._fetch_order = 'topological'
+ self._fetch_reconcile = True
def get_format_description(self):
"""See RepositoryFormat.get_format_description()."""
@@ -418,6 +422,7 @@
def __init__(self):
super(RepositoryFormat6, self).__init__()
self._fetch_order = 'topological'
+ self._fetch_reconcile = True
def get_format_description(self):
"""See RepositoryFormat.get_format_description()."""
=== modified file 'bzrlib/repository.py'
--- a/bzrlib/repository.py 2008-07-28 08:39:15 +0000
+++ b/bzrlib/repository.py 2008-07-28 09:12:28 +0000
@@ -699,6 +699,9 @@
# We default to False, which will ensure that enough data to get
# a full text out of any fetch stream will be grabbed.
self._fetch_uses_deltas = False
+ # Should fetch trigger a reconcile after the fetch? Only needed for
+ # some repository formats that can suffer internal inconsistencies.
+ self._fetch_reconcile = False
def __repr__(self):
return '%s(%r)' % (self.__class__.__name__,
@@ -2496,11 +2499,11 @@
@needs_write_lock
def fetch(self, revision_id=None, pb=None, find_ghosts=False):
"""See InterRepository.fetch()."""
- from bzrlib.fetch import GenericRepoFetcher
+ from bzrlib.fetch import RepoFetcher
mutter("Using fetch logic to copy between %s(%s) and %s(%s)",
self.source, self.source._format, self.target,
self.target._format)
- f = GenericRepoFetcher(to_repository=self.target,
+ f = RepoFetcher(to_repository=self.target,
from_repository=self.source,
last_revision=revision_id,
pb=pb, find_ghosts=find_ghosts)
@@ -2577,10 +2580,10 @@
@needs_write_lock
def fetch(self, revision_id=None, pb=None, find_ghosts=False):
"""See InterRepository.fetch()."""
- from bzrlib.fetch import GenericRepoFetcher
+ from bzrlib.fetch import RepoFetcher
mutter("Using fetch logic to copy between %s(%s) and %s(%s)",
self.source, self.source._format, self.target, self.target._format)
- f = GenericRepoFetcher(to_repository=self.target,
+ f = RepoFetcher(to_repository=self.target,
from_repository=self.source,
last_revision=revision_id,
pb=pb, find_ghosts=find_ghosts)
=== modified file 'bzrlib/tests/repository_implementations/test_repository.py'
--- a/bzrlib/tests/repository_implementations/test_repository.py 2008-07-28 05:09:54 +0000
+++ b/bzrlib/tests/repository_implementations/test_repository.py 2008-07-28 09:12:28 +0000
@@ -76,6 +76,12 @@
repo = tree.branch.repository
self.assertTrue(repo._fetch_uses_deltas in (True, False))
+ def test_attribute__fetch_reconcile(self):
+ """Test the the _fetch_reconcile attribute."""
+ tree = self.make_branch_and_tree('tree')
+ repo = tree.branch.repository
+ self.assertTrue(repo._fetch_reconcile in (True, False))
+
def test_attribute_inventories_store(self):
"""Test the existence of the inventories attribute."""
tree = self.make_branch_and_tree('tree')
=== modified file 'bzrlib/tests/test_repository.py'
--- a/bzrlib/tests/test_repository.py 2008-07-28 05:09:54 +0000
+++ b/bzrlib/tests/test_repository.py 2008-07-28 09:12:28 +0000
@@ -174,6 +174,12 @@
repo = weaverepo.RepositoryFormat6().initialize(control)
self.assertEqual(False, repo._fetch_uses_deltas)
+ def test_attribute__fetch_reconcile(self):
+ """Weave repositories need a reconcile after fetch."""
+ control = bzrdir.BzrDirFormat6().initialize(self.get_url())
+ repo = weaverepo.RepositoryFormat6().initialize(control)
+ self.assertEqual(True, repo._fetch_reconcile)
+
def test_no_ancestry_weave(self):
control = bzrdir.BzrDirFormat6().initialize(self.get_url())
repo = weaverepo.RepositoryFormat6().initialize(control)
@@ -203,6 +209,12 @@
repo = weaverepo.RepositoryFormat7().initialize(control)
self.assertEqual(False, repo._fetch_uses_deltas)
+ def test_attribute__fetch_reconcile(self):
+ """Weave repositories need a reconcile after fetch."""
+ control = bzrdir.BzrDirMetaFormat1().initialize(self.get_url())
+ repo = weaverepo.RepositoryFormat7().initialize(control)
+ self.assertEqual(True, repo._fetch_reconcile)
+
def test_disk_layout(self):
control = bzrdir.BzrDirMetaFormat1().initialize(self.get_url())
repo = weaverepo.RepositoryFormat7().initialize(control)
More information about the bazaar-commits
mailing list