3 from bup.helpers import *
10 looseb = ''.join(git._encode_looseobj('blob', s))
11 looset = ''.join(git._encode_looseobj('tree', s))
12 loosec = ''.join(git._encode_looseobj('commit', s))
13 packb = ''.join(git._encode_packobj('blob', s))
14 packt = ''.join(git._encode_packobj('tree', s))
15 packc = ''.join(git._encode_packobj('commit', s))
16 WVPASSEQ(git._decode_looseobj(looseb), ('blob', s))
17 WVPASSEQ(git._decode_looseobj(looset), ('tree', s))
18 WVPASSEQ(git._decode_looseobj(loosec), ('commit', s))
19 WVPASSEQ(git._decode_packobj(packb), ('blob', s))
20 WVPASSEQ(git._decode_packobj(packt), ('tree', s))
21 WVPASSEQ(git._decode_packobj(packc), ('commit', s))
25 git.init_repo('pybuptest.tmp')
28 now = str(time.time()) # hopefully not in any packs yet
38 hashes.append(w.write('blob', str(i)))
40 nameprefix = w.close()
41 print repr(nameprefix)
42 WVPASS(os.path.exists(nameprefix + '.pack'))
43 WVPASS(os.path.exists(nameprefix + '.idx'))
45 r = git.PackIndex(nameprefix + '.idx')
49 WVPASS(r.find_offset(hashes[i]) > 0)
50 WVPASS(r.exists(hashes[99]))
51 WVFAIL(r.exists('\0'*20))
54 for h in sorted(hashes):
55 WVPASSEQ(str(pi.next()).encode('hex'), h.encode('hex'))
57 WVFAIL(r.find_offset('\0'*20))
59 r = git.MultiPackIndex('pybuptest.tmp/objects/pack')
60 WVPASS(r.exists(hashes[5]))
61 WVPASS(r.exists(hashes[6]))
62 WVFAIL(r.exists('\0'*20))