]> arthur.barton.de Git - bup.git/commitdiff
midx: automatically ignore .midx files if one of their .idx is missing.
authorAvery Pennarun <apenwarr@gmail.com>
Wed, 10 Feb 2010 22:52:41 +0000 (17:52 -0500)
committerAvery Pennarun <apenwarr@gmail.com>
Wed, 10 Feb 2010 23:05:20 +0000 (18:05 -0500)
That implies that a pack has been deleted, so the entire .midx is pretty
much worthless.  'bup midx -a' will generate a new one.

git.py

diff --git a/git.py b/git.py
index 3b62b19ab791de0406978ae60b7a9a4205a5e89e..89b4c11a01ed7fd4d83e40678180c5fc5ce31820 100644 (file)
--- a/git.py
+++ b/git.py
@@ -204,7 +204,7 @@ _mpi_count = 0
 class MultiPackIndex:
     def __init__(self, dir):
         global _mpi_count
-        assert(_mpi_count == 0)
+        assert(_mpi_count == 0) # these things suck tons of VM; don't waste it
         _mpi_count += 1
         self.dir = dir
         self.also = {}
@@ -241,7 +241,16 @@ class MultiPackIndex:
                 for f in os.listdir(self.dir):
                     full = os.path.join(self.dir, f)
                     if f.endswith('.midx') and not d.get(full):
-                        midxl.append(PackMidx(full))
+                        mx = PackMidx(full)
+                        (mxd, mxf) = os.path.split(mx.name)
+                        broken = 0
+                        for n in mx.idxnames:
+                            if not os.path.exists(os.path.join(mxd, n)):
+                                log(('warning: index %s missing\n' +
+                                    '  used by %s\n') % (n, mxf))
+                                broken += 1
+                        if not broken:
+                            midxl.append(mx)
                 midxl.sort(lambda x,y: -cmp(len(x),len(y)))
                 for ix in midxl:
                     any = 0