tests/test-storage.py
author Pierre-Yves David <pierre-yves.david@octobus.net>
Thu, 04 Jan 2024 14:51:48 +0100
changeset 51339 9a1239c362ae
parent 51230 f9a52a9603f9
permissions -rw-r--r--
delta-find: split the "sparse" part of `_pre_filter_rev` in a method Since `_pre_filter_rev` contains logic from various sources of constraint, we start splitting is in subfunction to clarify and document the grouping.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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:
51230
f9a52a9603f9 tests: ignore test-storage when using Rust
Raphaël Gomès <rgomes@octobus.net>
parents: 48875
diff changeset
    18
    from mercurial import rustext
f9a52a9603f9 tests: ignore test-storage when using Rust
Raphaël Gomès <rgomes@octobus.net>
parents: 48875
diff changeset
    19
f9a52a9603f9 tests: ignore test-storage when using Rust
Raphaël Gomès <rgomes@octobus.net>
parents: 48875
diff changeset
    20
    rustext.__name__
f9a52a9603f9 tests: ignore test-storage when using Rust
Raphaël Gomès <rgomes@octobus.net>
parents: 48875
diff changeset
    21
    # Does not pass with pure Rust index
f9a52a9603f9 tests: ignore test-storage when using Rust
Raphaël Gomès <rgomes@octobus.net>
parents: 48875
diff changeset
    22
    import sys
f9a52a9603f9 tests: ignore test-storage when using Rust
Raphaël Gomès <rgomes@octobus.net>
parents: 48875
diff changeset
    23
f9a52a9603f9 tests: ignore test-storage when using Rust
Raphaël Gomès <rgomes@octobus.net>
parents: 48875
diff changeset
    24
    sys.exit(80)
f9a52a9603f9 tests: ignore test-storage when using Rust
Raphaël Gomès <rgomes@octobus.net>
parents: 48875
diff changeset
    25
except ImportError:
f9a52a9603f9 tests: ignore test-storage when using Rust
Raphaël Gomès <rgomes@octobus.net>
parents: 48875
diff changeset
    26
    pass
f9a52a9603f9 tests: ignore test-storage when using Rust
Raphaël Gomès <rgomes@octobus.net>
parents: 48875
diff changeset
    27
f9a52a9603f9 tests: ignore test-storage when using Rust
Raphaël Gomès <rgomes@octobus.net>
parents: 48875
diff changeset
    28
try:
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 40453
diff changeset
    29
    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
    30
except ImportError:
c3ad9ef0876c tests: don't emit false failures when sqlite3 is missing
Augie Fackler <augie@google.com>
parents: 40326
diff changeset
    31
    sqlitestore = None
40326
fed697fa1734 sqlitestore: file storage backend using SQLite
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40323
diff changeset
    32
fed697fa1734 sqlitestore: file storage backend using SQLite
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40323
diff changeset
    33
try:
40453
1bf3e6041e2c tests: require SQLite 3.8.3+ as sqlitestore relies on "WITH" clause
Yuya Nishihara <yuya@tcha.org>
parents: 40363
diff changeset
    34
    import sqlite3
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 40453
diff changeset
    35
40453
1bf3e6041e2c tests: require SQLite 3.8.3+ as sqlitestore relies on "WITH" clause
Yuya Nishihara <yuya@tcha.org>
parents: 40363
diff changeset
    36
    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
    37
        # 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
    38
        sqlitestore = None
1bf3e6041e2c tests: require SQLite 3.8.3+ as sqlitestore relies on "WITH" clause
Yuya Nishihara <yuya@tcha.org>
parents: 40363
diff changeset
    39
except ImportError:
1bf3e6041e2c tests: require SQLite 3.8.3+ as sqlitestore relies on "WITH" clause
Yuya Nishihara <yuya@tcha.org>
parents: 40363
diff changeset
    40
    pass
1bf3e6041e2c tests: require SQLite 3.8.3+ as sqlitestore relies on "WITH" clause
Yuya Nishihara <yuya@tcha.org>
parents: 40363
diff changeset
    41
1bf3e6041e2c tests: require SQLite 3.8.3+ as sqlitestore relies on "WITH" clause
Yuya Nishihara <yuya@tcha.org>
parents: 40363
diff changeset
    42
try:
40326
fed697fa1734 sqlitestore: file storage backend using SQLite
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40323
diff changeset
    43
    from mercurial import zstd
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 40453
diff changeset
    44
40326
fed697fa1734 sqlitestore: file storage backend using SQLite
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40323
diff changeset
    45
    zstd.__version__
fed697fa1734 sqlitestore: file storage backend using SQLite
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40323
diff changeset
    46
