Rev 3329: * ``VersionedFile.annotate_iter`` is deprecated. While in principal this in http://people.ubuntu.com/~robertc/baz2.0/versioned_files

Robert Collins robertc at robertcollins.net
Wed Apr 9 01:35:21 BST 2008


At http://people.ubuntu.com/~robertc/baz2.0/versioned_files

------------------------------------------------------------
revno: 3329
revision-id: robertc at robertcollins.net-20080409003454-x19fm1n0o2govzh6
parent: robertc at robertcollins.net-20080408224755-cv6j2zt6ij6mvsav
committer: Robert Collins <robertc at robertcollins.net>
branch nick: api-cleanup
timestamp: Wed 2008-04-09 10:34:54 +1000
message:
   * ``VersionedFile.annotate_iter`` is deprecated. While in principal this
     allows lower memory use, all users of annotations wanted full file 
     annotations, and there is no storage format suitable for incremental
     line-by-line annotation. (Robert Collins)
modified:
  NEWS                           NEWS-20050323055033-4e00b5db738777ff
  bzrlib/annotate.py             annotate.py-20050922133147-7c60541d2614f022
  bzrlib/knit.py                 knit.py-20051212171256-f056ac8f0fbe1bd9
  bzrlib/multiparent.py          __init__.py-20070410133617-n1jdhcc1n1mibarp-1
  bzrlib/revisiontree.py         revisiontree.py-20060724012533-bg8xyryhxd0o0i0h-1
  bzrlib/tests/test_knit.py      test_knit.py-20051212171302-95d4c00dd5f11f2b
  bzrlib/versionedfile.py        versionedfile.py-20060222045106-5039c71ee3b65490
  bzrlib/weave.py                knit.py-20050627021749-759c29984154256b
  bzrlib/workingtree_4.py        workingtree_4.py-20070208044105-5fgpc5j3ljlh5q6c-1
=== modified file 'NEWS'
--- a/NEWS	2008-04-08 21:41:15 +0000
+++ b/NEWS	2008-04-09 00:34:54 +0000
@@ -140,6 +140,11 @@
       than using a call to ``transaction_finished``, allowing the removal of
       the fixed list of versioned files per repository. (Robert Collins)
 
+    * ``VersionedFile.annotate_iter`` is deprecated. While in principal this
+      allows lower memory use, all users of annotations wanted full file 
+      annotations, and there is no storage format suitable for incremental
+      line-by-line annotation. (Robert Collins)
+
     * ``VersionedFile.clone_text`` is deprecated. This performance optimisation
       is no longer used - reading the content of a file that is undergoing a
       file level merge to identical state on two branches is rare enough, and

=== modified file 'bzrlib/annotate.py'
--- a/bzrlib/annotate.py	2008-03-14 11:52:07 +0000
+++ b/bzrlib/annotate.py	2008-04-09 00:34:54 +0000
@@ -113,7 +113,7 @@
 def _annotations(repo, file_id, rev_id):
     """Return the list of (origin,text) for a revision of a file in a repository."""
     w = repo.weave_store.get_weave(file_id, repo.get_transaction())
-    return list(w.annotate_iter(rev_id))
+    return w.annotate(rev_id)
 
 
 def _annotate_file(branch, rev_id, file_id):

=== modified file 'bzrlib/knit.py'
--- a/bzrlib/knit.py	2008-04-08 21:41:15 +0000
+++ b/bzrlib/knit.py	2008-04-09 00:34:54 +0000
@@ -144,10 +144,6 @@
     def __init__(self):
         self._should_strip_eol = False
 
-    def annotate(self):
-        """Return a list of (origin, text) tuples."""
-        return list(self.annotate_iter())
-
     def apply_delta(self, delta, new_version_id):
         """Apply delta to this object to become new_version_id."""
         raise NotImplementedError(self.apply_delta)
@@ -206,9 +202,9 @@
         KnitContent.__init__(self)
         self._lines = lines
 
