3 from bup.helpers import *
8 cd = os.path.realpath('')
10 sd = os.path.realpath('sampledata')
11 WVPASSEQ(index.realpath('sampledata'), cd + '/sampledata')
12 WVPASSEQ(os.path.realpath('sampledata/x'), sd + '/x')
13 WVPASSEQ(os.path.realpath('sampledata/etc'), os.path.realpath('/etc'))
14 WVPASSEQ(index.realpath('sampledata/etc'), sd + '/etc')
21 fs = os.stat('tindex.py')
22 w = index.Writer('index.tmp')
23 w.add('/var/tmp/sporky', fs)
24 w.add('/etc/passwd', fs)
32 print '%s%s %s' % (e.is_valid() and ' ' or 'M',
33 e.is_fake() and 'F' or ' ',
36 def fake_validate(*l):
39 e.validate(0100644, index.FAKE_SHA)
53 fs = os.stat('tindex.py')
55 w1 = index.Writer('index.tmp')
63 w2 = index.Writer('index2.tmp')
64 w2.add('/a/b/n/2', fs)
68 w3 = index.Writer('index3.tmp')
69 w3.add('/a/c/n/3', fs)
78 r1all = [e.name for e in r1]
80 ['/a/b/x', '/a/b/c', '/a/b/', '/a/', '/'])
81 r2all = [e.name for e in r2]
83 ['/a/b/n/2', '/a/b/n/', '/a/b/', '/a/', '/'])
84 r3all = [e.name for e in r3]
86 ['/a/c/n/3', '/a/c/n/', '/a/c/', '/a/', '/'])
87 m = index.MergeIter([r2,r1,r3])
88 all = [e.name for e in m]
90 ['/a/c/n/3', '/a/c/n/', '/a/c/',
91 '/a/b/x', '/a/b/n/2', '/a/b/n/', '/a/b/c',
96 print [hex(e.flags) for e in r1]
97 WVPASSEQ([e.name for e in r1 if e.is_valid()], r1all)
98 WVPASSEQ([e.name for e in r1 if not e.is_valid()], [])
99 WVPASSEQ([e.name for e in m if not e.is_valid()],
100 ['/a/c/n/3', '/a/c/n/', '/a/c/',
101 '/a/b/n/2', '/a/b/n/', '/a/b/', '/a/', '/'])
103 expect_invalid = ['/'] + r2all + r3all
104 expect_real = (set(r1all) - set(r2all) - set(r3all)) \
105 | set(['/a/b/n/2', '/a/c/n/3'])
108 print e.name, hex(e.flags), e.ctime
109 eiv = e.name in expect_invalid
110 er = e.name in expect_real
111 WVPASSEQ(eiv, not e.is_valid())
112 WVPASSEQ(er, e.is_real())
113 fake_validate(r2, r3)
115 WVPASSEQ([e.name for e in m if not e.is_valid()], [])
117 e = eget(m, '/a/b/c')
121 WVPASSEQ([e.name for e in m if not e.is_valid()],
122 ['/a/b/c', '/a/b/', '/a/', '/'])