def _create_idx(d, i): idx = git.PackIdxV2Writer() # add 255 vaguely reasonable entries for s in range(255): idx.add(struct.pack('18xBB', i, s), s, 100 * s) packbin = struct.pack('B19x', i) packname = os.path.join(d, b'pack-%s.idx' % hexlify(packbin)) idx.write(packname, packbin)
def _create_new_pack(self, kind): fakesha = libnacl.randombytes(20) hexsha = hexlify(fakesha) return fakesha, EncryptedContainer(self, self.storage, b'pack-%s.encpack' % hexsha, 'w', kind, self.compression, key=self.writekey, idxwriter=git.PackIdxV2Writer())
def test_long_index(tmpdir): environ[b'BUP_DIR'] = bupdir = tmpdir + b'/bup' git.init_repo(bupdir) idx = git.PackIdxV2Writer() obj_bin = struct.pack('!IIIII', 0x00112233, 0x44556677, 0x88990011, 0x22334455, 0x66778899) obj2_bin = struct.pack('!IIIII', 0x11223344, 0x55667788, 0x99001122, 0x33445566, 0x77889900) obj3_bin = struct.pack('!IIIII', 0x22334455, 0x66778899, 0x00112233, 0x44556677, 0x88990011) pack_bin = struct.pack('!IIIII', 0x99887766, 0x55443322, 0x11009988, 0x77665544, 0x33221100) idx.add(obj_bin, 1, 0xfffffffff) idx.add(obj2_bin, 2, 0xffffffffff) idx.add(obj3_bin, 3, 0xff) name = tmpdir + b'/tmp.idx' r = idx.write(name, pack_bin) i = git.PackIdxV2(name, open(name, 'rb')) WVPASSEQ(i.find_offset(obj_bin), 0xfffffffff) WVPASSEQ(i.find_offset(obj2_bin), 0xffffffffff) WVPASSEQ(i.find_offset(obj3_bin), 0xff)