-    def annotate_iter(self):
-        """Yield tuples of (origin, text) for each content line."""
-        return iter(self._lines)
+    def annotate(self):
+        """Return a list of (origin, text) for each content line."""
+        return list(self._lines)
 
     def apply_delta(self, delta, new_version_id):
         """Apply delta to this object to become new_version_id."""
@@ -256,10 +252,9 @@
         self._lines = lines
         self._version_id = version_id
 
-    def annotate_iter(self):
-        """Yield tuples of (origin, text) for each content line."""
-        for line in self._lines:
-            yield self._version_id, line
+    def annotate(self):
+        """Return a list of (origin, text) for each content line."""
+        return [(self._version_id, line) for line in self._lines]
 
     def apply_delta(self, delta, new_version_id):
         """Apply delta to this object to become new_version_id."""
@@ -427,9 +422,9 @@
                        for origin, text in lines)
         return out
 
-    def annotate_iter(self, knit, version_id):
+    def annotate(self, knit, version_id):
         content = knit._get_content(version_id)
-        return content.annotate_iter()
+        return content.annotate()
 
 
 class KnitPlainFactory(_KnitFactory):
@@ -489,9 +484,9 @@
             out.extend(lines)
         return out
 
-    def annotate_iter(self, knit, version_id):
+    def annotate(self, knit, version_id):
         annotator = _KnitAnnotator(knit)
-        return iter(annotator.annotate(version_id))
+        return annotator.annotate(version_id)
 
 
 def make_empty_knit(transport, relpath):
@@ -1240,9 +1235,9 @@
 
     __len__ = num_versions
 
-    def annotate_iter(self, version_id):
-        """See VersionedFile.annotate_iter."""
-        return self.factory.annotate_iter(self, version_id)
+    def annotate(self, version_id):
+        """See VersionedFile.annotate."""
+        return self.factory.annotate(self, version_id)
 
     def get_parent_map(self, version_ids):
         """See VersionedFile.get_parent_map."""

=== modified file 'bzrlib/multiparent.py'
--- a/bzrlib/multiparent.py	2008-03-19 04:39:04 +0000
+++ b/bzrlib/multiparent.py	2008-04-09 00:34:54 +0000
@@ -382,7 +382,7 @@
                     if [p for p in parents if p not in self._parents] != []:
                         continue
                     lines = [a + ' ' + l for a, l in
-                             vf.annotate_iter(revision)]
+                             vf.annotate(revision)]
                     if snapshots is None:
                         force_snapshot = None
                     else:

=== modified file 'bzrlib/revisiontree.py'
--- a/bzrlib/revisiontree.py	2007-12-06 20:06:01 +0000
+++ b/bzrlib/revisiontree.py	2008-04-09 00:34:54 +0000
@@ -93,7 +93,7 @@
                       default_revision=revision.CURRENT_REVISION):
         """See Tree.annotate_iter"""
         w = self._get_weave(file_id)
-        return w.annotate_iter(self.inventory[file_id].revision)
+        return w.annotate(self.inventory[file_id].revision)
 
     def get_file_size(self, file_id):
         return self._inventory[file_id].text_size

=== modified file 'bzrlib/tests/test_knit.py'
--- a/bzrlib/tests/test_knit.py	2008-04-08 21:41:15 +0000
+++ b/bzrlib/tests/test_knit.py	2008-04-09 00:34:54 +0000
@@ -56,6 +56,7 @@
     KnitSequenceMatcher,
     )
 from bzrlib.osutils import split_lines
