Rev 5859: (jelmer) Split versioned-file specific bits out Check into in file:///home/pqm/archives/thelove/bzr/%2Btrunk/

Canonical.com Patch Queue Manager pqm at pqm.ubuntu.com
Fri May 13 15:37:52 UTC 2011


At file:///home/pqm/archives/thelove/bzr/%2Btrunk/

------------------------------------------------------------
revno: 5859 [merge]
revision-id: pqm at pqm.ubuntu.com-20110513153747-aw3d2lsjyk40bp9q
parent: pqm at pqm.ubuntu.com-20110513132429-krofy2n5nfmhlf5h
parent: jelmer at samba.org-20110512120301-sx3r2b5d0nduge17
committer: Canonical.com Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: +trunk
timestamp: Fri 2011-05-13 15:37:47 +0000
message:
  (jelmer) Split versioned-file specific bits out Check into
   VersionedFileCheck. (Jelmer Vernooij)
modified:
  bzrlib/check.py                check.py-20050309040759-f3a679400c06bcc1
  bzrlib/repository.py           rev_storage.py-20051111201905-119e9401e46257e3
  bzrlib/vf_repository.py        vf_repository.py-20110502151858-yh9nnoxpokg86unk-1
  bzrlib/workingtree.py          workingtree.py-20050511021032-29b6ec0a681e02e3
=== modified file 'bzrlib/check.py'
--- a/bzrlib/check.py	2011-04-08 12:28:37 +0000
+++ b/bzrlib/check.py	2011-05-11 15:39:20 +0000
@@ -53,13 +53,23 @@
 from bzrlib.branch import Branch
 from bzrlib.bzrdir import BzrDir
 from bzrlib.revision import NULL_REVISION
-from bzrlib.symbol_versioning import deprecated_function, deprecated_in
 from bzrlib.trace import note
 from bzrlib.workingtree import WorkingTree
 
+
 class Check(object):
     """Check a repository"""
 
+    def __init__(self, repository, check_repo=True):
+        self.repository = repository
+
+    def report_results(self, verbose):
+        raise NotImplementedError(self.report_results)
+
+
+class VersionedFileCheck(Check):
+    """Check a versioned file repository"""
+
     # The Check object interacts with InventoryEntry.check, etc.
 
     def __init__(self, repository, check_repo=True):

