Mercurial > hg
annotate mercurial/testing/storage.py @ 51576:de5bf3fe0233
revset: stop serializing node when using "%ln"
Turning hundred of thousand of node from node to hex and back can be slow… what
about we stop doing it?
In many case were we are using node id we should be using revision id. However
this is not a good reason to have a stupidly slow implementation of "%ln".
This caught my attention again because the phase discovery during push make an
extensive use of "%ln" or huge set. In absolute, that phase discovery probably
should use "%ld" and need to improves its algorithmic complexity, but improving
"%ln" seems simple and long overdue. This greatly speeds up `hg push` on
repository with many drafts.
Here are some relevant poulpe benchmarks:
### data-env-vars.name = mozilla-try-2023-03-22-zstd-sparse-revlog
# benchmark.name = hg.command.push
# bin-env-vars.hg.flavor = default
# bin-env-vars.hg.py-re2-module = default
# benchmark.variants.explicit-rev = all-out-heads
# benchmark.variants.issue6528 = disabled
# benchmark.variants.protocol = ssh
# benchmark.variants.reuse-external-delta-parent = default
## benchmark.variants.revs = any-1-extra-rev
before: 44.235070
after: 20.416329 (-53.85%, -23.82)
## benchmark.variants.revs = any-100-extra-rev
before: 49.234697
after: 26.519829 (-46.14%, -22.71)
### benchmark.name = hg.command.bundle
# bin-env-vars.hg.flavor = default
# bin-env-vars.hg.py-re2-module = default
# benchmark.variants.revs = all
# benchmark.variants.type = none-streamv2
## data-env-vars.name = heptapod-public-2024-03-25-zstd-sparse-revlog
before: 10.138396
after: 7.750458 (-23.55%, -2.39)
## data-env-vars.name = mercurial-public-2024-03-22-zstd-sparse-revlog
before: 1.263859
after: 0.700229 (-44.60%, -0.56)
## data-env-vars.name = mozilla-try-2023-03-22-zstd-sparse-revlog
before: 399.484481
after: 346.5089 (-13.26%, -52.98)
## data-env-vars.name = pypy-2024-03-22-zstd-sparse-revlog
before: 4.540080
after: 3.401700 (-25.07%, -1.14)
## data-env-vars.name = tryton-public-2024-03-22-zstd-sparse-revlog
before: 2.975765
after: 1.870798 (-37.13%, -1.10)
author | Pierre-Yves David <pierre-yves.david@octobus.net> |
---|---|
date | Fri, 05 Apr 2024 11:05:54 +0200 |
parents | ceeb8fa23cc8 |
children |
rev | line source |
---|---|
39772
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 |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
9 import unittest |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
10 |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
11 from ..node import ( |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
12 hex, |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
13 nullrev, |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
14 ) |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
15 from .. import ( |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
16 error, |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
17 mdiff, |
42813
268662aac075
interfaces: create a new folder for interfaces and move repository.py in it
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
42778
diff
changeset
|
18 ) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42813
diff
changeset
|
19 from ..interfaces import repository |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42813
diff
changeset
|
20 from ..utils import storageutil |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42813
diff
changeset
|
21 |
39772
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): |
43103
c95b2f40db7c
py3: stop normalizing 2nd argument of *attr() to unicode
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43089
diff
changeset
|
24 if not getattr(unittest.TestCase, 'assertRaisesRegex', False): |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42813
diff
changeset
|
25 assertRaisesRegex = ( # camelcase-required |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42813
diff
changeset
|
26 unittest.TestCase.assertRaisesRegexp |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42813
diff
changeset
|
27 ) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42813
diff
changeset
|
28 |
39772
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
29 |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
30 class ifileindextests(basetestcase): |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
31 """Generic tests for the ifileindex interface. |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
32 |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
33 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
|
34 class. |
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 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
|
37 """ |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42813
diff
changeset
|
38 |
39772
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
39 def testempty(self): |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
40 f = self._makefilefn() |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
41 self.assertEqual(len(f), 0, b'new file store has 0 length by default') |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
42 self.assertEqual(list(f), [], b'iter yields nothing by default') |
39772
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
43 |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
44 gen = iter(f) |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
45 with self.assertRaises(StopIteration): |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
46 next(gen) |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
47 |
40387
f1a39128da95
filelog: add a hasnode() method (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40323
diff
changeset
|
48 self.assertFalse(f.hasnode(None)) |
f1a39128da95
filelog: add a hasnode() method (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40323
diff
changeset
|
49 self.assertFalse(f.hasnode(0)) |
f1a39128da95
filelog: add a hasnode() method (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40323
diff
changeset
|
50 self.assertFalse(f.hasnode(nullrev)) |
47012
d55b71393907
node: replace nullid and friends with nodeconstants class
Joerg Sonnenberger <joerg@bec.de>
parents:
46712
diff
changeset
|
51 self.assertFalse(f.hasnode(f.nullid)) |
40387
f1a39128da95
filelog: add a hasnode() method (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40323
diff
changeset
|
52 self.assertFalse(f.hasnode(b'0')) |
f1a39128da95
filelog: add a hasnode() method (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40323
diff
changeset
|
53 self.assertFalse(f.hasnode(b'a' * 20)) |
f1a39128da95
filelog: add a hasnode() method (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40323
diff
changeset
|
54 |
39772
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
55 # 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
|
56 self.assertEqual(list(f.revs()), []) |
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 revs = iter(f.revs()) |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
59 with self.assertRaises(StopIteration): |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
60 next(revs) |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
61 |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
62 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
|
63 |
47012
d55b71393907
node: replace nullid and friends with nodeconstants class
Joerg Sonnenberger <joerg@bec.de>
parents:
46712
diff
changeset
|
64 # parents() and parentrevs() work with f.nullid/nullrev. |
d55b71393907
node: replace nullid and friends with nodeconstants class
Joerg Sonnenberger <joerg@bec.de>
parents:
46712
diff
changeset
|
65 self.assertEqual(f.parents(f.nullid), (f.nullid, f.nullid)) |
39772
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
66 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
|
67 |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
68 with self.assertRaises(error.LookupError): |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
69 f.parents(b'\x01' * 20) |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
70 |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
71 for i in range(-5, 5): |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
72 if i == nullrev: |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
73 continue |
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 with self.assertRaises(IndexError): |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
76 f.parentrevs(i) |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
77 |
47012
d55b71393907
node: replace nullid and friends with nodeconstants class
Joerg Sonnenberger <joerg@bec.de>
parents:
46712
diff
changeset
|
78 # f.nullid/nullrev lookup always works. |
d55b71393907
node: replace nullid and friends with nodeconstants class
Joerg Sonnenberger <joerg@bec.de>
parents:
46712
diff
changeset
|
79 self.assertEqual(f.rev(f.nullid), nullrev) |
d55b71393907
node: replace nullid and friends with nodeconstants class
Joerg Sonnenberger <joerg@bec.de>
parents:
46712
diff
changeset
|
80 self.assertEqual(f.node(nullrev), f.nullid) |
39772
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 with self.assertRaises(error.LookupError): |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
83 f.rev(b'\x01' * 20) |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
84 |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
85 for i in range(-5, 5): |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
86 if i == nullrev: |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
87 continue |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
88 |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
89 with self.assertRaises(IndexError): |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
90 f.node(i) |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
91 |
47012
d55b71393907
node: replace nullid and friends with nodeconstants class
Joerg Sonnenberger <joerg@bec.de>
parents:
46712
diff
changeset
|
92 self.assertEqual(f.lookup(f.nullid), f.nullid) |
d55b71393907
node: replace nullid and friends with nodeconstants class
Joerg Sonnenberger <joerg@bec.de>
parents:
46712
diff
changeset
|
93 self.assertEqual(f.lookup(nullrev), f.nullid) |
d55b71393907
node: replace nullid and friends with nodeconstants class
Joerg Sonnenberger <joerg@bec.de>
parents:
46712
diff
changeset
|
94 self.assertEqual(f.lookup(hex(f.nullid)), f.nullid) |
d55b71393907
node: replace nullid and friends with nodeconstants class
Joerg Sonnenberger <joerg@bec.de>
parents:
46712
diff
changeset
|
95 self.assertEqual(f.lookup(b'%d' % nullrev), f.nullid) |
39772
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
96 |
40001
215fd73cfe52
testing: add more testing for ifileindex.lookup()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39998
diff
changeset
|
97 with self.assertRaises(error.LookupError): |
215fd73cfe52
testing: add more testing for ifileindex.lookup()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39998
diff
changeset
|
98 f.lookup(b'badvalue') |
215fd73cfe52
testing: add more testing for ifileindex.lookup()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39998
diff
changeset
|
99 |
40002
0e8836be9541
storageutil: implement file identifier resolution method (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40001
diff
changeset
|
100 with self.assertRaises(error.LookupError): |
47012
d55b71393907
node: replace nullid and friends with nodeconstants class
Joerg Sonnenberger <joerg@bec.de>
parents:
46712
diff
changeset
|
101 f.lookup(hex(f.nullid)[0:12]) |
40001
215fd73cfe52
testing: add more testing for ifileindex.lookup()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39998
diff
changeset
|
102 |
215fd73cfe52
testing: add more testing for ifileindex.lookup()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39998
diff
changeset
|
103 with self.assertRaises(error.LookupError): |
215fd73cfe52
testing: add more testing for ifileindex.lookup()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39998
diff
changeset
|
104 f.lookup(b'-2') |
215fd73cfe52
testing: add more testing for ifileindex.lookup()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39998
diff
changeset
|
105 |
40002
0e8836be9541
storageutil: implement file identifier resolution method (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40001
diff
changeset
|
106 with self.assertRaises(error.LookupError): |
0e8836be9541
storageutil: implement file identifier resolution method (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40001
diff
changeset
|
107 f.lookup(b'0') |
40001
215fd73cfe52
testing: add more testing for ifileindex.lookup()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39998
diff
changeset
|
108 |
215fd73cfe52
testing: add more testing for ifileindex.lookup()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39998
diff
changeset
|
109 with self.assertRaises(error.LookupError): |
215fd73cfe52
testing: add more testing for ifileindex.lookup()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39998
diff
changeset
|
110 f.lookup(b'1') |
215fd73cfe52
testing: add more testing for ifileindex.lookup()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39998
diff
changeset
|
111 |
215fd73cfe52
testing: add more testing for ifileindex.lookup()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39998
diff
changeset
|
112 with self.assertRaises(error.LookupError): |
215fd73cfe52
testing: add more testing for ifileindex.lookup()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39998
diff
changeset
|
113 f.lookup(b'11111111111111111111111111111111111111') |
215fd73cfe52
testing: add more testing for ifileindex.lookup()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39998
diff
changeset
|
114 |
215fd73cfe52
testing: add more testing for ifileindex.lookup()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39998
diff
changeset
|
115 for i in range(-5, 5): |
215fd73cfe52
testing: add more testing for ifileindex.lookup()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39998
diff
changeset
|
116 if i == nullrev: |
215fd73cfe52
testing: add more testing for ifileindex.lookup()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39998
diff
changeset
|
117 continue |
215fd73cfe52
testing: add more testing for ifileindex.lookup()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39998
diff
changeset
|
118 |
215fd73cfe52
testing: add more testing for ifileindex.lookup()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39998
diff
changeset
|
119 with self.assertRaises(LookupError): |
215fd73cfe52
testing: add more testing for ifileindex.lookup()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39998
diff
changeset
|
120 f.lookup(i) |
215fd73cfe52
testing: add more testing for ifileindex.lookup()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39998
diff
changeset
|
121 |
39772
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
122 self.assertEqual(f.linkrev(nullrev), 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 for i in range(-5, 5): |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
125 if i == nullrev: |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
126 continue |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
127 |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
128 with self.assertRaises(IndexError): |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
129 f.linkrev(i) |
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 self.assertFalse(f.iscensored(nullrev)) |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
132 |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
133 for i in range(-5, 5): |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
134 if i == nullrev: |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
135 continue |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
136 |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
137 with self.assertRaises(IndexError): |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
138 f.iscensored(i) |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
139 |
47012
d55b71393907
node: replace nullid and friends with nodeconstants class
Joerg Sonnenberger <joerg@bec.de>
parents:
46712
diff
changeset
|
140 self.assertEqual(list(f.commonancestorsheads(f.nullid, f.nullid)), []) |
39772
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
141 |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
142 with self.assertRaises(ValueError): |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
143 self.assertEqual(list(f.descendants([])), []) |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
144 |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
145 self.assertEqual(list(f.descendants([nullrev])), []) |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
146 |
47012
d55b71393907
node: replace nullid and friends with nodeconstants class
Joerg Sonnenberger <joerg@bec.de>
parents:
46712
diff
changeset
|
147 self.assertEqual(f.heads(), [f.nullid]) |
d55b71393907
node: replace nullid and friends with nodeconstants class
Joerg Sonnenberger <joerg@bec.de>
parents:
46712
diff
changeset
|
148 self.assertEqual(f.heads(f.nullid), [f.nullid]) |
d55b71393907
node: replace nullid and friends with nodeconstants class
Joerg Sonnenberger <joerg@bec.de>
parents:
46712
diff
changeset
|
149 self.assertEqual(f.heads(None, [f.nullid]), [f.nullid]) |
d55b71393907
node: replace nullid and friends with nodeconstants class
Joerg Sonnenberger <joerg@bec.de>
parents:
46712
diff
changeset
|
150 self.assertEqual(f.heads(f.nullid, [f.nullid]), [f.nullid]) |
39772
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
151 |
47012
d55b71393907
node: replace nullid and friends with nodeconstants class
Joerg Sonnenberger <joerg@bec.de>
parents:
46712
diff
changeset
|
152 self.assertEqual(f.children(f.nullid), []) |
39772
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(error.LookupError): |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
155 f.children(b'\x01' * 20) |
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 def testsinglerevision(self): |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
158 f = self._makefilefn() |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
159 with self._maketransactionfn() as tr: |
47012
d55b71393907
node: replace nullid and friends with nodeconstants class
Joerg Sonnenberger <joerg@bec.de>
parents:
46712
diff
changeset
|
160 node = f.add(b'initial', None, tr, 0, f.nullid, f.nullid) |
39772
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
161 |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
162 self.assertEqual(len(f), 1) |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
163 self.assertEqual(list(f), [0]) |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
164 |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
165 gen = iter(f) |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
166 self.assertEqual(next(gen), 0) |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
167 |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
168 with self.assertRaises(StopIteration): |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
169 next(gen) |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
170 |
40387
f1a39128da95
filelog: add a hasnode() method (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40323
diff
changeset
|
171 self.assertTrue(f.hasnode(node)) |
f1a39128da95
filelog: add a hasnode() method (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40323
diff
changeset
|
172 self.assertFalse(f.hasnode(hex(node))) |
f1a39128da95
filelog: add a hasnode() method (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40323
diff
changeset
|
173 self.assertFalse(f.hasnode(nullrev)) |
47012
d55b71393907
node: replace nullid and friends with nodeconstants class
Joerg Sonnenberger <joerg@bec.de>
parents:
46712
diff
changeset
|
174 self.assertFalse(f.hasnode(f.nullid)) |
40387
f1a39128da95
filelog: add a hasnode() method (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40323
diff
changeset
|
175 self.assertFalse(f.hasnode(node[0:12])) |
f1a39128da95
filelog: add a hasnode() method (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40323
diff
changeset
|
176 self.assertFalse(f.hasnode(hex(node)[0:20])) |
f1a39128da95
filelog: add a hasnode() method (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40323
diff
changeset
|
177 |
39772
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
178 self.assertEqual(list(f.revs()), [0]) |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
179 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
|
180 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
|
181 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
|
182 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
|
183 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
|
184 # TODO buggy |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
185 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
|
186 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
|
187 |
47012
d55b71393907
node: replace nullid and friends with nodeconstants class
Joerg Sonnenberger <joerg@bec.de>
parents:
46712
diff
changeset
|
188 self.assertEqual(f.parents(node), (f.nullid, f.nullid)) |
39772
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
189 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
|
190 |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
191 with self.assertRaises(error.LookupError): |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
192 f.parents(b'\x01' * 20) |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
193 |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
194 with self.assertRaises(IndexError): |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
195 f.parentrevs(1) |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
196 |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
197 self.assertEqual(f.rev(node), 0) |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
198 |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
199 with self.assertRaises(error.LookupError): |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
200 f.rev(b'\x01' * 20) |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
201 |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
202 self.assertEqual(f.node(0), node) |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
203 |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
204 with self.assertRaises(IndexError): |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
205 f.node(1) |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
206 |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
207 self.assertEqual(f.lookup(node), node) |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
208 self.assertEqual(f.lookup(0), node) |
47012
d55b71393907
node: replace nullid and friends with nodeconstants class
Joerg Sonnenberger <joerg@bec.de>
parents:
46712
diff
changeset
|
209 self.assertEqual(f.lookup(-1), f.nullid) |
39772
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
210 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
|
211 self.assertEqual(f.lookup(hex(node)), node) |
40002
0e8836be9541
storageutil: implement file identifier resolution method (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40001
diff
changeset
|
212 |
0e8836be9541
storageutil: implement file identifier resolution method (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40001
diff
changeset
|
213 with self.assertRaises(error.LookupError): |
0e8836be9541
storageutil: implement file identifier resolution method (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40001
diff
changeset
|
214 f.lookup(hex(node)[0:12]) |
40001
215fd73cfe52
testing: add more testing for ifileindex.lookup()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39998
diff
changeset
|
215 |
40003
ad8389ecd3f5
storageutil: consistently raise LookupError (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40002
diff
changeset
|
216 with self.assertRaises(error.LookupError): |
40001
215fd73cfe52
testing: add more testing for ifileindex.lookup()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39998
diff
changeset
|
217 f.lookup(-2) |
215fd73cfe52
testing: add more testing for ifileindex.lookup()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39998
diff
changeset
|
218 |
215fd73cfe52
testing: add more testing for ifileindex.lookup()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39998
diff
changeset
|
219 with self.assertRaises(error.LookupError): |
215fd73cfe52
testing: add more testing for ifileindex.lookup()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39998
diff
changeset
|
220 f.lookup(b'-2') |
215fd73cfe52
testing: add more testing for ifileindex.lookup()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39998
diff
changeset
|
221 |
40003
ad8389ecd3f5
storageutil: consistently raise LookupError (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40002
diff
changeset
|
222 with self.assertRaises(error.LookupError): |
40001
215fd73cfe52
testing: add more testing for ifileindex.lookup()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39998
diff
changeset
|
223 f.lookup(1) |
215fd73cfe52
testing: add more testing for ifileindex.lookup()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39998
diff
changeset
|
224 |
215fd73cfe52
testing: add more testing for ifileindex.lookup()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39998
diff
changeset
|
225 with self.assertRaises(error.LookupError): |
215fd73cfe52
testing: add more testing for ifileindex.lookup()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39998
diff
changeset
|
226 f.lookup(b'1') |
39772
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
227 |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
228 self.assertEqual(f.linkrev(0), 0) |
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 with self.assertRaises(IndexError): |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
231 f.linkrev(1) |
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 self.assertFalse(f.iscensored(0)) |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
234 |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
235 with self.assertRaises(IndexError): |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
236 f.iscensored(1) |
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 self.assertEqual(list(f.descendants([0])), []) |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
239 |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
240 self.assertEqual(f.heads(), [node]) |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
241 self.assertEqual(f.heads(node), [node]) |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
242 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
|
243 |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
244 with self.assertRaises(error.LookupError): |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
245 f.heads(stop=[b'\x01' * 20]) |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
246 |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
247 self.assertEqual(f.children(node), []) |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
248 |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
249 def testmultiplerevisions(self): |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
250 fulltext0 = b'x' * 1024 |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
251 fulltext1 = fulltext0 + b'y' |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
252 fulltext2 = b'y' + fulltext0 + b'z' |
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 f = self._makefilefn() |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
255 with self._maketransactionfn() as tr: |
47012
d55b71393907
node: replace nullid and friends with nodeconstants class
Joerg Sonnenberger <joerg@bec.de>
parents:
46712
diff
changeset
|
256 node0 = f.add(fulltext0, None, tr, 0, f.nullid, f.nullid) |
d55b71393907
node: replace nullid and friends with nodeconstants class
Joerg Sonnenberger <joerg@bec.de>
parents:
46712
diff
changeset
|
257 node1 = f.add(fulltext1, None, tr, 1, node0, f.nullid) |
d55b71393907
node: replace nullid and friends with nodeconstants class
Joerg Sonnenberger <joerg@bec.de>
parents:
46712
diff
changeset
|
258 node2 = f.add(fulltext2, None, tr, 3, node1, f.nullid) |
39772
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
259 |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
260 self.assertEqual(len(f), 3) |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
261 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
|
262 |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
263 gen = iter(f) |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
264 self.assertEqual(next(gen), 0) |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
265 self.assertEqual(next(gen), 1) |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
266 self.assertEqual(next(gen), 2) |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
267 |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
268 with self.assertRaises(StopIteration): |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
269 next(gen) |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
270 |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
271 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
|
272 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
|
273 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
|
274 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
|
275 self.assertEqual(list(f.revs(3)), []) |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
276 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
|
277 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
|
278 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
|
279 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
|
280 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
|
281 # TODO this is wrong |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
282 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
|
283 |
47012
d55b71393907
node: replace nullid and friends with nodeconstants class
Joerg Sonnenberger <joerg@bec.de>
parents:
46712
diff
changeset
|
284 self.assertEqual(f.parents(node0), (f.nullid, f.nullid)) |
d55b71393907
node: replace nullid and friends with nodeconstants class
Joerg Sonnenberger <joerg@bec.de>
parents:
46712
diff
changeset
|
285 self.assertEqual(f.parents(node1), (node0, f.nullid)) |
d55b71393907
node: replace nullid and friends with nodeconstants class
Joerg Sonnenberger <joerg@bec.de>
parents:
46712
diff
changeset
|
286 self.assertEqual(f.parents(node2), (node1, f.nullid)) |
39772
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
287 |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
288 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
|
289 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
|
290 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
|
291 |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
292 self.assertEqual(f.rev(node0), 0) |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
293 self.assertEqual(f.rev(node1), 1) |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
294 self.assertEqual(f.rev(node2), 2) |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
295 |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
296 with self.assertRaises(error.LookupError): |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
297 f.rev(b'\x01' * 20) |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
298 |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
299 self.assertEqual(f.node(0), node0) |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
300 self.assertEqual(f.node(1), node1) |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
301 self.assertEqual(f.node(2), node2) |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
302 |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
303 with self.assertRaises(IndexError): |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
304 f.node(3) |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
305 |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
306 self.assertEqual(f.lookup(node0), node0) |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
307 self.assertEqual(f.lookup(0), node0) |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
308 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
|
309 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
|
310 |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
311 self.assertEqual(f.lookup(node1), node1) |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
312 self.assertEqual(f.lookup(1), node1) |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
313 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
|
314 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
|
315 |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
316 self.assertEqual(f.linkrev(0), 0) |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
317 self.assertEqual(f.linkrev(1), 1) |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
318 self.assertEqual(f.linkrev(2), 3) |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
319 |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
320 with self.assertRaises(IndexError): |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
321 f.linkrev(3) |
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 self.assertFalse(f.iscensored(0)) |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
324 self.assertFalse(f.iscensored(1)) |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
325 self.assertFalse(f.iscensored(2)) |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
326 |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
327 with self.assertRaises(IndexError): |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
328 f.iscensored(3) |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
329 |
47012
d55b71393907
node: replace nullid and friends with nodeconstants class
Joerg Sonnenberger <joerg@bec.de>
parents:
46712
diff
changeset
|
330 self.assertEqual(f.commonancestorsheads(node1, f.nullid), []) |
39772
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
331 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
|
332 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
|
333 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
|
334 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
|
335 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
|
336 |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
337 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
|
338 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
|
339 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
|
340 |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
341 self.assertEqual(f.heads(), [node2]) |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
342 self.assertEqual(f.heads(node0), [node2]) |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
343 self.assertEqual(f.heads(node1), [node2]) |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
344 self.assertEqual(f.heads(node2), [node2]) |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
345 |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
346 # 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
|
347 # 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
|
348 # behavior. |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
349 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
|
350 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
|
351 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
|
352 |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
353 with self.assertRaises(error.LookupError): |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
354 f.heads(stop=[b'\x01' * 20]) |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
355 |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
356 self.assertEqual(f.children(node0), [node1]) |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
357 self.assertEqual(f.children(node1), [node2]) |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
358 self.assertEqual(f.children(node2), []) |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
359 |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
360 def testmultipleheads(self): |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
361 f = self._makefilefn() |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
362 |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
363 with self._maketransactionfn() as tr: |
47012
d55b71393907
node: replace nullid and friends with nodeconstants class
Joerg Sonnenberger <joerg@bec.de>
parents:
46712
diff
changeset
|
364 node0 = f.add(b'0', None, tr, 0, f.nullid, f.nullid) |
d55b71393907
node: replace nullid and friends with nodeconstants class
Joerg Sonnenberger <joerg@bec.de>
parents:
46712
diff
changeset
|
365 node1 = f.add(b'1', None, tr, 1, node0, f.nullid) |
d55b71393907
node: replace nullid and friends with nodeconstants class
Joerg Sonnenberger <joerg@bec.de>
parents:
46712
diff
changeset
|
366 node2 = f.add(b'2', None, tr, 2, node1, f.nullid) |
d55b71393907
node: replace nullid and friends with nodeconstants class
Joerg Sonnenberger <joerg@bec.de>
parents:
46712
diff
changeset
|
367 node3 = f.add(b'3', None, tr, 3, node0, f.nullid) |
d55b71393907
node: replace nullid and friends with nodeconstants class
Joerg Sonnenberger <joerg@bec.de>
parents:
46712
diff
changeset
|
368 node4 = f.add(b'4', None, tr, 4, node3, f.nullid) |
d55b71393907
node: replace nullid and friends with nodeconstants class
Joerg Sonnenberger <joerg@bec.de>
parents:
46712
diff
changeset
|
369 node5 = f.add(b'5', None, tr, 5, node0, f.nullid) |
39772
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
370 |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
371 self.assertEqual(len(f), 6) |
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(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
|
374 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
|
375 self.assertEqual(list(f.descendants([2])), []) |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
376 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
|
377 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
|
378 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
|
379 |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
380 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
|
381 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
|
382 self.assertEqual(f.heads(node1), [node2]) |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
383 self.assertEqual(f.heads(node2), [node2]) |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
384 self.assertEqual(f.heads(node3), [node4]) |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
385 self.assertEqual(f.heads(node4), [node4]) |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
386 self.assertEqual(f.heads(node5), [node5]) |
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 # TODO this seems wrong. |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
389 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
|
390 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
|
391 |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
392 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
|
393 self.assertEqual(f.children(node1), [node2]) |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
394 self.assertEqual(f.children(node2), []) |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
395 self.assertEqual(f.children(node3), [node4]) |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
396 self.assertEqual(f.children(node4), []) |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
397 self.assertEqual(f.children(node5), []) |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
398 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42813
diff
changeset
|
399 |
39772
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
400 class ifiledatatests(basetestcase): |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
401 """Generic tests for the ifiledata interface. |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
402 |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
403 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
|
404 class. |
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 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
|
407 """ |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42813
diff
changeset
|
408 |
39772
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
409 def testempty(self): |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
410 f = self._makefilefn() |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
411 |
39869
14e500b58263
revlog: add method for obtaining storage info (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39866
diff
changeset
|
412 self.assertEqual(f.storageinfo(), {}) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42813
diff
changeset
|
413 self.assertEqual( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42813
diff
changeset
|
414 f.storageinfo(revisionscount=True, trackedsize=True), |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
415 {b'revisionscount': 0, b'trackedsize': 0}, |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42813
diff
changeset
|
416 ) |
39869
14e500b58263
revlog: add method for obtaining storage info (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39866
diff
changeset
|
417 |
39772
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
418 self.assertEqual(f.size(nullrev), 0) |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
419 |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
420 for i in range(-5, 5): |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
421 if i == nullrev: |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
422 continue |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
423 |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
424 with self.assertRaises(IndexError): |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
425 f.size(i) |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
426 |
47012
d55b71393907
node: replace nullid and friends with nodeconstants class
Joerg Sonnenberger <joerg@bec.de>
parents:
46712
diff
changeset
|
427 self.assertEqual(f.revision(f.nullid), b'') |
d55b71393907
node: replace nullid and friends with nodeconstants class
Joerg Sonnenberger <joerg@bec.de>
parents:
46712
diff
changeset
|
428 self.assertEqual(f.rawdata(f.nullid), b'') |
39772
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 with self.assertRaises(error.LookupError): |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
431 f.revision(b'\x01' * 20) |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
432 |
47012
d55b71393907
node: replace nullid and friends with nodeconstants class
Joerg Sonnenberger <joerg@bec.de>
parents:
46712
diff
changeset
|
433 self.assertEqual(f.read(f.nullid), b'') |
39772
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 with self.assertRaises(error.LookupError): |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
436 f.read(b'\x01' * 20) |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
437 |
47012
d55b71393907
node: replace nullid and friends with nodeconstants class
Joerg Sonnenberger <joerg@bec.de>
parents:
46712
diff
changeset
|
438 self.assertFalse(f.renamed(f.nullid)) |
39772
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
439 |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
440 with self.assertRaises(error.LookupError): |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
441 f.read(b'\x01' * 20) |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
442 |
47012
d55b71393907
node: replace nullid and friends with nodeconstants class
Joerg Sonnenberger <joerg@bec.de>
parents:
46712
diff
changeset
|
443 self.assertTrue(f.cmp(f.nullid, b'')) |
d55b71393907
node: replace nullid and friends with nodeconstants class
Joerg Sonnenberger <joerg@bec.de>
parents:
46712
diff
changeset
|
444 self.assertTrue(f.cmp(f.nullid, b'foo')) |
39772
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(error.LookupError): |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
447 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
|
448 |
39862
5a9ab91e0a45
revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39785
diff
changeset
|
449 # Emitting empty list is an empty generator. |
5a9ab91e0a45
revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39785
diff
changeset
|
450 gen = f.emitrevisions([]) |
5a9ab91e0a45
revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39785
diff
changeset
|
451 with self.assertRaises(StopIteration): |
5a9ab91e0a45
revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39785
diff
changeset
|
452 next(gen) |
5a9ab91e0a45
revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39785
diff
changeset
|
453 |
5a9ab91e0a45
revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39785
diff
changeset
|
454 # Emitting null node yields nothing. |
47012
d55b71393907
node: replace nullid and friends with nodeconstants class
Joerg Sonnenberger <joerg@bec.de>
parents:
46712
diff
changeset
|
455 gen = f.emitrevisions([f.nullid]) |
39862
5a9ab91e0a45
revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39785
diff
changeset
|
456 with self.assertRaises(StopIteration): |
5a9ab91e0a45
revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39785
diff
changeset
|
457 next(gen) |
5a9ab91e0a45
revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39785
diff
changeset
|
458 |
5a9ab91e0a45
revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39785
diff
changeset
|
459 # Requesting unknown node fails. |
5a9ab91e0a45
revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39785
diff
changeset
|
460 with self.assertRaises(error.LookupError): |
5a9ab91e0a45
revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39785
diff
changeset
|
461 list(f.emitrevisions([b'\x01' * 20])) |
5a9ab91e0a45
revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39785
diff
changeset
|
462 |
39772
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
463 def testsinglerevision(self): |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
464 fulltext = b'initial' |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
465 |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
466 f = self._makefilefn() |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
467 with self._maketransactionfn() as tr: |
47012
d55b71393907
node: replace nullid and friends with nodeconstants class
Joerg Sonnenberger <joerg@bec.de>
parents:
46712
diff
changeset
|
468 node = f.add(fulltext, None, tr, 0, f.nullid, f.nullid) |
39772
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
469 |
39869
14e500b58263
revlog: add method for obtaining storage info (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39866
diff
changeset
|
470 self.assertEqual(f.storageinfo(), {}) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42813
diff
changeset
|
471 self.assertEqual( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42813
diff
changeset
|
472 f.storageinfo(revisionscount=True, trackedsize=True), |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
473 {b'revisionscount': 1, b'trackedsize': len(fulltext)}, |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42813
diff
changeset
|
474 ) |
39869
14e500b58263
revlog: add method for obtaining storage info (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39866
diff
changeset
|
475 |
39772
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
476 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
|
477 |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
478 with self.assertRaises(IndexError): |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
479 f.size(1) |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
480 |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
481 self.assertEqual(f.revision(node), fulltext) |
42778
22e74b5aa59d
rawdata: update callers in testing/storage.py
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
40430
diff
changeset
|
482 self.assertEqual(f.rawdata(node), fulltext) |
39772
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 self.assertEqual(f.read(node), fulltext) |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
485 |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
486 self.assertFalse(f.renamed(node)) |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
487 |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
488 self.assertFalse(f.cmp(node, fulltext)) |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
489 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
|
490 |
39862
5a9ab91e0a45
revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39785
diff
changeset
|
491 # Emitting a single revision works. |
5a9ab91e0a45
revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39785
diff
changeset
|
492 gen = f.emitrevisions([node]) |
5a9ab91e0a45
revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39785
diff
changeset
|
493 rev = next(gen) |
5a9ab91e0a45
revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39785
diff
changeset
|
494 |
5a9ab91e0a45
revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39785
diff
changeset
|
495 self.assertEqual(rev.node, node) |
47012
d55b71393907
node: replace nullid and friends with nodeconstants class
Joerg Sonnenberger <joerg@bec.de>
parents:
46712
diff
changeset
|
496 self.assertEqual(rev.p1node, f.nullid) |
d55b71393907
node: replace nullid and friends with nodeconstants class
Joerg Sonnenberger <joerg@bec.de>
parents:
46712
diff
changeset
|
497 self.assertEqual(rev.p2node, f.nullid) |
39862
5a9ab91e0a45
revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39785
diff
changeset
|
498 self.assertIsNone(rev.linknode) |
47012
d55b71393907
node: replace nullid and friends with nodeconstants class
Joerg Sonnenberger <joerg@bec.de>
parents:
46712
diff
changeset
|
499 self.assertEqual(rev.basenode, f.nullid) |
39862
5a9ab91e0a45
revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39785
diff
changeset
|
500 self.assertIsNone(rev.baserevisionsize) |
5a9ab91e0a45
revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39785
diff
changeset
|
501 self.assertIsNone(rev.revision) |
5a9ab91e0a45
revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39785
diff
changeset
|
502 self.assertIsNone(rev.delta) |
5a9ab91e0a45
revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39785
diff
changeset
|
503 |
5a9ab91e0a45
revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39785
diff
changeset
|
504 with self.assertRaises(StopIteration): |
5a9ab91e0a45
revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39785
diff
changeset
|
505 next(gen) |
5a9ab91e0a45
revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39785
diff
changeset
|
506 |
5a9ab91e0a45
revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39785
diff
changeset
|
507 # Requesting revision data works. |
5a9ab91e0a45
revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39785
diff
changeset
|
508 gen = f.emitrevisions([node], revisiondata=True) |
5a9ab91e0a45
revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39785
diff
changeset
|
509 rev = next(gen) |
5a9ab91e0a45
revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39785
diff
changeset
|
510 |
5a9ab91e0a45
revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39785
diff
changeset
|
511 self.assertEqual(rev.node, node) |
47012
d55b71393907
node: replace nullid and friends with nodeconstants class
Joerg Sonnenberger <joerg@bec.de>
parents:
46712
diff
changeset
|
512 self.assertEqual(rev.p1node, f.nullid) |
d55b71393907
node: replace nullid and friends with nodeconstants class
Joerg Sonnenberger <joerg@bec.de>
parents:
46712
diff
changeset
|
513 self.assertEqual(rev.p2node, f.nullid) |
39862
5a9ab91e0a45
revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39785
diff
changeset
|
514 self.assertIsNone(rev.linknode) |
47012
d55b71393907
node: replace nullid and friends with nodeconstants class
Joerg Sonnenberger <joerg@bec.de>
parents:
46712
diff
changeset
|
515 self.assertEqual(rev.basenode, f.nullid) |
39862
5a9ab91e0a45
revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39785
diff
changeset
|
516 self.assertIsNone(rev.baserevisionsize) |
5a9ab91e0a45
revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39785
diff
changeset
|
517 self.assertEqual(rev.revision, fulltext) |
5a9ab91e0a45
revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39785
diff
changeset
|
518 self.assertIsNone(rev.delta) |
5a9ab91e0a45
revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39785
diff
changeset
|
519 |
5a9ab91e0a45
revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39785
diff
changeset
|
520 with self.assertRaises(StopIteration): |
5a9ab91e0a45
revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39785
diff
changeset
|
521 next(gen) |
5a9ab91e0a45
revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39785
diff
changeset
|
522 |
5a9ab91e0a45
revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39785
diff
changeset
|
523 # 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:
39785
diff
changeset
|
524 with self.assertRaises(error.LookupError): |
5a9ab91e0a45
revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39785
diff
changeset
|
525 list(f.emitrevisions([node, b'\x01' * 20])) |
5a9ab91e0a45
revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39785
diff
changeset
|
526 |
39772
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
527 def testmultiplerevisions(self): |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
528 fulltext0 = b'x' * 1024 |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
529 fulltext1 = fulltext0 + b'y' |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
530 fulltext2 = b'y' + fulltext0 + b'z' |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
531 |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
532 f = self._makefilefn() |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
533 with self._maketransactionfn() as tr: |
47012
d55b71393907
node: replace nullid and friends with nodeconstants class
Joerg Sonnenberger <joerg@bec.de>
parents:
46712
diff
changeset
|
534 node0 = f.add(fulltext0, None, tr, 0, f.nullid, f.nullid) |
d55b71393907
node: replace nullid and friends with nodeconstants class
Joerg Sonnenberger <joerg@bec.de>
parents:
46712
diff
changeset
|
535 node1 = f.add(fulltext1, None, tr, 1, node0, f.nullid) |
d55b71393907
node: replace nullid and friends with nodeconstants class
Joerg Sonnenberger <joerg@bec.de>
parents:
46712
diff
changeset
|
536 node2 = f.add(fulltext2, None, tr, 3, node1, f.nullid) |
39772
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
537 |
39869
14e500b58263
revlog: add method for obtaining storage info (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39866
diff
changeset
|
538 self.assertEqual(f.storageinfo(), {}) |
14e500b58263
revlog: add method for obtaining storage info (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39866
diff
changeset
|
539 self.assertEqual( |
14e500b58263
revlog: add method for obtaining storage info (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39866
diff
changeset
|
540 f.storageinfo(revisionscount=True, trackedsize=True), |
14e500b58263
revlog: add method for obtaining storage info (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39866
diff
changeset
|
541 { |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
542 b'revisionscount': 3, |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
543 b'trackedsize': len(fulltext0) |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
544 + len(fulltext1) |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
545 + len(fulltext2), |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42813
diff
changeset
|
546 }, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42813
diff
changeset
|
547 ) |
39869
14e500b58263
revlog: add method for obtaining storage info (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39866
diff
changeset
|
548 |
39772
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
549 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
|
550 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
|
551 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
|
552 |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
553 with self.assertRaises(IndexError): |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
554 f.size(3) |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
555 |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
556 self.assertEqual(f.revision(node0), fulltext0) |
42778
22e74b5aa59d
rawdata: update callers in testing/storage.py
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
40430
diff
changeset
|
557 self.assertEqual(f.rawdata(node0), fulltext0) |
39772
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
558 self.assertEqual(f.revision(node1), fulltext1) |
42778
22e74b5aa59d
rawdata: update callers in testing/storage.py
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
40430
diff
changeset
|
559 self.assertEqual(f.rawdata(node1), fulltext1) |
39772
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
560 self.assertEqual(f.revision(node2), fulltext2) |
42778
22e74b5aa59d
rawdata: update callers in testing/storage.py
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
40430
diff
changeset
|
561 self.assertEqual(f.rawdata(node2), fulltext2) |
39772
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
562 |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
563 with self.assertRaises(error.LookupError): |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
564 f.revision(b'\x01' * 20) |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
565 |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
566 self.assertEqual(f.read(node0), fulltext0) |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
567 self.assertEqual(f.read(node1), fulltext1) |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
568 self.assertEqual(f.read(node2), fulltext2) |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
569 |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
570 with self.assertRaises(error.LookupError): |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
571 f.read(b'\x01' * 20) |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
572 |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
573 self.assertFalse(f.renamed(node0)) |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
574 self.assertFalse(f.renamed(node1)) |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
575 self.assertFalse(f.renamed(node2)) |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
576 |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
577 with self.assertRaises(error.LookupError): |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
578 f.renamed(b'\x01' * 20) |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
579 |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
580 self.assertFalse(f.cmp(node0, fulltext0)) |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
581 self.assertFalse(f.cmp(node1, fulltext1)) |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
582 self.assertFalse(f.cmp(node2, fulltext2)) |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
583 |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
584 self.assertTrue(f.cmp(node1, fulltext0)) |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
585 self.assertTrue(f.cmp(node2, fulltext1)) |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
586 |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
587 with self.assertRaises(error.LookupError): |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
588 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
|
589 |
39862
5a9ab91e0a45
revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39785
diff
changeset
|
590 # Nodes should be emitted in order. |
5a9ab91e0a45
revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39785
diff
changeset
|
591 gen = f.emitrevisions([node0, node1, node2], revisiondata=True) |
5a9ab91e0a45
revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39785
diff
changeset
|
592 |
5a9ab91e0a45
revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39785
diff
changeset
|
593 rev = next(gen) |
5a9ab91e0a45
revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39785
diff
changeset
|
594 |
5a9ab91e0a45
revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39785
diff
changeset
|
595 self.assertEqual(rev.node, node0) |
47012
d55b71393907
node: replace nullid and friends with nodeconstants class
Joerg Sonnenberger <joerg@bec.de>
parents:
46712
diff
changeset
|
596 self.assertEqual(rev.p1node, f.nullid) |
d55b71393907
node: replace nullid and friends with nodeconstants class
Joerg Sonnenberger <joerg@bec.de>
parents:
46712
diff
changeset
|
597 self.assertEqual(rev.p2node, f.nullid) |
39862
5a9ab91e0a45
revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39785
diff
changeset
|
598 self.assertIsNone(rev.linknode) |
47012
d55b71393907
node: replace nullid and friends with nodeconstants class
Joerg Sonnenberger <joerg@bec.de>
parents:
46712
diff
changeset
|
599 self.assertEqual(rev.basenode, f.nullid) |
39862
5a9ab91e0a45
revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39785
diff
changeset
|
600 self.assertIsNone(rev.baserevisionsize) |
5a9ab91e0a45
revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39785
diff
changeset
|
601 self.assertEqual(rev.revision, fulltext0) |
5a9ab91e0a45
revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39785
diff
changeset
|
602 self.assertIsNone(rev.delta) |
5a9ab91e0a45
revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39785
diff
changeset
|
603 |
5a9ab91e0a45
revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39785
diff
changeset
|
604 rev = next(gen) |
5a9ab91e0a45
revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39785
diff
changeset
|
605 |
5a9ab91e0a45
revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39785
diff
changeset
|
606 self.assertEqual(rev.node, node1) |
5a9ab91e0a45
revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39785
diff
changeset
|
607 self.assertEqual(rev.p1node, node0) |
47012
d55b71393907
node: replace nullid and friends with nodeconstants class
Joerg Sonnenberger <joerg@bec.de>
parents:
46712
diff
changeset
|
608 self.assertEqual(rev.p2node, f.nullid) |
39862
5a9ab91e0a45
revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39785
diff
changeset
|
609 self.assertIsNone(rev.linknode) |
5a9ab91e0a45
revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39785
diff
changeset
|
610 self.assertEqual(rev.basenode, node0) |
5a9ab91e0a45
revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39785
diff
changeset
|
611 self.assertIsNone(rev.baserevisionsize) |
5a9ab91e0a45
revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39785
diff
changeset
|
612 self.assertIsNone(rev.revision) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42813
diff
changeset
|
613 self.assertEqual( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42813
diff
changeset
|
614 rev.delta, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42813
diff
changeset
|
615 b'\x00\x00\x00\x00\x00\x00\x04\x00\x00\x00\x04\x01' + fulltext1, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42813
diff
changeset
|
616 ) |
39862
5a9ab91e0a45
revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39785
diff
changeset
|
617 |
5a9ab91e0a45
revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39785
diff
changeset
|
618 rev = next(gen) |
5a9ab91e0a45
revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39785
diff
changeset
|
619 |
5a9ab91e0a45
revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39785
diff
changeset
|
620 self.assertEqual(rev.node, node2) |
5a9ab91e0a45
revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39785
diff
changeset
|
621 self.assertEqual(rev.p1node, node1) |
47012
d55b71393907
node: replace nullid and friends with nodeconstants class
Joerg Sonnenberger <joerg@bec.de>
parents:
46712
diff
changeset
|
622 self.assertEqual(rev.p2node, f.nullid) |
39862
5a9ab91e0a45
revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39785
diff
changeset
|
623 self.assertIsNone(rev.linknode) |
5a9ab91e0a45
revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39785
diff
changeset
|
624 self.assertEqual(rev.basenode, node1) |
5a9ab91e0a45
revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39785
diff
changeset
|
625 self.assertIsNone(rev.baserevisionsize) |
5a9ab91e0a45
revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39785
diff
changeset
|
626 self.assertIsNone(rev.revision) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42813
diff
changeset
|
627 self.assertEqual( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42813
diff
changeset
|
628 rev.delta, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42813
diff
changeset
|
629 b'\x00\x00\x00\x00\x00\x00\x04\x01\x00\x00\x04\x02' + fulltext2, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42813
diff
changeset
|
630 ) |
39862
5a9ab91e0a45
revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39785
diff
changeset
|
631 |
5a9ab91e0a45
revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39785
diff
changeset
|
632 with self.assertRaises(StopIteration): |
5a9ab91e0a45
revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39785
diff
changeset
|
633 next(gen) |
5a9ab91e0a45
revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39785
diff
changeset
|
634 |
5a9ab91e0a45
revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39785
diff
changeset
|
635 # 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:
39785
diff
changeset
|
636 gen = f.emitrevisions([node2, node1, node0], revisiondata=True) |
5a9ab91e0a45
revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39785
diff
changeset
|
637 |
5a9ab91e0a45
revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39785
diff
changeset
|
638 rev = next(gen) |
5a9ab91e0a45
revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39785
diff
changeset
|
639 |
5a9ab91e0a45
revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39785
diff
changeset
|
640 self.assertEqual(rev.node, node0) |
47012
d55b71393907
node: replace nullid and friends with nodeconstants class
Joerg Sonnenberger <joerg@bec.de>
parents:
46712
diff
changeset
|
641 self.assertEqual(rev.p1node, f.nullid) |
d55b71393907
node: replace nullid and friends with nodeconstants class
Joerg Sonnenberger <joerg@bec.de>
parents:
46712
diff
changeset
|
642 self.assertEqual(rev.p2node, f.nullid) |
39862
5a9ab91e0a45
revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39785
diff
changeset
|
643 self.assertIsNone(rev.linknode) |
47012
d55b71393907
node: replace nullid and friends with nodeconstants class
Joerg Sonnenberger <joerg@bec.de>
parents:
46712
diff
changeset
|
644 self.assertEqual(rev.basenode, f.nullid) |
39862
5a9ab91e0a45
revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39785
diff
changeset
|
645 self.assertIsNone(rev.baserevisionsize) |
5a9ab91e0a45
revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39785
diff
changeset
|
646 self.assertEqual(rev.revision, fulltext0) |
5a9ab91e0a45
revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39785
diff
changeset
|
647 self.assertIsNone(rev.delta) |
5a9ab91e0a45
revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39785
diff
changeset
|
648 |
5a9ab91e0a45
revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39785
diff
changeset
|
649 rev = next(gen) |
5a9ab91e0a45
revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39785
diff
changeset
|
650 |
5a9ab91e0a45
revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39785
diff
changeset
|
651 self.assertEqual(rev.node, node1) |
5a9ab91e0a45
revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39785
diff
changeset
|
652 self.assertEqual(rev.p1node, node0) |
47012
d55b71393907
node: replace nullid and friends with nodeconstants class
Joerg Sonnenberger <joerg@bec.de>
parents:
46712
diff
changeset
|
653 self.assertEqual(rev.p2node, f.nullid) |
39862
5a9ab91e0a45
revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39785
diff
changeset
|
654 self.assertIsNone(rev.linknode) |
5a9ab91e0a45
revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39785
diff
changeset
|
655 self.assertEqual(rev.basenode, node0) |
5a9ab91e0a45
revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39785
diff
changeset
|
656 self.assertIsNone(rev.baserevisionsize) |
5a9ab91e0a45
revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39785
diff
changeset
|
657 self.assertIsNone(rev.revision) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42813
diff
changeset
|
658 self.assertEqual( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42813
diff
changeset
|
659 rev.delta, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42813
diff
changeset
|
660 b'\x00\x00\x00\x00\x00\x00\x04\x00\x00\x00\x04\x01' + fulltext1, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42813
diff
changeset
|
661 ) |
39862
5a9ab91e0a45
revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39785
diff
changeset
|
662 |
5a9ab91e0a45
revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39785
diff
changeset
|
663 rev = next(gen) |
5a9ab91e0a45
revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39785
diff
changeset
|
664 |
5a9ab91e0a45
revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39785
diff
changeset
|
665 self.assertEqual(rev.node, node2) |
5a9ab91e0a45
revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39785
diff
changeset
|
666 self.assertEqual(rev.p1node, node1) |
47012
d55b71393907
node: replace nullid and friends with nodeconstants class
Joerg Sonnenberger <joerg@bec.de>
parents:
46712
diff
changeset
|
667 self.assertEqual(rev.p2node, f.nullid) |
39862
5a9ab91e0a45
revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39785
diff
changeset
|
668 self.assertIsNone(rev.linknode) |
5a9ab91e0a45
revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39785
diff
changeset
|
669 self.assertEqual(rev.basenode, node1) |
5a9ab91e0a45
revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39785
diff
changeset
|
670 self.assertIsNone(rev.baserevisionsize) |
5a9ab91e0a45
revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39785
diff
changeset
|
671 self.assertIsNone(rev.revision) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42813
diff
changeset
|
672 self.assertEqual( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42813
diff
changeset
|
673 rev.delta, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42813
diff
changeset
|
674 b'\x00\x00\x00\x00\x00\x00\x04\x01\x00\x00\x04\x02' + fulltext2, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42813
diff
changeset
|
675 ) |
39862
5a9ab91e0a45
revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39785
diff
changeset
|
676 |
5a9ab91e0a45
revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39785
diff
changeset
|
677 with self.assertRaises(StopIteration): |
5a9ab91e0a45
revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39785
diff
changeset
|
678 next(gen) |
5a9ab91e0a45
revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39785
diff
changeset
|
679 |
5a9ab91e0a45
revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39785
diff
changeset
|
680 # Unrecognized nodesorder value raises ProgrammingError. |
5a9ab91e0a45
revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39785
diff
changeset
|
681 with self.assertRaises(error.ProgrammingError): |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
682 list(f.emitrevisions([], nodesorder=b'bad')) |
39862
5a9ab91e0a45
revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39785
diff
changeset
|
683 |
5a9ab91e0a45
revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39785
diff
changeset
|
684 # 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:
39785
diff
changeset
|
685 # because behavior is storage-dependent. |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
686 res = list( |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
687 f.emitrevisions([node2, node1, node0], nodesorder=b'storage') |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
688 ) |
39862
5a9ab91e0a45
revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39785
diff
changeset
|
689 self.assertEqual(len(res), 3) |
5a9ab91e0a45
revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39785
diff
changeset
|
690 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:
39785
diff
changeset
|
691 |
5a9ab91e0a45
revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39785
diff
changeset
|
692 # nodesorder=nodes forces the order. |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42813
diff
changeset
|
693 gen = f.emitrevisions( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
694 [node2, node0], nodesorder=b'nodes', revisiondata=True |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42813
diff
changeset
|
695 ) |
39862
5a9ab91e0a45
revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39785
diff
changeset
|
696 |
5a9ab91e0a45
revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39785
diff
changeset
|
697 rev = next(gen) |
5a9ab91e0a45
revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39785
diff
changeset
|
698 self.assertEqual(rev.node, node2) |
5a9ab91e0a45
revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39785
diff
changeset
|
699 self.assertEqual(rev.p1node, node1) |
47012
d55b71393907
node: replace nullid and friends with nodeconstants class
Joerg Sonnenberger <joerg@bec.de>
parents:
46712
diff
changeset
|
700 self.assertEqual(rev.p2node, f.nullid) |
d55b71393907
node: replace nullid and friends with nodeconstants class
Joerg Sonnenberger <joerg@bec.de>
parents:
46712
diff
changeset
|
701 self.assertEqual(rev.basenode, f.nullid) |
39862
5a9ab91e0a45
revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39785
diff
changeset
|
702 self.assertIsNone(rev.baserevisionsize) |
5a9ab91e0a45
revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39785
diff
changeset
|
703 self.assertEqual(rev.revision, fulltext2) |
5a9ab91e0a45
revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39785
diff
changeset
|
704 self.assertIsNone(rev.delta) |
5a9ab91e0a45
revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39785
diff
changeset
|
705 |
5a9ab91e0a45
revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39785
diff
changeset
|
706 rev = next(gen) |
5a9ab91e0a45
revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39785
diff
changeset
|
707 self.assertEqual(rev.node, node0) |
47012
d55b71393907
node: replace nullid and friends with nodeconstants class
Joerg Sonnenberger <joerg@bec.de>
parents:
46712
diff
changeset
|
708 self.assertEqual(rev.p1node, f.nullid) |
d55b71393907
node: replace nullid and friends with nodeconstants class
Joerg Sonnenberger <joerg@bec.de>
parents:
46712
diff
changeset
|
709 self.assertEqual(rev.p2node, f.nullid) |
39862
5a9ab91e0a45
revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39785
diff
changeset
|
710 # 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:
39785
diff
changeset
|
711 |
5a9ab91e0a45
revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39785
diff
changeset
|
712 with self.assertRaises(StopIteration): |
5a9ab91e0a45
revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39785
diff
changeset
|
713 next(gen) |
5a9ab91e0a45
revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39785
diff
changeset
|
714 |
5a9ab91e0a45
revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39785
diff
changeset
|
715 # 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:
39785
diff
changeset
|
716 # the first revision. |
5a9ab91e0a45
revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39785
diff
changeset
|
717 gen = f.emitrevisions({node2, node1}, revisiondata=True) |
5a9ab91e0a45
revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39785
diff
changeset
|
718 |
5a9ab91e0a45
revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39785
diff
changeset
|
719 rev = next(gen) |
5a9ab91e0a45
revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39785
diff
changeset
|
720 self.assertEqual(rev.node, node1) |
5a9ab91e0a45
revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39785
diff
changeset
|
721 self.assertEqual(rev.p1node, node0) |
47012
d55b71393907
node: replace nullid and friends with nodeconstants class
Joerg Sonnenberger <joerg@bec.de>
parents:
46712
diff
changeset
|
722 self.assertEqual(rev.p2node, f.nullid) |
d55b71393907
node: replace nullid and friends with nodeconstants class
Joerg Sonnenberger <joerg@bec.de>
parents:
46712
diff
changeset
|
723 self.assertEqual(rev.basenode, f.nullid) |
39862
5a9ab91e0a45
revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39785
diff
changeset
|
724 self.assertIsNone(rev.baserevisionsize) |
5a9ab91e0a45
revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39785
diff
changeset
|
725 self.assertEqual(rev.revision, fulltext1) |
5a9ab91e0a45
revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39785
diff
changeset
|
726 self.assertIsNone(rev.delta) |
5a9ab91e0a45
revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39785
diff
changeset
|
727 |
5a9ab91e0a45
revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39785
diff
changeset
|
728 rev = next(gen) |
5a9ab91e0a45
revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39785
diff
changeset
|
729 self.assertEqual(rev.node, node2) |
5a9ab91e0a45
revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39785
diff
changeset
|
730 self.assertEqual(rev.p1node, node1) |
47012
d55b71393907
node: replace nullid and friends with nodeconstants class
Joerg Sonnenberger <joerg@bec.de>
parents:
46712
diff
changeset
|
731 self.assertEqual(rev.p2node, f.nullid) |
39862
5a9ab91e0a45
revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39785
diff
changeset
|
732 self.assertEqual(rev.basenode, node1) |
5a9ab91e0a45
revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39785
diff
changeset
|
733 self.assertIsNone(rev.baserevisionsize) |
5a9ab91e0a45
revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39785
diff
changeset
|
734 self.assertIsNone(rev.revision) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42813
diff
changeset
|
735 self.assertEqual( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42813
diff
changeset
|
736 rev.delta, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42813
diff
changeset
|
737 b'\x00\x00\x00\x00\x00\x00\x04\x01\x00\x00\x04\x02' + fulltext2, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42813
diff
changeset
|
738 ) |
39862
5a9ab91e0a45
revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39785
diff
changeset
|
739 |
5a9ab91e0a45
revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39785
diff
changeset
|
740 with self.assertRaises(StopIteration): |
5a9ab91e0a45
revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39785
diff
changeset
|
741 next(gen) |
5a9ab91e0a45
revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39785
diff
changeset
|
742 |
5a9ab91e0a45
revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39785
diff
changeset
|
743 # assumehaveparentrevisions=True allows delta against initial revision. |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42813
diff
changeset
|
744 gen = f.emitrevisions( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42813
diff
changeset
|
745 [node2, node1], revisiondata=True, assumehaveparentrevisions=True |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42813
diff
changeset
|
746 ) |
39862
5a9ab91e0a45
revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39785
diff
changeset
|
747 |
5a9ab91e0a45
revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39785
diff
changeset
|
748 rev = next(gen) |
5a9ab91e0a45
revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39785
diff
changeset
|
749 self.assertEqual(rev.node, node1) |
5a9ab91e0a45
revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39785
diff
changeset
|
750 self.assertEqual(rev.p1node, node0) |
47012
d55b71393907
node: replace nullid and friends with nodeconstants class
Joerg Sonnenberger <joerg@bec.de>
parents:
46712
diff
changeset
|
751 self.assertEqual(rev.p2node, f.nullid) |
39862
5a9ab91e0a45
revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39785
diff
changeset
|
752 self.assertEqual(rev.basenode, node0) |
5a9ab91e0a45
revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39785
diff
changeset
|
753 self.assertIsNone(rev.baserevisionsize) |
5a9ab91e0a45
revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39785
diff
changeset
|
754 self.assertIsNone(rev.revision) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42813
diff
changeset
|
755 self.assertEqual( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42813
diff
changeset
|
756 rev.delta, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42813
diff
changeset
|
757 b'\x00\x00\x00\x00\x00\x00\x04\x00\x00\x00\x04\x01' + fulltext1, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42813
diff
changeset
|
758 ) |
39862
5a9ab91e0a45
revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39785
diff
changeset
|
759 |
5a9ab91e0a45
revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39785
diff
changeset
|
760 # forceprevious=True forces a delta against the previous revision. |
5a9ab91e0a45
revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39785
diff
changeset
|
761 # Special case for initial revision. |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42813
diff
changeset
|
762 gen = f.emitrevisions( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42813
diff
changeset
|
763 [node0], revisiondata=True, deltamode=repository.CG_DELTAMODE_PREV |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42813
diff
changeset
|
764 ) |
39862
5a9ab91e0a45
revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39785
diff
changeset
|
765 |
5a9ab91e0a45
revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39785
diff
changeset
|
766 rev = next(gen) |
5a9ab91e0a45
revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39785
diff
changeset
|
767 self.assertEqual(rev.node, node0) |
47012
d55b71393907
node: replace nullid and friends with nodeconstants class
Joerg Sonnenberger <joerg@bec.de>
parents:
46712
diff
changeset
|
768 self.assertEqual(rev.p1node, f.nullid) |
d55b71393907
node: replace nullid and friends with nodeconstants class
Joerg Sonnenberger <joerg@bec.de>
parents:
46712
diff
changeset
|
769 self.assertEqual(rev.p2node, f.nullid) |
d55b71393907
node: replace nullid and friends with nodeconstants class
Joerg Sonnenberger <joerg@bec.de>
parents:
46712
diff
changeset
|
770 self.assertEqual(rev.basenode, f.nullid) |
39862
5a9ab91e0a45
revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39785
diff
changeset
|
771 self.assertIsNone(rev.baserevisionsize) |
5a9ab91e0a45
revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39785
diff
changeset
|
772 self.assertIsNone(rev.revision) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42813
diff
changeset
|
773 self.assertEqual( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42813
diff
changeset
|
774 rev.delta, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42813
diff
changeset
|
775 b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x04\x00' + fulltext0, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42813
diff
changeset
|
776 ) |
39862
5a9ab91e0a45
revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39785
diff
changeset
|
777 |
5a9ab91e0a45
revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39785
diff
changeset
|
778 with self.assertRaises(StopIteration): |
5a9ab91e0a45
revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39785
diff
changeset
|
779 next(gen) |
5a9ab91e0a45
revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39785
diff
changeset
|
780 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42813
diff
changeset
|
781 gen = f.emitrevisions( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42813
diff
changeset
|
782 [node0, node2], |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42813
diff
changeset
|
783 revisiondata=True, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42813
diff
changeset
|
784 deltamode=repository.CG_DELTAMODE_PREV, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42813
diff
changeset
|
785 ) |
39862
5a9ab91e0a45
revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39785
diff
changeset
|
786 |
5a9ab91e0a45
revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39785
diff
changeset
|
787 rev = next(gen) |
5a9ab91e0a45
revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39785
diff
changeset
|
788 self.assertEqual(rev.node, node0) |
47012
d55b71393907
node: replace nullid and friends with nodeconstants class
Joerg Sonnenberger <joerg@bec.de>
parents:
46712
diff
changeset
|
789 self.assertEqual(rev.p1node, f.nullid) |
d55b71393907
node: replace nullid and friends with nodeconstants class
Joerg Sonnenberger <joerg@bec.de>
parents:
46712
diff
changeset
|
790 self.assertEqual(rev.p2node, f.nullid) |
d55b71393907
node: replace nullid and friends with nodeconstants class
Joerg Sonnenberger <joerg@bec.de>
parents:
46712
diff
changeset
|
791 self.assertEqual(rev.basenode, f.nullid) |
39862
5a9ab91e0a45
revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39785
diff
changeset
|
792 self.assertIsNone(rev.baserevisionsize) |
5a9ab91e0a45
revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39785
diff
changeset
|
793 self.assertIsNone(rev.revision) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42813
diff
changeset
|
794 self.assertEqual( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42813
diff
changeset
|
795 rev.delta, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42813
diff
changeset
|
796 b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x04\x00' + fulltext0, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42813
diff
changeset
|
797 ) |
39862
5a9ab91e0a45
revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39785
diff
changeset
|
798 |
5a9ab91e0a45
revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39785
diff
changeset
|
799 rev = next(gen) |
5a9ab91e0a45
revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39785
diff
changeset
|
800 self.assertEqual(rev.node, node2) |
5a9ab91e0a45
revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39785
diff
changeset
|
801 self.assertEqual(rev.p1node, node1) |
47012
d55b71393907
node: replace nullid and friends with nodeconstants class
Joerg Sonnenberger <joerg@bec.de>
parents:
46712
diff
changeset
|
802 self.assertEqual(rev.p2node, f.nullid) |
39862
5a9ab91e0a45
revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39785
diff
changeset
|
803 self.assertEqual(rev.basenode, node0) |
5a9ab91e0a45
revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39785
diff
changeset
|
804 |
5a9ab91e0a45
revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39785
diff
changeset
|
805 with self.assertRaises(StopIteration): |
5a9ab91e0a45
revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39785
diff
changeset
|
806 next(gen) |
5a9ab91e0a45
revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39785
diff
changeset
|
807 |
39772
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
808 def testrenamed(self): |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
809 fulltext0 = b'foo' |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
810 fulltext1 = b'bar' |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
811 fulltext2 = b'baz' |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
812 |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
813 meta1 = { |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
814 b'copy': b'source0', |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
815 b'copyrev': b'a' * 40, |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
816 } |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
817 |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
818 meta2 = { |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
819 b'copy': b'source1', |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
820 b'copyrev': b'b' * 40, |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
821 } |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
822 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42813
diff
changeset
|
823 stored1 = b''.join( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42813
diff
changeset
|
824 [ |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42813
diff
changeset
|
825 b'\x01\ncopy: source0\n', |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42813
diff
changeset
|
826 b'copyrev: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\n\x01\n', |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42813
diff
changeset
|
827 fulltext1, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42813
diff
changeset
|
828 ] |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42813
diff
changeset
|
829 ) |
39772
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
830 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42813
diff
changeset
|
831 stored2 = b''.join( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42813
diff
changeset
|
832 [ |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42813
diff
changeset
|
833 b'\x01\ncopy: source1\n', |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42813
diff
changeset
|
834 b'copyrev: bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb\n\x01\n', |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42813
diff
changeset
|
835 fulltext2, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42813
diff
changeset
|
836 ] |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42813
diff
changeset
|
837 ) |
39772
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
838 |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
839 f = self._makefilefn() |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
840 with self._maketransactionfn() as tr: |
47012
d55b71393907
node: replace nullid and friends with nodeconstants class
Joerg Sonnenberger <joerg@bec.de>
parents:
46712
diff
changeset
|
841 node0 = f.add(fulltext0, None, tr, 0, f.nullid, f.nullid) |
d55b71393907
node: replace nullid and friends with nodeconstants class
Joerg Sonnenberger <joerg@bec.de>
parents:
46712
diff
changeset
|
842 node1 = f.add(fulltext1, meta1, tr, 1, node0, f.nullid) |
d55b71393907
node: replace nullid and friends with nodeconstants class
Joerg Sonnenberger <joerg@bec.de>
parents:
46712
diff
changeset
|
843 node2 = f.add(fulltext2, meta2, tr, 2, f.nullid, f.nullid) |
39772
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
844 |
47012
d55b71393907
node: replace nullid and friends with nodeconstants class
Joerg Sonnenberger <joerg@bec.de>
parents:
46712
diff
changeset
|
845 # Metadata header isn't recognized when parent isn't f.nullid. |
39772
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
846 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
|
847 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
|
848 |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
849 self.assertEqual(f.revision(node1), stored1) |
42778
22e74b5aa59d
rawdata: update callers in testing/storage.py
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
40430
diff
changeset
|
850 self.assertEqual(f.rawdata(node1), stored1) |
39772
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
851 self.assertEqual(f.revision(node2), stored2) |
42778
22e74b5aa59d
rawdata: update callers in testing/storage.py
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
40430
diff
changeset
|
852 self.assertEqual(f.rawdata(node2), stored2) |
39772
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 self.assertEqual(f.read(node1), fulltext1) |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
855 self.assertEqual(f.read(node2), fulltext2) |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
856 |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
857 # 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
|
858 self.assertFalse(f.renamed(node1)) |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
859 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
|
860 |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
861 self.assertTrue(f.cmp(node1, fulltext1)) |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
862 self.assertTrue(f.cmp(node1, stored1)) |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
863 self.assertFalse(f.cmp(node2, fulltext2)) |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
864 self.assertTrue(f.cmp(node2, stored2)) |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
865 |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
866 def testmetadataprefix(self): |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
867 # 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
|
868 fulltext0 = b'\x01\nfoo' |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
869 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
|
870 |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
871 fulltext1 = b'\x01\nbar' |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
872 meta1 = { |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
873 b'copy': b'source0', |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
874 b'copyrev': b'b' * 40, |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
875 } |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42813
diff
changeset
|
876 stored1 = b''.join( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42813
diff
changeset
|
877 [ |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42813
diff
changeset
|
878 b'\x01\ncopy: source0\n', |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42813
diff
changeset
|
879 b'copyrev: %s\n' % (b'b' * 40), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42813
diff
changeset
|
880 b'\x01\n\x01\nbar', |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42813
diff
changeset
|
881 ] |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42813
diff
changeset
|
882 ) |
39772
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 f = self._makefilefn() |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
885 with self._maketransactionfn() as tr: |
47012
d55b71393907
node: replace nullid and friends with nodeconstants class
Joerg Sonnenberger <joerg@bec.de>
parents:
46712
diff
changeset
|
886 node0 = f.add(fulltext0, {}, tr, 0, f.nullid, f.nullid) |
d55b71393907
node: replace nullid and friends with nodeconstants class
Joerg Sonnenberger <joerg@bec.de>
parents:
46712
diff
changeset
|
887 node1 = f.add(fulltext1, meta1, tr, 1, f.nullid, f.nullid) |
39772
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 # TODO this is buggy. |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
890 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
|
891 |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
892 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
|
893 |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
894 self.assertEqual(f.revision(node0), stored0) |
42778
22e74b5aa59d
rawdata: update callers in testing/storage.py
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
40430
diff
changeset
|
895 self.assertEqual(f.rawdata(node0), stored0) |
39772
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
896 |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
897 self.assertEqual(f.revision(node1), stored1) |
42778
22e74b5aa59d
rawdata: update callers in testing/storage.py
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
40430
diff
changeset
|
898 self.assertEqual(f.rawdata(node1), stored1) |
39772
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
899 |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
900 self.assertEqual(f.read(node0), fulltext0) |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
901 self.assertEqual(f.read(node1), fulltext1) |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
902 |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
903 self.assertFalse(f.cmp(node0, fulltext0)) |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
904 self.assertTrue(f.cmp(node0, stored0)) |
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 self.assertFalse(f.cmp(node1, fulltext1)) |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
907 self.assertTrue(f.cmp(node1, stored0)) |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
908 |
40051
cdf61ab1f54c
testing: add file storage integration for bad hashes and censoring
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40050
diff
changeset
|
909 def testbadnoderead(self): |
cdf61ab1f54c
testing: add file storage integration for bad hashes and censoring
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40050
diff
changeset
|
910 f = self._makefilefn() |
cdf61ab1f54c
testing: add file storage integration for bad hashes and censoring
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40050
diff
changeset
|
911 |
cdf61ab1f54c
testing: add file storage integration for bad hashes and censoring
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40050
diff
changeset
|
912 fulltext0 = b'foo\n' * 30 |
cdf61ab1f54c
testing: add file storage integration for bad hashes and censoring
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40050
diff
changeset
|
913 fulltext1 = fulltext0 + b'bar\n' |
cdf61ab1f54c
testing: add file storage integration for bad hashes and censoring
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40050
diff
changeset
|
914 |
cdf61ab1f54c
testing: add file storage integration for bad hashes and censoring
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40050
diff
changeset
|
915 with self._maketransactionfn() as tr: |
47012
d55b71393907
node: replace nullid and friends with nodeconstants class
Joerg Sonnenberger <joerg@bec.de>
parents:
46712
diff
changeset
|
916 node0 = f.add(fulltext0, None, tr, 0, f.nullid, f.nullid) |
40051
cdf61ab1f54c
testing: add file storage integration for bad hashes and censoring
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40050
diff
changeset
|
917 node1 = b'\xaa' * 20 |
cdf61ab1f54c
testing: add file storage integration for bad hashes and censoring
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40050
diff
changeset
|
918 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42813
diff
changeset
|
919 self._addrawrevisionfn( |
47012
d55b71393907
node: replace nullid and friends with nodeconstants class
Joerg Sonnenberger <joerg@bec.de>
parents:
46712
diff
changeset
|
920 f, tr, node1, node0, f.nullid, 1, rawtext=fulltext1 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42813
diff
changeset
|
921 ) |
40051
cdf61ab1f54c
testing: add file storage integration for bad hashes and censoring
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40050
diff
changeset
|
922 |
cdf61ab1f54c
testing: add file storage integration for bad hashes and censoring
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40050
diff
changeset
|
923 self.assertEqual(len(f), 2) |
47012
d55b71393907
node: replace nullid and friends with nodeconstants class
Joerg Sonnenberger <joerg@bec.de>
parents:
46712
diff
changeset
|
924 self.assertEqual(f.parents(node1), (node0, f.nullid)) |
40051
cdf61ab1f54c
testing: add file storage integration for bad hashes and censoring
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40050
diff
changeset
|
925 |
cdf61ab1f54c
testing: add file storage integration for bad hashes and censoring
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40050
diff
changeset
|
926 # revision() raises since it performs hash verification. |
cdf61ab1f54c
testing: add file storage integration for bad hashes and censoring
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40050
diff
changeset
|
927 with self.assertRaises(error.StorageError): |
cdf61ab1f54c
testing: add file storage integration for bad hashes and censoring
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40050
diff
changeset
|
928 f.revision(node1) |
cdf61ab1f54c
testing: add file storage integration for bad hashes and censoring
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40050
diff
changeset
|
929 |
42778
22e74b5aa59d
rawdata: update callers in testing/storage.py
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
40430
diff
changeset
|
930 # rawdata() still verifies because there are no special storage |
40054
801ccd8e67c0
revlog: clear revision cache on hash verification failure
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40051
diff
changeset
|
931 # settings. |
801ccd8e67c0
revlog: clear revision cache on hash verification failure
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40051
diff
changeset
|
932 with self.assertRaises(error.StorageError): |
42778
22e74b5aa59d
rawdata: update callers in testing/storage.py
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
40430
diff
changeset
|
933 f.rawdata(node1) |
40051
cdf61ab1f54c
testing: add file storage integration for bad hashes and censoring
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40050
diff
changeset
|
934 |
cdf61ab1f54c
testing: add file storage integration for bad hashes and censoring
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40050
diff
changeset
|
935 # read() behaves like revision(). |
40054
801ccd8e67c0
revlog: clear revision cache on hash verification failure
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40051
diff
changeset
|
936 with self.assertRaises(error.StorageError): |
801ccd8e67c0
revlog: clear revision cache on hash verification failure
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40051
diff
changeset
|
937 f.read(node1) |
40051
cdf61ab1f54c
testing: add file storage integration for bad hashes and censoring
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40050
diff
changeset
|
938 |
cdf61ab1f54c
testing: add file storage integration for bad hashes and censoring
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40050
diff
changeset
|
939 # We can't test renamed() here because some backends may not require |
cdf61ab1f54c
testing: add file storage integration for bad hashes and censoring
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40050
diff
changeset
|
940 # reading/validating the fulltext to return rename metadata. |
cdf61ab1f54c
testing: add file storage integration for bad hashes and censoring
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40050
diff
changeset
|
941 |
cdf61ab1f54c
testing: add file storage integration for bad hashes and censoring
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40050
diff
changeset
|
942 def testbadnoderevisionraw(self): |
42778
22e74b5aa59d
rawdata: update callers in testing/storage.py
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
40430
diff
changeset
|
943 # Like above except we test rawdata() first to isolate |
40051
cdf61ab1f54c
testing: add file storage integration for bad hashes and censoring
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40050
diff
changeset
|
944 # revision caching behavior. |
cdf61ab1f54c
testing: add file storage integration for bad hashes and censoring
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40050
diff
changeset
|
945 f = self._makefilefn() |
cdf61ab1f54c
testing: add file storage integration for bad hashes and censoring
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40050
diff
changeset
|
946 |
cdf61ab1f54c
testing: add file storage integration for bad hashes and censoring
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40050
diff
changeset
|
947 fulltext0 = b'foo\n' * 30 |
cdf61ab1f54c
testing: add file storage integration for bad hashes and censoring
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40050
diff
changeset
|
948 fulltext1 = fulltext0 + b'bar\n' |
cdf61ab1f54c
testing: add file storage integration for bad hashes and censoring
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40050
diff
changeset
|
949 |
cdf61ab1f54c
testing: add file storage integration for bad hashes and censoring
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40050
diff
changeset
|
950 with self._maketransactionfn() as tr: |
47012
d55b71393907
node: replace nullid and friends with nodeconstants class
Joerg Sonnenberger <joerg@bec.de>
parents:
46712
diff
changeset
|
951 node0 = f.add(fulltext0, None, tr, 0, f.nullid, f.nullid) |
40051
cdf61ab1f54c
testing: add file storage integration for bad hashes and censoring
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40050
diff
changeset
|
952 node1 = b'\xaa' * 20 |
cdf61ab1f54c
testing: add file storage integration for bad hashes and censoring
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40050
diff
changeset
|
953 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42813
diff
changeset
|
954 self._addrawrevisionfn( |
47012
d55b71393907
node: replace nullid and friends with nodeconstants class
Joerg Sonnenberger <joerg@bec.de>
parents:
46712
diff
changeset
|
955 f, tr, node1, node0, f.nullid, 1, rawtext=fulltext1 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42813
diff
changeset
|
956 ) |
40051
cdf61ab1f54c
testing: add file storage integration for bad hashes and censoring
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40050
diff
changeset
|
957 |
cdf61ab1f54c
testing: add file storage integration for bad hashes and censoring
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40050
diff
changeset
|
958 with self.assertRaises(error.StorageError): |
42778
22e74b5aa59d
rawdata: update callers in testing/storage.py
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
40430
diff
changeset
|
959 f.rawdata(node1) |
40051
cdf61ab1f54c
testing: add file storage integration for bad hashes and censoring
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40050
diff
changeset
|
960 |
cdf61ab1f54c
testing: add file storage integration for bad hashes and censoring
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40050
diff
changeset
|
961 with self.assertRaises(error.StorageError): |
42778
22e74b5aa59d
rawdata: update callers in testing/storage.py
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
40430
diff
changeset
|
962 f.rawdata(node1) |
40051
cdf61ab1f54c
testing: add file storage integration for bad hashes and censoring
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40050
diff
changeset
|
963 |
44024
a1ee825fc6c5
tests: fix a copy/paste name duplication in storage.py
Matt Harbison <matt_harbison@yahoo.com>
parents:
43506
diff
changeset
|
964 def testbadnoderevision(self): |
40051
cdf61ab1f54c
testing: add file storage integration for bad hashes and censoring
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40050
diff
changeset
|
965 # Like above except we test read() first to isolate revision caching |
cdf61ab1f54c
testing: add file storage integration for bad hashes and censoring
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40050
diff
changeset
|
966 # behavior. |
cdf61ab1f54c
testing: add file storage integration for bad hashes and censoring
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40050
diff
changeset
|
967 f = self._makefilefn() |
cdf61ab1f54c
testing: add file storage integration for bad hashes and censoring
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40050
diff
changeset
|
968 |
cdf61ab1f54c
testing: add file storage integration for bad hashes and censoring
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40050
diff
changeset
|
969 fulltext0 = b'foo\n' * 30 |
cdf61ab1f54c
testing: add file storage integration for bad hashes and censoring
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40050
diff
changeset
|
970 fulltext1 = fulltext0 + b'bar\n' |
cdf61ab1f54c
testing: add file storage integration for bad hashes and censoring
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40050
diff
changeset
|
971 |
cdf61ab1f54c
testing: add file storage integration for bad hashes and censoring
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40050
diff
changeset
|
972 with self._maketransactionfn() as tr: |
47012
d55b71393907
node: replace nullid and friends with nodeconstants class
Joerg Sonnenberger <joerg@bec.de>
parents:
46712
diff
changeset
|
973 node0 = f.add(fulltext0, None, tr, 0, f.nullid, f.nullid) |
40051
cdf61ab1f54c
testing: add file storage integration for bad hashes and censoring
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40050
diff
changeset
|
974 node1 = b'\xaa' * 20 |
cdf61ab1f54c
testing: add file storage integration for bad hashes and censoring
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40050
diff
changeset
|
975 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42813
diff
changeset
|
976 self._addrawrevisionfn( |
47012
d55b71393907
node: replace nullid and friends with nodeconstants class
Joerg Sonnenberger <joerg@bec.de>
parents:
46712
diff
changeset
|
977 f, tr, node1, node0, f.nullid, 1, rawtext=fulltext1 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42813
diff
changeset
|
978 ) |
40051
cdf61ab1f54c
testing: add file storage integration for bad hashes and censoring
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40050
diff
changeset
|
979 |
cdf61ab1f54c
testing: add file storage integration for bad hashes and censoring
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40050
diff
changeset
|
980 with self.assertRaises(error.StorageError): |
cdf61ab1f54c
testing: add file storage integration for bad hashes and censoring
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40050
diff
changeset
|
981 f.read(node1) |
cdf61ab1f54c
testing: add file storage integration for bad hashes and censoring
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40050
diff
changeset
|
982 |
40054
801ccd8e67c0
revlog: clear revision cache on hash verification failure
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40051
diff
changeset
|
983 with self.assertRaises(error.StorageError): |
801ccd8e67c0
revlog: clear revision cache on hash verification failure
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40051
diff
changeset
|
984 f.read(node1) |
40051
cdf61ab1f54c
testing: add file storage integration for bad hashes and censoring
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40050
diff
changeset
|
985 |
cdf61ab1f54c
testing: add file storage integration for bad hashes and censoring
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40050
diff
changeset
|
986 def testbadnodedelta(self): |
cdf61ab1f54c
testing: add file storage integration for bad hashes and censoring
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40050
diff
changeset
|
987 f = self._makefilefn() |
cdf61ab1f54c
testing: add file storage integration for bad hashes and censoring
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40050
diff
changeset
|
988 |
cdf61ab1f54c
testing: add file storage integration for bad hashes and censoring
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40050
diff
changeset
|
989 fulltext0 = b'foo\n' * 31 |
cdf61ab1f54c
testing: add file storage integration for bad hashes and censoring
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40050
diff
changeset
|
990 fulltext1 = fulltext0 + b'bar\n' |
cdf61ab1f54c
testing: add file storage integration for bad hashes and censoring
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40050
diff
changeset
|
991 fulltext2 = fulltext1 + b'baz\n' |
cdf61ab1f54c
testing: add file storage integration for bad hashes and censoring
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40050
diff
changeset
|
992 |
cdf61ab1f54c
testing: add file storage integration for bad hashes and censoring
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40050
diff
changeset
|
993 with self._maketransactionfn() as tr: |
47012
d55b71393907
node: replace nullid and friends with nodeconstants class
Joerg Sonnenberger <joerg@bec.de>
parents:
46712
diff
changeset
|
994 node0 = f.add(fulltext0, None, tr, 0, f.nullid, f.nullid) |
40051
cdf61ab1f54c
testing: add file storage integration for bad hashes and censoring
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40050
diff
changeset
|
995 node1 = b'\xaa' * 20 |
cdf61ab1f54c
testing: add file storage integration for bad hashes and censoring
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40050
diff
changeset
|
996 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42813
diff
changeset
|
997 self._addrawrevisionfn( |
47012
d55b71393907
node: replace nullid and friends with nodeconstants class
Joerg Sonnenberger <joerg@bec.de>
parents:
46712
diff
changeset
|
998 f, tr, node1, node0, f.nullid, 1, rawtext=fulltext1 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42813
diff
changeset
|
999 ) |
40051
cdf61ab1f54c
testing: add file storage integration for bad hashes and censoring
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40050
diff
changeset
|
1000 |
cdf61ab1f54c
testing: add file storage integration for bad hashes and censoring
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40050
diff
changeset
|
1001 with self.assertRaises(error.StorageError): |
cdf61ab1f54c
testing: add file storage integration for bad hashes and censoring
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40050
diff
changeset
|
1002 f.read(node1) |
cdf61ab1f54c
testing: add file storage integration for bad hashes and censoring
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40050
diff
changeset
|
1003 |
47012
d55b71393907
node: replace nullid and friends with nodeconstants class
Joerg Sonnenberger <joerg@bec.de>
parents:
46712
diff
changeset
|
1004 node2 = storageutil.hashrevisionsha1(fulltext2, node1, f.nullid) |
40051
cdf61ab1f54c
testing: add file storage integration for bad hashes and censoring
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40050
diff
changeset
|
1005 |
cdf61ab1f54c
testing: add file storage integration for bad hashes and censoring
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40050
diff
changeset
|
1006 with self._maketransactionfn() as tr: |
40323
2c0aa02ecd5a
testing: switch to inserting deltas
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40322
diff
changeset
|
1007 delta = mdiff.textdiff(fulltext1, fulltext2) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42813
diff
changeset
|
1008 self._addrawrevisionfn( |
47012
d55b71393907
node: replace nullid and friends with nodeconstants class
Joerg Sonnenberger <joerg@bec.de>
parents:
46712
diff
changeset
|
1009 f, tr, node2, node1, f.nullid, 2, delta=(1, delta) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42813
diff
changeset
|
1010 ) |
40051
cdf61ab1f54c
testing: add file storage integration for bad hashes and censoring
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40050
diff
changeset
|
1011 |
cdf61ab1f54c
testing: add file storage integration for bad hashes and censoring
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40050
diff
changeset
|
1012 self.assertEqual(len(f), 3) |
cdf61ab1f54c
testing: add file storage integration for bad hashes and censoring
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40050
diff
changeset
|
1013 |
cdf61ab1f54c
testing: add file storage integration for bad hashes and censoring
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40050
diff
changeset
|
1014 # Assuming a delta is stored, we shouldn't need to validate node1 in |
cdf61ab1f54c
testing: add file storage integration for bad hashes and censoring
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40050
diff
changeset
|
1015 # order to retrieve node2. |
cdf61ab1f54c
testing: add file storage integration for bad hashes and censoring
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40050
diff
changeset
|
1016 self.assertEqual(f.read(node2), fulltext2) |
cdf61ab1f54c
testing: add file storage integration for bad hashes and censoring
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40050
diff
changeset
|
1017 |
39772
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1018 def testcensored(self): |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1019 f = self._makefilefn() |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1020 |
45942
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45788
diff
changeset
|
1021 stored1 = storageutil.packmeta( |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45788
diff
changeset
|
1022 { |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45788
diff
changeset
|
1023 b'censored': b'tombstone', |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45788
diff
changeset
|
1024 }, |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45788
diff
changeset
|
1025 b'', |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45788
diff
changeset
|
1026 ) |
39772
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1027 |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1028 with self._maketransactionfn() as tr: |
47012
d55b71393907
node: replace nullid and friends with nodeconstants class
Joerg Sonnenberger <joerg@bec.de>
parents:
46712
diff
changeset
|
1029 node0 = f.add(b'foo', None, tr, 0, f.nullid, f.nullid) |
40051
cdf61ab1f54c
testing: add file storage integration for bad hashes and censoring
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40050
diff
changeset
|
1030 |
cdf61ab1f54c
testing: add file storage integration for bad hashes and censoring
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40050
diff
changeset
|
1031 # The node value doesn't matter since we can't verify it. |
cdf61ab1f54c
testing: add file storage integration for bad hashes and censoring
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40050
diff
changeset
|
1032 node1 = b'\xbb' * 20 |
cdf61ab1f54c
testing: add file storage integration for bad hashes and censoring
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40050
diff
changeset
|
1033 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42813
diff
changeset
|
1034 self._addrawrevisionfn( |
47012
d55b71393907
node: replace nullid and friends with nodeconstants class
Joerg Sonnenberger <joerg@bec.de>
parents:
46712
diff
changeset
|
1035 f, tr, node1, node0, f.nullid, 1, stored1, censored=True |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42813
diff
changeset
|
1036 ) |
39772
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 self.assertTrue(f.iscensored(1)) |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1039 |
40051
cdf61ab1f54c
testing: add file storage integration for bad hashes and censoring
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40050
diff
changeset
|
1040 with self.assertRaises(error.CensoredNodeError): |
cdf61ab1f54c
testing: add file storage integration for bad hashes and censoring
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40050
diff
changeset
|
1041 f.revision(1) |
cdf61ab1f54c
testing: add file storage integration for bad hashes and censoring
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40050
diff
changeset
|
1042 |
40054
801ccd8e67c0
revlog: clear revision cache on hash verification failure
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40051
diff
changeset
|
1043 with self.assertRaises(error.CensoredNodeError): |
42778
22e74b5aa59d
rawdata: update callers in testing/storage.py
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
40430
diff
changeset
|
1044 f.rawdata(1) |
39772
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1045 |
40051
cdf61ab1f54c
testing: add file storage integration for bad hashes and censoring
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40050
diff
changeset
|
1046 with self.assertRaises(error.CensoredNodeError): |
cdf61ab1f54c
testing: add file storage integration for bad hashes and censoring
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40050
diff
changeset
|
1047 f.read(1) |
cdf61ab1f54c
testing: add file storage integration for bad hashes and censoring
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40050
diff
changeset
|
1048 |
cdf61ab1f54c
testing: add file storage integration for bad hashes and censoring
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40050
diff
changeset
|
1049 def testcensoredrawrevision(self): |
42778
22e74b5aa59d
rawdata: update callers in testing/storage.py
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
40430
diff
changeset
|
1050 # Like above, except we do the rawdata() request first to |
40051
cdf61ab1f54c
testing: add file storage integration for bad hashes and censoring
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40050
diff
changeset
|
1051 # isolate revision caching behavior. |
cdf61ab1f54c
testing: add file storage integration for bad hashes and censoring
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40050
diff
changeset
|
1052 |
cdf61ab1f54c
testing: add file storage integration for bad hashes and censoring
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40050
diff
changeset
|
1053 f = self._makefilefn() |
cdf61ab1f54c
testing: add file storage integration for bad hashes and censoring
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40050
diff
changeset
|
1054 |
45942
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45788
diff
changeset
|
1055 stored1 = storageutil.packmeta( |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45788
diff
changeset
|
1056 { |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45788
diff
changeset
|
1057 b'censored': b'tombstone', |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45788
diff
changeset
|
1058 }, |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45788
diff
changeset
|
1059 b'', |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45788
diff
changeset
|
1060 ) |
40051
cdf61ab1f54c
testing: add file storage integration for bad hashes and censoring
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40050
diff
changeset
|
1061 |
cdf61ab1f54c
testing: add file storage integration for bad hashes and censoring
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40050
diff
changeset
|
1062 with self._maketransactionfn() as tr: |
47012
d55b71393907
node: replace nullid and friends with nodeconstants class
Joerg Sonnenberger <joerg@bec.de>
parents:
46712
diff
changeset
|
1063 node0 = f.add(b'foo', None, tr, 0, f.nullid, f.nullid) |
40051
cdf61ab1f54c
testing: add file storage integration for bad hashes and censoring
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40050
diff
changeset
|
1064 |
cdf61ab1f54c
testing: add file storage integration for bad hashes and censoring
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40050
diff
changeset
|
1065 # The node value doesn't matter since we can't verify it. |
cdf61ab1f54c
testing: add file storage integration for bad hashes and censoring
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40050
diff
changeset
|
1066 node1 = b'\xbb' * 20 |
cdf61ab1f54c
testing: add file storage integration for bad hashes and censoring
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40050
diff
changeset
|
1067 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42813
diff
changeset
|
1068 self._addrawrevisionfn( |
47012
d55b71393907
node: replace nullid and friends with nodeconstants class
Joerg Sonnenberger <joerg@bec.de>
parents:
46712
diff
changeset
|
1069 f, tr, node1, node0, f.nullid, 1, stored1, censored=True |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42813
diff
changeset
|
1070 ) |
40051
cdf61ab1f54c
testing: add file storage integration for bad hashes and censoring
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40050
diff
changeset
|
1071 |
cdf61ab1f54c
testing: add file storage integration for bad hashes and censoring
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40050
diff
changeset
|
1072 with self.assertRaises(error.CensoredNodeError): |
42778
22e74b5aa59d
rawdata: update callers in testing/storage.py
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
40430
diff
changeset
|
1073 f.rawdata(1) |
39772
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1074 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42813
diff
changeset
|
1075 |
39772
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1076 class ifilemutationtests(basetestcase): |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1077 """Generic tests for the ifilemutation interface. |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1078 |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1079 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
|
1080 interface. |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1081 |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1082 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
|
1083 """ |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42813
diff
changeset
|
1084 |
39772
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1085 def testaddnoop(self): |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1086 f = self._makefilefn() |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1087 with self._maketransactionfn() as tr: |
47012
d55b71393907
node: replace nullid and friends with nodeconstants class
Joerg Sonnenberger <joerg@bec.de>
parents:
46712
diff
changeset
|
1088 node0 = f.add(b'foo', None, tr, 0, f.nullid, f.nullid) |
d55b71393907
node: replace nullid and friends with nodeconstants class
Joerg Sonnenberger <joerg@bec.de>
parents:
46712
diff
changeset
|
1089 node1 = f.add(b'foo', None, tr, 0, f.nullid, f.nullid) |
39772
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1090 # Varying by linkrev shouldn't impact hash. |
47012
d55b71393907
node: replace nullid and friends with nodeconstants class
Joerg Sonnenberger <joerg@bec.de>
parents:
46712
diff
changeset
|
1091 node2 = f.add(b'foo', None, tr, 1, f.nullid, f.nullid) |
39772
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1092 |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1093 self.assertEqual(node1, node0) |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1094 self.assertEqual(node2, node0) |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1095 self.assertEqual(len(f), 1) |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1096 |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1097 def testaddrevisionbadnode(self): |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1098 f = self._makefilefn() |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1099 with self._maketransactionfn() as tr: |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1100 # Adding a revision with bad node value fails. |
39776
cb65d4b7e429
error: introduce StorageError
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39772
diff
changeset
|
1101 with self.assertRaises(error.StorageError): |
47012
d55b71393907
node: replace nullid and friends with nodeconstants class
Joerg Sonnenberger <joerg@bec.de>
parents:
46712
diff
changeset
|
1102 f.addrevision( |
d55b71393907
node: replace nullid and friends with nodeconstants class
Joerg Sonnenberger <joerg@bec.de>
parents:
46712
diff
changeset
|
1103 b'foo', tr, 0, f.nullid, f.nullid, node=b'\x01' * 20 |
d55b71393907
node: replace nullid and friends with nodeconstants class
Joerg Sonnenberger <joerg@bec.de>
parents:
46712
diff
changeset
|
1104 ) |
39772
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1105 |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1106 def testaddrevisionunknownflag(self): |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1107 f = self._makefilefn() |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1108 with self._maketransactionfn() as tr: |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1109 for i in range(15, 0, -1): |
40047
8e398628a3f2
repository: define and use revision flag constants
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40003
diff
changeset
|
1110 if (1 << i) & ~repository.REVISION_FLAGS_KNOWN: |
39772
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1111 flags = 1 << i |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1112 break |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1113 |
39776
cb65d4b7e429
error: introduce StorageError
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39772
diff
changeset
|
1114 with self.assertRaises(error.StorageError): |
47012
d55b71393907
node: replace nullid and friends with nodeconstants class
Joerg Sonnenberger <joerg@bec.de>
parents:
46712
diff
changeset
|
1115 f.addrevision(b'foo', tr, 0, f.nullid, f.nullid, flags=flags) |
39772
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1116 |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1117 def testaddgroupsimple(self): |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1118 f = self._makefilefn() |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1119 |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1120 callbackargs = [] |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42813
diff
changeset
|
1121 |
39772
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1122 def cb(*args, **kwargs): |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1123 callbackargs.append((args, kwargs)) |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1124 |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1125 def linkmapper(node): |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1126 return 0 |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1127 |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1128 with self._maketransactionfn() as tr: |
45788
a5206e71c536
revlog: extend addgroup() with callback for duplicates
Joerg Sonnenberger <joerg@bec.de>
parents:
44024
diff
changeset
|
1129 nodes = [] |
a5206e71c536
revlog: extend addgroup() with callback for duplicates
Joerg Sonnenberger <joerg@bec.de>
parents:
44024
diff
changeset
|
1130 |
46509
7a93b7b3dc2d
revlog: change addgroup callbacks to take revision numbers
Joerg Sonnenberger <joerg@bec.de>
parents:
45942
diff
changeset
|
1131 def onchangeset(cl, rev): |
7a93b7b3dc2d
revlog: change addgroup callbacks to take revision numbers
Joerg Sonnenberger <joerg@bec.de>
parents:
45942
diff
changeset
|
1132 node = cl.node(rev) |
45788
a5206e71c536
revlog: extend addgroup() with callback for duplicates
Joerg Sonnenberger <joerg@bec.de>
parents:
44024
diff
changeset
|
1133 nodes.append(node) |
a5206e71c536
revlog: extend addgroup() with callback for duplicates
Joerg Sonnenberger <joerg@bec.de>
parents:
44024
diff
changeset
|
1134 cb(cl, node) |
a5206e71c536
revlog: extend addgroup() with callback for duplicates
Joerg Sonnenberger <joerg@bec.de>
parents:
44024
diff
changeset
|
1135 |
46509
7a93b7b3dc2d
revlog: change addgroup callbacks to take revision numbers
Joerg Sonnenberger <joerg@bec.de>
parents:
45942
diff
changeset
|
1136 def ondupchangeset(cl, rev): |
7a93b7b3dc2d
revlog: change addgroup callbacks to take revision numbers
Joerg Sonnenberger <joerg@bec.de>
parents:
45942
diff
changeset
|
1137 nodes.append(cl.node(rev)) |
45788
a5206e71c536
revlog: extend addgroup() with callback for duplicates
Joerg Sonnenberger <joerg@bec.de>
parents:
44024
diff
changeset
|
1138 |
a5206e71c536
revlog: extend addgroup() with callback for duplicates
Joerg Sonnenberger <joerg@bec.de>
parents:
44024
diff
changeset
|
1139 f.addgroup( |
a5206e71c536
revlog: extend addgroup() with callback for duplicates
Joerg Sonnenberger <joerg@bec.de>
parents:
44024
diff
changeset
|
1140 [], |
a5206e71c536
revlog: extend addgroup() with callback for duplicates
Joerg Sonnenberger <joerg@bec.de>
parents:
44024
diff
changeset
|
1141 None, |
a5206e71c536
revlog: extend addgroup() with callback for duplicates
Joerg Sonnenberger <joerg@bec.de>
parents:
44024
diff
changeset
|
1142 tr, |
a5206e71c536
revlog: extend addgroup() with callback for duplicates
Joerg Sonnenberger <joerg@bec.de>
parents:
44024
diff
changeset
|
1143 addrevisioncb=onchangeset, |
a5206e71c536
revlog: extend addgroup() with callback for duplicates
Joerg Sonnenberger <joerg@bec.de>
parents:
44024
diff
changeset
|
1144 duplicaterevisioncb=ondupchangeset, |
a5206e71c536
revlog: extend addgroup() with callback for duplicates
Joerg Sonnenberger <joerg@bec.de>
parents:
44024
diff
changeset
|
1145 ) |
39772
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1146 |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1147 self.assertEqual(nodes, []) |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1148 self.assertEqual(callbackargs, []) |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1149 self.assertEqual(len(f), 0) |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1150 |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1151 fulltext0 = b'foo' |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1152 delta0 = mdiff.trivialdiffheader(len(fulltext0)) + fulltext0 |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1153 |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1154 with self._maketransactionfn() as tr: |
47012
d55b71393907
node: replace nullid and friends with nodeconstants class
Joerg Sonnenberger <joerg@bec.de>
parents:
46712
diff
changeset
|
1155 node0 = f.add(fulltext0, None, tr, 0, f.nullid, f.nullid) |
39772
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1156 |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1157 f = self._makefilefn() |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1158 |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1159 deltas = [ |
47012
d55b71393907
node: replace nullid and friends with nodeconstants class
Joerg Sonnenberger <joerg@bec.de>
parents:
46712
diff
changeset
|
1160 (node0, f.nullid, f.nullid, f.nullid, f.nullid, delta0, 0, {}), |
39772
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1161 ] |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1162 |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1163 with self._maketransactionfn() as tr: |
45788
a5206e71c536
revlog: extend addgroup() with callback for duplicates
Joerg Sonnenberger <joerg@bec.de>
parents:
44024
diff
changeset
|
1164 nodes = [] |
a5206e71c536
revlog: extend addgroup() with callback for duplicates
Joerg Sonnenberger <joerg@bec.de>
parents:
44024
diff
changeset
|
1165 |
46509
7a93b7b3dc2d
revlog: change addgroup callbacks to take revision numbers
Joerg Sonnenberger <joerg@bec.de>
parents:
45942
diff
changeset
|
1166 def onchangeset(cl, rev): |
7a93b7b3dc2d
revlog: change addgroup callbacks to take revision numbers
Joerg Sonnenberger <joerg@bec.de>
parents:
45942
diff
changeset
|
1167 node = cl.node(rev) |
45788
a5206e71c536
revlog: extend addgroup() with callback for duplicates
Joerg Sonnenberger <joerg@bec.de>
parents:
44024
diff
changeset
|
1168 nodes.append(node) |
a5206e71c536
revlog: extend addgroup() with callback for duplicates
Joerg Sonnenberger <joerg@bec.de>
parents:
44024
diff
changeset
|
1169 cb(cl, node) |
a5206e71c536
revlog: extend addgroup() with callback for duplicates
Joerg Sonnenberger <joerg@bec.de>
parents:
44024
diff
changeset
|
1170 |
46509
7a93b7b3dc2d
revlog: change addgroup callbacks to take revision numbers
Joerg Sonnenberger <joerg@bec.de>
parents:
45942
diff
changeset
|
1171 def ondupchangeset(cl, rev): |
7a93b7b3dc2d
revlog: change addgroup callbacks to take revision numbers
Joerg Sonnenberger <joerg@bec.de>
parents:
45942
diff
changeset
|
1172 nodes.append(cl.node(rev)) |
45788
a5206e71c536
revlog: extend addgroup() with callback for duplicates
Joerg Sonnenberger <joerg@bec.de>
parents:
44024
diff
changeset
|
1173 |
a5206e71c536
revlog: extend addgroup() with callback for duplicates
Joerg Sonnenberger <joerg@bec.de>
parents:
44024
diff
changeset
|
1174 f.addgroup( |
a5206e71c536
revlog: extend addgroup() with callback for duplicates
Joerg Sonnenberger <joerg@bec.de>
parents:
44024
diff
changeset
|
1175 deltas, |
a5206e71c536
revlog: extend addgroup() with callback for duplicates
Joerg Sonnenberger <joerg@bec.de>
parents:
44024
diff
changeset
|
1176 linkmapper, |
a5206e71c536
revlog: extend addgroup() with callback for duplicates
Joerg Sonnenberger <joerg@bec.de>
parents:
44024
diff
changeset
|
1177 tr, |
a5206e71c536
revlog: extend addgroup() with callback for duplicates
Joerg Sonnenberger <joerg@bec.de>
parents:
44024
diff
changeset
|
1178 addrevisioncb=onchangeset, |
a5206e71c536
revlog: extend addgroup() with callback for duplicates
Joerg Sonnenberger <joerg@bec.de>
parents:
44024
diff
changeset
|
1179 duplicaterevisioncb=ondupchangeset, |
a5206e71c536
revlog: extend addgroup() with callback for duplicates
Joerg Sonnenberger <joerg@bec.de>
parents:
44024
diff
changeset
|
1180 ) |
39772
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1181 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42813
diff
changeset
|
1182 self.assertEqual( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42813
diff
changeset
|
1183 nodes, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42813
diff
changeset
|
1184 [ |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42813
diff
changeset
|
1185 b'\x49\xd8\xcb\xb1\x5c\xe2\x57\x92\x04\x47' |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42813
diff
changeset
|
1186 b'\x00\x6b\x46\x97\x8b\x7a\xf9\x80\xa9\x79' |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42813
diff
changeset
|
1187 ], |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42813
diff
changeset
|
1188 ) |
39772
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1189 |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1190 self.assertEqual(len(callbackargs), 1) |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1191 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
|
1192 |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1193 self.assertEqual(list(f.revs()), [0]) |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1194 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
|
1195 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
|
1196 |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1197 def testaddgroupmultiple(self): |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1198 f = self._makefilefn() |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1199 |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1200 fulltexts = [ |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1201 b'foo', |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1202 b'bar', |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1203 b'x' * 1024, |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1204 ] |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1205 |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1206 nodes = [] |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1207 with self._maketransactionfn() as tr: |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1208 for fulltext in fulltexts: |
47012
d55b71393907
node: replace nullid and friends with nodeconstants class
Joerg Sonnenberger <joerg@bec.de>
parents:
46712
diff
changeset
|
1209 nodes.append(f.add(fulltext, None, tr, 0, f.nullid, f.nullid)) |
39772
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1210 |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1211 f = self._makefilefn() |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1212 deltas = [] |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1213 for i, fulltext in enumerate(fulltexts): |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1214 delta = mdiff.trivialdiffheader(len(fulltext)) + fulltext |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1215 |
46712
e8c11a2c96c0
delta: add sidedata field to revision delta
Raphaël Gomès <rgomes@octobus.net>
parents:
46509
diff
changeset
|
1216 deltas.append( |
47012
d55b71393907
node: replace nullid and friends with nodeconstants class
Joerg Sonnenberger <joerg@bec.de>
parents:
46712
diff
changeset
|
1217 (nodes[i], f.nullid, f.nullid, f.nullid, f.nullid, delta, 0, {}) |
46712
e8c11a2c96c0
delta: add sidedata field to revision delta
Raphaël Gomès <rgomes@octobus.net>
parents:
46509
diff
changeset
|
1218 ) |
39772
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1219 |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1220 with self._maketransactionfn() as tr: |
45788
a5206e71c536
revlog: extend addgroup() with callback for duplicates
Joerg Sonnenberger <joerg@bec.de>
parents:
44024
diff
changeset
|
1221 newnodes = [] |
a5206e71c536
revlog: extend addgroup() with callback for duplicates
Joerg Sonnenberger <joerg@bec.de>
parents:
44024
diff
changeset
|
1222 |
46509
7a93b7b3dc2d
revlog: change addgroup callbacks to take revision numbers
Joerg Sonnenberger <joerg@bec.de>
parents:
45942
diff
changeset
|
1223 def onchangeset(cl, rev): |
7a93b7b3dc2d
revlog: change addgroup callbacks to take revision numbers
Joerg Sonnenberger <joerg@bec.de>
parents:
45942
diff
changeset
|
1224 newnodes.append(cl.node(rev)) |
45788
a5206e71c536
revlog: extend addgroup() with callback for duplicates
Joerg Sonnenberger <joerg@bec.de>
parents:
44024
diff
changeset
|
1225 |
a5206e71c536
revlog: extend addgroup() with callback for duplicates
Joerg Sonnenberger <joerg@bec.de>
parents:
44024
diff
changeset
|
1226 f.addgroup( |
a5206e71c536
revlog: extend addgroup() with callback for duplicates
Joerg Sonnenberger <joerg@bec.de>
parents:
44024
diff
changeset
|
1227 deltas, |
a5206e71c536
revlog: extend addgroup() with callback for duplicates
Joerg Sonnenberger <joerg@bec.de>
parents:
44024
diff
changeset
|
1228 lambda x: 0, |
a5206e71c536
revlog: extend addgroup() with callback for duplicates
Joerg Sonnenberger <joerg@bec.de>
parents:
44024
diff
changeset
|
1229 tr, |
a5206e71c536
revlog: extend addgroup() with callback for duplicates
Joerg Sonnenberger <joerg@bec.de>
parents:
44024
diff
changeset
|
1230 addrevisioncb=onchangeset, |
a5206e71c536
revlog: extend addgroup() with callback for duplicates
Joerg Sonnenberger <joerg@bec.de>
parents:
44024
diff
changeset
|
1231 duplicaterevisioncb=onchangeset, |
a5206e71c536
revlog: extend addgroup() with callback for duplicates
Joerg Sonnenberger <joerg@bec.de>
parents:
44024
diff
changeset
|
1232 ) |
a5206e71c536
revlog: extend addgroup() with callback for duplicates
Joerg Sonnenberger <joerg@bec.de>
parents:
44024
diff
changeset
|
1233 self.assertEqual(newnodes, nodes) |
39772
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1234 |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1235 self.assertEqual(len(f), len(deltas)) |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1236 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
|
1237 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
|
1238 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
|
1239 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
|
1240 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
|
1241 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
|
1242 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
|
1243 |
40051
cdf61ab1f54c
testing: add file storage integration for bad hashes and censoring
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40050
diff
changeset
|
1244 def testdeltaagainstcensored(self): |
cdf61ab1f54c
testing: add file storage integration for bad hashes and censoring
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40050
diff
changeset
|
1245 # Attempt to apply a delta made against a censored revision. |
cdf61ab1f54c
testing: add file storage integration for bad hashes and censoring
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40050
diff
changeset
|
1246 f = self._makefilefn() |
cdf61ab1f54c
testing: add file storage integration for bad hashes and censoring
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40050
diff
changeset
|
1247 |
45942
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45788
diff
changeset
|
1248 stored1 = storageutil.packmeta( |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45788
diff
changeset
|
1249 { |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45788
diff
changeset
|
1250 b'censored': b'tombstone', |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45788
diff
changeset
|
1251 }, |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45788
diff
changeset
|
1252 b'', |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45788
diff
changeset
|
1253 ) |
40051
cdf61ab1f54c
testing: add file storage integration for bad hashes and censoring
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40050
diff
changeset
|
1254 |
cdf61ab1f54c
testing: add file storage integration for bad hashes and censoring
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40050
diff
changeset
|
1255 with self._maketransactionfn() as tr: |
47012
d55b71393907
node: replace nullid and friends with nodeconstants class
Joerg Sonnenberger <joerg@bec.de>
parents:
46712
diff
changeset
|
1256 node0 = f.add(b'foo\n' * 30, None, tr, 0, f.nullid, f.nullid) |
40051
cdf61ab1f54c
testing: add file storage integration for bad hashes and censoring
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40050
diff
changeset
|
1257 |
cdf61ab1f54c
testing: add file storage integration for bad hashes and censoring
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40050
diff
changeset
|
1258 # The node value doesn't matter since we can't verify it. |
cdf61ab1f54c
testing: add file storage integration for bad hashes and censoring
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40050
diff
changeset
|
1259 node1 = b'\xbb' * 20 |
cdf61ab1f54c
testing: add file storage integration for bad hashes and censoring
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40050
diff
changeset
|
1260 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42813
diff
changeset
|
1261 self._addrawrevisionfn( |
47012
d55b71393907
node: replace nullid and friends with nodeconstants class
Joerg Sonnenberger <joerg@bec.de>
parents:
46712
diff
changeset
|
1262 f, tr, node1, node0, f.nullid, 1, stored1, censored=True |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42813
diff
changeset
|
1263 ) |
40051
cdf61ab1f54c
testing: add file storage integration for bad hashes and censoring
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40050
diff
changeset
|
1264 |
cdf61ab1f54c
testing: add file storage integration for bad hashes and censoring
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40050
diff
changeset
|
1265 delta = mdiff.textdiff(b'bar\n' * 30, (b'bar\n' * 30) + b'baz\n') |
46712
e8c11a2c96c0
delta: add sidedata field to revision delta
Raphaël Gomès <rgomes@octobus.net>
parents:
46509
diff
changeset
|
1266 deltas = [ |
47012
d55b71393907
node: replace nullid and friends with nodeconstants class
Joerg Sonnenberger <joerg@bec.de>
parents:
46712
diff
changeset
|
1267 (b'\xcc' * 20, node1, f.nullid, b'\x01' * 20, node1, delta, 0, {}) |
46712
e8c11a2c96c0
delta: add sidedata field to revision delta
Raphaël Gomès <rgomes@octobus.net>
parents:
46509
diff
changeset
|
1268 ] |
40051
cdf61ab1f54c
testing: add file storage integration for bad hashes and censoring
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40050
diff
changeset
|
1269 |
cdf61ab1f54c
testing: add file storage integration for bad hashes and censoring
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40050
diff
changeset
|
1270 with self._maketransactionfn() as tr: |
cdf61ab1f54c
testing: add file storage integration for bad hashes and censoring
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40050
diff
changeset
|
1271 with self.assertRaises(error.CensoredBaseError): |
cdf61ab1f54c
testing: add file storage integration for bad hashes and censoring
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40050
diff
changeset
|
1272 f.addgroup(deltas, lambda x: 0, tr) |
cdf61ab1f54c
testing: add file storage integration for bad hashes and censoring
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40050
diff
changeset
|
1273 |
cdf61ab1f54c
testing: add file storage integration for bad hashes and censoring
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40050
diff
changeset
|
1274 def testcensorrevisionbasic(self): |
cdf61ab1f54c
testing: add file storage integration for bad hashes and censoring
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40050
diff
changeset
|
1275 f = self._makefilefn() |
cdf61ab1f54c
testing: add file storage integration for bad hashes and censoring
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40050
diff
changeset
|
1276 |
cdf61ab1f54c
testing: add file storage integration for bad hashes and censoring
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40050
diff
changeset
|
1277 with self._maketransactionfn() as tr: |
47012
d55b71393907
node: replace nullid and friends with nodeconstants class
Joerg Sonnenberger <joerg@bec.de>
parents:
46712
diff
changeset
|
1278 node0 = f.add(b'foo\n' * 30, None, tr, 0, f.nullid, f.nullid) |
d55b71393907
node: replace nullid and friends with nodeconstants class
Joerg Sonnenberger <joerg@bec.de>
parents:
46712
diff
changeset
|
1279 node1 = f.add(b'foo\n' * 31, None, tr, 1, node0, f.nullid) |
d55b71393907
node: replace nullid and friends with nodeconstants class
Joerg Sonnenberger <joerg@bec.de>
parents:
46712
diff
changeset
|
1280 node2 = f.add(b'foo\n' * 32, None, tr, 2, node1, f.nullid) |
40051
cdf61ab1f54c
testing: add file storage integration for bad hashes and censoring
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40050
diff
changeset
|
1281 |
cdf61ab1f54c
testing: add file storage integration for bad hashes and censoring
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40050
diff
changeset
|
1282 with self._maketransactionfn() as tr: |
51270
ceeb8fa23cc8
censor: accept multiple revision in a single call
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50929
diff
changeset
|
1283 f.censorrevision(tr, [node1]) |
40051
cdf61ab1f54c
testing: add file storage integration for bad hashes and censoring
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40050
diff
changeset
|
1284 |
cdf61ab1f54c
testing: add file storage integration for bad hashes and censoring
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40050
diff
changeset
|
1285 self.assertEqual(len(f), 3) |
cdf61ab1f54c
testing: add file storage integration for bad hashes and censoring
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40050
diff
changeset
|
1286 self.assertEqual(list(f.revs()), [0, 1, 2]) |
cdf61ab1f54c
testing: add file storage integration for bad hashes and censoring
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40050
diff
changeset
|
1287 |
cdf61ab1f54c
testing: add file storage integration for bad hashes and censoring
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40050
diff
changeset
|
1288 self.assertEqual(f.read(node0), b'foo\n' * 30) |
40056
324b4b10351e
revlog: rewrite censoring logic
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40054
diff
changeset
|
1289 self.assertEqual(f.read(node2), b'foo\n' * 32) |
40051
cdf61ab1f54c
testing: add file storage integration for bad hashes and censoring
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40050
diff
changeset
|
1290 |
40056
324b4b10351e
revlog: rewrite censoring logic
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40054
diff
changeset
|
1291 with self.assertRaises(error.CensoredNodeError): |
40051
cdf61ab1f54c
testing: add file storage integration for bad hashes and censoring
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40050
diff
changeset
|
1292 f.read(node1) |
cdf61ab1f54c
testing: add file storage integration for bad hashes and censoring
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40050
diff
changeset
|
1293 |
40050
8e136940c0e6
testing: add file storage tests for getstrippoint() and strip()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40047
diff
changeset
|
1294 def testgetstrippointnoparents(self): |
8e136940c0e6
testing: add file storage tests for getstrippoint() and strip()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40047
diff
changeset
|
1295 # N revisions where none have parents. |
8e136940c0e6
testing: add file storage tests for getstrippoint() and strip()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40047
diff
changeset
|
1296 f = self._makefilefn() |
8e136940c0e6
testing: add file storage tests for getstrippoint() and strip()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40047
diff
changeset
|
1297 |
8e136940c0e6
testing: add file storage tests for getstrippoint() and strip()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40047
diff
changeset
|
1298 with self._maketransactionfn() as tr: |
8e136940c0e6
testing: add file storage tests for getstrippoint() and strip()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40047
diff
changeset
|
1299 for rev in range(10): |
47012
d55b71393907
node: replace nullid and friends with nodeconstants class
Joerg Sonnenberger <joerg@bec.de>
parents:
46712
diff
changeset
|
1300 f.add(b'%d' % rev, None, tr, rev, f.nullid, f.nullid) |
40050
8e136940c0e6
testing: add file storage tests for getstrippoint() and strip()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40047
diff
changeset
|
1301 |
8e136940c0e6
testing: add file storage tests for getstrippoint() and strip()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40047
diff
changeset
|
1302 for rev in range(10): |
8e136940c0e6
testing: add file storage tests for getstrippoint() and strip()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40047
diff
changeset
|
1303 self.assertEqual(f.getstrippoint(rev), (rev, set())) |
8e136940c0e6
testing: add file storage tests for getstrippoint() and strip()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40047
diff
changeset
|
1304 |
8e136940c0e6
testing: add file storage tests for getstrippoint() and strip()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40047
diff
changeset
|
1305 def testgetstrippointlinear(self): |
8e136940c0e6
testing: add file storage tests for getstrippoint() and strip()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40047
diff
changeset
|
1306 # N revisions in a linear chain. |
8e136940c0e6
testing: add file storage tests for getstrippoint() and strip()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40047
diff
changeset
|
1307 f = self._makefilefn() |
8e136940c0e6
testing: add file storage tests for getstrippoint() and strip()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40047
diff
changeset
|
1308 |
8e136940c0e6
testing: add file storage tests for getstrippoint() and strip()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40047
diff
changeset
|
1309 with self._maketransactionfn() as tr: |
47012
d55b71393907
node: replace nullid and friends with nodeconstants class
Joerg Sonnenberger <joerg@bec.de>
parents:
46712
diff
changeset
|
1310 p1 = f.nullid |
40050
8e136940c0e6
testing: add file storage tests for getstrippoint() and strip()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40047
diff
changeset
|
1311 |
8e136940c0e6
testing: add file storage tests for getstrippoint() and strip()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40047
diff
changeset
|
1312 for rev in range(10): |
47012
d55b71393907
node: replace nullid and friends with nodeconstants class
Joerg Sonnenberger <joerg@bec.de>
parents:
46712
diff
changeset
|
1313 f.add(b'%d' % rev, None, tr, rev, p1, f.nullid) |
40050
8e136940c0e6
testing: add file storage tests for getstrippoint() and strip()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40047
diff
changeset
|
1314 |
8e136940c0e6
testing: add file storage tests for getstrippoint() and strip()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40047
diff
changeset
|
1315 for rev in range(10): |
8e136940c0e6
testing: add file storage tests for getstrippoint() and strip()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40047
diff
changeset
|
1316 self.assertEqual(f.getstrippoint(rev), (rev, set())) |
8e136940c0e6
testing: add file storage tests for getstrippoint() and strip()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40047
diff
changeset
|
1317 |
8e136940c0e6
testing: add file storage tests for getstrippoint() and strip()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40047
diff
changeset
|
1318 def testgetstrippointmultipleheads(self): |
8e136940c0e6
testing: add file storage tests for getstrippoint() and strip()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40047
diff
changeset
|
1319 f = self._makefilefn() |
8e136940c0e6
testing: add file storage tests for getstrippoint() and strip()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40047
diff
changeset
|
1320 |
8e136940c0e6
testing: add file storage tests for getstrippoint() and strip()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40047
diff
changeset
|
1321 with self._maketransactionfn() as tr: |
47012
d55b71393907
node: replace nullid and friends with nodeconstants class
Joerg Sonnenberger <joerg@bec.de>
parents:
46712
diff
changeset
|
1322 node0 = f.add(b'0', None, tr, 0, f.nullid, f.nullid) |
d55b71393907
node: replace nullid and friends with nodeconstants class
Joerg Sonnenberger <joerg@bec.de>
parents:
46712
diff
changeset
|
1323 node1 = f.add(b'1', None, tr, 1, node0, f.nullid) |
d55b71393907
node: replace nullid and friends with nodeconstants class
Joerg Sonnenberger <joerg@bec.de>
parents:
46712
diff
changeset
|
1324 f.add(b'2', None, tr, 2, node1, f.nullid) |
d55b71393907
node: replace nullid and friends with nodeconstants class
Joerg Sonnenberger <joerg@bec.de>
parents:
46712
diff
changeset
|
1325 f.add(b'3', None, tr, 3, node0, f.nullid) |
d55b71393907
node: replace nullid and friends with nodeconstants class
Joerg Sonnenberger <joerg@bec.de>
parents:
46712
diff
changeset
|
1326 f.add(b'4', None, tr, 4, node0, f.nullid) |
40050
8e136940c0e6
testing: add file storage tests for getstrippoint() and strip()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40047
diff
changeset
|
1327 |
8e136940c0e6
testing: add file storage tests for getstrippoint() and strip()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40047
diff
changeset
|
1328 for rev in range(5): |
8e136940c0e6
testing: add file storage tests for getstrippoint() and strip()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40047
diff
changeset
|
1329 self.assertEqual(f.getstrippoint(rev), (rev, set())) |
8e136940c0e6
testing: add file storage tests for getstrippoint() and strip()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40047
diff
changeset
|
1330 |
8e136940c0e6
testing: add file storage tests for getstrippoint() and strip()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40047
diff
changeset
|
1331 def testgetstrippointearlierlinkrevs(self): |
8e136940c0e6
testing: add file storage tests for getstrippoint() and strip()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40047
diff
changeset
|
1332 f = self._makefilefn() |
8e136940c0e6
testing: add file storage tests for getstrippoint() and strip()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40047
diff
changeset
|
1333 |
8e136940c0e6
testing: add file storage tests for getstrippoint() and strip()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40047
diff
changeset
|
1334 with self._maketransactionfn() as tr: |
47012
d55b71393907
node: replace nullid and friends with nodeconstants class
Joerg Sonnenberger <joerg@bec.de>
parents:
46712
diff
changeset
|
1335 node0 = f.add(b'0', None, tr, 0, f.nullid, f.nullid) |
d55b71393907
node: replace nullid and friends with nodeconstants class
Joerg Sonnenberger <joerg@bec.de>
parents:
46712
diff
changeset
|
1336 f.add(b'1', None, tr, 10, node0, f.nullid) |
d55b71393907
node: replace nullid and friends with nodeconstants class
Joerg Sonnenberger <joerg@bec.de>
parents:
46712
diff
changeset
|
1337 f.add(b'2', None, tr, 5, node0, f.nullid) |
40050
8e136940c0e6
testing: add file storage tests for getstrippoint() and strip()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40047
diff
changeset
|
1338 |
8e136940c0e6
testing: add file storage tests for getstrippoint() and strip()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40047
diff
changeset
|
1339 self.assertEqual(f.getstrippoint(0), (0, set())) |
8e136940c0e6
testing: add file storage tests for getstrippoint() and strip()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40047
diff
changeset
|
1340 self.assertEqual(f.getstrippoint(1), (1, set())) |
8e136940c0e6
testing: add file storage tests for getstrippoint() and strip()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40047
diff
changeset
|
1341 self.assertEqual(f.getstrippoint(2), (1, set())) |
8e136940c0e6
testing: add file storage tests for getstrippoint() and strip()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40047
diff
changeset
|
1342 self.assertEqual(f.getstrippoint(3), (1, set())) |
8e136940c0e6
testing: add file storage tests for getstrippoint() and strip()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40047
diff
changeset
|
1343 self.assertEqual(f.getstrippoint(4), (1, set())) |
8e136940c0e6
testing: add file storage tests for getstrippoint() and strip()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40047
diff
changeset
|
1344 self.assertEqual(f.getstrippoint(5), (1, set())) |
8e136940c0e6
testing: add file storage tests for getstrippoint() and strip()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40047
diff
changeset
|
1345 self.assertEqual(f.getstrippoint(6), (1, {2})) |
8e136940c0e6
testing: add file storage tests for getstrippoint() and strip()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40047
diff
changeset
|
1346 self.assertEqual(f.getstrippoint(7), (1, {2})) |
8e136940c0e6
testing: add file storage tests for getstrippoint() and strip()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40047
diff
changeset
|
1347 self.assertEqual(f.getstrippoint(8), (1, {2})) |
8e136940c0e6
testing: add file storage tests for getstrippoint() and strip()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40047
diff
changeset
|
1348 self.assertEqual(f.getstrippoint(9), (1, {2})) |
8e136940c0e6
testing: add file storage tests for getstrippoint() and strip()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40047
diff
changeset
|
1349 self.assertEqual(f.getstrippoint(10), (1, {2})) |
8e136940c0e6
testing: add file storage tests for getstrippoint() and strip()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40047
diff
changeset
|
1350 self.assertEqual(f.getstrippoint(11), (3, set())) |
8e136940c0e6
testing: add file storage tests for getstrippoint() and strip()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40047
diff
changeset
|
1351 |
8e136940c0e6
testing: add file storage tests for getstrippoint() and strip()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40047
diff
changeset
|
1352 def teststripempty(self): |
8e136940c0e6
testing: add file storage tests for getstrippoint() and strip()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40047
diff
changeset
|
1353 f = self._makefilefn() |
8e136940c0e6
testing: add file storage tests for getstrippoint() and strip()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40047
diff
changeset
|
1354 |
8e136940c0e6
testing: add file storage tests for getstrippoint() and strip()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40047
diff
changeset
|
1355 with self._maketransactionfn() as tr: |
8e136940c0e6
testing: add file storage tests for getstrippoint() and strip()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40047
diff
changeset
|
1356 f.strip(0, tr) |
8e136940c0e6
testing: add file storage tests for getstrippoint() and strip()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40047
diff
changeset
|
1357 |
8e136940c0e6
testing: add file storage tests for getstrippoint() and strip()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40047
diff
changeset
|
1358 self.assertEqual(len(f), 0) |
8e136940c0e6
testing: add file storage tests for getstrippoint() and strip()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40047
diff
changeset
|
1359 |
8e136940c0e6
testing: add file storage tests for getstrippoint() and strip()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40047
diff
changeset
|
1360 def teststripall(self): |
8e136940c0e6
testing: add file storage tests for getstrippoint() and strip()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40047
diff
changeset
|
1361 f = self._makefilefn() |
8e136940c0e6
testing: add file storage tests for getstrippoint() and strip()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40047
diff
changeset
|
1362 |
8e136940c0e6
testing: add file storage tests for getstrippoint() and strip()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40047
diff
changeset
|
1363 with self._maketransactionfn() as tr: |
47012
d55b71393907
node: replace nullid and friends with nodeconstants class
Joerg Sonnenberger <joerg@bec.de>
parents:
46712
diff
changeset
|
1364 p1 = f.nullid |
40050
8e136940c0e6
testing: add file storage tests for getstrippoint() and strip()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40047
diff
changeset
|
1365 for rev in range(10): |
47012
d55b71393907
node: replace nullid and friends with nodeconstants class
Joerg Sonnenberger <joerg@bec.de>
parents:
46712
diff
changeset
|
1366 p1 = f.add(b'%d' % rev, None, tr, rev, p1, f.nullid) |
40050
8e136940c0e6
testing: add file storage tests for getstrippoint() and strip()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40047
diff
changeset
|
1367 |
8e136940c0e6
testing: add file storage tests for getstrippoint() and strip()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40047
diff
changeset
|
1368 self.assertEqual(len(f), 10) |
8e136940c0e6
testing: add file storage tests for getstrippoint() and strip()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40047
diff
changeset
|
1369 |
8e136940c0e6
testing: add file storage tests for getstrippoint() and strip()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40047
diff
changeset
|
1370 with self._maketransactionfn() as tr: |
8e136940c0e6
testing: add file storage tests for getstrippoint() and strip()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40047
diff
changeset
|
1371 f.strip(0, tr) |
8e136940c0e6
testing: add file storage tests for getstrippoint() and strip()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40047
diff
changeset
|
1372 |
8e136940c0e6
testing: add file storage tests for getstrippoint() and strip()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40047
diff
changeset
|
1373 self.assertEqual(len(f), 0) |
8e136940c0e6
testing: add file storage tests for getstrippoint() and strip()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40047
diff
changeset
|
1374 |
8e136940c0e6
testing: add file storage tests for getstrippoint() and strip()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40047
diff
changeset
|
1375 def teststrippartial(self): |
8e136940c0e6
testing: add file storage tests for getstrippoint() and strip()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40047
diff
changeset
|
1376 f = self._makefilefn() |
8e136940c0e6
testing: add file storage tests for getstrippoint() and strip()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40047
diff
changeset
|
1377 |
8e136940c0e6
testing: add file storage tests for getstrippoint() and strip()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40047
diff
changeset
|
1378 with self._maketransactionfn() as tr: |
47012
d55b71393907
node: replace nullid and friends with nodeconstants class
Joerg Sonnenberger <joerg@bec.de>
parents:
46712
diff
changeset
|
1379 f.add(b'0', None, tr, 0, f.nullid, f.nullid) |
d55b71393907
node: replace nullid and friends with nodeconstants class
Joerg Sonnenberger <joerg@bec.de>
parents:
46712
diff
changeset
|
1380 node1 = f.add(b'1', None, tr, 5, f.nullid, f.nullid) |
d55b71393907
node: replace nullid and friends with nodeconstants class
Joerg Sonnenberger <joerg@bec.de>
parents:
46712
diff
changeset
|
1381 node2 = f.add(b'2', None, tr, 10, f.nullid, f.nullid) |
40050
8e136940c0e6
testing: add file storage tests for getstrippoint() and strip()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40047
diff
changeset
|
1382 |
8e136940c0e6
testing: add file storage tests for getstrippoint() and strip()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40047
diff
changeset
|
1383 self.assertEqual(len(f), 3) |
8e136940c0e6
testing: add file storage tests for getstrippoint() and strip()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40047
diff
changeset
|
1384 |
8e136940c0e6
testing: add file storage tests for getstrippoint() and strip()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40047
diff
changeset
|
1385 with self._maketransactionfn() as tr: |
8e136940c0e6
testing: add file storage tests for getstrippoint() and strip()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40047
diff
changeset
|
1386 f.strip(11, tr) |
8e136940c0e6
testing: add file storage tests for getstrippoint() and strip()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40047
diff
changeset
|
1387 |
8e136940c0e6
testing: add file storage tests for getstrippoint() and strip()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40047
diff
changeset
|
1388 self.assertEqual(len(f), 3) |
8e136940c0e6
testing: add file storage tests for getstrippoint() and strip()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40047
diff
changeset
|
1389 |
8e136940c0e6
testing: add file storage tests for getstrippoint() and strip()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40047
diff
changeset
|
1390 with self._maketransactionfn() as tr: |
8e136940c0e6
testing: add file storage tests for getstrippoint() and strip()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40047
diff
changeset
|
1391 f.strip(10, tr) |
8e136940c0e6
testing: add file storage tests for getstrippoint() and strip()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40047
diff
changeset
|
1392 |
8e136940c0e6
testing: add file storage tests for getstrippoint() and strip()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40047
diff
changeset
|
1393 self.assertEqual(len(f), 2) |
8e136940c0e6
testing: add file storage tests for getstrippoint() and strip()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40047
diff
changeset
|
1394 |
8e136940c0e6
testing: add file storage tests for getstrippoint() and strip()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40047
diff
changeset
|
1395 with self.assertRaises(error.LookupError): |
8e136940c0e6
testing: add file storage tests for getstrippoint() and strip()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40047
diff
changeset
|
1396 f.rev(node2) |
8e136940c0e6
testing: add file storage tests for getstrippoint() and strip()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40047
diff
changeset
|
1397 |
8e136940c0e6
testing: add file storage tests for getstrippoint() and strip()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40047
diff
changeset
|
1398 with self._maketransactionfn() as tr: |
8e136940c0e6
testing: add file storage tests for getstrippoint() and strip()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40047
diff
changeset
|
1399 f.strip(6, tr) |
8e136940c0e6
testing: add file storage tests for getstrippoint() and strip()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40047
diff
changeset
|
1400 |
8e136940c0e6
testing: add file storage tests for getstrippoint() and strip()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40047
diff
changeset
|
1401 self.assertEqual(len(f), 2) |
8e136940c0e6
testing: add file storage tests for getstrippoint() and strip()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40047
diff
changeset
|
1402 |
8e136940c0e6
testing: add file storage tests for getstrippoint() and strip()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40047
diff
changeset
|
1403 with self._maketransactionfn() as tr: |
8e136940c0e6
testing: add file storage tests for getstrippoint() and strip()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40047
diff
changeset
|
1404 f.strip(3, tr) |
8e136940c0e6
testing: add file storage tests for getstrippoint() and strip()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40047
diff
changeset
|
1405 |
8e136940c0e6
testing: add file storage tests for getstrippoint() and strip()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40047
diff
changeset
|
1406 self.assertEqual(len(f), 1) |
8e136940c0e6
testing: add file storage tests for getstrippoint() and strip()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40047
diff
changeset
|
1407 |
8e136940c0e6
testing: add file storage tests for getstrippoint() and strip()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40047
diff
changeset
|
1408 with self.assertRaises(error.LookupError): |
8e136940c0e6
testing: add file storage tests for getstrippoint() and strip()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40047
diff
changeset
|
1409 f.rev(node1) |
8e136940c0e6
testing: add file storage tests for getstrippoint() and strip()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40047
diff
changeset
|
1410 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42813
diff
changeset
|
1411 |
40051
cdf61ab1f54c
testing: add file storage integration for bad hashes and censoring
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40050
diff
changeset
|
1412 def makeifileindextests(makefilefn, maketransactionfn, addrawrevisionfn): |
39772
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1413 """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
|
1414 |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1415 ``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
|
1416 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
|
1417 |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1418 ``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
|
1419 argument and returns a transaction object. |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1420 |
40051
cdf61ab1f54c
testing: add file storage integration for bad hashes and censoring
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40050
diff
changeset
|
1421 ``addrawrevisionfn`` is a callable which receives arguments describing a |
cdf61ab1f54c
testing: add file storage integration for bad hashes and censoring
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40050
diff
changeset
|
1422 low-level revision to add. This callable allows the insertion of |
cdf61ab1f54c
testing: add file storage integration for bad hashes and censoring
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40050
diff
changeset
|
1423 potentially bad data into the store in order to facilitate testing. |
cdf61ab1f54c
testing: add file storage integration for bad hashes and censoring
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40050
diff
changeset
|
1424 |
39772
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1425 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
|
1426 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
|
1427 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
|
1428 should find and run it automatically. |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1429 """ |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1430 d = { |
43506
9f70512ae2cf
cleanup: remove pointless r-prefixes on single-quoted strings
Augie Fackler <augie@google.com>
parents:
43103
diff
changeset
|
1431 '_makefilefn': makefilefn, |
9f70512ae2cf
cleanup: remove pointless r-prefixes on single-quoted strings
Augie Fackler <augie@google.com>
parents:
43103
diff
changeset
|
1432 '_maketransactionfn': maketransactionfn, |
9f70512ae2cf
cleanup: remove pointless r-prefixes on single-quoted strings
Augie Fackler <augie@google.com>
parents:
43103
diff
changeset
|
1433 '_addrawrevisionfn': addrawrevisionfn, |
39772
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1434 } |
43506
9f70512ae2cf
cleanup: remove pointless r-prefixes on single-quoted strings
Augie Fackler <augie@google.com>
parents:
43103
diff
changeset
|
1435 return type('ifileindextests', (ifileindextests,), d) |
39772
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1436 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42813
diff
changeset
|
1437 |
40051
cdf61ab1f54c
testing: add file storage integration for bad hashes and censoring
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40050
diff
changeset
|
1438 def makeifiledatatests(makefilefn, maketransactionfn, addrawrevisionfn): |
39772
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1439 d = { |
43506
9f70512ae2cf
cleanup: remove pointless r-prefixes on single-quoted strings
Augie Fackler <augie@google.com>
parents:
43103
diff
changeset
|
1440 '_makefilefn': makefilefn, |
9f70512ae2cf
cleanup: remove pointless r-prefixes on single-quoted strings
Augie Fackler <augie@google.com>
parents:
43103
diff
changeset
|
1441 '_maketransactionfn': maketransactionfn, |
9f70512ae2cf
cleanup: remove pointless r-prefixes on single-quoted strings
Augie Fackler <augie@google.com>
parents:
43103
diff
changeset
|
1442 '_addrawrevisionfn': addrawrevisionfn, |
39772
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1443 } |
43506
9f70512ae2cf
cleanup: remove pointless r-prefixes on single-quoted strings
Augie Fackler <augie@google.com>
parents:
43103
diff
changeset
|
1444 return type('ifiledatatests', (ifiledatatests,), d) |
39772
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1445 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42813
diff
changeset
|
1446 |
40051
cdf61ab1f54c
testing: add file storage integration for bad hashes and censoring
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40050
diff
changeset
|
1447 def makeifilemutationtests(makefilefn, maketransactionfn, addrawrevisionfn): |
39772
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1448 d = { |
43506
9f70512ae2cf
cleanup: remove pointless r-prefixes on single-quoted strings
Augie Fackler <augie@google.com>
parents:
43103
diff
changeset
|
1449 '_makefilefn': makefilefn, |
9f70512ae2cf
cleanup: remove pointless r-prefixes on single-quoted strings
Augie Fackler <augie@google.com>
parents:
43103
diff
changeset
|
1450 '_maketransactionfn': maketransactionfn, |
9f70512ae2cf
cleanup: remove pointless r-prefixes on single-quoted strings
Augie Fackler <augie@google.com>
parents:
43103
diff
changeset
|
1451 '_addrawrevisionfn': addrawrevisionfn, |
39772
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1452 } |
43506
9f70512ae2cf
cleanup: remove pointless r-prefixes on single-quoted strings
Augie Fackler <augie@google.com>
parents:
43103
diff
changeset
|
1453 return type('ifilemutationtests', (ifilemutationtests,), d) |