[MERGE] Update to bzr.dev.

Martin Pool mbp at canonical.com
Tue Jun 17 07:35:14 BST 2008


=== modified file 'bzrlib/merge.py'

@@ -1241,21 +1243,38 @@

 class _PlanMergeBase(object):

-    def __init__(self, a_rev, b_rev, vf):
+    def __init__(self, a_rev, b_rev, vf, prefix):
         """Contructor.

         :param a_rev: Revision-id of one revision to merge
         :param b_rev: Revision-id of the other revision to merge
-        :param vf: A versionedfile containing both revisions
+        :param vf: A VersionedFiles containing both revisions
+        :param prefix: A prefix for accessing keys in vf.
         """

I'd change it to key_prefix (and also more importantly in the member
variable) just because 'prefix' is such a generic name.

+        lines = self.get_lines([a_rev, b_rev])
+        self.lines_a = lines[a_rev]
+        self.lines_b = lines[b_rev]

Nice.

+    def get_lines(self, revisions):
+        """Get lines for revisions from the backing VersionedFiles.
+
+        :raises RevisionNotPresent on absent texts.
+        """

You need a colon after the class name.

+        keys = dict((self._prefix + (rev,), rev) for rev in revisions)
+        result = {}
+        for record in self.vf.get_record_stream(keys, 'unordered', True):
+            if record.storage_kind == 'absent':
+                raise errors.RevisionNotPresent(record.key, self.vf)
+            result[keys[record.key]] = osutils.split_lines(
+                record.get_bytes_as('fulltext'))
+        return result

Why are you building a dictionary here?  It looks like get_record_stream
takes just a list of keys?  (I think maybe it's getting the dict but
treating it as a sequence of dict keys?)  If you did that then you could
insert into the result by taking record.key[-1].

@@ -1309,9 +1328,11 @@
             return cached
         if self._last_lines_revision_id == left_revision:
             left_lines = self._last_lines
+            right_lines = self.get_lines([right_revision])[right_revision]
         else:
-            left_lines = self.vf.get_lines(left_revision)
-        right_lines = self.vf.get_lines(right_revision)
+            lines = self.get_lines([left_revision, right_revision])
+            left_lines = lines[left_revision]
+            right_lines = lines[right_revision]
         self._last_lines = right_lines
         self._last_lines_revision_id = right_revision
         matcher = patiencediff.PatienceSequenceMatcher(None, left_lines,

It seems like this will sometimes be redundant with self.lines_a and
lines_b set during the constructor?  (I haven't checked.)  Maybe get_lines
should be caching them for the life of the merge.  I guess this can wait.

These files I've read but have no specific comments:

=== modified file 'bzrlib/inventory.py'
=== modified file 'bzrlib/log.py'

-- 
Martin



More information about the bazaar mailing list