[MERGE] Update to bzr.dev.

Martin Pool mbp at canonical.com
Tue Jun 17 09:49:12 BST 2008


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

     def get_file_lines(self, file_id):
-        ie = self._inventory[file_id]
-        weave = self._get_weave(file_id)
-        return weave.get_lines(ie.revision)
+        return osutils.split_lines(self.get_file_text(file_id))

This seems like potentially a performance regression: if we want the
file lines we will get them back from the line-based delta composition
then join them then potentially split them again.  With the old code it
might have been avoided.

I can't promise it definitely was, or that there are enough callers of
this code that it matters.

     def get_file_text(self, file_id):
-        return ''.join(self.get_file_lines(file_id))
+        return list(self.iter_files_bytes([(file_id, None)]))[0][1]

This is correct but a bit ugly, oh well.

     def iter_files_bytes(self, desired_files):
-        """See Tree.extract_files_bytes.
+        """See Tree.iter_files_bytes.

         This version is implemented on top of
Repository.extract_files_bytes"""

 ^^ not anymore, it would seem.

         repo_desired_files = [(f, self.inventory[f].revision, i)
                               for f, i in desired_files]
-        return self._repository.iter_files_bytes(repo_desired_files)
+        try:
+            for result in
self._repository.iter_files_bytes(repo_desired_files):
+                yield result
+        except errors.RevisionNotPresent, e:
+            raise errors.NoSuchFile(e.revision_id)



=== modified file 'bzrlib/store/__init__.py'
@@ -251,20 +253,21 @@
         # will just use the filesystem defaults
         self._dir_mode = dir_mode
         self._file_mode = file_mode
-
-    def _unescape(self, file_id):
-        """If filename escaping is enabled for this store, unescape
and return the filename."""
-        if self._escaped:
-            return urllib.unquote(file_id)
+        # Create a key mapper to use
+        if escaped and prefixed:
+            self._mapper = versionedfile.HashEscapedPrefixMapper()
+        elif not escaped and prefixed:
+            self._mapper = versionedfile.HashPrefixMapper()
+        elif self._escaped:
+            import pdb;pdb.set_trace()
+            raise ValueError("escaped unprefixed stores are not permitted.")
         else:
-            return file_id
+            self._mapper = versionedfile.PrefixMapper()

remove the pdb please :-)

     def _iter_files_recursive(self):
         """Iterate through the files in the transport."""
         for quoted_relpath in self._transport.iter_files_recursive():
-            # transport iterator always returns quoted paths, regardless of
-            # escaping
-            yield urllib.unquote(quoted_relpath)
+            yield quoted_relpath

Now this method is doing no more than just calling
_transport.iter_files_recursive so why not just delete it and call that
from __iter__, particularly because it now has a different contract?

However, this method is also used by store/versioned/__init__.py, and
that class does not seem to have been updated to expect

I also read the other bzrlib/store changes and see no problems.

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

@@ -98,6 +131,23 @@
         self.parents = None


+class AdapterFactory(ContentFactory):
+    """A content factory to adapt between key prefix's."""
+

spelled 'prefixes'

@@ -496,146 +527,683 @@
     """

     def __init__(self, backing_vf):
-        """Create a RecordingVersionedFileDecorator decorating backing_vf.
+        """Create a RecordingVersionedFileDsecorator decorating backing_vf.

typo 'Dsecor'


+class VersionedFiles(object):
+    """Storage for many versioned files.
+

Nice docstrings here, thanks.
+
+    def _check_lines_not_unicode(self, lines):
+        """Check that lines being added to a versioned file are not unicode."""
+        for line in lines:
+            if line.__class__ is not str:
+                raise errors.BzrBadParameterUnicode("lines")
+
+    def _check_lines_are_lines(self, lines):
+        """Check that the lines really are full lines without inline EOL."""
+        for line in lines:
+            if '\n' in line[:-1]:
+                raise errors.BzrBadParameterContainsNewline("lines")

(comment) I'm not sure these error classes add much value over
just raising a ValueError or TypeError.  But they're not new in your
patch.

+    def __init__(self, transport, file_factory, mapper, is_locked):
+        """Create a ThunkedVersionedFiles."""
+        self._transport = transport
+        self._file_factory = file_factory
+        self._mapper = mapper
+        self._is_locked = is_locked
+

docstring would be nice, particularly for whether is_locked is a
boolean or a callable.

And this is about as far as I got in this file.

-- 
Martin



More information about the bazaar mailing list