[Pkg-bazaar-commits] ./bzr/unstable r213: Revfile: don't store deltas if they'd be larger than just storing the whole text

mbp at sourcefrog.net mbp at sourcefrog.net
Fri Apr 10 07:51:26 UTC 2009


------------------------------------------------------------
revno: 213
committer: mbp at sourcefrog.net
timestamp: Sat 2005-04-09 15:20:25 +1000
message:
  Revfile: don't store deltas if they'd be larger than just storing the whole text
modified:
  bzrlib/revfile.py
-------------- next part --------------
=== modified file 'bzrlib/revfile.py'
--- a/bzrlib/revfile.py	2005-04-09 05:17:31 +0000
+++ b/bzrlib/revfile.py	2005-04-09 05:20:25 +0000
@@ -203,7 +203,15 @@
         self._check_index(base)
         base_text = self.get(base)
         data = mdiff.bdiff(base_text, text)
-        return self._add_common(text_sha, data, base)
+        
+        # If the delta is larger than the text, we might as well just
+        # store the text.  (OK, the delta might be more compressible,
+        # but the overhead of applying it probably still makes it
+        # bad.)
+        if len(data) >= len(text):
+            return self._add_full_text(text, text_sha)
+        else:
+            return self._add_common(text_sha, data, base)
 
 
     def add(self, text, base=_NO_RECORD):



More information about the Pkg-bazaar-commits mailing list