Show More
@@ -15,6 +15,7 b' import silenttestrunner' | |||||
15 |
|
15 | |||
16 | from mercurial.node import nullid |
|
16 | from mercurial.node import nullid | |
17 | from mercurial import ( |
|
17 | from mercurial import ( | |
|
18 | pycompat, | |||
18 | ui as uimod, |
|
19 | ui as uimod, | |
19 | ) |
|
20 | ) | |
20 | # Load the local remotefilelog, not the system one |
|
21 | # Load the local remotefilelog, not the system one | |
@@ -35,13 +36,14 b' class histpacktests(unittest.TestCase):' | |||||
35 | def makeTempDir(self): |
|
36 | def makeTempDir(self): | |
36 | tempdir = tempfile.mkdtemp() |
|
37 | tempdir = tempfile.mkdtemp() | |
37 | self.tempdirs.append(tempdir) |
|
38 | self.tempdirs.append(tempdir) | |
38 | return tempdir |
|
39 | return pycompat.fsencode(tempdir) | |
39 |
|
40 | |||
40 | def getHash(self, content): |
|
41 | def getHash(self, content): | |
41 | return hashlib.sha1(content).digest() |
|
42 | return hashlib.sha1(content).digest() | |
42 |
|
43 | |||
43 | def getFakeHash(self): |
|
44 | def getFakeHash(self): | |
44 |
return ''.join(chr(random.randint(0, 255)) |
|
45 | return b''.join(pycompat.bytechr(random.randint(0, 255)) | |
|
46 | for _ in range(20)) | |||
45 |
|
47 | |||
46 | def createPack(self, revisions=None): |
|
48 | def createPack(self, revisions=None): | |
47 | """Creates and returns a historypack containing the specified revisions. |
|
49 | """Creates and returns a historypack containing the specified revisions. | |
@@ -53,7 +55,7 b' class histpacktests(unittest.TestCase):' | |||||
53 | revisions = [("filename", self.getFakeHash(), nullid, nullid, |
|
55 | revisions = [("filename", self.getFakeHash(), nullid, nullid, | |
54 | self.getFakeHash(), None)] |
|
56 | self.getFakeHash(), None)] | |
55 |
|
57 | |||
56 | packdir = self.makeTempDir() |
|
58 | packdir = pycompat.fsencode(self.makeTempDir()) | |
57 | packer = historypack.mutablehistorypack(uimod.ui(), packdir, |
|
59 | packer = historypack.mutablehistorypack(uimod.ui(), packdir, | |
58 | version=2) |
|
60 | version=2) | |
59 |
|
61 | |||
@@ -107,7 +109,7 b' class histpacktests(unittest.TestCase):' | |||||
107 | chain. |
|
109 | chain. | |
108 | """ |
|
110 | """ | |
109 | revisions = [] |
|
111 | revisions = [] | |
110 | filename = "foo" |
|
112 | filename = b"foo" | |
111 | lastnode = nullid |
|
113 | lastnode = nullid | |
112 | for i in range(10): |
|
114 | for i in range(10): | |
113 | node = self.getFakeHash() |
|
115 | node = self.getFakeHash() | |
@@ -136,7 +138,7 b' class histpacktests(unittest.TestCase):' | |||||
136 | revisions = [] |
|
138 | revisions = [] | |
137 | random.seed(0) |
|
139 | random.seed(0) | |
138 | for i in range(100): |
|
140 | for i in range(100): | |
139 |
filename = "filename-% |
|
141 | filename = b"filename-%d" % i | |
140 | entries = [] |
|
142 | entries = [] | |
141 | p2 = nullid |
|
143 | p2 = nullid | |
142 | linknode = nullid |
|
144 | linknode = nullid | |
@@ -172,7 +174,7 b' class histpacktests(unittest.TestCase):' | |||||
172 |
|
174 | |||
173 | def testGetNodeInfo(self): |
|
175 | def testGetNodeInfo(self): | |
174 | revisions = [] |
|
176 | revisions = [] | |
175 | filename = "foo" |
|
177 | filename = b"foo" | |
176 | lastnode = nullid |
|
178 | lastnode = nullid | |
177 | for i in range(10): |
|
179 | for i in range(10): | |
178 | node = self.getFakeHash() |
|
180 | node = self.getFakeHash() | |
@@ -193,7 +195,7 b' class histpacktests(unittest.TestCase):' | |||||
193 | """Test the getmissing() api. |
|
195 | """Test the getmissing() api. | |
194 | """ |
|
196 | """ | |
195 | revisions = [] |
|
197 | revisions = [] | |
196 | filename = "foo" |
|
198 | filename = b"foo" | |
197 | for i in range(10): |
|
199 | for i in range(10): | |
198 | node = self.getFakeHash() |
|
200 | node = self.getFakeHash() | |
199 | p1 = self.getFakeHash() |
|
201 | p1 = self.getFakeHash() | |
@@ -223,7 +225,7 b' class histpacktests(unittest.TestCase):' | |||||
223 | pack = self.createPack() |
|
225 | pack = self.createPack() | |
224 |
|
226 | |||
225 | try: |
|
227 | try: | |
226 | pack.add('filename', nullid, nullid, nullid, nullid, None) |
|
228 | pack.add(b'filename', nullid, nullid, nullid, nullid, None) | |
227 | self.assertTrue(False, "historypack.add should throw") |
|
229 | self.assertTrue(False, "historypack.add should throw") | |
228 | except RuntimeError: |
|
230 | except RuntimeError: | |
229 | pass |
|
231 | pass | |
@@ -250,7 +252,7 b' class histpacktests(unittest.TestCase):' | |||||
250 | total = basepack.SMALLFANOUTCUTOFF + 1 |
|
252 | total = basepack.SMALLFANOUTCUTOFF + 1 | |
251 | revisions = [] |
|
253 | revisions = [] | |
252 | for i in xrange(total): |
|
254 | for i in xrange(total): | |
253 |
filename = "foo-% |
|
255 | filename = b"foo-%d" % i | |
254 | node = self.getFakeHash() |
|
256 | node = self.getFakeHash() | |
255 | p1 = self.getFakeHash() |
|
257 | p1 = self.getFakeHash() | |
256 | p2 = self.getFakeHash() |
|
258 | p2 = self.getFakeHash() |
General Comments 0
You need to be logged in to leave comments.
Login now