+from bzrlib.symbol_versioning import one_four
 from bzrlib.tests import (
     Feature,
     TestCase,
@@ -161,17 +162,6 @@
         self.assertEqual(content.annotate(),
             [("bogus", "text1"), ("bogus", "text2")])
 
-    def test_annotate_iter(self):
-        content = self._make_content([])
-        it = content.annotate_iter()
-        self.assertRaises(StopIteration, it.next)
-
-        content = self._make_content([("bogus", "text1"), ("bogus", "text2")])
-        it = content.annotate_iter()
-        self.assertEqual(it.next(), ("bogus", "text1"))
-        self.assertEqual(it.next(), ("bogus", "text2"))
-        self.assertRaises(StopIteration, it.next)
-
     def test_line_delta(self):
         content1 = self._make_content([("", "a"), ("", "b")])
         content2 = self._make_content([("", "a"), ("", "a"), ("", "c")])
@@ -199,17 +189,6 @@
         self.assertEqual(content.annotate(),
             [("origin1", "text1"), ("origin2", "text2")])
 
-    def test_annotate_iter(self):
-        content = self._make_content([])
-        it = content.annotate_iter()
-        self.assertRaises(StopIteration, it.next)
-
-        content = self._make_content([("origin1", "text1"), ("origin2", "text2")])
-        it = content.annotate_iter()
-        self.assertEqual(it.next(), ("origin1", "text1"))
-        self.assertEqual(it.next(), ("origin2", "text2"))
-        self.assertRaises(StopIteration, it.next)
-
     def test_line_delta(self):
         content1 = self._make_content([("", "a"), ("", "b")])
         content2 = self._make_content([("", "a"), ("", "a"), ("", "c")])

=== modified file 'bzrlib/versionedfile.py'
--- a/bzrlib/versionedfile.py	2008-04-08 21:41:15 +0000
+++ b/bzrlib/versionedfile.py	2008-04-09 00:34:54 +0000
@@ -422,6 +422,7 @@
         except KeyError:
             raise errors.RevisionNotPresent(version_id, self)
 
+    @deprecated_method(one_four)
     def annotate_iter(self, version_id):
         """Yield list of (version-id, line) pairs for the specified
         version.
@@ -429,10 +430,15 @@
         Must raise RevisionNotPresent if the given version is
         not present in file history.
         """
-        raise NotImplementedError(self.annotate_iter)
+        return iter(self.annotate(version_id))
 
     def annotate(self, version_id):
-        return list(self.annotate_iter(version_id))
+        """Return a list of (version-id, line) tuples for version_id.
+
+        :raise RevisionNotPresent: If the given version is
+        not present in file history.
+        """
+        raise NotImplementedError(self.annotate)
 
     def join(self, other, pb=None, msg=None, version_ids=None,
              ignore_missing=False):

=== modified file 'bzrlib/weave.py'
--- a/bzrlib/weave.py	2008-04-08 04:13:08 +0000
+++ b/bzrlib/weave.py	2008-04-09 00:34:54 +0000
@@ -466,13 +466,13 @@
         """
         return len(other_parents.difference(my_parents)) == 0
 
-    def annotate_iter(self, version_id):
-        """Yield list of (version-id, line) pairs for the specified version.
+    def annotate(self, version_id):
+        """Return a list of (version-id, line) tuples for version_id.
 
         The index indicates when the line originated in the weave."""
         incls = [self._lookup(version_id)]
-        for origin, lineno, text in self._extract(incls):
-            yield self._idx_to_name(origin), text
+        return [(self._idx_to_name(origin), text) for origin, lineno, text in
+            self._extract(incls)]
 
     def iter_lines_added_or_present_in_versions(self, version_ids=None,
                                                 pb=None):

=== modified file 'bzrlib/workingtree_4.py'
--- a/bzrlib/workingtree_4.py	2008-03-17 21:58:47 +0000
+++ b/bzrlib/workingtree_4.py	2008-04-09 00:34:54 +0000
@@ -1402,7 +1402,7 @@
                       default_revision=_mod_revision.CURRENT_REVISION):
         """See Tree.annotate_iter"""
         w = self._get_weave(file_id)
-        return w.annotate_iter(self.inventory[file_id].revision)
+        return w.annotate(self.inventory[file_id].revision)
 
     def _get_ancestors(self, default_revision):
         return set(self._repository.get_ancestry(self._revision_id,




More information about the bazaar-commits mailing list