except ImportError:
fed697fa1734 sqlitestore: file storage backend using SQLite
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40323
diff changeset
    47
    zstd = None
fed697fa1734 sqlitestore: file storage backend using SQLite
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40323
diff changeset
    48
39772
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    49
STATE = {
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    50
    'lastindex': 0,
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    51
    'ui': uimod.ui(),
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    52
    'vfs': vfsmod.vfs(b'.', realpath=True),
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    53
}
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    54
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 40453
diff changeset
    55
39772
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    56
def makefilefn(self):
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    57
    """Factory for filelog instances."""
39953
a3a9b93bff80 py3: byteify test-storage.py
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39772
diff changeset
    58
    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
    59
    STATE['lastindex'] += 1
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    60
    return fl
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    61
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 40453
diff changeset
    62
39772
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    63
def maketransaction(self):
40320
9b2e1b00ee94 tests: use byte literals in test-storage.py
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40056
diff changeset
    64
    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
    65
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 40453
diff changeset
    66
    return transaction.transaction(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 40453
diff changeset
    67
        STATE['ui'].warn, STATE['vfs'], vfsmap, b'journal', b'undo'
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 40453
diff changeset
    68
    )
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 40453
diff changeset
    69
39772
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    70
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 40453
diff changeset
    71
def addrawrevision(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 40453
diff changeset
    72
    self,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 40453
diff changeset
    73
    fl,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 40453
diff changeset
    74
    tr,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 40453
diff changeset
    75
    node,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 40453
diff changeset
    76
    p1,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 40453
diff changeset
    77
    p2,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 40453
diff changeset
    78
    linkrev,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 40453
diff changeset
    79
    rawtext=None,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 40453
diff changeset
    80
    delta=None,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 40453
diff changeset
    81
    censored=False,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 40453
diff changeset
    82
    ellipsis=False,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 40453
diff changeset
    83
    extstored=False,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 40453
diff changeset
    84
):
40051
cdf61ab1f54c testing: add file storage integration for bad hashes and censoring
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39953
diff changeset
    85
    flags = 0
cdf61ab1f54c testing: add file storage integration for bad hashes and censoring
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39953
diff changeset
    86
cdf61ab1f54c testing: add file storage integration for bad hashes and censoring
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39953
diff changeset
    87
    if censored:
cdf61ab1f54c testing: add file storage integration for bad hashes and censoring
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39953
diff changeset
    88
        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
    89
    if ellipsis:
cdf61ab1f54c testing: add file storage integration for bad hashes and censoring
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39953
diff changeset
    90
        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
    91
    if extstored:
cdf61ab1f54c testing: add file storage integration for bad hashes and censoring
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39953
diff changeset
    92
        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
    93
cdf61ab1f54c testing: add file storage integration for bad hashes and censoring
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39953
diff changeset
    94
    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
    95
        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
    96
    elif delta is not None:
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 40453
diff changeset
    97
        fl._revlog.addrawrevision(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 40453
diff changeset
    98
            rawtext, tr, linkrev, p1, p2, node, flags, cachedelta=delta
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 40453
diff changeset
    99
        )
40051
cdf61ab1f54c testing: add file storage integration for bad hashes and censoring
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39953
diff changeset
   100
    else:
cdf61ab1f54c testing: add file storage integration for bad hashes and censoring
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39953
diff changeset
   101
        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
   102
cdf61ab1f54c testing: add file storage integration for bad hashes and censoring
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39953
diff changeset
   103
    # 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
   104
    # bypass hash verification.
cdf61ab1f54c testing: add file storage integration for bad hashes and censoring
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39953
diff changeset
   105
    fl._revlog.clearcaches()
cdf61ab1f54c testing: add file storage integration for bad hashes and censoring
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39953
diff changeset
   106
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 40453
diff changeset
   107
39772
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   108
# 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
   109
# is all that is needed to register tests.
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 40453
diff changeset
   110
filelogindextests = storagetesting.makeifileindextests(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 40453
diff changeset
   111
    makefilefn, maketransaction, addrawrevision
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 40453
diff changeset
   112
)
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 40453
diff changeset
   113
filelogdatatests = storagetesting.makeifiledatatests(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 40453
diff changeset
   114
    makefilefn, maketransaction, addrawrevision
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 40453
diff changeset
   115
)
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 40453
diff changeset
   116
filelogmutationtests = storagetesting.makeifilemutationtests(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 40453
diff changeset
   117
    makefilefn, maketransaction, addrawrevision
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 40453
diff changeset
   118
)
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 40453
diff changeset
   119
39772
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   120
40326
fed697fa1734 sqlitestore: file storage backend using SQLite
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40323
diff changeset
   121