=== modified file 'bzrlib/repository.py'
--- a/bzrlib/repository.py	2011-05-13 10:07:00 +0000
+++ b/bzrlib/repository.py	2011-05-13 15:37:47 +0000
@@ -20,7 +20,6 @@
 
 from bzrlib import (
     bzrdir,
-    check,
     config,
     controldir,
     debug,
@@ -1203,7 +1202,6 @@
         """Return the text for a signature."""
         raise NotImplementedError(self.get_signature_text)
 
-    @needs_read_lock
     def check(self, revision_ids=None, callback_refs=None, check_repo=True):
         """Check consistency of all history of given revision_ids.
 
@@ -1217,13 +1215,11 @@
         :param check_repo: If False do not check the repository contents, just 
             calculate the data callback_refs requires and call them back.
         """
-        return self._check(revision_ids, callback_refs=callback_refs,
+        return self._check(revision_ids=revision_ids, callback_refs=callback_refs,
             check_repo=check_repo)
 
-    def _check(self, revision_ids, callback_refs, check_repo):
-        result = check.Check(self, check_repo=check_repo)
-        result.check(callback_refs)
-        return result
+    def _check(self, revision_ids=None, callback_refs=None, check_repo=True):
+        raise NotImplementedError(self.check)
 
     def _warn_if_deprecated(self, branch=None):
         if not self._format.is_deprecated():

=== modified file 'bzrlib/vf_repository.py'
--- a/bzrlib/vf_repository.py	2011-05-08 13:06:20 +0000
+++ b/bzrlib/vf_repository.py	2011-05-12 12:03:01 +0000
@@ -20,6 +20,7 @@
 from bzrlib.lazy_import import lazy_import
 lazy_import(globals(), """
 from bzrlib import (
+    check,
     debug,
     fetch as _mod_fetch,
     fifo_cache,
@@ -1850,6 +1851,12 @@
             raise errors.NoSuchRevision(self, revision_id)
         return record.get_bytes_as('fulltext')
 
+    @needs_read_lock
+    def _check(self, revision_ids, callback_refs, check_repo):
+        result = check.VersionedFileCheck(self, check_repo=check_repo)
+        result.check(callback_refs)
+        return result
+
     def _find_inconsistent_revision_parents(self, revisions_iterator=None):
         """Find revisions with different parent lists in the revision object
         and in the index graph.

=== modified file 'bzrlib/workingtree.py'
--- a/bzrlib/workingtree.py	2011-05-11 11:45:52 +0000
+++ b/bzrlib/workingtree.py	2011-05-11 15:31:44 +0000
@@ -268,16 +268,6 @@
         self._control_files.break_lock()
         self.branch.break_lock()
 
-    def _get_check_refs(self):
-        """Return the references needed to perform a check of this tree.
-        
-        The default implementation returns no refs, and is only suitable for
-        trees that have no local caching and can commit on ghosts at any time.
-
-        :seealso: bzrlib.check for details about check_refs.
-        """
-        return []
-
     def requires_rich_root(self):
         return self._format.requires_rich_root
 
@@ -1785,25 +1775,6 @@
         self.set_conflicts(un_resolved)
         return un_resolved, resolved
 
-    @needs_read_lock
-    def _check(self, references):
-        """Check the tree for consistency.
-
-        :param references: A dict with keys matching the items returned by
-            self._get_check_refs(), and values from looking those keys up in
-            the repository.
-        """
-        tree_basis = self.basis_tree()
-        tree_basis.lock_read()
-        try:
-            repo_basis = references[('trees', self.last_revision())]
-            if len(list(repo_basis.iter_changes(tree_basis))) > 0:
-                raise errors.BzrCheckError(
-                    "Mismatched basis inventory content.")
-            self._validate()
-        finally:
-            tree_basis.unlock()
-
     def _validate(self):
         """Validate internal structures.
 
@@ -1815,16 +1786,9 @@
         """
         return
 
-    @needs_read_lock
     def check_state(self):
         """Check that the working state is/isn't valid."""
-        check_refs = self._get_check_refs()
-        refs = {}
-        for ref in check_refs:
-            kind, value = ref
-            if kind == 'trees':
-                refs[ref] = self.branch.repository.revision_tree(value)
-        self._check(refs)
+        raise NotImplementedError(self.check_state)
 
     def reset_state(self, revision_ids=None):
         """Reset the state of the working tree.
@@ -2139,6 +2103,46 @@
         if self._change_last_revision(new_revision):
             self._cache_basis_inventory(new_revision)
 
+    def _get_check_refs(self):
+        """Return the references needed to perform a check of this tree.
+        
+        The default implementation returns no refs, and is only suitable for
+        trees that have no local caching and can commit on ghosts at any time.
+
+        :seealso: bzrlib.check for details about check_refs.
+        """
+        return []
+
+    @needs_read_lock
+    def _check(self, references):
+        """Check the tree for consistency.
+
+        :param references: A dict with keys matching the items returned by
+            self._get_check_refs(), and values from looking those keys up in
+            the repository.
+        """
+        tree_basis = self.basis_tree()
+        tree_basis.lock_read()
+        try:
+            repo_basis = references[('trees', self.last_revision())]
+            if len(list(repo_basis.iter_changes(tree_basis))) > 0:
+                raise errors.BzrCheckError(
+                    "Mismatched basis inventory content.")
+            self._validate()
+        finally:
+            tree_basis.unlock()
+
+    @needs_read_lock
+    def check_state(self):
+        """Check that the working state is/isn't valid."""
+        check_refs = self._get_check_refs()
+        refs = {}
+        for ref in check_refs:
+            kind, value = ref
+            if kind == 'trees':
+                refs[ref] = self.branch.repository.revision_tree(value)
+        self._check(refs)
+
     @needs_tree_write_lock
     def reset_state(self, revision_ids=None):
         """Reset the state of the working tree.




More information about the bazaar-commits mailing list