]> arthur.barton.de Git - bup.git/blobdiff - cmd/midx-cmd.py
mux: handle python 3's change to default close_fds=True
[bup.git] / cmd / midx-cmd.py
index 7b4a2adc689c535cc948395ea0fbdb3497b3198b..ef0a312e0318df72fda9ec05de120f7f381977ec 100755 (executable)
@@ -5,9 +5,11 @@ exec "$bup_python" "$0" ${1+"$@"}
 """
 # end of bup preamble
 
+from __future__ import absolute_import
 import glob, math, os, resource, struct, sys, tempfile
 
 from bup import options, git, midx, _helpers, xstat
+from bup.compat import hexstr, range
 from bup.helpers import (Sha1, add_error, atomically_replaced_file, debug1, fdatasync,
                          handle_ctrl_c, log, mmap_readwrite, qprogress,
                          saved_errors, unlink)
@@ -32,10 +34,10 @@ merge_into = _helpers.merge_into
 
 
 def _group(l, count):
-    for i in xrange(0, len(l), count):
+    for i in range(0, len(l), count):
         yield l[i:i+count]
-        
-        
+
+
 def max_files():
     mf = min(resource.getrlimit(resource.RLIMIT_NOFILE))
     if mf > 32:
@@ -62,20 +64,17 @@ def check_midx(name):
                              git.shorten_hash(subname), ecount, len(sub)))
             if not sub.exists(e):
                 add_error("%s: %s: %s missing from idx"
-                          % (nicename, git.shorten_hash(subname),
-                             str(e).encode('hex')))
+                          % (nicename, git.shorten_hash(subname), hexstr(e)))
             if not ix.exists(e):
                 add_error("%s: %s: %s missing from midx"
-                          % (nicename, git.shorten_hash(subname),
-                             str(e).encode('hex')))
+                          % (nicename, git.shorten_hash(subname), hexstr(e)))
     prev = None
     for ecount,e in enumerate(ix):
         if not (ecount % 1234):
             qprogress('  Ordering: %d/%d\r' % (ecount, len(ix)))
         if not e >= prev:
             add_error('%s: ordering error: %s < %s'
-                      % (nicename,
-                         str(e).encode('hex'), str(prev).encode('hex')))
+                      % (nicename, hexstr(e), hexstr(prev)))
         prev = e