def makesqlitefile(self):
fed697fa1734 sqlitestore: file storage backend using SQLite
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40323
diff changeset
   122
    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
   123
    STATE['lastindex'] += 1
fed697fa1734 sqlitestore: file storage backend using SQLite
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40323
diff changeset
   124
fed697fa1734 sqlitestore: file storage backend using SQLite
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40323
diff changeset
   125
    db = sqlitestore.makedb(path)
fed697fa1734 sqlitestore: file storage backend using SQLite
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40323
diff changeset
   126
fed697fa1734 sqlitestore: file storage backend using SQLite
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40323
diff changeset
   127
    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
   128
fed697fa1734 sqlitestore: file storage backend using SQLite
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40323
diff changeset
   129
    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
   130
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 40453
diff changeset
   131
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 40453
diff changeset
   132
def addrawrevisionsqlite(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 40453
diff changeset
   133
    self,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 40453
diff changeset
   134
    fl,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 40453
diff changeset
   135
    tr,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 40453
diff changeset
   136
    node,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 40453
diff changeset
   137
    p1,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 40453
diff changeset
   138
    p2,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 40453
diff changeset
   139
    linkrev,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 40453
diff changeset
   140
    rawtext=None,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 40453
diff changeset
   141
    delta=None,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 40453
diff changeset
   142
    censored=False,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 40453
diff changeset
   143
    ellipsis=False,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 40453
diff changeset
   144
    extstored=False,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 40453
diff changeset
   145
):
40326
fed697fa1734 sqlitestore: file storage backend using SQLite
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40323
diff changeset
   146
    flags = 0
fed697fa1734 sqlitestore: file storage backend using SQLite
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40323
diff changeset
   147
fed697fa1734 sqlitestore: file storage backend using SQLite
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40323
diff changeset
   148
    if censored:
fed697fa1734 sqlitestore: file storage backend using SQLite
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40323
diff changeset
   149
        flags |= sqlitestore.FLAG_CENSORED
fed697fa1734 sqlitestore: file storage backend using SQLite
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40323
diff changeset
   150
fed697fa1734 sqlitestore: file storage backend using SQLite
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40323
diff changeset
   151
    if ellipsis | extstored:
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 40453
diff changeset
   152
        raise error.Abort(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 40453
diff changeset
   153
            b'support for ellipsis and extstored flags not ' b'supported'
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 40453
diff changeset
   154
        )
40326
fed697fa1734 sqlitestore: file storage backend using SQLite
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40323
diff changeset
   155
fed697fa1734 sqlitestore: file storage backend using SQLite
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40323
diff changeset
   156
    if rawtext is not None:
fed697fa1734 sqlitestore: file storage backend using SQLite
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40323
diff changeset
   157
        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
   158
    elif delta is not None:
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 40453
diff changeset
   159
        fl._addrawrevision(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 40453
diff changeset
   160
            node, rawtext, tr, linkrev, p1, p2, storedelta=delta, flags=flags
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 40453
diff changeset
   161
        )
40326
fed697fa1734 sqlitestore: file storage backend using SQLite
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40323
diff changeset
   162
    else:
fed697fa1734 sqlitestore: file storage backend using SQLite
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40323
diff changeset
   163
        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
   164
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 40453
diff changeset
   165
40363
c3ad9ef0876c tests: don't emit false failures when sqlite3 is missing
Augie Fackler <augie@google.com>
parents: 40326
diff changeset
   166
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
   167
    sqlitefileindextests = storagetesting.makeifileindextests(
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 40453
diff changeset
   168
        makesqlitefile, maketransaction, addrawrevisionsqlite
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 40453
diff changeset
   169
    )
40363
c3ad9ef0876c tests: don't emit false failures when sqlite3 is missing
Augie Fackler <augie@google.com>
parents: 40326
diff changeset
   170
    sqlitefiledatatests = storagetesting.makeifiledatatests(
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 40453
diff changeset
   171
        makesqlitefile, maketransaction, addrawrevisionsqlite
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 40453
diff changeset
   172
    )
40363
c3ad9ef0876c tests: don't emit false failures when sqlite3 is missing
Augie Fackler <augie@google.com>
parents: 40326
diff changeset
   173
    sqlitefilemutationtests = storagetesting.makeifilemutationtests(
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 40453
diff changeset
   174
        makesqlitefile, maketransaction, addrawrevisionsqlite
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 40453
diff changeset
   175
    )
40326
fed697fa1734 sqlitestore: file storage backend using SQLite
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40323
diff changeset
   176
39772
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   177
if __name__ == '__main__':
ae531f5e583c testing: add interface unit tests for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   178
    silenttestrunner.main(__name__)