Rev 2840: versionedfile.py code cleanups (Ian Clatworthy) in file:///home/pqm/archives/thelove/bzr/%2Btrunk/

Canonical.com Patch Queue Manager pqm at pqm.ubuntu.com
Fri Sep 21 00:55:08 BST 2007


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

------------------------------------------------------------
revno: 2840
revision-id: pqm at pqm.ubuntu.com-20070920235505-6w61gqyajy9i0ioj
parent: pqm at pqm.ubuntu.com-20070920125023-upjqmzln7mjtvj1h
parent: ian.clatworthy at internode.on.net-20070920061251-hmtw92x5y19nhwa1
committer: Canonical.com Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: +trunk
timestamp: Fri 2007-09-21 00:55:05 +0100
message:
  versionedfile.py code cleanups (Ian Clatworthy)
modified:
  bzrlib/knit.py                 knit.py-20051212171256-f056ac8f0fbe1bd9
  bzrlib/versionedfile.py        versionedfile.py-20060222045106-5039c71ee3b65490
    ------------------------------------------------------------
    revno: 2836.1.1
    merged: ian.clatworthy at internode.on.net-20070920061251-hmtw92x5y19nhwa1
    parent: pqm at pqm.ubuntu.com-20070920024052-y2l7r5o00zrpnr73
    parent: ian.clatworthy at internode.on.net-20070920011247-0me000hq8e69yi6l
    committer: Ian Clatworthy <ian.clatworthy at internode.on.net>
    branch nick: ianc-integration
    timestamp: Thu 2007-09-20 16:12:51 +1000
    message:
      versionedfile.py code cleanups (Ian Clatworthy)
    ------------------------------------------------------------
    revno: 2831.7.2
    merged: ian.clatworthy at internode.on.net-20070920011247-0me000hq8e69yi6l
    parent: ian.clatworthy at internode.on.net-20070919233838-b0da8j380rleae9f
    committer: Ian Clatworthy <ian.clatworthy at internode.on.net>
    branch nick: bzr.versionedfile
    timestamp: Thu 2007-09-20 11:12:47 +1000
    message:
      incorporate feedback from lifeless & abentley on _apply_delta
    ------------------------------------------------------------
    revno: 2831.7.1
    merged: ian.clatworthy at internode.on.net-20070919233838-b0da8j380rleae9f
    parent: pqm at pqm.ubuntu.com-20070918045733-es6jch43pxvogvhj
    committer: Ian Clatworthy <ian.clatworthy at internode.on.net>
    branch nick: bzr.versionedfile
    timestamp: Thu 2007-09-20 09:38:38 +1000
    message:
      versionedfile.py code cleanups
=== modified file 'bzrlib/knit.py'
--- a/bzrlib/knit.py	2007-09-19 05:14:14 +0000
+++ b/bzrlib/knit.py	2007-09-20 06:12:51 +0000
@@ -1022,6 +1022,16 @@
             text_map[version_id] = text
         return text_map, final_content
 
+    @staticmethod
+    def _apply_delta(lines, delta):
+        """Apply delta to lines."""
+        lines = list(lines)
+        offset = 0
+        for start, end, count, delta_lines in delta:
+            lines[offset+start:offset+end] = delta_lines
+            offset = offset + (start - end) + count
+        return lines
+
     def iter_lines_added_or_present_in_versions(self, version_ids=None, 
                                                 pb=None):
         """See VersionedFile.iter_lines_added_or_present_in_versions()."""

=== modified file 'bzrlib/versionedfile.py'
--- a/bzrlib/versionedfile.py	2007-09-19 05:14:14 +0000
+++ b/bzrlib/versionedfile.py	2007-09-20 06:12:51 +0000
@@ -193,6 +193,7 @@
         already present in file history."""
         new_version_id = osutils.safe_revision_id(new_version_id)
         old_version_id = osutils.safe_revision_id(old_version_id)
+        parents = [osutils.safe_revision_id(v) for v in parents]
         self._check_write_ok()
         return self._clone_text(new_version_id, old_version_id, parents)
 
@@ -212,12 +213,12 @@
     def get_format_signature(self):
         """Get a text description of the data encoding in this file.
         
