Show More
@@ -35,7 +35,8 b' def testbasicreadwrite():' | |||||
35 | ensure(rm.rev2hsh(i) is None) |
|
35 | ensure(rm.rev2hsh(i) is None) | |
36 | ensure(rm.hsh2rev(b'\0' * 20) is None) |
|
36 | ensure(rm.hsh2rev(b'\0' * 20) is None) | |
37 |
|
37 | |||
38 | paths = ['', 'a', None, 'b', 'b', 'c', 'c', None, 'a', 'b', 'a', 'a'] |
|
38 | paths = [ | |
|
39 | b'', b'a', None, b'b', b'b', b'c', b'c', None, b'a', b'b', b'a', b'a'] | |||
39 | for i in xrange(1, 5): |
|
40 | for i in xrange(1, 5): | |
40 | ensure(rm.append(genhsh(i), sidebranch=(i & 1), path=paths[i]) == i) |
|
41 | ensure(rm.append(genhsh(i), sidebranch=(i & 1), path=paths[i]) == i) | |
41 |
|
42 | |||
@@ -88,7 +89,7 b' def testcorruptformat():' | |||||
88 | path = gettemppath() |
|
89 | path = gettemppath() | |
89 |
|
90 | |||
90 | # incorrect header |
|
91 | # incorrect header | |
91 | with open(path, 'w') as f: |
|
92 | with open(path, 'wb') as f: | |
92 | f.write(b'NOT A VALID HEADER') |
|
93 | f.write(b'NOT A VALID HEADER') | |
93 | try: |
|
94 | try: | |
94 | revmap.revmap(path) |
|
95 | revmap.revmap(path) | |
@@ -106,8 +107,8 b' def testcorruptformat():' | |||||
106 |
|
107 | |||
107 | # corrupt the file by appending a byte |
|
108 | # corrupt the file by appending a byte | |
108 | size = os.stat(path).st_size |
|
109 | size = os.stat(path).st_size | |
109 | with open(path, 'a') as f: |
|
110 | with open(path, 'ab') as f: | |
110 | f.write('\xff') |
|
111 | f.write(b'\xff') | |
111 | try: |
|
112 | try: | |
112 | revmap.revmap(path) |
|
113 | revmap.revmap(path) | |
113 | ensure(False) |
|
114 | ensure(False) | |
@@ -116,7 +117,7 b' def testcorruptformat():' | |||||
116 |
|
117 | |||
117 | # corrupt the file by removing the last byte |
|
118 | # corrupt the file by removing the last byte | |
118 | ensure(size > 0) |
|
119 | ensure(size > 0) | |
119 | with open(path, 'w') as f: |
|
120 | with open(path, 'wb') as f: | |
120 | f.truncate(size - 1) |
|
121 | f.truncate(size - 1) | |
121 | try: |
|
122 | try: | |
122 | revmap.revmap(path) |
|
123 | revmap.revmap(path) | |
@@ -130,7 +131,8 b' def testcopyfrom():' | |||||
130 | path = gettemppath() |
|
131 | path = gettemppath() | |
131 | rm = revmap.revmap(path) |
|
132 | rm = revmap.revmap(path) | |
132 | for i in xrange(1, 10): |
|
133 | for i in xrange(1, 10): | |
133 |
ensure(rm.append(genhsh(i), |
|
134 | ensure(rm.append(genhsh(i), | |
|
135 | sidebranch=(i & 1), path=(b'%d' % (i // 3))) == i) | |||
134 | rm.flush() |
|
136 | rm.flush() | |
135 |
|
137 | |||
136 | # copy rm to rm2 |
|
138 | # copy rm to rm2 | |
@@ -174,10 +176,10 b' def testcontains():' | |||||
174 | # "contains" checks paths |
|
176 | # "contains" checks paths | |
175 | rm = revmap.revmap() |
|
177 | rm = revmap.revmap() | |
176 | for i in xrange(1, 5): |
|
178 | for i in xrange(1, 5): | |
177 |
ensure(rm.append(genhsh(i), path= |
|
179 | ensure(rm.append(genhsh(i), path=(b'%d' % (i // 2))) == i) | |
178 | for i in xrange(1, 5): |
|
180 | for i in xrange(1, 5): | |
179 |
ensure(fakefctx(genhsh(i), path= |
|
181 | ensure(fakefctx(genhsh(i), path=(b'%d' % (i // 2))) in rm) | |
180 | ensure(fakefctx(genhsh(i), path='a') not in rm) |
|
182 | ensure(fakefctx(genhsh(i), path=b'a') not in rm) | |
181 |
|
183 | |||
182 | def testlastnode(): |
|
184 | def testlastnode(): | |
183 | path = gettemppath() |
|
185 | path = gettemppath() | |
@@ -186,7 +188,7 b' def testlastnode():' | |||||
186 | ensure(revmap.getlastnode(path) is None) |
|
188 | ensure(revmap.getlastnode(path) is None) | |
187 | for i in xrange(1, 10): |
|
189 | for i in xrange(1, 10): | |
188 | hsh = genhsh(i) |
|
190 | hsh = genhsh(i) | |
189 |
rm.append(hsh, path= |
|
191 | rm.append(hsh, path=(b'%d' % (i // 2)), flush=True) | |
190 | ensure(revmap.getlastnode(path) == hsh) |
|
192 | ensure(revmap.getlastnode(path) == hsh) | |
191 | rm2 = revmap.revmap(path) |
|
193 | rm2 = revmap.revmap(path) | |
192 | ensure(rm2.rev2hsh(rm2.maxrev) == hsh) |
|
194 | ensure(rm2.rev2hsh(rm2.maxrev) == hsh) |
General Comments 0
You need to be logged in to leave comments.
Login now