]> git.michaelhowe.org Git - packages/b/bup.git/commitdiff
midx4: Fix the other side of my previous nasty bug
authorBrandon Low <lostlogic@lostlogicx.com>
Thu, 10 Feb 2011 21:23:36 +0000 (13:23 -0800)
committerAvery Pennarun <apenwarr@gmail.com>
Sat, 12 Feb 2011 22:39:55 +0000 (14:39 -0800)
The previous one was a problem with midx4s generated from idx files,
this one is similar but when they are generated from other .midx4 files.

Many thanks to Aneurin Price for putting up with the awful behavior and
prodding at bup and whatnot while I was trying to make this one
disappear under a rug.

Once again, midx4 files generated prior to this patch will want to be
regenerated.  Once again, only smart servers which have objects not on
the client's index cache will be effected, but they sure as hell well be
effected.

Signed-off-by: Brandon Low <lostlogic@lostlogicx.com>
cmd/midx-cmd.py
lib/bup/git.py
lib/bup/t/tgit.py

index efd3f7f86ae1f54e57197cbd7b8f4a820703f34b..9c6dcd473e2601e567d6d6e040f52d3c3e3cd79c 100755 (executable)
@@ -49,7 +49,7 @@ def _do_midx(outdir, outfilename, infilenames, prefixstr):
             ix.map,
             len(ix),
             ix.sha_ofs,
-            isinstance(ix, git.PackMidx) and ix.idxname_ofs or 0,
+            isinstance(ix, git.PackMidx) and ix.which_ofs or 0,
             len(allfilenames),
         ))
         for n in ix.idxnames:
index 8a6808e03b59a5070babe73dbee51b3b49e66ee9..78fb9ec6804eadf45833c70094eec14b98ce4cbb 100644 (file)
@@ -513,9 +513,9 @@ class PackMidx:
         self.sha_ofs = 12 + self.entries*4
         self.nsha = nsha = self._fanget(self.entries-1)
         self.shatable = buffer(self.map, self.sha_ofs, nsha*20)
-        self.whichlist = buffer(self.map, self.sha_ofs + nsha*20, nsha*4)
-        self.idxname_ofs = self.sha_ofs + 24*nsha
-        self.idxnames = str(self.map[self.idxname_ofs:]).split('\0')
+        self.which_ofs = self.sha_ofs + 20*nsha
+        self.whichlist = buffer(self.map, self.which_ofs, nsha*4)
+        self.idxnames = str(self.map[self.which_ofs + 4*nsha:]).split('\0')
 
     def _init_failed(self):
         self.bits = 0
index 656303784a68a8f215461156fcd5d5e8b87c2422..bb38075c1cde0f1fa976839bec71544b5e3ace25 100644 (file)
@@ -97,40 +97,23 @@ def test_pack_name_lookup():
     subprocess.call(['rm','-rf', bupdir])
     git.init_repo(bupdir)
     git.verbose = 1
+    packdir = git.repo('objects/pack')
 
     idxnames = []
-
-    w = git.PackWriter()
     hashes = []
-    for i in range(2):
-        hashes.append(w.new_blob(str(i)))
-    log('\n')
-    idxnames.append(w.close() + '.idx')
 
-    w = git.PackWriter()
-    for i in range(2,4):
-        hashes.append(w.new_blob(str(i)))
-    log('\n')
-    idxnames.append(w.close() + '.idx')
+    for start in range(0,28,2):
+        w = git.PackWriter()
+        for i in range(start, start+2):
+            hashes.append(w.new_blob(str(i)))
+        log('\n')
+        idxnames.append(os.path.basename(w.close() + '.idx'))
 
-    idxnames = [os.path.basename(ix) for ix in idxnames]
-
-    def verify(r):
-       for i in range(2):
-           WVPASSEQ(r.exists(hashes[i], want_source=True), idxnames[0])
-       for i in range(2,4):
-           WVPASSEQ(r.exists(hashes[i], want_source=True), idxnames[1])
-
-    r = git.PackIdxList('pybuptest.tmp/objects/pack')
+    r = git.PackIdxList(packdir)
     WVPASSEQ(len(r.packs), 2)
-    verify(r)
-    del r
-
-    subprocess.call([bupmain, 'midx', '-f'])
-
-    r = git.PackIdxList('pybuptest.tmp/objects/pack')
-    WVPASSEQ(len(r.packs), 1)
-    verify(r)
+    for e,idxname in enumerate(idxnames):
+        for i in range(e*2, (e+1)*2):
+            WVPASSEQ(r.exists(hashes[i], want_source=True), idxname)
 
 
 @wvtest