changeset 5453:9d77f2b47eb7

fix UnboundLocalError, refactor a bit bin wasn't defined in all branches (bug introduced in 82b4ff3abbcd
author Benoit Boissinot <benoit.boissinot@ens-lyon.org>
date Thu, 11 Oct 2007 12:16:55 +0200
parents 82b4ff3abbcd
children f2ca8d2c988f
files mercurial/revlog.py
diffstat 1 files changed, 3 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/revlog.py
+++ b/mercurial/revlog.py
@@ -62,10 +62,9 @@ def compress(text):
     if not text:
         return ("", text)
     l = len(text)
+    bin = None
     if l < 44:
-        if text[0] == '\0':
-            return ("", text)
-        return ('u', text)
+        pass
     elif l > 1000000:
         # zlib makes an internal copy, thus doubling memory usage for
         # large files, so lets do this in pieces
@@ -81,7 +80,7 @@ def compress(text):
             bin = "".join(p)
     else:
         bin = _compress(text)
-    if len(bin) > l:
+    if bin is None or len(bin) > l:
         if text[0] == '\0':
             return ("", text)
         return ('u', text)