Rev 3040: (robertc) Fix check to correctly report unreferenced texts. (Robert in file:///home/pqm/archives/thelove/bzr/%2Btrunk/

Canonical.com Patch Queue Manager pqm at pqm.ubuntu.com
Wed Nov 28 01:35:53 GMT 2007


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

------------------------------------------------------------
revno: 3040
revision-id:pqm at pqm.ubuntu.com-20071128013549-w54seazrf4oeywb9
parent: pqm at pqm.ubuntu.com-20071128005930-4wb5pl12fyq8ek13
parent: robertc at robertcollins.net-20071128003519-a5hpblnvtdnuvqb8
committer: Canonical.com Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: +trunk
timestamp: Wed 2007-11-28 01:35:49 +0000
message:
  (robertc) Fix check to correctly report unreferenced texts. (Robert
  	Collins, John A Meinel, 162931, 165071)
modified:
  NEWS                           NEWS-20050323055033-4e00b5db738777ff
  bzrlib/check.py                check.py-20050309040759-f3a679400c06bcc1
  bzrlib/reconcile.py            reweave_inventory.py-20051108164726-1e5e0934febac06e
  bzrlib/remote.py               remote.py-20060720103555-yeeg2x51vn0rbtdp-1
  bzrlib/repository.py           rev_storage.py-20051111201905-119e9401e46257e3
  bzrlib/tests/repository_implementations/__init__.py __init__.py-20060131092037-9564957a7d4a841b
  bzrlib/tests/repository_implementations/test_check.py test_check.py-20070824124512-38g4d135gcqxo4zb-1
    ------------------------------------------------------------
    revno: 3036.1.4
    revision-id:robertc at robertcollins.net-20071128003519-a5hpblnvtdnuvqb8
    parent: robertc at robertcollins.net-20071127233922-1492vwylotgzjw9p
    committer: Robert Collins <robertc at robertcollins.net>
    branch nick: check
    timestamp: Wed 2007-11-28 11:35:19 +1100
    message:
      Fix failing test due to correct check code.
    modified:
      bzrlib/tests/repository_implementations/__init__.py __init__.py-20060131092037-9564957a7d4a841b
    ------------------------------------------------------------
    revno: 3036.1.3
    revision-id:robertc at robertcollins.net-20071127233922-1492vwylotgzjw9p
    parent: robertc at robertcollins.net-20071127220431-tdbtagcse2nigx8k
    committer: Robert Collins <robertc at robertcollins.net>
    branch nick: check
    timestamp: Wed 2007-11-28 10:39:22 +1100
    message:
      Privatise VersionedFileChecker.
    modified:
      NEWS                           NEWS-20050323055033-4e00b5db738777ff
      bzrlib/check.py                check.py-20050309040759-f3a679400c06bcc1
      bzrlib/reconcile.py            reweave_inventory.py-20051108164726-1e5e0934febac06e
      bzrlib/remote.py               remote.py-20060720103555-yeeg2x51vn0rbtdp-1
      bzrlib/repository.py           rev_storage.py-20051111201905-119e9401e46257e3
    ------------------------------------------------------------
    revno: 3036.1.2
    revision-id:robertc at robertcollins.net-20071127220431-tdbtagcse2nigx8k
    parent: robertc at robertcollins.net-20071127215836-300j320ru8mbyl85
    committer: Robert Collins <robertc at robertcollins.net>
    branch nick: check
    timestamp: Wed 2007-11-28 09:04:31 +1100
    message:
      Simplify the check_file_version_parents API some more. This has already changed in this release cycle.
    modified:
      bzrlib/check.py                check.py-20050309040759-f3a679400c06bcc1
      bzrlib/reconcile.py            reweave_inventory.py-20051108164726-1e5e0934febac06e
      bzrlib/repository.py           rev_storage.py-20051111201905-119e9401e46257e3
    ------------------------------------------------------------
    revno: 3036.1.1
    revision-id:robertc at robertcollins.net-20071127215836-300j320ru8mbyl85
    parent: pqm at pqm.ubuntu.com-20071127143838-lkx79x6q91uptc1o
    committer: Robert Collins <robertc at robertcollins.net>
    branch nick: check
    timestamp: Wed 2007-11-28 08:58:36 +1100
    message:
      * ``check`` no longer reports spurious unreferenced text versions.
        (Robert Collins, John A Meinel, #162931, #165071)
    modified:
      NEWS                           NEWS-20050323055033-4e00b5db738777ff
      bzrlib/check.py                check.py-20050309040759-f3a679400c06bcc1
      bzrlib/tests/repository_implementations/test_check.py test_check.py-20070824124512-38g4d135gcqxo4zb-1
=== modified file 'NEWS'
--- a/NEWS	2007-11-27 20:35:02 +0000
+++ b/NEWS	2007-11-28 01:35:49 +0000
@@ -84,6 +84,9 @@
    * Catch connection errors for ftp.
      (Vincent Ladeuil, #164567)
 
+   * ``check`` no longer reports spurious unreferenced text versions.
+     (Robert Collins, John A Meinel, #162931, #165071)
+
    * Conflicts are now resolved recursively by ``revert``.
      (Aaron Bentley, #102739)
 
@@ -185,6 +188,9 @@
      (line, version_id) tuples. This change has been made to aid reconcile and
      fetch operations. (Robert Collins)
 
+   * ``bzrlib.repository.get_versioned_file_checker`` is now private.
+     (Robert Collins)
+
   INTERNALS:
 
    * Added ``ContainerSerialiser`` and ``ContainerPushParser`` to

=== modified file 'bzrlib/check.py'
--- a/bzrlib/check.py	2007-11-16 01:28:59 +0000
+++ b/bzrlib/check.py	2007-11-27 23:39:22 +0000
@@ -202,15 +202,14 @@
         self.inventory_weave.check(progress_bar=self.progress)
         files_in_revisions = {}
         revisions_of_files = {}
-        weave_checker = self.repository.get_versioned_file_checker()
+        weave_checker = self.repository._get_versioned_file_checker()
         for i, weave_id in enumerate(weave_ids):
             self.progress.update('checking versionedfile', i, n_weaves)
             w = self.repository.weave_store.get_weave(weave_id,
                     self.repository.get_transaction())
             # No progress here, because it looks ugly.
             w.check()
-            result = weave_checker.check_file_version_parents(w, weave_id,
-                self.planned_revisions)
+            result = weave_checker.check_file_version_parents(w, weave_id)
             bad_parents, unused_versions = result
             bad_parents = bad_parents.items()
             for revision_id, (weave_parents, correct_parents) in bad_parents:

=== modified file 'bzrlib/reconcile.py'
--- a/bzrlib/reconcile.py	2007-11-16 01:28:59 +0000
+++ b/bzrlib/reconcile.py	2007-11-27 23:39:22 +0000
@@ -379,7 +379,7 @@
         versions = self.revisions.versions()
         mutter('Prepopulating revision text cache with %d revisions',
                 len(versions))
-        vf_checker = self.repo.get_versioned_file_checker()
+        vf_checker = self.repo._get_versioned_file_checker()
         # List all weaves before altering, to avoid race conditions when we
         # delete unused weaves.
         weaves = list(enumerate(self.repo.weave_store))
@@ -388,8 +388,7 @@
                            len(self.repo.weave_store))
             vf = self.repo.weave_store.get_weave(file_id, transaction)
             versions_with_bad_parents, unused_versions = \
-                vf_checker.check_file_version_parents(vf, file_id,
-                vf.versions())
+                vf_checker.check_file_version_parents(vf, file_id)
             if (len(versions_with_bad_parents) == 0 and
                 len(unused_versions) == 0):
                 continue

=== modified file 'bzrlib/remote.py'
--- a/bzrlib/remote.py	2007-11-26 20:30:08 +0000
+++ b/bzrlib/remote.py	2007-11-27 23:39:22 +0000
@@ -689,9 +689,9 @@
         self._ensure_real()
         return self._real_repository.fileids_altered_by_revision_ids(revision_ids)
 
-    def get_versioned_file_checker(self, revisions, revision_versions_cache):
+    def _get_versioned_file_checker(self, revisions, revision_versions_cache):
         self._ensure_real()
-        return self._real_repository.get_versioned_file_checker(
+        return self._real_repository._get_versioned_file_checker(
             revisions, revision_versions_cache)
         
     def iter_files_bytes(self, desired_files):

=== modified file 'bzrlib/repository.py'
--- a/bzrlib/repository.py	2007-11-28 00:59:30 +0000
+++ b/bzrlib/repository.py	2007-11-28 01:35:49 +0000
@@ -1670,9 +1670,9 @@
                 [parents_provider, other_repository._make_parents_provider()])
         return graph.Graph(parents_provider)
 
-    def get_versioned_file_checker(self):
+    def _get_versioned_file_checker(self):
         """Return an object suitable for checking versioned files."""
-        return VersionedFileChecker(self)
+        return _VersionedFileChecker(self)
 
     @needs_write_lock
     def set_make_working_trees(self, new_value):
@@ -2892,7 +2892,7 @@
     return _unescape_re.sub(_unescaper, data)
 
 
-class VersionedFileChecker(object):
+class _VersionedFileChecker(object):
 
     def __init__(self, repository):
         self.repository = repository
@@ -2908,7 +2908,7 @@
         # strip the file_id, for the weave api
         return tuple([revision_id for file_id, revision_id in parent_keys])
 
-    def check_file_version_parents(self, weave, file_id, planned_revisions):
+    def check_file_version_parents(self, weave, file_id):
         """Check the parents stored in a versioned file are correct.
 
         It also detects file versions that are not referenced by their
@@ -2923,12 +2923,12 @@
         """
         wrong_parents = {}
         unused_versions = set()
-        for num, revision_id in enumerate(planned_revisions):
+        for num, revision_id in enumerate(weave.versions()):
             try:
                 correct_parents = self.calculate_file_version_parents(
                     revision_id, file_id)
             except KeyError:
-                # we were asked to investigate a non-existant version.
+                # The version is not part of the used keys.
                 unused_versions.add(revision_id)
             else:
                 try:

=== modified file 'bzrlib/tests/repository_implementations/__init__.py'
--- a/bzrlib/tests/repository_implementations/__init__.py	2007-11-16 01:28:59 +0000
+++ b/bzrlib/tests/repository_implementations/__init__.py	2007-11-28 00:35:19 +0000
@@ -218,7 +218,7 @@
     def check_regexes(self, repo):
         return [r"\* a-file-id version rev2 has parents \('rev1a', 'rev1b'\) "
                 r"but should have \('rev1a',\)",
-                "0 unreferenced text versions",
+                "1 unreferenced text versions",
                 ]
 
     def populate_repository(self, repo):

=== modified file 'bzrlib/tests/repository_implementations/test_check.py'
--- a/bzrlib/tests/repository_implementations/test_check.py	2007-11-16 01:28:59 +0000
+++ b/bzrlib/tests/repository_implementations/test_check.py	2007-11-27 21:58:36 +0000
@@ -30,6 +30,27 @@
     )
 
 
+class TestNoSpuriousInconsistentAncestors(TestCaseWithRepository):
+
+    def test_two_files_different_versions_no_inconsistencies_bug_165071(self):
+        """Two files, with different versions can be clean."""
+        tree = self.make_branch_and_tree('.')
+        self.build_tree(['foo'])
+        tree.smart_add(['.'])
+        tree.commit('1')
+        self.build_tree(['bar'])
+        tree.smart_add(['.'])
+        tree.commit('2')
+        # XXX: check requires a non-empty revision IDs list, but it ignores the
+        # contents of it!
+        check_object = tree.branch.repository.check(['ignored'])
+        check_object.report_results(verbose=False)
+        log = self._get_log(keep_log_file=True)
+        self.assertContainsRe(
+            log,
+            "0 unreferenced text versions")
+
+
 class TestFindInconsistentRevisionParents(TestCaseWithBrokenRevisionIndex):
 
     def test__find_inconsistent_revision_parents(self):




More information about the bazaar-commits mailing list