author | Anton Shestakov <av6@dwimlabs.net> |
Fri, 27 May 2022 14:37:12 +0400 | |
changeset 49236 | e5e3a340b965 |
parent 48875 | 6000f5b25c9b |
child 51230 | f9a52a9603f9 |
permissions | -rw-r--r-- |
39772
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1 |
# This test verifies the conformance of various classes to various |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
2 |
# storage interfaces. |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
3 |
|
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
4 |
import silenttestrunner |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
5 |
|
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
6 |
from mercurial import ( |
40051
cdf61ab1f54c
testing: add file storage integration for bad hashes and censoring
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39953
diff
changeset
|
7 |
error, |
39772
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
8 |
filelog, |
40051
cdf61ab1f54c
testing: add file storage integration for bad hashes and censoring
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39953
diff
changeset
|
9 |
revlog, |
39772
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
10 |
transaction, |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
11 |
ui as uimod, |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
12 |
vfs as vfsmod, |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
13 |
) |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
14 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
40453
diff
changeset
|
15 |
from mercurial.testing import storage as storagetesting |
39772
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
16 |
|
40363
c3ad9ef0876c
tests: don't emit false failures when sqlite3 is missing
Augie Fackler <augie@google.com>
parents:
40326
diff
changeset
|
17 |
try: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
40453
diff
changeset
|
18 |
from hgext import sqlitestore |
40363
c3ad9ef0876c
tests: don't emit false failures when sqlite3 is missing
Augie Fackler <augie@google.com>
parents:
40326
diff
changeset
|
19 |
except ImportError: |
c3ad9ef0876c
tests: don't emit false failures when sqlite3 is missing
Augie Fackler <augie@google.com>
parents:
40326
diff
changeset
|
20 |
sqlitestore = None |
40326
fed697fa1734
sqlitestore: file storage backend using SQLite
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40323
diff
changeset
|
21 |
|
fed697fa1734
sqlitestore: file storage backend using SQLite
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40323
diff
changeset
|
22 |
try: |
40453
1bf3e6041e2c
tests: require SQLite 3.8.3+ as sqlitestore relies on "WITH" clause
Yuya Nishihara <yuya@tcha.org>
parents:
40363
diff
changeset
|
23 |
import sqlite3 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
40453
diff
changeset
|
24 |
|
40453
1bf3e6041e2c
tests: require SQLite 3.8.3+ as sqlitestore relies on "WITH" clause
Yuya Nishihara <yuya@tcha.org>
parents:
40363
diff
changeset
|
25 |
if sqlite3.sqlite_version_info < (3, 8, 3): |
1bf3e6041e2c
tests: require SQLite 3.8.3+ as sqlitestore relies on "WITH" clause
Yuya Nishihara <yuya@tcha.org>
parents:
40363
diff
changeset
|
26 |
# WITH clause not supported |
1bf3e6041e2c
tests: require SQLite 3.8.3+ as sqlitestore relies on "WITH" clause
Yuya Nishihara <yuya@tcha.org>
parents:
40363
diff
changeset
|
27 |
sqlitestore = None |
1bf3e6041e2c
tests: require SQLite 3.8.3+ as sqlitestore relies on "WITH" clause
Yuya Nishihara <yuya@tcha.org>
parents:
40363
diff
changeset
|
28 |
except ImportError: |
1bf3e6041e2c
tests: require SQLite 3.8.3+ as sqlitestore relies on "WITH" clause
Yuya Nishihara <yuya@tcha.org>
parents:
40363
diff
changeset
|
29 |
pass |
1bf3e6041e2c
tests: require SQLite 3.8.3+ as sqlitestore relies on "WITH" clause
Yuya Nishihara <yuya@tcha.org>
parents:
40363
diff
changeset
|
30 |
|
1bf3e6041e2c
tests: require SQLite 3.8.3+ as sqlitestore relies on "WITH" clause
Yuya Nishihara <yuya@tcha.org>
parents:
40363
diff
changeset
|
31 |
try: |
40326
fed697fa1734
sqlitestore: file storage backend using SQLite
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40323
diff
changeset
|
32 |
from mercurial import zstd |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
40453
diff
changeset
|
33 |
|
40326
fed697fa1734
sqlitestore: file storage backend using SQLite
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40323
diff
changeset
|
34 |
zstd.__version__ |
fed697fa1734
sqlitestore: file storage backend using SQLite
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40323
diff
changeset
|
35 |
except ImportError: |
fed697fa1734
sqlitestore: file storage backend using SQLite
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40323
diff
changeset
|
36 |
zstd = None |
fed697fa1734
sqlitestore: file storage backend using SQLite
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40323
diff
changeset
|
37 |
|
39772
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
38 |
STATE = { |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
39 |
'lastindex': 0, |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
40 |
'ui': uimod.ui(), |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
41 |
'vfs': vfsmod.vfs(b'.', realpath=True), |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
42 |
} |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
43 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
40453
diff
changeset
|
44 |
|
39772
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
45 |
def makefilefn(self): |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
46 |
"""Factory for filelog instances.""" |
39953
a3a9b93bff80
py3: byteify test-storage.py
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39772
diff
changeset
|
47 |
fl = filelog.filelog(STATE['vfs'], b'filelog-%d' % STATE['lastindex']) |
39772
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
48 |
STATE['lastindex'] += 1 |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
49 |
return fl |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
50 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
40453
diff
changeset
|
51 |
|
39772
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
52 |
def maketransaction(self): |
40320
9b2e1b00ee94
tests: use byte literals in test-storage.py
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40056
diff
changeset
|
53 |
vfsmap = {b'plain': STATE['vfs'], b'store': STATE['vfs']} |
39772
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
54 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
40453
diff
changeset
|
55 |
return transaction.transaction( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
40453
diff
changeset
|
56 |
STATE['ui'].warn, STATE['vfs'], vfsmap, b'journal', b'undo' |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
40453
diff
changeset
|
57 |
) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
40453
diff
changeset
|
58 |
|
39772
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
59 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
40453
diff
changeset
|
60 |
def addrawrevision( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
40453
diff
changeset
|
61 |
self, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
40453
diff
changeset
|
62 |
fl, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
40453
diff
changeset
|
63 |
tr, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
40453
diff
changeset
|
64 |
node, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
40453
diff
changeset
|
65 |
p1, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
40453
diff
changeset
|
66 |
p2, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
40453
diff
changeset
|
67 |
linkrev, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
40453
diff
changeset
|
68 |
rawtext=None, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
40453
diff
changeset
|
69 |
delta=None, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
40453
diff
changeset
|
70 |
censored=False, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
40453
diff
changeset
|
71 |
ellipsis=False, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
40453
diff
changeset
|
72 |
extstored=False, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
40453
diff
changeset
|
73 |
): |
40051
cdf61ab1f54c
testing: add file storage integration for bad hashes and censoring
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39953
diff
changeset
|
74 |
flags = 0 |
cdf61ab1f54c
testing: add file storage integration for bad hashes and censoring
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39953
diff
changeset
|
75 |
|
cdf61ab1f54c
testing: add file storage integration for bad hashes and censoring
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39953
diff
changeset
|
76 |
if censored: |
cdf61ab1f54c
testing: add file storage integration for bad hashes and censoring
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39953
diff
changeset
|
77 |
flags |= revlog.REVIDX_ISCENSORED |
cdf61ab1f54c
testing: add file storage integration for bad hashes and censoring
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39953
diff
changeset
|
78 |
if ellipsis: |
cdf61ab1f54c
testing: add file storage integration for bad hashes and censoring
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39953
diff
changeset
|
79 |
flags |= revlog.REVIDX_ELLIPSIS |
cdf61ab1f54c
testing: add file storage integration for bad hashes and censoring
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39953
diff
changeset
|
80 |
if extstored: |
cdf61ab1f54c
testing: add file storage integration for bad hashes and censoring
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39953
diff
changeset
|
81 |
flags |= revlog.REVIDX_EXTSTORED |
cdf61ab1f54c
testing: add file storage integration for bad hashes and censoring
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39953
diff
changeset
|
82 |
|
cdf61ab1f54c
testing: add file storage integration for bad hashes and censoring
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39953
diff
changeset
|
83 |
if rawtext is not None: |
cdf61ab1f54c
testing: add file storage integration for bad hashes and censoring
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39953
diff
changeset
|
84 |
fl._revlog.addrawrevision(rawtext, tr, linkrev, p1, p2, node, flags) |
cdf61ab1f54c
testing: add file storage integration for bad hashes and censoring
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39953
diff
changeset
|
85 |
elif delta is not None: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
40453
diff
changeset
|
86 |
fl._revlog.addrawrevision( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
40453
diff
changeset
|
87 |
rawtext, tr, linkrev, p1, p2, node, flags, cachedelta=delta |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
40453
diff
changeset
|
88 |
) |
40051
cdf61ab1f54c
testing: add file storage integration for bad hashes and censoring
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39953
diff
changeset
|
89 |
else: |
cdf61ab1f54c
testing: add file storage integration for bad hashes and censoring
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39953
diff
changeset
|
90 |
raise error.Abort('must supply rawtext or delta arguments') |
cdf61ab1f54c
testing: add file storage integration for bad hashes and censoring
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39953
diff
changeset
|
91 |
|
cdf61ab1f54c
testing: add file storage integration for bad hashes and censoring
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39953
diff
changeset
|
92 |
# We may insert bad data. Clear caches to prevent e.g. cache hits to |
cdf61ab1f54c
testing: add file storage integration for bad hashes and censoring
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39953
diff
changeset
|
93 |
# bypass hash verification. |
cdf61ab1f54c
testing: add file storage integration for bad hashes and censoring
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39953
diff
changeset
|
94 |
fl._revlog.clearcaches() |
cdf61ab1f54c
testing: add file storage integration for bad hashes and censoring
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39953
diff
changeset
|
95 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
40453
diff
changeset
|
96 |
|
39772
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
97 |
# Assigning module-level attributes that inherit from unittest.TestCase |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
98 |
# is all that is needed to register tests. |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
40453
diff
changeset
|
99 |
filelogindextests = storagetesting.makeifileindextests( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
40453
diff
changeset
|
100 |
makefilefn, maketransaction, addrawrevision |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
40453
diff
changeset
|
101 |
) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
40453
diff
changeset
|
102 |
filelogdatatests = storagetesting.makeifiledatatests( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
40453
diff
changeset
|
103 |
makefilefn, maketransaction, addrawrevision |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
40453
diff
changeset
|
104 |
) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
40453
diff
changeset
|
105 |
filelogmutationtests = storagetesting.makeifilemutationtests( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
40453
diff
changeset
|
106 |
makefilefn, maketransaction, addrawrevision |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
40453
diff
changeset
|
107 |
) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
40453
diff
changeset
|
108 |
|
39772
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
109 |
|
40326
fed697fa1734
sqlitestore: file storage backend using SQLite
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40323
diff
changeset
|
110 |
def makesqlitefile(self): |
fed697fa1734
sqlitestore: file storage backend using SQLite
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40323
diff
changeset
|
111 |
path = STATE['vfs'].join(b'db-%d.db' % STATE['lastindex']) |
fed697fa1734
sqlitestore: file storage backend using SQLite
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40323
diff
changeset
|
112 |
STATE['lastindex'] += 1 |
fed697fa1734
sqlitestore: file storage backend using SQLite
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40323
diff
changeset
|
113 |
|
fed697fa1734
sqlitestore: file storage backend using SQLite
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40323
diff
changeset
|
114 |
db = sqlitestore.makedb(path) |
fed697fa1734
sqlitestore: file storage backend using SQLite
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40323
diff
changeset
|
115 |
|
fed697fa1734
sqlitestore: file storage backend using SQLite
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40323
diff
changeset
|
116 |
compression = b'zstd' if zstd else b'zlib' |
fed697fa1734
sqlitestore: file storage backend using SQLite
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40323
diff
changeset
|
117 |
|
fed697fa1734
sqlitestore: file storage backend using SQLite
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40323
diff
changeset
|
118 |
return sqlitestore.sqlitefilestore(db, b'dummy-path', compression) |
fed697fa1734
sqlitestore: file storage backend using SQLite
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40323
diff
changeset
|
119 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
40453
diff
changeset
|
120 |
|
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
40453
diff
changeset
|
121 |
def addrawrevisionsqlite( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
40453
diff
changeset
|
122 |
self, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
40453
diff
changeset
|
123 |
fl, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
40453
diff
changeset
|
124 |
tr, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
40453
diff
changeset
|
125 |
node, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
40453
diff
changeset
|
126 |
p1, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
40453
diff
changeset
|
127 |
p2, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
40453
diff
changeset
|
128 |
linkrev, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
40453
diff
changeset
|
129 |
rawtext=None, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
40453
diff
changeset
|
130 |
delta=None, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
40453
diff
changeset
|
131 |
censored=False, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
40453
diff
changeset
|
132 |
ellipsis=False, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
40453
diff
changeset
|
133 |
extstored=False, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
40453
diff
changeset
|
134 |
): |
40326
fed697fa1734
sqlitestore: file storage backend using SQLite
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40323
diff
changeset
|
135 |
flags = 0 |
fed697fa1734
sqlitestore: file storage backend using SQLite
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40323
diff
changeset
|
136 |
|
fed697fa1734
sqlitestore: file storage backend using SQLite
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40323
diff
changeset
|
137 |
if censored: |
fed697fa1734
sqlitestore: file storage backend using SQLite
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40323
diff
changeset
|
138 |
flags |= sqlitestore.FLAG_CENSORED |
fed697fa1734
sqlitestore: file storage backend using SQLite
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40323
diff
changeset
|
139 |
|
fed697fa1734
sqlitestore: file storage backend using SQLite
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40323
diff
changeset
|
140 |
if ellipsis | extstored: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
40453
diff
changeset
|
141 |
raise error.Abort( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
40453
diff
changeset
|
142 |
b'support for ellipsis and extstored flags not ' b'supported' |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
40453
diff
changeset
|
143 |
) |
40326
fed697fa1734
sqlitestore: file storage backend using SQLite
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40323
diff
changeset
|
144 |
|
fed697fa1734
sqlitestore: file storage backend using SQLite
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40323
diff
changeset
|
145 |
if rawtext is not None: |
fed697fa1734
sqlitestore: file storage backend using SQLite
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40323
diff
changeset
|
146 |
fl._addrawrevision(node, rawtext, tr, linkrev, p1, p2, flags=flags) |
fed697fa1734
sqlitestore: file storage backend using SQLite
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40323
diff
changeset
|
147 |
elif delta is not None: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
40453
diff
changeset
|
148 |
fl._addrawrevision( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
40453
diff
changeset
|
149 |
node, rawtext, tr, linkrev, p1, p2, storedelta=delta, flags=flags |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
40453
diff
changeset
|
150 |
) |
40326
fed697fa1734
sqlitestore: file storage backend using SQLite
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40323
diff
changeset
|
151 |
else: |
fed697fa1734
sqlitestore: file storage backend using SQLite
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40323
diff
changeset
|
152 |
raise error.Abort(b'must supply rawtext or delta arguments') |
fed697fa1734
sqlitestore: file storage backend using SQLite
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40323
diff
changeset
|
153 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
40453
diff
changeset
|
154 |
|
40363
c3ad9ef0876c
tests: don't emit false failures when sqlite3 is missing
Augie Fackler <augie@google.com>
parents:
40326
diff
changeset
|
155 |
if sqlitestore is not None: |
c3ad9ef0876c
tests: don't emit false failures when sqlite3 is missing
Augie Fackler <augie@google.com>
parents:
40326
diff
changeset
|
156 |
sqlitefileindextests = storagetesting.makeifileindextests( |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
40453
diff
changeset
|
157 |
makesqlitefile, maketransaction, addrawrevisionsqlite |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
40453
diff
changeset
|
158 |
) |
40363
c3ad9ef0876c
tests: don't emit false failures when sqlite3 is missing
Augie Fackler <augie@google.com>
parents:
40326
diff
changeset
|
159 |
sqlitefiledatatests = storagetesting.makeifiledatatests( |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
40453
diff
changeset
|
160 |
makesqlitefile, maketransaction, addrawrevisionsqlite |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
40453
diff
changeset
|
161 |
) |
40363
c3ad9ef0876c
tests: don't emit false failures when sqlite3 is missing
Augie Fackler <augie@google.com>
parents:
40326
diff
changeset
|
162 |
sqlitefilemutationtests = storagetesting.makeifilemutationtests( |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
40453
diff
changeset
|
163 |
makesqlitefile, maketransaction, addrawrevisionsqlite |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
40453
diff
changeset
|
164 |
) |
40326
fed697fa1734
sqlitestore: file storage backend using SQLite
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40323
diff
changeset
|
165 |
|
39772
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
166 |
if __name__ == '__main__': |
ae531f5e583c
testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
167 |
silenttestrunner.main(__name__) |