Rev 2977: Review feedback - document the API change and improve readability in pack's _do_copy_nodes. in http://people.ubuntu.com/~robertc/baz2.0/iter-lines

Robert Collins robertc at robertcollins.net
Tue Nov 13 21:39:53 GMT 2007


At http://people.ubuntu.com/~robertc/baz2.0/iter-lines

------------------------------------------------------------
revno: 2977
revision-id:robertc at robertcollins.net-20071113213937-zguxb7m0j6ofy2au
parent: robertc at robertcollins.net-20071109175031-agaiy6530rvbprmb
committer: Robert Collins <robertc at robertcollins.net>
branch nick: iter-lines
timestamp: Wed 2007-11-14 08:39:37 +1100
message:
  Review feedback - document the API change and improve readability in pack's _do_copy_nodes.
modified:
  NEWS                           NEWS-20050323055033-4e00b5db738777ff
  bzrlib/repofmt/pack_repo.py    pack_repo.py-20070813041115-gjv5ma7ktfqwsjgn-1
  bzrlib/versionedfile.py        versionedfile.py-20060222045106-5039c71ee3b65490
=== modified file 'NEWS'
--- a/NEWS	2007-11-07 13:14:09 +0000
+++ b/NEWS	2007-11-13 21:39:37 +0000
@@ -72,6 +72,12 @@
    * ``osutils.backup_file`` is deprecated. Actually it's not used in bzrlib
      during very long time. (Alexander Belchenko)
 
+   * The return value of
+     ``VersionedFile.iter_lines_added_or_present_in_versions`` has been
+     changed. Previously it was an iterator of lines, now it is an iterator of
+     (line, version_id) tuples. This change has been made to aid reconcile and
+     fetch operations. (Robert Collins)
+
   INTERNALS:
 
   TESTING:

=== modified file 'bzrlib/repofmt/pack_repo.py'
--- a/bzrlib/repofmt/pack_repo.py	2007-11-09 17:50:31 +0000
+++ b/bzrlib/repofmt/pack_repo.py	2007-11-13 21:39:37 +0000
@@ -754,18 +754,19 @@
             for (names, read_func), (_1, _2, (key, eol_flag, references)) in \
                 izip(reader.iter_records(), pack_readv_requests):
                 raw_data = read_func(None)
+                version_id = key[-1]
                 if output_lines:
                     # read the entire thing
-                    content, _ = knit_data._parse_record(key[-1], raw_data)
+                    content, _ = knit_data._parse_record(version_id, raw_data)
                     if len(references[-1]) == 0:
                         line_iterator = factory.get_fulltext_content(content)
                     else:
                         line_iterator = factory.get_linedelta_content(content)
                     for line in line_iterator:
-                        yield line, key[-1]
+                        yield line, version_id
                 else:
                     # check the header only
-                    df, _ = knit_data._parse_record_header(key[-1], raw_data)
+                    df, _ = knit_data._parse_record_header(version_id, raw_data)
                     df.close()
                 pos, size = writer.add_bytes_record(raw_data, names)
                 write_index.add_node(key, eol_flag + "%d %d" % (pos, size), references)

=== modified file 'bzrlib/versionedfile.py'
--- a/bzrlib/versionedfile.py	2007-10-17 09:39:41 +0000
+++ b/bzrlib/versionedfile.py	2007-11-13 21:39:37 +0000
@@ -420,15 +420,16 @@
             version_ids,
             ignore_missing)
 
-    def iter_lines_added_or_present_in_versions(self, version_ids=None, 
+    def iter_lines_added_or_present_in_versions(self, version_ids=None,
                                                 pb=None):
         """Iterate over the lines in the versioned file from version_ids.
 
-        This may return lines from other versions, and does not return the
-        specific version marker at this point. The api may be changed
-        during development to include the version that the versioned file
-        thinks is relevant, but given that such hints are just guesses,
-        its better not to have it if we don't need it.
+        This may return lines from other versions. Each item the returned
+        iterator yields is a tuple of a line and a text version that that line
+        is present in (not introduced in).
+
+        Ordering of results is in whatever order is most suitable for the
+        underlying storage format.
 
         If a progress bar is supplied, it may be used to indicate progress.
         The caller is responsible for cleaning up progress bars (because this
@@ -436,6 +437,8 @@
 
         NOTES: Lines are normalised: they will all have \n terminators.
                Lines are returned in arbitrary order.
+
+        :return: An iterator over (line, version_id).
         """
         raise NotImplementedError(self.iter_lines_added_or_present_in_versions)
 



More information about the bazaar-commits mailing list