annotate mercurial/testing/storage.py @ 39874:14e500b58263

revlog: add method for obtaining storage info (API) We currently have a handful of methods on the file and manifest storage interfaces for obtaining metadata about storage. e.g. files() is used to obtain the files backing storage. rawsize() is to quickly compute the size of tracked revisions without resolving their fulltext. Code in upgrade and stream clone make heavy use of these methods. The existing APIs are generic and don't necessarily have the specialization that we need going forward. For example, files() doesn't distinguish between exclusive storage and shared storage. This makes stream clone difficult to implement when e.g. there may be a single file backing storage for multiple tracked paths. It also makes reporting difficult, as we don't know how many bytes are actually used by storage since we can't easily identify shared files. This commit implements a new method for obtaining storage metadata. It is designed to accept arguments specifying what metadata to request and to return a dict with those fields populated. We /could/ make each of these attributes a separate method. But this is a specialized API and I'm trying to avoid method bloat on the interfaces. There is also the possibility that certain callers will want to obtain multiple fields in different combinations and some backends may have performance issues obtaining all that data via separate method calls. Simple storage integration tests have been added. For now, we assume fields can't be "None" (ignoring the interface documentation). We can revisit this later. Differential Revision: https://phab.mercurial-scm.org/D4747
author Gregory Szorc <gregory.szorc@gmail.com>
date Mon, 24 Sep 2018 11:56:48 -0700
parents e23c03dc5cf9
children 2ac4f3e97813
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
39788
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
1 # storage.py - Testing of storage primitives.
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
2 #
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
3 # Copyright 2018 Gregory Szorc <gregory.szorc@gmail.com>
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
4 #
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
5 # This software may be used and distributed according to the terms of the
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
6 # GNU General Public License version 2 or any later version.
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
7
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
8 from __future__ import absolute_import
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
9
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
10 import unittest
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
11
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
12 from ..node import (
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
13 hex,
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
14 nullid,
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
15 nullrev,
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
16 )
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
17 from .. import (
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
18 error,
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
19 mdiff,
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
20 revlog,
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
21 )
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
22
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
23 class basetestcase(unittest.TestCase):
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
24 if not getattr(unittest.TestCase, r'assertRaisesRegex', False):
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
25 assertRaisesRegex = (# camelcase-required
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
26 unittest.TestCase.assertRaisesRegexp)
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
27
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
28 class ifileindextests(basetestcase):
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
29 """Generic tests for the ifileindex interface.
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
30
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
31 All file storage backends for index data should conform to the tests in this
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
32 class.
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
33
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
34 Use ``makeifileindextests()`` to create an instance of this type.
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
35 """
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
36 def testempty(self):
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
37 f = self._makefilefn()
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
38 self.assertEqual(len(f), 0, 'new file store has 0 length by default')
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
39 self.assertEqual(list(f), [], 'iter yields nothing by default')
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
40
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
41 gen = iter(f)
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
42 with self.assertRaises(StopIteration):
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
43 next(gen)
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
44
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
45 # revs() should evaluate to an empty list.
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
46 self.assertEqual(list(f.revs()), [])
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
47
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
48 revs = iter(f.revs())
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
49 with self.assertRaises(StopIteration):
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
50 next(revs)
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
51
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
52 self.assertEqual(list(f.revs(start=20)), [])
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
53
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
54 # parents() and parentrevs() work with nullid/nullrev.
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
55 self.assertEqual(f.parents(nullid), (nullid, nullid))
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
56 self.assertEqual(f.parentrevs(nullrev), (nullrev, nullrev))
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
57
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
58 with self.assertRaises(error.LookupError):
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
59 f.parents(b'\x01' * 20)
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
60
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
61 for i in range(-5, 5):
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
62 if i == nullrev:
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
63 continue
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
64
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
65 with self.assertRaises(IndexError):
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
66 f.parentrevs(i)
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
67
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
68 # nullid/nullrev lookup always works.
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
69 self.assertEqual(f.rev(nullid), nullrev)
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
70 self.assertEqual(f.node(nullrev), nullid)
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
71
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
72 with self.assertRaises(error.LookupError):
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
73 f.rev(b'\x01' * 20)
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
74
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
75 for i in range(-5, 5):
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
76 if i == nullrev:
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
77 continue
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
78
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
79 with self.assertRaises(IndexError):
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
80 f.node(i)
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
81
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
82 self.assertEqual(f.lookup(nullid), nullid)
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
83 self.assertEqual(f.lookup(nullrev), nullid)
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
84 self.assertEqual(f.lookup(hex(nullid)), nullid)
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
85
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
86 # String converted to integer doesn't work for nullrev.
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
87 with self.assertRaises(error.LookupError):
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
88 f.lookup(b'%d' % nullrev)
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
89
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
90 self.assertEqual(f.linkrev(nullrev), nullrev)
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
91
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
92 for i in range(-5, 5):
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
93 if i == nullrev:
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
94 continue
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
95
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
96 with self.assertRaises(IndexError):
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
97 f.linkrev(i)
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
98
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
99 self.assertEqual(f.flags(nullrev), 0)
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
100
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
101 for i in range(-5, 5):
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
102 if i == nullrev:
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
103 continue
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
104
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
105 with self.assertRaises(IndexError):
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
106 f.flags(i)
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
107
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
108 self.assertFalse(f.iscensored(nullrev))
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
109
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
110 for i in range(-5, 5):
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
111 if i == nullrev:
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
112 continue
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
113
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
114 with self.assertRaises(IndexError):
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
115 f.iscensored(i)
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
116
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
117 self.assertEqual(list(f.commonancestorsheads(nullid, nullid)), [])
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
118
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
119 with self.assertRaises(ValueError):
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
120 self.assertEqual(list(f.descendants([])), [])
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
121
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
122 self.assertEqual(list(f.descendants([nullrev])), [])
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
123
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
124 self.assertEqual(f.heads(), [nullid])
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
125 self.assertEqual(f.heads(nullid), [nullid])
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
126 self.assertEqual(f.heads(None, [nullid]), [nullid])
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
127 self.assertEqual(f.heads(nullid, [nullid]), [nullid])
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
128
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
129 self.assertEqual(f.children(nullid), [])
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
130
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
131 with self.assertRaises(error.LookupError):
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
132 f.children(b'\x01' * 20)
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
133
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
134 self.assertEqual(f.deltaparent(nullrev), nullrev)
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
135
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
136 for i in range(-5, 5):
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
137 if i == nullrev:
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
138 continue
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
139
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
140 with self.assertRaises(IndexError):
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
141 f.deltaparent(i)
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
142
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
143 def testsinglerevision(self):
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
144 f = self._makefilefn()
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
145 with self._maketransactionfn() as tr:
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
146 node = f.add(b'initial', None, tr, 0, nullid, nullid)
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
147
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
148 self.assertEqual(len(f), 1)
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
149 self.assertEqual(list(f), [0])
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
150
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
151 gen = iter(f)
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
152 self.assertEqual(next(gen), 0)
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
153
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
154 with self.assertRaises(StopIteration):
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
155 next(gen)
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
156
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
157 self.assertEqual(list(f.revs()), [0])
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
158 self.assertEqual(list(f.revs(start=1)), [])
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
159 self.assertEqual(list(f.revs(start=0)), [0])
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
160 self.assertEqual(list(f.revs(stop=0)), [0])
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
161 self.assertEqual(list(f.revs(stop=1)), [0])
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
162 self.assertEqual(list(f.revs(1, 1)), [])
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
163 # TODO buggy
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
164 self.assertEqual(list(f.revs(1, 0)), [1, 0])
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
165 self.assertEqual(list(f.revs(2, 0)), [2, 1, 0])
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
166
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
167 self.assertEqual(f.parents(node), (nullid, nullid))
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
168 self.assertEqual(f.parentrevs(0), (nullrev, nullrev))
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
169
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
170 with self.assertRaises(error.LookupError):
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
171 f.parents(b'\x01' * 20)
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
172
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
173 with self.assertRaises(IndexError):
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
174 f.parentrevs(1)
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
175
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
176 self.assertEqual(f.rev(node), 0)
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
177
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
178 with self.assertRaises(error.LookupError):
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
179 f.rev(b'\x01' * 20)
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
180
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
181 self.assertEqual(f.node(0), node)
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
182
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
183 with self.assertRaises(IndexError):
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
184 f.node(1)
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
185
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
186 self.assertEqual(f.lookup(node), node)
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
187 self.assertEqual(f.lookup(0), node)
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
188 self.assertEqual(f.lookup(b'0'), node)
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
189 self.assertEqual(f.lookup(hex(node)), node)
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
190
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
191 self.assertEqual(f.linkrev(0), 0)
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
192
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
193 with self.assertRaises(IndexError):
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
194 f.linkrev(1)
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
195
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
196 self.assertEqual(f.flags(0), 0)
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
197
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
198 with self.assertRaises(IndexError):
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
199 f.flags(1)
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
200
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
201 self.assertFalse(f.iscensored(0))
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
202
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
203 with self.assertRaises(IndexError):
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
204 f.iscensored(1)
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
205
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
206 self.assertEqual(list(f.descendants([0])), [])
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
207
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
208 self.assertEqual(f.heads(), [node])
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
209 self.assertEqual(f.heads(node), [node])
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
210 self.assertEqual(f.heads(stop=[node]), [node])
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
211
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
212 with self.assertRaises(error.LookupError):
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
213 f.heads(stop=[b'\x01' * 20])
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
214
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
215 self.assertEqual(f.children(node), [])
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
216
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
217 self.assertEqual(f.deltaparent(0), nullrev)
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
218
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
219 def testmultiplerevisions(self):
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
220 fulltext0 = b'x' * 1024
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
221 fulltext1 = fulltext0 + b'y'
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
222 fulltext2 = b'y' + fulltext0 + b'z'
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
223
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
224 f = self._makefilefn()
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
225 with self._maketransactionfn() as tr:
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
226 node0 = f.add(fulltext0, None, tr, 0, nullid, nullid)
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
227 node1 = f.add(fulltext1, None, tr, 1, node0, nullid)
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
228 node2 = f.add(fulltext2, None, tr, 3, node1, nullid)
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
229
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
230 self.assertEqual(len(f), 3)
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
231 self.assertEqual(list(f), [0, 1, 2])
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
232
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
233 gen = iter(f)
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
234 self.assertEqual(next(gen), 0)
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
235 self.assertEqual(next(gen), 1)
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
236 self.assertEqual(next(gen), 2)
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
237
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
238 with self.assertRaises(StopIteration):
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
239 next(gen)
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
240
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
241 self.assertEqual(list(f.revs()), [0, 1, 2])
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
242 self.assertEqual(list(f.revs(0)), [0, 1, 2])
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
243 self.assertEqual(list(f.revs(1)), [1, 2])
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
244 self.assertEqual(list(f.revs(2)), [2])
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
245 self.assertEqual(list(f.revs(3)), [])
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
246 self.assertEqual(list(f.revs(stop=1)), [0, 1])
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
247 self.assertEqual(list(f.revs(stop=2)), [0, 1, 2])
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
248 self.assertEqual(list(f.revs(stop=3)), [0, 1, 2])
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
249 self.assertEqual(list(f.revs(2, 0)), [2, 1, 0])
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
250 self.assertEqual(list(f.revs(2, 1)), [2, 1])
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
251 # TODO this is wrong
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
252 self.assertEqual(list(f.revs(3, 2)), [3, 2])
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
253
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
254 self.assertEqual(f.parents(node0), (nullid, nullid))
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
255 self.assertEqual(f.parents(node1), (node0, nullid))
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
256 self.assertEqual(f.parents(node2), (node1, nullid))
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
257
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
258 self.assertEqual(f.parentrevs(0), (nullrev, nullrev))
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
259 self.assertEqual(f.parentrevs(1), (0, nullrev))
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
260 self.assertEqual(f.parentrevs(2), (1, nullrev))
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
261
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
262 self.assertEqual(f.rev(node0), 0)
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
263 self.assertEqual(f.rev(node1), 1)
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
264 self.assertEqual(f.rev(node2), 2)
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
265
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
266 with self.assertRaises(error.LookupError):
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
267 f.rev(b'\x01' * 20)
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
268
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
269 self.assertEqual(f.node(0), node0)
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
270 self.assertEqual(f.node(1), node1)
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
271 self.assertEqual(f.node(2), node2)
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
272
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
273 with self.assertRaises(IndexError):
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
274 f.node(3)
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
275
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
276 self.assertEqual(f.lookup(node0), node0)
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
277 self.assertEqual(f.lookup(0), node0)
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
278 self.assertEqual(f.lookup(b'0'), node0)
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
279 self.assertEqual(f.lookup(hex(node0)), node0)
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
280
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
281 self.assertEqual(f.lookup(node1), node1)
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
282 self.assertEqual(f.lookup(1), node1)
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
283 self.assertEqual(f.lookup(b'1'), node1)
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
284 self.assertEqual(f.lookup(hex(node1)), node1)
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
285
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
286 self.assertEqual(f.linkrev(0), 0)
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
287 self.assertEqual(f.linkrev(1), 1)
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
288 self.assertEqual(f.linkrev(2), 3)
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
289
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
290 with self.assertRaises(IndexError):
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
291 f.linkrev(3)
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
292
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
293 self.assertEqual(f.flags(0), 0)
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
294 self.assertEqual(f.flags(1), 0)
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
295 self.assertEqual(f.flags(2), 0)
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
296
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
297 with self.assertRaises(IndexError):
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
298 f.flags(3)
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
299
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
300 self.assertFalse(f.iscensored(0))
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
301 self.assertFalse(f.iscensored(1))
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
302 self.assertFalse(f.iscensored(2))
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
303
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
304 with self.assertRaises(IndexError):
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
305 f.iscensored(3)
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
306
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
307 self.assertEqual(f.commonancestorsheads(node1, nullid), [])
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
308 self.assertEqual(f.commonancestorsheads(node1, node0), [node0])
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
309 self.assertEqual(f.commonancestorsheads(node1, node1), [node1])
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
310 self.assertEqual(f.commonancestorsheads(node0, node1), [node0])
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
311 self.assertEqual(f.commonancestorsheads(node1, node2), [node1])
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
312 self.assertEqual(f.commonancestorsheads(node2, node1), [node1])
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
313
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
314 self.assertEqual(list(f.descendants([0])), [1, 2])
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
315 self.assertEqual(list(f.descendants([1])), [2])
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
316 self.assertEqual(list(f.descendants([0, 1])), [1, 2])
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
317
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
318 self.assertEqual(f.heads(), [node2])
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
319 self.assertEqual(f.heads(node0), [node2])
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
320 self.assertEqual(f.heads(node1), [node2])
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
321 self.assertEqual(f.heads(node2), [node2])
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
322
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
323 # TODO this behavior seems wonky. Is it correct? If so, the
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
324 # docstring for heads() should be updated to reflect desired
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
325 # behavior.
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
326 self.assertEqual(f.heads(stop=[node1]), [node1, node2])
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
327 self.assertEqual(f.heads(stop=[node0]), [node0, node2])
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
328 self.assertEqual(f.heads(stop=[node1, node2]), [node1, node2])
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
329
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
330 with self.assertRaises(error.LookupError):
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
331 f.heads(stop=[b'\x01' * 20])
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
332
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
333 self.assertEqual(f.children(node0), [node1])
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
334 self.assertEqual(f.children(node1), [node2])
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
335 self.assertEqual(f.children(node2), [])
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
336
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
337 self.assertEqual(f.deltaparent(0), nullrev)
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
338 self.assertEqual(f.deltaparent(1), 0)
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
339 self.assertEqual(f.deltaparent(2), 1)
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
340
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
341 def testmultipleheads(self):
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
342 f = self._makefilefn()
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
343
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
344 with self._maketransactionfn() as tr:
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
345 node0 = f.add(b'0', None, tr, 0, nullid, nullid)
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
346 node1 = f.add(b'1', None, tr, 1, node0, nullid)
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
347 node2 = f.add(b'2', None, tr, 2, node1, nullid)
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
348 node3 = f.add(b'3', None, tr, 3, node0, nullid)
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
349 node4 = f.add(b'4', None, tr, 4, node3, nullid)
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
350 node5 = f.add(b'5', None, tr, 5, node0, nullid)
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
351
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
352 self.assertEqual(len(f), 6)
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
353
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
354 self.assertEqual(list(f.descendants([0])), [1, 2, 3, 4, 5])
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
355 self.assertEqual(list(f.descendants([1])), [2])
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
356 self.assertEqual(list(f.descendants([2])), [])
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
357 self.assertEqual(list(f.descendants([3])), [4])
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
358 self.assertEqual(list(f.descendants([0, 1])), [1, 2, 3, 4, 5])
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
359 self.assertEqual(list(f.descendants([1, 3])), [2, 4])
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
360
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
361 self.assertEqual(f.heads(), [node2, node4, node5])
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
362 self.assertEqual(f.heads(node0), [node2, node4, node5])
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
363 self.assertEqual(f.heads(node1), [node2])
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
364 self.assertEqual(f.heads(node2), [node2])
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
365 self.assertEqual(f.heads(node3), [node4])
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
366 self.assertEqual(f.heads(node4), [node4])
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
367 self.assertEqual(f.heads(node5), [node5])
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
368
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
369 # TODO this seems wrong.
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
370 self.assertEqual(f.heads(stop=[node0]), [node0, node2, node4, node5])
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
371 self.assertEqual(f.heads(stop=[node1]), [node1, node2, node4, node5])
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
372
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
373 self.assertEqual(f.children(node0), [node1, node3, node5])
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
374 self.assertEqual(f.children(node1), [node2])
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
375 self.assertEqual(f.children(node2), [])
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
376 self.assertEqual(f.children(node3), [node4])
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
377 self.assertEqual(f.children(node4), [])
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
378 self.assertEqual(f.children(node5), [])
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
379
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
380 class ifiledatatests(basetestcase):
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
381 """Generic tests for the ifiledata interface.
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
382
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
383 All file storage backends for data should conform to the tests in this
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
384 class.
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
385
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
386 Use ``makeifiledatatests()`` to create an instance of this type.
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
387 """
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
388 def testempty(self):
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
389 f = self._makefilefn()
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
390
39874
14e500b58263 revlog: add method for obtaining storage info (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39871
diff changeset
391 self.assertEqual(f.storageinfo(), {})
14e500b58263 revlog: add method for obtaining storage info (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39871
diff changeset
392 self.assertEqual(f.storageinfo(revisionscount=True, trackedsize=True),
14e500b58263 revlog: add method for obtaining storage info (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39871
diff changeset
393 {'revisionscount': 0, 'trackedsize': 0})
14e500b58263 revlog: add method for obtaining storage info (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39871
diff changeset
394
39788
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
395 self.assertEqual(f.rawsize(nullrev), 0)
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
396
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
397 for i in range(-5, 5):
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
398 if i == nullrev:
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
399 continue
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
400
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
401 with self.assertRaises(IndexError):
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
402 f.rawsize(i)
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
403
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
404 self.assertEqual(f.size(nullrev), 0)
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
405
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
406 for i in range(-5, 5):
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
407 if i == nullrev:
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
408 continue
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
409
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
410 with self.assertRaises(IndexError):
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
411 f.size(i)
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
412
39792
cb65d4b7e429 error: introduce StorageError
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39788
diff changeset
413 with self.assertRaises(error.StorageError):
39788
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
414 f.checkhash(b'', nullid)
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
415
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
416 with self.assertRaises(error.LookupError):
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
417 f.checkhash(b'', b'\x01' * 20)
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
418
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
419 self.assertEqual(f.revision(nullid), b'')
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
420 self.assertEqual(f.revision(nullid, raw=True), b'')
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
421
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
422 with self.assertRaises(error.LookupError):
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
423 f.revision(b'\x01' * 20)
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
424
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
425 self.assertEqual(f.read(nullid), b'')
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
426
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
427 with self.assertRaises(error.LookupError):
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
428 f.read(b'\x01' * 20)
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
429
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
430 self.assertFalse(f.renamed(nullid))
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
431
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
432 with self.assertRaises(error.LookupError):
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
433 f.read(b'\x01' * 20)
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
434
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
435 self.assertTrue(f.cmp(nullid, b''))
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
436 self.assertTrue(f.cmp(nullid, b'foo'))
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
437
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
438 with self.assertRaises(error.LookupError):
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
439 f.cmp(b'\x01' * 20, b'irrelevant')
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
440
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
441 self.assertEqual(f.revdiff(nullrev, nullrev), b'')
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
442
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
443 with self.assertRaises(IndexError):
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
444 f.revdiff(0, nullrev)
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
445
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
446 with self.assertRaises(IndexError):
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
447 f.revdiff(nullrev, 0)
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
448
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
449 with self.assertRaises(IndexError):
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
450 f.revdiff(0, 0)
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
451
39867
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39801
diff changeset
452 # Emitting empty list is an empty generator.
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39801
diff changeset
453 gen = f.emitrevisions([])
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39801
diff changeset
454 with self.assertRaises(StopIteration):
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39801
diff changeset
455 next(gen)
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39801
diff changeset
456
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39801
diff changeset
457 # Emitting null node yields nothing.
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39801
diff changeset
458 gen = f.emitrevisions([nullid])
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39801
diff changeset
459 with self.assertRaises(StopIteration):
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39801
diff changeset
460 next(gen)
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39801
diff changeset
461
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39801
diff changeset
462 # Requesting unknown node fails.
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39801
diff changeset
463 with self.assertRaises(error.LookupError):
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39801
diff changeset
464 list(f.emitrevisions([b'\x01' * 20]))
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39801
diff changeset
465
39788
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
466 def testsinglerevision(self):
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
467 fulltext = b'initial'
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
468
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
469 f = self._makefilefn()
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
470 with self._maketransactionfn() as tr:
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
471 node = f.add(fulltext, None, tr, 0, nullid, nullid)
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
472
39874
14e500b58263 revlog: add method for obtaining storage info (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39871
diff changeset
473 self.assertEqual(f.storageinfo(), {})
14e500b58263 revlog: add method for obtaining storage info (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39871
diff changeset
474 self.assertEqual(f.storageinfo(revisionscount=True, trackedsize=True),
14e500b58263 revlog: add method for obtaining storage info (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39871
diff changeset
475 {'revisionscount': 1, 'trackedsize': len(fulltext)})
14e500b58263 revlog: add method for obtaining storage info (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39871
diff changeset
476
39788
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
477 self.assertEqual(f.rawsize(0), len(fulltext))
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
478
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
479 with self.assertRaises(IndexError):
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
480 f.rawsize(1)
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
481
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
482 self.assertEqual(f.size(0), len(fulltext))
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
483
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
484 with self.assertRaises(IndexError):
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
485 f.size(1)
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
486
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
487 f.checkhash(fulltext, node)
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
488 f.checkhash(fulltext, node, nullid, nullid)
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
489
39792
cb65d4b7e429 error: introduce StorageError
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39788
diff changeset
490 with self.assertRaises(error.StorageError):
39788
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
491 f.checkhash(fulltext + b'extra', node)
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
492
39792
cb65d4b7e429 error: introduce StorageError
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39788
diff changeset
493 with self.assertRaises(error.StorageError):
39788
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
494 f.checkhash(fulltext, node, b'\x01' * 20, nullid)
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
495
39792
cb65d4b7e429 error: introduce StorageError
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39788
diff changeset
496 with self.assertRaises(error.StorageError):
39788
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
497 f.checkhash(fulltext, node, nullid, b'\x01' * 20)
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
498
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
499 self.assertEqual(f.revision(node), fulltext)
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
500 self.assertEqual(f.revision(node, raw=True), fulltext)
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
501
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
502 self.assertEqual(f.read(node), fulltext)
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
503
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
504 self.assertFalse(f.renamed(node))
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
505
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
506 self.assertFalse(f.cmp(node, fulltext))
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
507 self.assertTrue(f.cmp(node, fulltext + b'extra'))
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
508
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
509 self.assertEqual(f.revdiff(0, 0), b'')
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
510 self.assertEqual(f.revdiff(nullrev, 0),
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
511 b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x07%s' %
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
512 fulltext)
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
513
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
514 self.assertEqual(f.revdiff(0, nullrev),
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
515 b'\x00\x00\x00\x00\x00\x00\x00\x07\x00\x00\x00\x00')
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
516
39867
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39801
diff changeset
517 # Emitting a single revision works.
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39801
diff changeset
518 gen = f.emitrevisions([node])
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39801
diff changeset
519 rev = next(gen)
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39801
diff changeset
520
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39801
diff changeset
521 self.assertEqual(rev.node, node)
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39801
diff changeset
522 self.assertEqual(rev.p1node, nullid)
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39801
diff changeset
523 self.assertEqual(rev.p2node, nullid)
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39801
diff changeset
524 self.assertIsNone(rev.linknode)
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39801
diff changeset
525 self.assertEqual(rev.basenode, nullid)
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39801
diff changeset
526 self.assertIsNone(rev.baserevisionsize)
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39801
diff changeset
527 self.assertIsNone(rev.revision)
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39801
diff changeset
528 self.assertIsNone(rev.delta)
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39801
diff changeset
529
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39801
diff changeset
530 with self.assertRaises(StopIteration):
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39801
diff changeset
531 next(gen)
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39801
diff changeset
532
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39801
diff changeset
533 # Requesting revision data works.
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39801
diff changeset
534 gen = f.emitrevisions([node], revisiondata=True)
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39801
diff changeset
535 rev = next(gen)
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39801
diff changeset
536
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39801
diff changeset
537 self.assertEqual(rev.node, node)
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39801
diff changeset
538 self.assertEqual(rev.p1node, nullid)
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39801
diff changeset
539 self.assertEqual(rev.p2node, nullid)
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39801
diff changeset
540 self.assertIsNone(rev.linknode)
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39801
diff changeset
541 self.assertEqual(rev.basenode, nullid)
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39801
diff changeset
542 self.assertIsNone(rev.baserevisionsize)
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39801
diff changeset
543 self.assertEqual(rev.revision, fulltext)
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39801
diff changeset
544 self.assertIsNone(rev.delta)
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39801
diff changeset
545
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39801
diff changeset
546 with self.assertRaises(StopIteration):
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39801
diff changeset
547 next(gen)
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39801
diff changeset
548
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39801
diff changeset
549 # Emitting an unknown node after a known revision results in error.
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39801
diff changeset
550 with self.assertRaises(error.LookupError):
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39801
diff changeset
551 list(f.emitrevisions([node, b'\x01' * 20]))
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39801
diff changeset
552
39788
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
553 def testmultiplerevisions(self):
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
554 fulltext0 = b'x' * 1024
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
555 fulltext1 = fulltext0 + b'y'
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
556 fulltext2 = b'y' + fulltext0 + b'z'
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
557
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
558 f = self._makefilefn()
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
559 with self._maketransactionfn() as tr:
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
560 node0 = f.add(fulltext0, None, tr, 0, nullid, nullid)
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
561 node1 = f.add(fulltext1, None, tr, 1, node0, nullid)
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
562 node2 = f.add(fulltext2, None, tr, 3, node1, nullid)
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
563
39874
14e500b58263 revlog: add method for obtaining storage info (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39871
diff changeset
564 self.assertEqual(f.storageinfo(), {})
14e500b58263 revlog: add method for obtaining storage info (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39871
diff changeset
565 self.assertEqual(
14e500b58263 revlog: add method for obtaining storage info (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39871
diff changeset
566 f.storageinfo(revisionscount=True, trackedsize=True),
14e500b58263 revlog: add method for obtaining storage info (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39871
diff changeset
567 {
14e500b58263 revlog: add method for obtaining storage info (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39871
diff changeset
568 'revisionscount': 3,
14e500b58263 revlog: add method for obtaining storage info (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39871
diff changeset
569 'trackedsize': len(fulltext0) + len(fulltext1) + len(fulltext2),
14e500b58263 revlog: add method for obtaining storage info (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39871
diff changeset
570 })
14e500b58263 revlog: add method for obtaining storage info (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39871
diff changeset
571
39788
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
572 self.assertEqual(f.rawsize(0), len(fulltext0))
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
573 self.assertEqual(f.rawsize(1), len(fulltext1))
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
574 self.assertEqual(f.rawsize(2), len(fulltext2))
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
575
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
576 with self.assertRaises(IndexError):
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
577 f.rawsize(3)
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
578
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
579 self.assertEqual(f.size(0), len(fulltext0))
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
580 self.assertEqual(f.size(1), len(fulltext1))
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
581 self.assertEqual(f.size(2), len(fulltext2))
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
582
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
583 with self.assertRaises(IndexError):
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
584 f.size(3)
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
585
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
586 f.checkhash(fulltext0, node0)
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
587 f.checkhash(fulltext1, node1)
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
588 f.checkhash(fulltext1, node1, node0, nullid)
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
589 f.checkhash(fulltext2, node2, node1, nullid)
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
590
39792
cb65d4b7e429 error: introduce StorageError
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39788
diff changeset
591 with self.assertRaises(error.StorageError):
39788
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
592 f.checkhash(fulltext1, b'\x01' * 20)
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
593
39792
cb65d4b7e429 error: introduce StorageError
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39788
diff changeset
594 with self.assertRaises(error.StorageError):
39788
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
595 f.checkhash(fulltext1 + b'extra', node1, node0, nullid)
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
596
39792
cb65d4b7e429 error: introduce StorageError
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39788
diff changeset
597 with self.assertRaises(error.StorageError):
39788
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
598 f.checkhash(fulltext1, node1, node0, node0)
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
599
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
600 self.assertEqual(f.revision(node0), fulltext0)
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
601 self.assertEqual(f.revision(node0, raw=True), fulltext0)
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
602 self.assertEqual(f.revision(node1), fulltext1)
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
603 self.assertEqual(f.revision(node1, raw=True), fulltext1)
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
604 self.assertEqual(f.revision(node2), fulltext2)
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
605 self.assertEqual(f.revision(node2, raw=True), fulltext2)
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
606
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
607 with self.assertRaises(error.LookupError):
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
608 f.revision(b'\x01' * 20)
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
609
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
610 self.assertEqual(f.read(node0), fulltext0)
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
611 self.assertEqual(f.read(node1), fulltext1)
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
612 self.assertEqual(f.read(node2), fulltext2)
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
613
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
614 with self.assertRaises(error.LookupError):
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
615 f.read(b'\x01' * 20)
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
616
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
617 self.assertFalse(f.renamed(node0))
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
618 self.assertFalse(f.renamed(node1))
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
619 self.assertFalse(f.renamed(node2))
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
620
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
621 with self.assertRaises(error.LookupError):
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
622 f.renamed(b'\x01' * 20)
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
623
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
624 self.assertFalse(f.cmp(node0, fulltext0))
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
625 self.assertFalse(f.cmp(node1, fulltext1))
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
626 self.assertFalse(f.cmp(node2, fulltext2))
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
627
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
628 self.assertTrue(f.cmp(node1, fulltext0))
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
629 self.assertTrue(f.cmp(node2, fulltext1))
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
630
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
631 with self.assertRaises(error.LookupError):
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
632 f.cmp(b'\x01' * 20, b'irrelevant')
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
633
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
634 self.assertEqual(f.revdiff(0, 1),
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
635 b'\x00\x00\x00\x00\x00\x00\x04\x00\x00\x00\x04\x01' +
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
636 fulltext1)
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
637
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
638 self.assertEqual(f.revdiff(0, 2),
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
639 b'\x00\x00\x00\x00\x00\x00\x04\x00\x00\x00\x04\x02' +
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
640 fulltext2)
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
641
39867
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39801
diff changeset
642 # Nodes should be emitted in order.
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39801
diff changeset
643 gen = f.emitrevisions([node0, node1, node2], revisiondata=True)
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39801
diff changeset
644
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39801
diff changeset
645 rev = next(gen)
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39801
diff changeset
646
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39801
diff changeset
647 self.assertEqual(rev.node, node0)
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39801
diff changeset
648 self.assertEqual(rev.p1node, nullid)
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39801
diff changeset
649 self.assertEqual(rev.p2node, nullid)
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39801
diff changeset
650 self.assertIsNone(rev.linknode)
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39801
diff changeset
651 self.assertEqual(rev.basenode, nullid)
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39801
diff changeset
652 self.assertIsNone(rev.baserevisionsize)
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39801
diff changeset
653 self.assertEqual(rev.revision, fulltext0)
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39801
diff changeset
654 self.assertIsNone(rev.delta)
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39801
diff changeset
655
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39801
diff changeset
656 rev = next(gen)
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39801
diff changeset
657
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39801
diff changeset
658 self.assertEqual(rev.node, node1)
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39801
diff changeset
659 self.assertEqual(rev.p1node, node0)
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39801
diff changeset
660 self.assertEqual(rev.p2node, nullid)
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39801
diff changeset
661 self.assertIsNone(rev.linknode)
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39801
diff changeset
662 self.assertEqual(rev.basenode, node0)
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39801
diff changeset
663 self.assertIsNone(rev.baserevisionsize)
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39801
diff changeset
664 self.assertIsNone(rev.revision)
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39801
diff changeset
665 self.assertEqual(rev.delta,
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39801
diff changeset
666 b'\x00\x00\x00\x00\x00\x00\x04\x00\x00\x00\x04\x01' +
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39801
diff changeset
667 fulltext1)
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39801
diff changeset
668
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39801
diff changeset
669 rev = next(gen)
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39801
diff changeset
670
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39801
diff changeset
671 self.assertEqual(rev.node, node2)
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39801
diff changeset
672 self.assertEqual(rev.p1node, node1)
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39801
diff changeset
673 self.assertEqual(rev.p2node, nullid)
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39801
diff changeset
674 self.assertIsNone(rev.linknode)
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39801
diff changeset
675 self.assertEqual(rev.basenode, node1)
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39801
diff changeset
676 self.assertIsNone(rev.baserevisionsize)
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39801
diff changeset
677 self.assertIsNone(rev.revision)
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39801
diff changeset
678 self.assertEqual(rev.delta,
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39801
diff changeset
679 b'\x00\x00\x00\x00\x00\x00\x04\x01\x00\x00\x04\x02' +
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39801
diff changeset
680 fulltext2)
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39801
diff changeset
681
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39801
diff changeset
682 with self.assertRaises(StopIteration):
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39801
diff changeset
683 next(gen)
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39801
diff changeset
684
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39801
diff changeset
685 # Request not in DAG order is reordered to be in DAG order.
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39801
diff changeset
686 gen = f.emitrevisions([node2, node1, node0], revisiondata=True)
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39801
diff changeset
687
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39801
diff changeset
688 rev = next(gen)
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39801
diff changeset
689
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39801
diff changeset
690 self.assertEqual(rev.node, node0)
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39801
diff changeset
691 self.assertEqual(rev.p1node, nullid)
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39801
diff changeset
692 self.assertEqual(rev.p2node, nullid)
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39801
diff changeset
693 self.assertIsNone(rev.linknode)
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39801
diff changeset
694 self.assertEqual(rev.basenode, nullid)
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39801
diff changeset
695 self.assertIsNone(rev.baserevisionsize)
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39801
diff changeset
696 self.assertEqual(rev.revision, fulltext0)
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39801
diff changeset
697 self.assertIsNone(rev.delta)
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39801
diff changeset
698
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39801
diff changeset
699 rev = next(gen)
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39801
diff changeset
700
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39801
diff changeset
701 self.assertEqual(rev.node, node1)
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39801
diff changeset
702 self.assertEqual(rev.p1node, node0)
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39801
diff changeset
703 self.assertEqual(rev.p2node, nullid)
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39801
diff changeset
704 self.assertIsNone(rev.linknode)
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39801
diff changeset
705 self.assertEqual(rev.basenode, node0)
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39801
diff changeset
706 self.assertIsNone(rev.baserevisionsize)
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39801
diff changeset
707 self.assertIsNone(rev.revision)
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39801
diff changeset
708 self.assertEqual(rev.delta,
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39801
diff changeset
709 b'\x00\x00\x00\x00\x00\x00\x04\x00\x00\x00\x04\x01' +
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39801
diff changeset
710 fulltext1)
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39801
diff changeset
711
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39801
diff changeset
712 rev = next(gen)
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39801
diff changeset
713
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39801
diff changeset
714 self.assertEqual(rev.node, node2)
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39801
diff changeset
715 self.assertEqual(rev.p1node, node1)
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39801
diff changeset
716 self.assertEqual(rev.p2node, nullid)
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39801
diff changeset
717 self.assertIsNone(rev.linknode)
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39801
diff changeset
718 self.assertEqual(rev.basenode, node1)
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39801
diff changeset
719 self.assertIsNone(rev.baserevisionsize)
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39801
diff changeset
720 self.assertIsNone(rev.revision)
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39801
diff changeset
721 self.assertEqual(rev.delta,
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39801
diff changeset
722 b'\x00\x00\x00\x00\x00\x00\x04\x01\x00\x00\x04\x02' +
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39801
diff changeset
723 fulltext2)
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39801
diff changeset
724
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39801
diff changeset
725 with self.assertRaises(StopIteration):
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39801
diff changeset
726 next(gen)
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39801
diff changeset
727
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39801
diff changeset
728 # Unrecognized nodesorder value raises ProgrammingError.
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39801
diff changeset
729 with self.assertRaises(error.ProgrammingError):
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39801
diff changeset
730 list(f.emitrevisions([], nodesorder='bad'))
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39801
diff changeset
731
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39801
diff changeset
732 # nodesorder=storage is recognized. But we can't test it thoroughly
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39801
diff changeset
733 # because behavior is storage-dependent.
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39801
diff changeset
734 res = list(f.emitrevisions([node2, node1, node0],
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39801
diff changeset
735 nodesorder='storage'))
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39801
diff changeset
736 self.assertEqual(len(res), 3)
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39801
diff changeset
737 self.assertEqual({o.node for o in res}, {node0, node1, node2})
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39801
diff changeset
738
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39801
diff changeset
739 # nodesorder=nodes forces the order.
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39801
diff changeset
740 gen = f.emitrevisions([node2, node0], nodesorder='nodes',
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39801
diff changeset
741 revisiondata=True)
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39801
diff changeset
742
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39801
diff changeset
743 rev = next(gen)
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39801
diff changeset
744 self.assertEqual(rev.node, node2)
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39801
diff changeset
745 self.assertEqual(rev.p1node, node1)
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39801
diff changeset
746 self.assertEqual(rev.p2node, nullid)
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39801
diff changeset
747 self.assertEqual(rev.basenode, nullid)
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39801
diff changeset
748 self.assertIsNone(rev.baserevisionsize)
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39801
diff changeset
749 self.assertEqual(rev.revision, fulltext2)
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39801
diff changeset
750 self.assertIsNone(rev.delta)
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39801
diff changeset
751
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39801
diff changeset
752 rev = next(gen)
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39801
diff changeset
753 self.assertEqual(rev.node, node0)
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39801
diff changeset
754 self.assertEqual(rev.p1node, nullid)
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39801
diff changeset
755 self.assertEqual(rev.p2node, nullid)
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39801
diff changeset
756 # Delta behavior is storage dependent, so we can't easily test it.
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39801
diff changeset
757
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39801
diff changeset
758 with self.assertRaises(StopIteration):
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39801
diff changeset
759 next(gen)
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39801
diff changeset
760
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39801
diff changeset
761 # assumehaveparentrevisions=False (the default) won't send a delta for
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39801
diff changeset
762 # the first revision.
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39801
diff changeset
763 gen = f.emitrevisions({node2, node1}, revisiondata=True)
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39801
diff changeset
764
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39801
diff changeset
765 rev = next(gen)
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39801
diff changeset
766 self.assertEqual(rev.node, node1)
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39801
diff changeset
767 self.assertEqual(rev.p1node, node0)
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39801
diff changeset
768 self.assertEqual(rev.p2node, nullid)
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39801
diff changeset
769 self.assertEqual(rev.basenode, nullid)
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39801
diff changeset
770 self.assertIsNone(rev.baserevisionsize)
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39801
diff changeset
771 self.assertEqual(rev.revision, fulltext1)
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39801
diff changeset
772 self.assertIsNone(rev.delta)
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39801
diff changeset
773
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39801
diff changeset
774 rev = next(gen)
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39801
diff changeset
775 self.assertEqual(rev.node, node2)
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39801
diff changeset
776 self.assertEqual(rev.p1node, node1)
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39801
diff changeset
777 self.assertEqual(rev.p2node, nullid)
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39801
diff changeset
778 self.assertEqual(rev.basenode, node1)
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39801
diff changeset
779 self.assertIsNone(rev.baserevisionsize)
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39801
diff changeset
780 self.assertIsNone(rev.revision)
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39801
diff changeset
781 self.assertEqual(rev.delta,
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39801
diff changeset
782 b'\x00\x00\x00\x00\x00\x00\x04\x01\x00\x00\x04\x02' +
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39801
diff changeset
783 fulltext2)
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39801
diff changeset
784
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39801
diff changeset
785 with self.assertRaises(StopIteration):
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39801
diff changeset
786 next(gen)
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39801
diff changeset
787
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39801
diff changeset
788 # assumehaveparentrevisions=True allows delta against initial revision.
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39801
diff changeset
789 gen = f.emitrevisions([node2, node1],
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39801
diff changeset
790 revisiondata=True, assumehaveparentrevisions=True)
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39801
diff changeset
791
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39801
diff changeset
792 rev = next(gen)
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39801
diff changeset
793 self.assertEqual(rev.node, node1)
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39801
diff changeset
794 self.assertEqual(rev.p1node, node0)
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39801
diff changeset
795 self.assertEqual(rev.p2node, nullid)
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39801
diff changeset
796 self.assertEqual(rev.basenode, node0)
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39801
diff changeset
797 self.assertIsNone(rev.baserevisionsize)
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39801
diff changeset
798 self.assertIsNone(rev.revision)
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39801
diff changeset
799 self.assertEqual(rev.delta,
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39801
diff changeset
800 b'\x00\x00\x00\x00\x00\x00\x04\x00\x00\x00\x04\x01' +
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39801
diff changeset
801 fulltext1)
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39801
diff changeset
802
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39801
diff changeset
803 # forceprevious=True forces a delta against the previous revision.
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39801
diff changeset
804 # Special case for initial revision.
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39801
diff changeset
805 gen = f.emitrevisions([node0], revisiondata=True, deltaprevious=True)
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39801
diff changeset
806
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39801
diff changeset
807 rev = next(gen)
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39801
diff changeset
808 self.assertEqual(rev.node, node0)
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39801
diff changeset
809 self.assertEqual(rev.p1node, nullid)
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39801
diff changeset
810 self.assertEqual(rev.p2node, nullid)
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39801
diff changeset
811 self.assertEqual(rev.basenode, nullid)
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39801
diff changeset
812 self.assertIsNone(rev.baserevisionsize)
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39801
diff changeset
813 self.assertIsNone(rev.revision)
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39801
diff changeset
814 self.assertEqual(rev.delta,
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39801
diff changeset
815 b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x04\x00' +
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39801
diff changeset
816 fulltext0)
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39801
diff changeset
817
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39801
diff changeset
818 with self.assertRaises(StopIteration):
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39801
diff changeset
819 next(gen)
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39801
diff changeset
820
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39801
diff changeset
821 gen = f.emitrevisions([node0, node2], revisiondata=True,
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39801
diff changeset
822 deltaprevious=True)
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39801
diff changeset
823
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39801
diff changeset
824 rev = next(gen)
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39801
diff changeset
825 self.assertEqual(rev.node, node0)
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39801
diff changeset
826 self.assertEqual(rev.p1node, nullid)
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39801
diff changeset
827 self.assertEqual(rev.p2node, nullid)
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39801
diff changeset
828 self.assertEqual(rev.basenode, nullid)
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39801
diff changeset
829 self.assertIsNone(rev.baserevisionsize)
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39801
diff changeset
830 self.assertIsNone(rev.revision)
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39801
diff changeset
831 self.assertEqual(rev.delta,
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39801
diff changeset
832 b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x04\x00' +
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39801
diff changeset
833 fulltext0)
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39801
diff changeset
834
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39801
diff changeset
835 rev = next(gen)
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39801
diff changeset
836 self.assertEqual(rev.node, node2)
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39801
diff changeset
837 self.assertEqual(rev.p1node, node1)
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39801
diff changeset
838 self.assertEqual(rev.p2node, nullid)
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39801
diff changeset
839 self.assertEqual(rev.basenode, node0)
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39801
diff changeset
840
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39801
diff changeset
841 with self.assertRaises(StopIteration):
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39801
diff changeset
842 next(gen)
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39801
diff changeset
843
39788
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
844 def testrenamed(self):
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
845 fulltext0 = b'foo'
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
846 fulltext1 = b'bar'
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
847 fulltext2 = b'baz'
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
848
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
849 meta1 = {
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
850 b'copy': b'source0',
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
851 b'copyrev': b'a' * 40,
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
852 }
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
853
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
854 meta2 = {
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
855 b'copy': b'source1',
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
856 b'copyrev': b'b' * 40,
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
857 }
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
858
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
859 stored1 = b''.join([
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
860 b'\x01\ncopy: source0\n',
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
861 b'copyrev: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\n\x01\n',
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
862 fulltext1,
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
863 ])
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
864
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
865 stored2 = b''.join([
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
866 b'\x01\ncopy: source1\n',
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
867 b'copyrev: bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb\n\x01\n',
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
868 fulltext2,
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
869 ])
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
870
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
871 f = self._makefilefn()
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
872 with self._maketransactionfn() as tr:
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
873 node0 = f.add(fulltext0, None, tr, 0, nullid, nullid)
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
874 node1 = f.add(fulltext1, meta1, tr, 1, node0, nullid)
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
875 node2 = f.add(fulltext2, meta2, tr, 2, nullid, nullid)
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
876
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
877 self.assertEqual(f.rawsize(1), len(stored1))
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
878 self.assertEqual(f.rawsize(2), len(stored2))
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
879
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
880 # Metadata header isn't recognized when parent isn't nullid.
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
881 self.assertEqual(f.size(1), len(stored1))
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
882 self.assertEqual(f.size(2), len(fulltext2))
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
883
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
884 self.assertEqual(f.revision(node1), stored1)
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
885 self.assertEqual(f.revision(node1, raw=True), stored1)
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
886 self.assertEqual(f.revision(node2), stored2)
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
887 self.assertEqual(f.revision(node2, raw=True), stored2)
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
888
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
889 self.assertEqual(f.read(node1), fulltext1)
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
890 self.assertEqual(f.read(node2), fulltext2)
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
891
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
892 # Returns False when first parent is set.
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
893 self.assertFalse(f.renamed(node1))
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
894 self.assertEqual(f.renamed(node2), (b'source1', b'\xbb' * 20))
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
895
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
896 self.assertTrue(f.cmp(node1, fulltext1))
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
897 self.assertTrue(f.cmp(node1, stored1))
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
898 self.assertFalse(f.cmp(node2, fulltext2))
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
899 self.assertTrue(f.cmp(node2, stored2))
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
900
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
901 def testmetadataprefix(self):
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
902 # Content with metadata prefix has extra prefix inserted in storage.
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
903 fulltext0 = b'\x01\nfoo'
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
904 stored0 = b'\x01\n\x01\n\x01\nfoo'
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
905
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
906 fulltext1 = b'\x01\nbar'
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
907 meta1 = {
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
908 b'copy': b'source0',
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
909 b'copyrev': b'b' * 40,
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
910 }
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
911 stored1 = b''.join([
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
912 b'\x01\ncopy: source0\n',
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
913 b'copyrev: %s\n' % (b'b' * 40),
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
914 b'\x01\n\x01\nbar',
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
915 ])
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
916
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
917 f = self._makefilefn()
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
918 with self._maketransactionfn() as tr:
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
919 node0 = f.add(fulltext0, {}, tr, 0, nullid, nullid)
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
920 node1 = f.add(fulltext1, meta1, tr, 1, nullid, nullid)
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
921
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
922 self.assertEqual(f.rawsize(0), len(stored0))
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
923 self.assertEqual(f.rawsize(1), len(stored1))
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
924
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
925 # TODO this is buggy.
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
926 self.assertEqual(f.size(0), len(fulltext0) + 4)
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
927
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
928 self.assertEqual(f.size(1), len(fulltext1))
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
929
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
930 self.assertEqual(f.revision(node0), stored0)
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
931 self.assertEqual(f.revision(node0, raw=True), stored0)
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
932
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
933 self.assertEqual(f.revision(node1), stored1)
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
934 self.assertEqual(f.revision(node1, raw=True), stored1)
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
935
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
936 self.assertEqual(f.read(node0), fulltext0)
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
937 self.assertEqual(f.read(node1), fulltext1)
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
938
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
939 self.assertFalse(f.cmp(node0, fulltext0))
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
940 self.assertTrue(f.cmp(node0, stored0))
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
941
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
942 self.assertFalse(f.cmp(node1, fulltext1))
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
943 self.assertTrue(f.cmp(node1, stored0))
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
944
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
945 def testcensored(self):
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
946 f = self._makefilefn()
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
947
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
948 stored1 = revlog.packmeta({
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
949 b'censored': b'tombstone',
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
950 }, b'')
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
951
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
952 # TODO tests are incomplete because we need the node to be
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
953 # different due to presence of censor metadata. But we can't
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
954 # do this with addrevision().
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
955 with self._maketransactionfn() as tr:
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
956 node0 = f.add(b'foo', None, tr, 0, nullid, nullid)
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
957 f.addrevision(stored1, tr, 1, node0, nullid,
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
958 flags=revlog.REVIDX_ISCENSORED)
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
959
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
960 self.assertEqual(f.flags(1), revlog.REVIDX_ISCENSORED)
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
961 self.assertTrue(f.iscensored(1))
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
962
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
963 self.assertEqual(f.revision(1), stored1)
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
964 self.assertEqual(f.revision(1, raw=True), stored1)
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
965
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
966 self.assertEqual(f.read(1), b'')
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
967
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
968 class ifilemutationtests(basetestcase):
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
969 """Generic tests for the ifilemutation interface.
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
970
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
971 All file storage backends that support writing should conform to this
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
972 interface.
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
973
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
974 Use ``makeifilemutationtests()`` to create an instance of this type.
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
975 """
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
976 def testaddnoop(self):
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
977 f = self._makefilefn()
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
978 with self._maketransactionfn() as tr:
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
979 node0 = f.add(b'foo', None, tr, 0, nullid, nullid)
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
980 node1 = f.add(b'foo', None, tr, 0, nullid, nullid)
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
981 # Varying by linkrev shouldn't impact hash.
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
982 node2 = f.add(b'foo', None, tr, 1, nullid, nullid)
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
983
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
984 self.assertEqual(node1, node0)
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
985 self.assertEqual(node2, node0)
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
986 self.assertEqual(len(f), 1)
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
987
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
988 def testaddrevisionbadnode(self):
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
989 f = self._makefilefn()
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
990 with self._maketransactionfn() as tr:
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
991 # Adding a revision with bad node value fails.
39792
cb65d4b7e429 error: introduce StorageError
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39788
diff changeset
992 with self.assertRaises(error.StorageError):
39788
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
993 f.addrevision(b'foo', tr, 0, nullid, nullid, node=b'\x01' * 20)
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
994
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
995 def testaddrevisionunknownflag(self):
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
996 f = self._makefilefn()
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
997 with self._maketransactionfn() as tr:
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
998 for i in range(15, 0, -1):
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
999 if (1 << i) & ~revlog.REVIDX_KNOWN_FLAGS:
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
1000 flags = 1 << i
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
1001 break
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
1002
39792
cb65d4b7e429 error: introduce StorageError
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39788
diff changeset
1003 with self.assertRaises(error.StorageError):
39788
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
1004 f.addrevision(b'foo', tr, 0, nullid, nullid, flags=flags)
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
1005
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
1006 def testaddgroupsimple(self):
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
1007 f = self._makefilefn()
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
1008
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
1009 callbackargs = []
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
1010 def cb(*args, **kwargs):
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
1011 callbackargs.append((args, kwargs))
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
1012
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
1013 def linkmapper(node):
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
1014 return 0
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
1015
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
1016 with self._maketransactionfn() as tr:
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
1017 nodes = f.addgroup([], None, tr, addrevisioncb=cb)
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
1018
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
1019 self.assertEqual(nodes, [])
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
1020 self.assertEqual(callbackargs, [])
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
1021 self.assertEqual(len(f), 0)
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
1022
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
1023 fulltext0 = b'foo'
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
1024 delta0 = mdiff.trivialdiffheader(len(fulltext0)) + fulltext0
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
1025
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
1026 deltas = [
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
1027 (b'\x01' * 20, nullid, nullid, nullid, nullid, delta0, 0),
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
1028 ]
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
1029
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
1030 with self._maketransactionfn() as tr:
39792
cb65d4b7e429 error: introduce StorageError
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39788
diff changeset
1031 with self.assertRaises(error.StorageError):
39788
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
1032 f.addgroup(deltas, linkmapper, tr, addrevisioncb=cb)
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
1033
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
1034 node0 = f.add(fulltext0, None, tr, 0, nullid, nullid)
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
1035
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
1036 f = self._makefilefn()
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
1037
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
1038 deltas = [
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
1039 (node0, nullid, nullid, nullid, nullid, delta0, 0),
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
1040 ]
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
1041
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
1042 with self._maketransactionfn() as tr:
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
1043 nodes = f.addgroup(deltas, linkmapper, tr, addrevisioncb=cb)
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
1044
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
1045 self.assertEqual(nodes, [
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
1046 b'\x49\xd8\xcb\xb1\x5c\xe2\x57\x92\x04\x47'
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
1047 b'\x00\x6b\x46\x97\x8b\x7a\xf9\x80\xa9\x79'])
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
1048
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
1049 self.assertEqual(len(callbackargs), 1)
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
1050 self.assertEqual(callbackargs[0][0][1], nodes[0])
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
1051
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
1052 self.assertEqual(list(f.revs()), [0])
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
1053 self.assertEqual(f.rev(nodes[0]), 0)
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
1054 self.assertEqual(f.node(0), nodes[0])
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
1055
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
1056 def testaddgroupmultiple(self):
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
1057 f = self._makefilefn()
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
1058
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
1059 fulltexts = [
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
1060 b'foo',
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
1061 b'bar',
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
1062 b'x' * 1024,
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
1063 ]
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
1064
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
1065 nodes = []
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
1066 with self._maketransactionfn() as tr:
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
1067 for fulltext in fulltexts:
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
1068 nodes.append(f.add(fulltext, None, tr, 0, nullid, nullid))
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
1069
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
1070 f = self._makefilefn()
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
1071 deltas = []
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
1072 for i, fulltext in enumerate(fulltexts):
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
1073 delta = mdiff.trivialdiffheader(len(fulltext)) + fulltext
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
1074
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
1075 deltas.append((nodes[i], nullid, nullid, nullid, nullid, delta, 0))
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
1076
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
1077 with self._maketransactionfn() as tr:
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
1078 self.assertEqual(f.addgroup(deltas, lambda x: 0, tr), nodes)
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
1079
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
1080 self.assertEqual(len(f), len(deltas))
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
1081 self.assertEqual(list(f.revs()), [0, 1, 2])
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
1082 self.assertEqual(f.rev(nodes[0]), 0)
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
1083 self.assertEqual(f.rev(nodes[1]), 1)
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
1084 self.assertEqual(f.rev(nodes[2]), 2)
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
1085 self.assertEqual(f.node(0), nodes[0])
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
1086 self.assertEqual(f.node(1), nodes[1])
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
1087 self.assertEqual(f.node(2), nodes[2])
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
1088
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
1089 def makeifileindextests(makefilefn, maketransactionfn):
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
1090 """Create a unittest.TestCase class suitable for testing file storage.
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
1091
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
1092 ``makefilefn`` is a callable which receives the test case as an
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
1093 argument and returns an object implementing the ``ifilestorage`` interface.
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
1094
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
1095 ``maketransactionfn`` is a callable which receives the test case as an
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
1096 argument and returns a transaction object.
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
1097
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
1098 Returns a type that is a ``unittest.TestCase`` that can be used for
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
1099 testing the object implementing the file storage interface. Simply
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
1100 assign the returned value to a module-level attribute and a test loader
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
1101 should find and run it automatically.
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
1102 """
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
1103 d = {
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
1104 r'_makefilefn': makefilefn,
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
1105 r'_maketransactionfn': maketransactionfn,
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
1106 }
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
1107 return type(r'ifileindextests', (ifileindextests,), d)
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
1108
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
1109 def makeifiledatatests(makefilefn, maketransactionfn):
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
1110 d = {
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
1111 r'_makefilefn': makefilefn,
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
1112 r'_maketransactionfn': maketransactionfn,
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
1113 }
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
1114 return type(r'ifiledatatests', (ifiledatatests,), d)
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
1115
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
1116 def makeifilemutationtests(makefilefn, maketransactionfn):
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
1117 d = {
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
1118 r'_makefilefn': makefilefn,
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
1119 r'_maketransactionfn': maketransactionfn,
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
1120 }
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
1121 return type(r'ifilemutationtests', (ifilemutationtests,), d)