-        :since: 0.19
+        :since: 0.90
         """
         raise NotImplementedError(self.get_format_signature)
 
     def make_mpdiffs(self, version_ids):
-        """Create multiparent diffs for specified versions"""
+        """Create multiparent diffs for specified versions."""
         knit_versions = set()
         for version_id in version_ids:
             knit_versions.add(version_id)
@@ -241,11 +242,12 @@
         return None
 
     def add_mpdiffs(self, records):
-        """Add mpdiffs to this versionedfile
+        """Add mpdiffs to this VersionedFile.
 
         Records should be iterables of version, parents, expected_sha1,
-        mpdiff.  mpdiff should be a MultiParent instance.
+        mpdiff. mpdiff should be a MultiParent instance.
         """
+        # Does this need to call self._check_write_ok()? (IanC 20070919)
         vf_parents = {}
         mpvf = multiparent.MultiMemoryVersionedFile()
         versions = []
@@ -277,7 +279,7 @@
     def get_sha1(self, version_id):
         """Get the stored sha1 sum for the given revision.
         
-        :param name: The name of the version to lookup
+        :param version_id: The name of the version to lookup
         """
         raise NotImplementedError(self.get_sha1)
 
@@ -287,7 +289,7 @@
         :param version_ids: The names of the versions to lookup
         :return: a list of sha1s in order according to the version_ids
         """
-        raise NotImplementedError(self.get_sha1)
+        raise NotImplementedError(self.get_sha1s)
 
     def get_suffixes(self):
         """Return the file suffixes associated with this versioned file."""
@@ -399,7 +401,7 @@
         """Yield list of (version-id, line) pairs for the specified
         version.
 
-        Must raise RevisionNotPresent if any of the given versions are
+        Must raise RevisionNotPresent if the given version is
         not present in file history.
         """
         raise NotImplementedError(self.annotate_iter)
@@ -407,15 +409,6 @@
     def annotate(self, version_id):
         return list(self.annotate_iter(version_id))
 
-    def _apply_delta(self, lines, delta):
-        """Apply delta to lines."""
-        lines = list(lines)
-        offset = 0
-        for start, end, count, delta_lines in delta:
-            lines[offset+start:offset+end] = delta_lines
-            offset = offset + (start - end) + count
-        return lines
-
     def join(self, other, pb=None, msg=None, version_ids=None,
              ignore_missing=False):
         """Integrate versions from other into this versioned file.
@@ -424,8 +417,8 @@
         incorporated into this versioned file.
 
         Must raise RevisionNotPresent if any of the specified versions
-        are not present in the other files history unless ignore_missing
-        is supplied when they are silently skipped.
+        are not present in the other file's history unless ignore_missing
+        is supplied in which case they are silently skipped.
         """
         self._check_write_ok()
         return InterVersionedFile.get(other, self).join(
@@ -568,7 +561,7 @@
 
 
 class WeaveMerge(PlanWeaveMerge):
-    """Weave merge that takes a VersionedFile and two versions as its input"""
+    """Weave merge that takes a VersionedFile and two versions as its input."""
 
     def __init__(self, versionedfile, ver_a, ver_b, 
         a_marker=PlanWeaveMerge.A_MARKER, b_marker=PlanWeaveMerge.B_MARKER):
@@ -577,7 +570,7 @@
 
 
 class InterVersionedFile(InterObject):
-    """This class represents operations taking place between two versionedfiles..
+    """This class represents operations taking place between two VersionedFiles.
 
     Its instances have methods like join, and contain
     references to the source and target versionedfiles these operations can be 
@@ -598,8 +591,8 @@
         incorporated into this versioned file.
 
         Must raise RevisionNotPresent if any of the specified versions
-        are not present in the other files history unless ignore_missing is 
-        supplied when they are silently skipped.
+        are not present in the other file's history unless ignore_missing is 
+        supplied in which case they are silently skipped.
         """
         # the default join: 
         # - if the target is empty, just add all the versions from 




More information about the bazaar-commits mailing list