]> arthur.barton.de Git - bup.git/blobdiff - lib/bup/git.py
cmd/midx: --auto mode can combine existing midx files now.
[bup.git] / lib / bup / git.py
index 3bbd25a59c65ea523612ccc2fb3e5b9a27b44a1e..3612c836dbdec0bd296b63181657785767ae1ce7 100644 (file)
@@ -133,6 +133,7 @@ class PackIdx:
     """Object representation of a Git pack index file."""
     def __init__(self, filename):
         self.name = filename
+        self.idxnames = [self.name]
         self.map = mmap_read(open(filename))
         assert(str(self.map[0:8]) == '\377tOc\0\0\0\2')
         self.fanout = list(struct.unpack('!256I',
@@ -411,6 +412,15 @@ def _shalist_sort_key(ent):
         return name
 
 
+def open_idx(filename):
+    if filename.endswith('.idx'):
+        return PackIdx(filename)
+    elif filename.endswith('.midx'):
+        return PackMidx(filename)
+    else:
+        raise GitError('idx filenames must end with .idx or .midx')
+
+
 def idxmerge(idxlist):
     """Generate a list of all the objects reachable in a PackIdxList."""
     total = sum(len(i) for i in idxlist)