annotate tests/simplestorerepo.py @ 47995:e7d0a511965c

dirstate: drop the `_addpath` method All user have been migrated. Differential Revision: https://phab.mercurial-scm.org/D11435
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Wed, 15 Sep 2021 12:38:56 +0200
parents 2174f54aab18
children 6000f5b25c9b
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
37337
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
1 # simplestorerepo.py - Extension that swaps in alternate repository storage.
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
2 #
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
3 # Copyright 2018 Gregory Szorc <gregory.szorc@gmail.com>
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
4 #
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
5 # This software may be used and distributed according to the terms of the
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
6 # GNU General Public License version 2 or any later version.
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
7
37338
cbc4425e81b5 tests: conditionalize tests based on presence of revlogs for files
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37337
diff changeset
8 # To use this with the test suite:
cbc4425e81b5 tests: conditionalize tests based on presence of revlogs for files
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37337
diff changeset
9 #
cbc4425e81b5 tests: conditionalize tests based on presence of revlogs for files
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37337
diff changeset
10 # $ HGREPOFEATURES="simplestore" ./run-tests.py \
cbc4425e81b5 tests: conditionalize tests based on presence of revlogs for files
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37337
diff changeset
11 # --extra-config-opt extensions.simplestore=`pwd`/simplestorerepo.py
cbc4425e81b5 tests: conditionalize tests based on presence of revlogs for files
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37337
diff changeset
12
37337
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
13 from __future__ import absolute_import
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
14
37415
c2c8962a9465 simplestore: use a custom store for the simple store repo
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37408
diff changeset
15 import stat
c2c8962a9465 simplestore: use a custom store for the simple store repo
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37408
diff changeset
16
37337
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
17 from mercurial.i18n import _
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
18 from mercurial.node import (
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
19 bin,
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
20 hex,
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
21 nullrev,
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
22 )
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42995
diff changeset
23 from mercurial.thirdparty import attr
37337
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
24 from mercurial import (
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
25 ancestor,
37346
45a4799174a1 tests: disallow using simple store repo with bundlerepo
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37341
diff changeset
26 bundlerepo,
37337
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
27 error,
37415
c2c8962a9465 simplestore: use a custom store for the simple store repo
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37408
diff changeset
28 extensions,
c2c8962a9465 simplestore: use a custom store for the simple store repo
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37408
diff changeset
29 localrepo,
37337
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
30 mdiff,
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
31 pycompat,
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
32 revlog,
37415
c2c8962a9465 simplestore: use a custom store for the simple store repo
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37408
diff changeset
33 store,
37417
76d2115cb817 verify: allow suppressing warnings about extra files
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37415
diff changeset
34 verify,
37337
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
35 )
42813
268662aac075 interfaces: create a new folder for interfaces and move repository.py in it
Pulkit Goyal <pulkit@yandex-team.ru>
parents: 42730
diff changeset
36 from mercurial.interfaces import (
268662aac075 interfaces: create a new folder for interfaces and move repository.py in it
Pulkit Goyal <pulkit@yandex-team.ru>
parents: 42730
diff changeset
37 repository,
42814
2c4f656c8e9f interfaceutil: move to interfaces/
Pulkit Goyal <pulkit@yandex-team.ru>
parents: 42813
diff changeset
38 util as interfaceutil,
42813
268662aac075 interfaces: create a new folder for interfaces and move repository.py in it
Pulkit Goyal <pulkit@yandex-team.ru>
parents: 42730
diff changeset
39 )
38547
404eab7ff33f tests: use interfaceutil in simplestorerepo
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37442
diff changeset
40 from mercurial.utils import (
41158
ad51e6117095 simplestorerepo: migrate to in-hg CBOR code
Augie Fackler <augie@google.com>
parents: 41157
diff changeset
41 cborutil,
39877
f8eb71f9e3bd storageutil: new module for storage primitives (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39876
diff changeset
42 storageutil,
38547
404eab7ff33f tests: use interfaceutil in simplestorerepo
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37442
diff changeset
43 )
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42995
diff changeset
44 from mercurial.revlogutils import flagutil
37337
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
45
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
46 # Note for extension authors: ONLY specify testedwith = 'ships-with-hg-core' for
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
47 # extensions which SHIP WITH MERCURIAL. Non-mainline extensions should
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
48 # be specifying the version(s) of Mercurial they are tested with, or
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
49 # leave the attribute unspecified.
43733
8ca92bcb3083 tests: byteify a few more things in simplestorerepo.py
Matt Harbison <matt_harbison@yahoo.com>
parents: 43076
diff changeset
50 testedwith = b'ships-with-hg-core'
37337
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
51
43733
8ca92bcb3083 tests: byteify a few more things in simplestorerepo.py
Matt Harbison <matt_harbison@yahoo.com>
parents: 43076
diff changeset
52 REQUIREMENT = b'testonly-simplestore'
37415
c2c8962a9465 simplestore: use a custom store for the simple store repo
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37408
diff changeset
53
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42995
diff changeset
54
37337
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
55 def validatenode(node):
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
56 if isinstance(node, int):
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
57 raise ValueError('expected node; got int')
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
58
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
59 if len(node) != 20:
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
60 raise ValueError('expected 20 byte node')
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
61
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42995
diff changeset
62
37337
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
63 def validaterev(rev):
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
64 if not isinstance(rev, int):
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
65 raise ValueError('expected int')
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
66
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42995
diff changeset
67
39777
b63dee7bd0d9 global: replace most uses of RevlogError with StorageError (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39773
diff changeset
68 class simplestoreerror(error.StorageError):
b63dee7bd0d9 global: replace most uses of RevlogError with StorageError (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39773
diff changeset
69 pass
b63dee7bd0d9 global: replace most uses of RevlogError with StorageError (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39773
diff changeset
70
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42995
diff changeset
71
39231
b41d023a412a repository: establish API for emitting revision deltas
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38547
diff changeset
72 @interfaceutil.implementer(repository.irevisiondelta)
41157
c4639fdae1b9 simplestorerepo: minimal changes required to get this mostly working again
Augie Fackler <augie@google.com>
parents: 40389
diff changeset
73 @attr.s(slots=True)
39231
b41d023a412a repository: establish API for emitting revision deltas
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38547
diff changeset
74 class simplestorerevisiondelta(object):
b41d023a412a repository: establish API for emitting revision deltas
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38547
diff changeset
75 node = attr.ib()
b41d023a412a repository: establish API for emitting revision deltas
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38547
diff changeset
76 p1node = attr.ib()
b41d023a412a repository: establish API for emitting revision deltas
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38547
diff changeset
77 p2node = attr.ib()
b41d023a412a repository: establish API for emitting revision deltas
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38547
diff changeset
78 basenode = attr.ib()
b41d023a412a repository: establish API for emitting revision deltas
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38547
diff changeset
79 flags = attr.ib()
b41d023a412a repository: establish API for emitting revision deltas
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38547
diff changeset
80 baserevisionsize = attr.ib()
b41d023a412a repository: establish API for emitting revision deltas
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38547
diff changeset
81 revision = attr.ib()
b41d023a412a repository: establish API for emitting revision deltas
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38547
diff changeset
82 delta = attr.ib()
41157
c4639fdae1b9 simplestorerepo: minimal changes required to get this mostly working again
Augie Fackler <augie@google.com>
parents: 40389
diff changeset
83 linknode = attr.ib(default=None)
c4639fdae1b9 simplestorerepo: minimal changes required to get this mostly working again
Augie Fackler <augie@google.com>
parents: 40389
diff changeset
84
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42995
diff changeset
85
41157
c4639fdae1b9 simplestorerepo: minimal changes required to get this mostly working again
Augie Fackler <augie@google.com>
parents: 40389
diff changeset
86 @interfaceutil.implementer(repository.iverifyproblem)
c4639fdae1b9 simplestorerepo: minimal changes required to get this mostly working again
Augie Fackler <augie@google.com>
parents: 40389
diff changeset
87 @attr.s(frozen=True)
c4639fdae1b9 simplestorerepo: minimal changes required to get this mostly working again
Augie Fackler <augie@google.com>
parents: 40389
diff changeset
88 class simplefilestoreproblem(object):
c4639fdae1b9 simplestorerepo: minimal changes required to get this mostly working again
Augie Fackler <augie@google.com>
parents: 40389
diff changeset
89 warning = attr.ib(default=None)
c4639fdae1b9 simplestorerepo: minimal changes required to get this mostly working again
Augie Fackler <augie@google.com>
parents: 40389
diff changeset
90 error = attr.ib(default=None)
c4639fdae1b9 simplestorerepo: minimal changes required to get this mostly working again
Augie Fackler <augie@google.com>
parents: 40389
diff changeset
91 node = attr.ib(default=None)
39231
b41d023a412a repository: establish API for emitting revision deltas
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38547
diff changeset
92
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42995
diff changeset
93
38547
404eab7ff33f tests: use interfaceutil in simplestorerepo
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37442
diff changeset
94 @interfaceutil.implementer(repository.ifilestorage)
42995
73288e7abe9b flagprocessors: remove flagprocessorsmixin
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 42992
diff changeset
95 class filestorage(object):
37337
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
96 """Implements storage for a tracked path.
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
97
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
98 Data is stored in the VFS in a directory corresponding to the tracked
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
99 path.
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
100
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
101 Index data is stored in an ``index`` file using CBOR.
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
102
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
103 Fulltext data is stored in files having names of the node.
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
104 """
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
105
42874
705428da231f flagutil: use it in simplestorerepo
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 42814
diff changeset
106 _flagserrorclass = simplestoreerror
705428da231f flagutil: use it in simplestorerepo
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 42814
diff changeset
107
46780
6266d19556ad node: introduce nodeconstants class
Joerg Sonnenberger <joerg@bec.de>
parents: 46715
diff changeset
108 def __init__(self, repo, svfs, path):
6266d19556ad node: introduce nodeconstants class
Joerg Sonnenberger <joerg@bec.de>
parents: 46715
diff changeset
109 self.nullid = repo.nullid
6266d19556ad node: introduce nodeconstants class
Joerg Sonnenberger <joerg@bec.de>
parents: 46715
diff changeset
110 self._repo = repo
37337
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
111 self._svfs = svfs
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
112 self._path = path
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
113
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
114 self._storepath = b'/'.join([b'data', path])
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
115 self._indexpath = b'/'.join([self._storepath, b'index'])
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
116
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
117 indexdata = self._svfs.tryread(self._indexpath)
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
118 if indexdata:
41158
ad51e6117095 simplestorerepo: migrate to in-hg CBOR code
Augie Fackler <augie@google.com>
parents: 41157
diff changeset
119 indexdata = cborutil.decodeall(indexdata)
37337
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
120
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
121 self._indexdata = indexdata or []
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
122 self._indexbynode = {}
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
123 self._indexbyrev = {}
39860
d9b3cc3d5d07 filelog: drop index attribute (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39844
diff changeset
124 self._index = []
37337
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
125 self._refreshindex()
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
126
42874
705428da231f flagutil: use it in simplestorerepo
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 42814
diff changeset
127 self._flagprocessors = dict(flagutil.flagprocessors)
705428da231f flagutil: use it in simplestorerepo
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 42814
diff changeset
128
37337
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
129 def _refreshindex(self):
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
130 self._indexbynode.clear()
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
131 self._indexbyrev.clear()
39860
d9b3cc3d5d07 filelog: drop index attribute (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39844
diff changeset
132 self._index = []
37337
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
133
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
134 for i, entry in enumerate(self._indexdata):
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
135 self._indexbynode[entry[b'node']] = entry
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
136 self._indexbyrev[i] = entry
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
137
47012
d55b71393907 node: replace nullid and friends with nodeconstants class
Joerg Sonnenberger <joerg@bec.de>
parents: 46780
diff changeset
138 self._indexbynode[self._repo.nullid] = {
d55b71393907 node: replace nullid and friends with nodeconstants class
Joerg Sonnenberger <joerg@bec.de>
parents: 46780
diff changeset
139 b'node': self._repo.nullid,
d55b71393907 node: replace nullid and friends with nodeconstants class
Joerg Sonnenberger <joerg@bec.de>
parents: 46780
diff changeset
140 b'p1': self._repo.nullid,
d55b71393907 node: replace nullid and friends with nodeconstants class
Joerg Sonnenberger <joerg@bec.de>
parents: 46780
diff changeset
141 b'p2': self._repo.nullid,
37337
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
142 b'linkrev': nullrev,
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
143 b'flags': 0,
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
144 }
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
145
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
146 self._indexbyrev[nullrev] = {
47012
d55b71393907 node: replace nullid and friends with nodeconstants class
Joerg Sonnenberger <joerg@bec.de>
parents: 46780
diff changeset
147 b'node': self._repo.nullid,
d55b71393907 node: replace nullid and friends with nodeconstants class
Joerg Sonnenberger <joerg@bec.de>
parents: 46780
diff changeset
148 b'p1': self._repo.nullid,
d55b71393907 node: replace nullid and friends with nodeconstants class
Joerg Sonnenberger <joerg@bec.de>
parents: 46780
diff changeset
149 b'p2': self._repo.nullid,
37337
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
150 b'linkrev': nullrev,
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
151 b'flags': 0,
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
152 }
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
153
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
154 for i, entry in enumerate(self._indexdata):
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
155 p1rev, p2rev = self.parentrevs(self.rev(entry[b'node']))
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
156
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
157 # start, length, rawsize, chainbase, linkrev, p1, p2, node
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42995
diff changeset
158 self._index.append(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42995
diff changeset
159 (0, 0, 0, -1, entry[b'linkrev'], p1rev, p2rev, entry[b'node'])
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42995
diff changeset
160 )
37337
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
161
47012
d55b71393907 node: replace nullid and friends with nodeconstants class
Joerg Sonnenberger <joerg@bec.de>
parents: 46780
diff changeset
162 self._index.append((0, 0, 0, -1, -1, -1, -1, self._repo.nullid))
37337
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
163
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
164 def __len__(self):
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
165 return len(self._indexdata)
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
166
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
167 def __iter__(self):
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
168 return iter(range(len(self)))
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
169
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
170 def revs(self, start=0, stop=None):
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
171 step = 1
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
172 if stop is not None:
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
173 if start > stop:
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
174 step = -1
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
175
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
176 stop += step
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
177 else:
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
178 stop = len(self)
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
179
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
180 return range(start, stop, step)
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
181
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
182 def parents(self, node):
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
183 validatenode(node)
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
184
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
185 if node not in self._indexbynode:
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
186 raise KeyError('unknown node')
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
187
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
188 entry = self._indexbynode[node]
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
189
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
190 return entry[b'p1'], entry[b'p2']
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
191
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
192 def parentrevs(self, rev):
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
193 p1, p2 = self.parents(self._indexbyrev[rev][b'node'])
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
194 return self.rev(p1), self.rev(p2)
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
195
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
196 def rev(self, node):
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
197 validatenode(node)
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
198
37408
dd2753729853 simplestore: shore up lookup errors
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37346
diff changeset
199 try:
dd2753729853 simplestore: shore up lookup errors
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37346
diff changeset
200 self._indexbynode[node]
dd2753729853 simplestore: shore up lookup errors
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37346
diff changeset
201 except KeyError:
dd2753729853 simplestore: shore up lookup errors
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37346
diff changeset
202 raise error.LookupError(node, self._indexpath, _('no node'))
37337
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
203
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
204 for rev, entry in self._indexbyrev.items():
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
205 if entry[b'node'] == node:
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
206 return rev
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
207
43733
8ca92bcb3083 tests: byteify a few more things in simplestorerepo.py
Matt Harbison <matt_harbison@yahoo.com>
parents: 43076
diff changeset
208 raise error.ProgrammingError(b'this should not occur')
37337
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
209
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
210 def node(self, rev):
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
211 validaterev(rev)
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
212
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
213 return self._indexbyrev[rev][b'node']
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
214
41157
c4639fdae1b9 simplestorerepo: minimal changes required to get this mostly working again
Augie Fackler <augie@google.com>
parents: 40389
diff changeset
215 def hasnode(self, node):
c4639fdae1b9 simplestorerepo: minimal changes required to get this mostly working again
Augie Fackler <augie@google.com>
parents: 40389
diff changeset
216 validatenode(node)
c4639fdae1b9 simplestorerepo: minimal changes required to get this mostly working again
Augie Fackler <augie@google.com>
parents: 40389
diff changeset
217 return node in self._indexbynode
c4639fdae1b9 simplestorerepo: minimal changes required to get this mostly working again
Augie Fackler <augie@google.com>
parents: 40389
diff changeset
218
c4639fdae1b9 simplestorerepo: minimal changes required to get this mostly working again
Augie Fackler <augie@google.com>
parents: 40389
diff changeset
219 def censorrevision(self, tr, censornode, tombstone=b''):
c4639fdae1b9 simplestorerepo: minimal changes required to get this mostly working again
Augie Fackler <augie@google.com>
parents: 40389
diff changeset
220 raise NotImplementedError('TODO')
c4639fdae1b9 simplestorerepo: minimal changes required to get this mostly working again
Augie Fackler <augie@google.com>
parents: 40389
diff changeset
221
37337
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
222 def lookup(self, node):
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
223 if isinstance(node, int):
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
224 return self.node(node)
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
225
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
226 if len(node) == 20:
37408
dd2753729853 simplestore: shore up lookup errors
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37346
diff changeset
227 self.rev(node)
dd2753729853 simplestore: shore up lookup errors
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37346
diff changeset
228 return node
37337
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
229
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
230 try:
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
231 rev = int(node)
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
232 if '%d' % rev != node:
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
233 raise ValueError
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
234
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
235 if rev < 0:
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
236 rev = len(self) + rev
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
237 if rev < 0 or rev >= len(self):
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
238 raise ValueError
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
239
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
240 return self.node(rev)
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
241 except (ValueError, OverflowError):
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
242 pass
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
243
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
244 if len(node) == 40:
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
245 try:
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
246 rawnode = bin(node)
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
247 self.rev(rawnode)
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
248 return rawnode
37408
dd2753729853 simplestore: shore up lookup errors
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37346
diff changeset
249 except TypeError:
37337
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
250 pass
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
251
37408
dd2753729853 simplestore: shore up lookup errors
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37346
diff changeset
252 raise error.LookupError(node, self._path, _('invalid lookup input'))
37337
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
253
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
254 def linkrev(self, rev):
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
255 validaterev(rev)
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
256
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
257 return self._indexbyrev[rev][b'linkrev']
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
258
39873
2ac4f3e97813 filelog: stop proxying flags() (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39867
diff changeset
259 def _flags(self, rev):
37337
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
260 validaterev(rev)
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
261
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
262 return self._indexbyrev[rev][b'flags']
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
263
39234
3682b49e0213 repository: remove candelta() from ifileindex
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39232
diff changeset
264 def _candelta(self, baserev, rev):
37337
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
265 validaterev(baserev)
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
266 validaterev(rev)
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
267
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42995
diff changeset
268 if (self._flags(baserev) & revlog.REVIDX_RAWTEXT_CHANGING_FLAGS) or (
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42995
diff changeset
269 self._flags(rev) & revlog.REVIDX_RAWTEXT_CHANGING_FLAGS
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42995
diff changeset
270 ):
37337
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
271 return False
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
272
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
273 return True
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
274
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
275 def checkhash(self, text, node, p1=None, p2=None, rev=None):
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
276 if p1 is None and p2 is None:
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
277 p1, p2 = self.parents(node)
39877
f8eb71f9e3bd storageutil: new module for storage primitives (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39876
diff changeset
278 if node != storageutil.hashrevisionsha1(text, p1, p2):
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42995
diff changeset
279 raise simplestoreerror(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42995
diff changeset
280 _("integrity check failed on %s") % self._path
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42995
diff changeset
281 )
37337
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
282
41157
c4639fdae1b9 simplestorerepo: minimal changes required to get this mostly working again
Augie Fackler <augie@google.com>
parents: 40389
diff changeset
283 def revision(self, nodeorrev, raw=False):
c4639fdae1b9 simplestorerepo: minimal changes required to get this mostly working again
Augie Fackler <augie@google.com>
parents: 40389
diff changeset
284 if isinstance(nodeorrev, int):
c4639fdae1b9 simplestorerepo: minimal changes required to get this mostly working again
Augie Fackler <augie@google.com>
parents: 40389
diff changeset
285 node = self.node(nodeorrev)
c4639fdae1b9 simplestorerepo: minimal changes required to get this mostly working again
Augie Fackler <augie@google.com>
parents: 40389
diff changeset
286 else:
c4639fdae1b9 simplestorerepo: minimal changes required to get this mostly working again
Augie Fackler <augie@google.com>
parents: 40389
diff changeset
287 node = nodeorrev
37337
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
288 validatenode(node)
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
289
47012
d55b71393907 node: replace nullid and friends with nodeconstants class
Joerg Sonnenberger <joerg@bec.de>
parents: 46780
diff changeset
290 if node == self._repo.nullid:
37337
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
291 return b''
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
292
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
293 rev = self.rev(node)
39873
2ac4f3e97813 filelog: stop proxying flags() (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39867
diff changeset
294 flags = self._flags(rev)
37337
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
295
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
296 path = b'/'.join([self._storepath, hex(node)])
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
297 rawtext = self._svfs.read(path)
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
298
42880
38c62272f462 simplestorerepo: stop using `_processflags` directly
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 42876
diff changeset
299 if raw:
42992
dff95420480f flagprocessors: make `processflagsraw` a module level function
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 42991
diff changeset
300 validatehash = flagutil.processflagsraw(self, rawtext, flags)
42880
38c62272f462 simplestorerepo: stop using `_processflags` directly
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 42876
diff changeset
301 text = rawtext
38c62272f462 simplestorerepo: stop using `_processflags` directly
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 42876
diff changeset
302 else:
42991
eb5048f8c533 flagprocessors: make `processflagsread` a module level function
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 42990
diff changeset
303 r = flagutil.processflagsread(self, rawtext, flags)
46709
3d740058b467 sidedata: move to new sidedata storage in revlogv2
Raphaël Gomès <rgomes@octobus.net>
parents: 46509
diff changeset
304 text, validatehash = r
37337
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
305 if validatehash:
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
306 self.checkhash(text, node, rev=rev)
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
307
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
308 return text
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
309
42724
2177133724ab rawdata: implement `rawdata` for `simplestore` too
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 41158
diff changeset
310 def rawdata(self, nodeorrev):
2177133724ab rawdata: implement `rawdata` for `simplestore` too
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 41158
diff changeset
311 return self.revision(raw=True)
2177133724ab rawdata: implement `rawdata` for `simplestore` too
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 41158
diff changeset
312
37337
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
313 def read(self, node):
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
314 validatenode(node)
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
315
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
316 revision = self.revision(node)
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
317
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
318 if not revision.startswith(b'\1\n'):
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
319 return revision
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
320
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
321 start = revision.index(b'\1\n', 2)
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42995
diff changeset
322 return revision[start + 2 :]
37337
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
323
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
324 def renamed(self, node):
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
325 validatenode(node)
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
326
47012
d55b71393907 node: replace nullid and friends with nodeconstants class
Joerg Sonnenberger <joerg@bec.de>
parents: 46780
diff changeset
327 if self.parents(node)[0] != self._repo.nullid:
37337
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
328 return False
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
329
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
330 fulltext = self.revision(node)
39878
3e896b51aa5d storageutil: move metadata parsing and packing from revlog (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39877
diff changeset
331 m = storageutil.parsemeta(fulltext)[0]
37337
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
332
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
333 if m and 'copy' in m:
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
334 return m['copy'], bin(m['copyrev'])
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
335
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
336 return False
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
337
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
338 def cmp(self, node, text):
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
339 validatenode(node)
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
340
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
341 t = text
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
342
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
343 if text.startswith(b'\1\n'):
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
344 t = b'\1\n\1\n' + text
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
345
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
346 p1, p2 = self.parents(node)
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
347
39877
f8eb71f9e3bd storageutil: new module for storage primitives (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39876
diff changeset
348 if storageutil.hashrevisionsha1(t, p1, p2) == node:
37337
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
349 return False
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
350
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
351 if self.iscensored(self.rev(node)):
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
352 return text != b''
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
353
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
354 if self.renamed(node):
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
355 t2 = self.read(node)
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
356 return t2 != text
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
357
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
358 return True
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
359
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
360 def size(self, rev):
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
361 validaterev(rev)
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
362
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
363 node = self._indexbyrev[rev][b'node']
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
364
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
365 if self.renamed(node):
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
366 return len(self.read(node))
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
367
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
368 if self.iscensored(rev):
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
369 return 0
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
370
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
371 return len(self.revision(node))
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
372
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
373 def iscensored(self, rev):
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
374 validaterev(rev)
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
375
40047
8e398628a3f2 repository: define and use revision flag constants
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39997
diff changeset
376 return self._flags(rev) & repository.REVISION_FLAG_CENSORED
37337
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
377
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
378 def commonancestorsheads(self, a, b):
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
379 validatenode(a)
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
380 validatenode(b)
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
381
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
382 a = self.rev(a)
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
383 b = self.rev(b)
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
384
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
385 ancestors = ancestor.commonancestorsheads(self.parentrevs, a, b)
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
386 return pycompat.maplist(self.node, ancestors)
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
387
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
388 def descendants(self, revs):
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
389 # This is a copy of revlog.descendants()
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
390 first = min(revs)
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
391 if first == nullrev:
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
392 for i in self:
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
393 yield i
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
394 return
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
395
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
396 seen = set(revs)
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
397 for i in self.revs(start=first + 1):
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
398 for x in self.parentrevs(i):
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
399 if x != nullrev and x in seen:
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
400 seen.add(i)
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
401 yield i
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
402 break
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
403
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
404 # Required by verify.
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
405 def files(self):
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
406 entries = self._svfs.listdir(self._storepath)
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
407
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
408 # Strip out undo.backup.* files created as part of transaction
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
409 # recording.
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
410 entries = [f for f in entries if not f.startswith('undo.backup.')]
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
411
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
412 return [b'/'.join((self._storepath, f)) for f in entries]
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
413
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42995
diff changeset
414 def storageinfo(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42995
diff changeset
415 self,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42995
diff changeset
416 exclusivefiles=False,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42995
diff changeset
417 sharedfiles=False,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42995
diff changeset
418 revisionscount=False,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42995
diff changeset
419 trackedsize=False,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42995
diff changeset
420 storedsize=False,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42995
diff changeset
421 ):
41157
c4639fdae1b9 simplestorerepo: minimal changes required to get this mostly working again
Augie Fackler <augie@google.com>
parents: 40389
diff changeset
422 # TODO do a real implementation of this
c4639fdae1b9 simplestorerepo: minimal changes required to get this mostly working again
Augie Fackler <augie@google.com>
parents: 40389
diff changeset
423 return {
c4639fdae1b9 simplestorerepo: minimal changes required to get this mostly working again
Augie Fackler <augie@google.com>
parents: 40389
diff changeset
424 'exclusivefiles': [],
c4639fdae1b9 simplestorerepo: minimal changes required to get this mostly working again
Augie Fackler <augie@google.com>
parents: 40389
diff changeset
425 'sharedfiles': [],
c4639fdae1b9 simplestorerepo: minimal changes required to get this mostly working again
Augie Fackler <augie@google.com>
parents: 40389
diff changeset
426 'revisionscount': len(self),
c4639fdae1b9 simplestorerepo: minimal changes required to get this mostly working again
Augie Fackler <augie@google.com>
parents: 40389
diff changeset
427 'trackedsize': 0,
c4639fdae1b9 simplestorerepo: minimal changes required to get this mostly working again
Augie Fackler <augie@google.com>
parents: 40389
diff changeset
428 'storedsize': None,
c4639fdae1b9 simplestorerepo: minimal changes required to get this mostly working again
Augie Fackler <augie@google.com>
parents: 40389
diff changeset
429 }
c4639fdae1b9 simplestorerepo: minimal changes required to get this mostly working again
Augie Fackler <augie@google.com>
parents: 40389
diff changeset
430
c4639fdae1b9 simplestorerepo: minimal changes required to get this mostly working again
Augie Fackler <augie@google.com>
parents: 40389
diff changeset
431 def verifyintegrity(self, state):
c4639fdae1b9 simplestorerepo: minimal changes required to get this mostly working again
Augie Fackler <augie@google.com>
parents: 40389
diff changeset
432 state['skipread'] = set()
c4639fdae1b9 simplestorerepo: minimal changes required to get this mostly working again
Augie Fackler <augie@google.com>
parents: 40389
diff changeset
433 for rev in self:
c4639fdae1b9 simplestorerepo: minimal changes required to get this mostly working again
Augie Fackler <augie@google.com>
parents: 40389
diff changeset
434 node = self.node(rev)
c4639fdae1b9 simplestorerepo: minimal changes required to get this mostly working again
Augie Fackler <augie@google.com>
parents: 40389
diff changeset
435 try:
c4639fdae1b9 simplestorerepo: minimal changes required to get this mostly working again
Augie Fackler <augie@google.com>
parents: 40389
diff changeset
436 self.revision(node)
c4639fdae1b9 simplestorerepo: minimal changes required to get this mostly working again
Augie Fackler <augie@google.com>
parents: 40389
diff changeset
437 except Exception as e:
c4639fdae1b9 simplestorerepo: minimal changes required to get this mostly working again
Augie Fackler <augie@google.com>
parents: 40389
diff changeset
438 yield simplefilestoreproblem(
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42995
diff changeset
439 error='unpacking %s: %s' % (node, e), node=node
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42995
diff changeset
440 )
41157
c4639fdae1b9 simplestorerepo: minimal changes required to get this mostly working again
Augie Fackler <augie@google.com>
parents: 40389
diff changeset
441 state['skipread'].add(node)
c4639fdae1b9 simplestorerepo: minimal changes required to get this mostly working again
Augie Fackler <augie@google.com>
parents: 40389
diff changeset
442
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42995
diff changeset
443 def emitrevisions(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42995
diff changeset
444 self,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42995
diff changeset
445 nodes,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42995
diff changeset
446 nodesorder=None,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42995
diff changeset
447 revisiondata=False,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42995
diff changeset
448 assumehaveparentrevisions=False,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42995
diff changeset
449 deltamode=repository.CG_DELTAMODE_STD,
46715
45f0d5297698 changegroupv4: add sidedata helpers
Raphaël Gomès <rgomes@octobus.net>
parents: 46709
diff changeset
450 sidedata_helpers=None,
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42995
diff changeset
451 ):
41157
c4639fdae1b9 simplestorerepo: minimal changes required to get this mostly working again
Augie Fackler <augie@google.com>
parents: 40389
diff changeset
452 # TODO this will probably break on some ordering options.
47012
d55b71393907 node: replace nullid and friends with nodeconstants class
Joerg Sonnenberger <joerg@bec.de>
parents: 46780
diff changeset
453 nodes = [n for n in nodes if n != self._repo.nullid]
41157
c4639fdae1b9 simplestorerepo: minimal changes required to get this mostly working again
Augie Fackler <augie@google.com>
parents: 40389
diff changeset
454 if not nodes:
c4639fdae1b9 simplestorerepo: minimal changes required to get this mostly working again
Augie Fackler <augie@google.com>
parents: 40389
diff changeset
455 return
c4639fdae1b9 simplestorerepo: minimal changes required to get this mostly working again
Augie Fackler <augie@google.com>
parents: 40389
diff changeset
456 for delta in storageutil.emitrevisions(
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42995
diff changeset
457 self,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42995
diff changeset
458 nodes,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42995
diff changeset
459 nodesorder,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42995
diff changeset
460 simplestorerevisiondelta,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42995
diff changeset
461 revisiondata=revisiondata,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42995
diff changeset
462 assumehaveparentrevisions=assumehaveparentrevisions,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42995
diff changeset
463 deltamode=deltamode,
46715
45f0d5297698 changegroupv4: add sidedata helpers
Raphaël Gomès <rgomes@octobus.net>
parents: 46709
diff changeset
464 sidedata_helpers=sidedata_helpers,
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42995
diff changeset
465 ):
41157
c4639fdae1b9 simplestorerepo: minimal changes required to get this mostly working again
Augie Fackler <augie@google.com>
parents: 40389
diff changeset
466 yield delta
c4639fdae1b9 simplestorerepo: minimal changes required to get this mostly working again
Augie Fackler <augie@google.com>
parents: 40389
diff changeset
467
37337
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
468 def add(self, text, meta, transaction, linkrev, p1, p2):
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
469 if meta or text.startswith(b'\1\n'):
39878
3e896b51aa5d storageutil: move metadata parsing and packing from revlog (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39877
diff changeset
470 text = storageutil.packmeta(meta, text)
37337
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
471
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
472 return self.addrevision(text, transaction, linkrev, p1, p2)
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
473
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42995
diff changeset
474 def addrevision(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42995
diff changeset
475 self,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42995
diff changeset
476 text,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42995
diff changeset
477 transaction,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42995
diff changeset
478 linkrev,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42995
diff changeset
479 p1,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42995
diff changeset
480 p2,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42995
diff changeset
481 node=None,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42995
diff changeset
482 flags=revlog.REVIDX_DEFAULT_FLAGS,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42995
diff changeset
483 cachedelta=None,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42995
diff changeset
484 ):
37337
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
485 validatenode(p1)
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
486 validatenode(p2)
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
487
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
488 if flags:
39877
f8eb71f9e3bd storageutil: new module for storage primitives (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39876
diff changeset
489 node = node or storageutil.hashrevisionsha1(text, p1, p2)
37337
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
490
42990
a04b2c010d03 flagprocessors: make `processflagswrite` a module level function
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 42983
diff changeset
491 rawtext, validatehash = flagutil.processflagswrite(self, text, flags)
37337
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
492
39877
f8eb71f9e3bd storageutil: new module for storage primitives (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39876
diff changeset
493 node = node or storageutil.hashrevisionsha1(text, p1, p2)
37337
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
494
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
495 if node in self._indexbynode:
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
496 return node
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
497
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
498 if validatehash:
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
499 self.checkhash(rawtext, node, p1=p1, p2=p2)
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
500
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42995
diff changeset
501 return self._addrawrevision(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42995
diff changeset
502 node, rawtext, transaction, linkrev, p1, p2, flags
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42995
diff changeset
503 )
37436
9d4f09bfe3ec simplestore: correctly implement flag processors
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37424
diff changeset
504
9d4f09bfe3ec simplestore: correctly implement flag processors
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37424
diff changeset
505 def _addrawrevision(self, node, rawtext, transaction, link, p1, p2, flags):
9d4f09bfe3ec simplestore: correctly implement flag processors
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37424
diff changeset
506 transaction.addbackup(self._indexpath)
9d4f09bfe3ec simplestore: correctly implement flag processors
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37424
diff changeset
507
37337
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
508 path = b'/'.join([self._storepath, hex(node)])
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
509
37436
9d4f09bfe3ec simplestore: correctly implement flag processors
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37424
diff changeset
510 self._svfs.write(path, rawtext)
37337
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
511
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42995
diff changeset
512 self._indexdata.append(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42995
diff changeset
513 {
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42995
diff changeset
514 b'node': node,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42995
diff changeset
515 b'p1': p1,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42995
diff changeset
516 b'p2': p2,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42995
diff changeset
517 b'linkrev': link,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42995
diff changeset
518 b'flags': flags,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42995
diff changeset
519 }
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42995
diff changeset
520 )
37337
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
521
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
522 self._reflectindexupdate()
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
523
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
524 return node
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
525
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
526 def _reflectindexupdate(self):
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
527 self._refreshindex()
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42995
diff changeset
528 self._svfs.write(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42995
diff changeset
529 self._indexpath, ''.join(cborutil.streamencode(self._indexdata))
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42995
diff changeset
530 )
37337
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
531
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42995
diff changeset
532 def addgroup(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42995
diff changeset
533 self,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42995
diff changeset
534 deltas,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42995
diff changeset
535 linkmapper,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42995
diff changeset
536 transaction,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42995
diff changeset
537 addrevisioncb=None,
45788
a5206e71c536 revlog: extend addgroup() with callback for duplicates
Joerg Sonnenberger <joerg@bec.de>
parents: 44452
diff changeset
538 duplicaterevisioncb=None,
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42995
diff changeset
539 maybemissingparents=False,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42995
diff changeset
540 ):
40389
1b183edbb68e repository: teach addgroup() to receive data with missing parents
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40047
diff changeset
541 if maybemissingparents:
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42995
diff changeset
542 raise error.Abort(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42995
diff changeset
543 _('simple store does not support missing parents ' 'write mode')
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42995
diff changeset
544 )
40389
1b183edbb68e repository: teach addgroup() to receive data with missing parents
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40047
diff changeset
545
45788
a5206e71c536 revlog: extend addgroup() with callback for duplicates
Joerg Sonnenberger <joerg@bec.de>
parents: 44452
diff changeset
546 empty = True
37337
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
547
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
548 transaction.addbackup(self._indexpath)
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
549
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
550 for node, p1, p2, linknode, deltabase, delta, flags in deltas:
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
551 linkrev = linkmapper(linknode)
37436
9d4f09bfe3ec simplestore: correctly implement flag processors
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37424
diff changeset
552 flags = flags or revlog.REVIDX_DEFAULT_FLAGS
37337
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
553
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
554 if node in self._indexbynode:
45788
a5206e71c536 revlog: extend addgroup() with callback for duplicates
Joerg Sonnenberger <joerg@bec.de>
parents: 44452
diff changeset
555 if duplicaterevisioncb:
46509
7a93b7b3dc2d revlog: change addgroup callbacks to take revision numbers
Joerg Sonnenberger <joerg@bec.de>
parents: 45788
diff changeset
556 duplicaterevisioncb(self, self.rev(node))
45788
a5206e71c536 revlog: extend addgroup() with callback for duplicates
Joerg Sonnenberger <joerg@bec.de>
parents: 44452
diff changeset
557 empty = False
37337
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
558 continue
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
559
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
560 # Need to resolve the fulltext from the delta base.
47012
d55b71393907 node: replace nullid and friends with nodeconstants class
Joerg Sonnenberger <joerg@bec.de>
parents: 46780
diff changeset
561 if deltabase == self._repo.nullid:
37337
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
562 text = mdiff.patch(b'', delta)
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
563 else:
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
564 text = mdiff.patch(self.revision(deltabase), delta)
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
565
46509
7a93b7b3dc2d revlog: change addgroup callbacks to take revision numbers
Joerg Sonnenberger <joerg@bec.de>
parents: 45788
diff changeset
566 rev = self._addrawrevision(
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42995
diff changeset
567 node, text, transaction, linkrev, p1, p2, flags
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42995
diff changeset
568 )
37337
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
569
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
570 if addrevisioncb:
46509
7a93b7b3dc2d revlog: change addgroup callbacks to take revision numbers
Joerg Sonnenberger <joerg@bec.de>
parents: 45788
diff changeset
571 addrevisioncb(self, rev)
45788
a5206e71c536 revlog: extend addgroup() with callback for duplicates
Joerg Sonnenberger <joerg@bec.de>
parents: 44452
diff changeset
572 empty = False
a5206e71c536 revlog: extend addgroup() with callback for duplicates
Joerg Sonnenberger <joerg@bec.de>
parents: 44452
diff changeset
573 return not empty
37337
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
574
41157
c4639fdae1b9 simplestorerepo: minimal changes required to get this mostly working again
Augie Fackler <augie@google.com>
parents: 40389
diff changeset
575 def _headrevs(self):
c4639fdae1b9 simplestorerepo: minimal changes required to get this mostly working again
Augie Fackler <augie@google.com>
parents: 40389
diff changeset
576 # Assume all revisions are heads by default.
c4639fdae1b9 simplestorerepo: minimal changes required to get this mostly working again
Augie Fackler <augie@google.com>
parents: 40389
diff changeset
577 revishead = {rev: True for rev in self._indexbyrev}
c4639fdae1b9 simplestorerepo: minimal changes required to get this mostly working again
Augie Fackler <augie@google.com>
parents: 40389
diff changeset
578
c4639fdae1b9 simplestorerepo: minimal changes required to get this mostly working again
Augie Fackler <augie@google.com>
parents: 40389
diff changeset
579 for rev, entry in self._indexbyrev.items():
c4639fdae1b9 simplestorerepo: minimal changes required to get this mostly working again
Augie Fackler <augie@google.com>
parents: 40389
diff changeset
580 # Unset head flag for all seen parents.
c4639fdae1b9 simplestorerepo: minimal changes required to get this mostly working again
Augie Fackler <augie@google.com>
parents: 40389
diff changeset
581 revishead[self.rev(entry[b'p1'])] = False
c4639fdae1b9 simplestorerepo: minimal changes required to get this mostly working again
Augie Fackler <augie@google.com>
parents: 40389
diff changeset
582 revishead[self.rev(entry[b'p2'])] = False
c4639fdae1b9 simplestorerepo: minimal changes required to get this mostly working again
Augie Fackler <augie@google.com>
parents: 40389
diff changeset
583
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42995
diff changeset
584 return [rev for rev, ishead in sorted(revishead.items()) if ishead]
37337
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
585
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
586 def heads(self, start=None, stop=None):
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
587 # This is copied from revlog.py.
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
588 if start is None and stop is None:
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
589 if not len(self):
47012
d55b71393907 node: replace nullid and friends with nodeconstants class
Joerg Sonnenberger <joerg@bec.de>
parents: 46780
diff changeset
590 return [self._repo.nullid]
41157
c4639fdae1b9 simplestorerepo: minimal changes required to get this mostly working again
Augie Fackler <augie@google.com>
parents: 40389
diff changeset
591 return [self.node(r) for r in self._headrevs()]
37337
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
592
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
593 if start is None:
47012
d55b71393907 node: replace nullid and friends with nodeconstants class
Joerg Sonnenberger <joerg@bec.de>
parents: 46780
diff changeset
594 start = self._repo.nullid
37337
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
595 if stop is None:
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
596 stop = []
44452
9d2b2df2c2ba cleanup: run pyupgrade on our source tree to clean up varying things
Augie Fackler <augie@google.com>
parents: 43733
diff changeset
597 stoprevs = {self.rev(n) for n in stop}
37337
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
598 startrev = self.rev(start)
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
599 reachable = {startrev}
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
600 heads = {startrev}
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
601
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
602 parentrevs = self.parentrevs
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
603 for r in self.revs(start=startrev + 1):
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
604 for p in parentrevs(r):
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
605 if p in reachable:
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
606 if r not in stoprevs:
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
607 reachable.add(r)
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
608 heads.add(r)
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
609 if p in heads and p not in stoprevs:
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
610 heads.remove(p)
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
611
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
612 return [self.node(r) for r in heads]
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
613
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
614 def children(self, node):
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
615 validatenode(node)
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
616
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
617 # This is a copy of revlog.children().
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
618 c = []
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
619 p = self.rev(node)
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
620 for r in self.revs(start=p + 1):
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
621 prevs = [pr for pr in self.parentrevs(r) if pr != nullrev]
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
622 if prevs:
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
623 for pr in prevs:
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
624 if pr == p:
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
625 c.append(self.node(r))
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
626 elif p == nullrev:
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
627 c.append(self.node(r))
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
628 return c
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
629
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
630 def getstrippoint(self, minlink):
41157
c4639fdae1b9 simplestorerepo: minimal changes required to get this mostly working again
Augie Fackler <augie@google.com>
parents: 40389
diff changeset
631 return storageutil.resolvestripinfo(
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42995
diff changeset
632 minlink,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42995
diff changeset
633 len(self) - 1,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42995
diff changeset
634 self._headrevs(),
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42995
diff changeset
635 self.linkrev,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42995
diff changeset
636 self.parentrevs,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42995
diff changeset
637 )
37337
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
638
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
639 def strip(self, minlink, transaction):
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
640 if not len(self):
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
641 return
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
642
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
643 rev, _ignored = self.getstrippoint(minlink)
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
644 if rev == len(self):
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
645 return
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
646
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
647 # Purge index data starting at the requested revision.
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
648 self._indexdata[rev:] = []
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
649 self._reflectindexupdate()
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
650
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42995
diff changeset
651
37415
c2c8962a9465 simplestore: use a custom store for the simple store repo
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37408
diff changeset
652 def issimplestorefile(f, kind, st):
c2c8962a9465 simplestore: use a custom store for the simple store repo
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37408
diff changeset
653 if kind != stat.S_IFREG:
c2c8962a9465 simplestore: use a custom store for the simple store repo
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37408
diff changeset
654 return False
c2c8962a9465 simplestore: use a custom store for the simple store repo
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37408
diff changeset
655
c2c8962a9465 simplestore: use a custom store for the simple store repo
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37408
diff changeset
656 if store.isrevlog(f, kind, st):
c2c8962a9465 simplestore: use a custom store for the simple store repo
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37408
diff changeset
657 return False
c2c8962a9465 simplestore: use a custom store for the simple store repo
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37408
diff changeset
658
c2c8962a9465 simplestore: use a custom store for the simple store repo
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37408
diff changeset
659 # Ignore transaction undo files.
c2c8962a9465 simplestore: use a custom store for the simple store repo
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37408
diff changeset
660 if f.startswith('undo.'):
c2c8962a9465 simplestore: use a custom store for the simple store repo
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37408
diff changeset
661 return False
c2c8962a9465 simplestore: use a custom store for the simple store repo
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37408
diff changeset
662
c2c8962a9465 simplestore: use a custom store for the simple store repo
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37408
diff changeset
663 # Otherwise assume it belongs to the simple store.
c2c8962a9465 simplestore: use a custom store for the simple store repo
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37408
diff changeset
664 return True
c2c8962a9465 simplestore: use a custom store for the simple store repo
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37408
diff changeset
665
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42995
diff changeset
666
37415
c2c8962a9465 simplestore: use a custom store for the simple store repo
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37408
diff changeset
667 class simplestore(store.encodedstore):
47877
2174f54aab18 store: return just one filename in walk functions
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents: 47012
diff changeset
668 def datafiles(self, undecodable=None):
37415
c2c8962a9465 simplestore: use a custom store for the simple store repo
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37408
diff changeset
669 for x in super(simplestore, self).datafiles():
c2c8962a9465 simplestore: use a custom store for the simple store repo
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37408
diff changeset
670 yield x
c2c8962a9465 simplestore: use a custom store for the simple store repo
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37408
diff changeset
671
c2c8962a9465 simplestore: use a custom store for the simple store repo
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37408
diff changeset
672 # Supplement with non-revlog files.
c2c8962a9465 simplestore: use a custom store for the simple store repo
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37408
diff changeset
673 extrafiles = self._walk('data', True, filefilter=issimplestorefile)
c2c8962a9465 simplestore: use a custom store for the simple store repo
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37408
diff changeset
674
47877
2174f54aab18 store: return just one filename in walk functions
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents: 47012
diff changeset
675 for f1, size in extrafiles:
37415
c2c8962a9465 simplestore: use a custom store for the simple store repo
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37408
diff changeset
676 try:
47877
2174f54aab18 store: return just one filename in walk functions
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents: 47012
diff changeset
677 f2 = store.decodefilename(f1)
37415
c2c8962a9465 simplestore: use a custom store for the simple store repo
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37408
diff changeset
678 except KeyError:
47877
2174f54aab18 store: return just one filename in walk functions
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents: 47012
diff changeset
679 if undecodable is None:
2174f54aab18 store: return just one filename in walk functions
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents: 47012
diff changeset
680 raise error.StorageError(b'undecodable revlog name %s' % f1)
2174f54aab18 store: return just one filename in walk functions
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents: 47012
diff changeset
681 else:
2174f54aab18 store: return just one filename in walk functions
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents: 47012
diff changeset
682 undecodable.append(f1)
2174f54aab18 store: return just one filename in walk functions
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents: 47012
diff changeset
683 continue
37415
c2c8962a9465 simplestore: use a custom store for the simple store repo
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37408
diff changeset
684
47877
2174f54aab18 store: return just one filename in walk functions
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents: 47012
diff changeset
685 yield f2, size
37415
c2c8962a9465 simplestore: use a custom store for the simple store repo
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37408
diff changeset
686
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42995
diff changeset
687
37337
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
688 def reposetup(ui, repo):
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
689 if not repo.local():
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
690 return
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
691
37346
45a4799174a1 tests: disallow using simple store repo with bundlerepo
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37341
diff changeset
692 if isinstance(repo, bundlerepo.bundlerepository):
45a4799174a1 tests: disallow using simple store repo with bundlerepo
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37341
diff changeset
693 raise error.Abort(_('cannot use simple store with bundlerepo'))
45a4799174a1 tests: disallow using simple store repo with bundlerepo
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37341
diff changeset
694
37337
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
695 class simplestorerepo(repo.__class__):
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
696 def file(self, f):
46780
6266d19556ad node: introduce nodeconstants class
Joerg Sonnenberger <joerg@bec.de>
parents: 46715
diff changeset
697 return filestorage(repo, self.svfs, f)
37337
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
698
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
699 repo.__class__ = simplestorerepo
37415
c2c8962a9465 simplestore: use a custom store for the simple store repo
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37408
diff changeset
700
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42995
diff changeset
701
37415
c2c8962a9465 simplestore: use a custom store for the simple store repo
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37408
diff changeset
702 def featuresetup(ui, supported):
c2c8962a9465 simplestore: use a custom store for the simple store repo
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37408
diff changeset
703 supported.add(REQUIREMENT)
c2c8962a9465 simplestore: use a custom store for the simple store repo
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37408
diff changeset
704
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42995
diff changeset
705
41157
c4639fdae1b9 simplestorerepo: minimal changes required to get this mostly working again
Augie Fackler <augie@google.com>
parents: 40389
diff changeset
706 def newreporequirements(orig, ui, createopts):
37415
c2c8962a9465 simplestore: use a custom store for the simple store repo
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37408
diff changeset
707 """Modifies default requirements for new repos to use the simple store."""
41157
c4639fdae1b9 simplestorerepo: minimal changes required to get this mostly working again
Augie Fackler <augie@google.com>
parents: 40389
diff changeset
708 requirements = orig(ui, createopts)
37415
c2c8962a9465 simplestore: use a custom store for the simple store repo
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37408
diff changeset
709
c2c8962a9465 simplestore: use a custom store for the simple store repo
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37408
diff changeset
710 # These requirements are only used to affect creation of the store
c2c8962a9465 simplestore: use a custom store for the simple store repo
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37408
diff changeset
711 # object. We have our own store. So we can remove them.
c2c8962a9465 simplestore: use a custom store for the simple store repo
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37408
diff changeset
712 # TODO do this once we feel like taking the test hit.
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42995
diff changeset
713 # if 'fncache' in requirements:
37415
c2c8962a9465 simplestore: use a custom store for the simple store repo
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37408
diff changeset
714 # requirements.remove('fncache')
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42995
diff changeset
715 # if 'dotencode' in requirements:
37415
c2c8962a9465 simplestore: use a custom store for the simple store repo
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37408
diff changeset
716 # requirements.remove('dotencode')
c2c8962a9465 simplestore: use a custom store for the simple store repo
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37408
diff changeset
717
c2c8962a9465 simplestore: use a custom store for the simple store repo
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37408
diff changeset
718 requirements.add(REQUIREMENT)
c2c8962a9465 simplestore: use a custom store for the simple store repo
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37408
diff changeset
719
c2c8962a9465 simplestore: use a custom store for the simple store repo
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37408
diff changeset
720 return requirements
c2c8962a9465 simplestore: use a custom store for the simple store repo
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37408
diff changeset
721
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42995
diff changeset
722
37415
c2c8962a9465 simplestore: use a custom store for the simple store repo
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37408
diff changeset
723 def makestore(orig, requirements, path, vfstype):
c2c8962a9465 simplestore: use a custom store for the simple store repo
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37408
diff changeset
724 if REQUIREMENT not in requirements:
c2c8962a9465 simplestore: use a custom store for the simple store repo
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37408
diff changeset
725 return orig(requirements, path, vfstype)
c2c8962a9465 simplestore: use a custom store for the simple store repo
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37408
diff changeset
726
c2c8962a9465 simplestore: use a custom store for the simple store repo
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37408
diff changeset
727 return simplestore(path, vfstype)
c2c8962a9465 simplestore: use a custom store for the simple store repo
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37408
diff changeset
728
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42995
diff changeset
729
37417
76d2115cb817 verify: allow suppressing warnings about extra files
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37415
diff changeset
730 def verifierinit(orig, self, *args, **kwargs):
76d2115cb817 verify: allow suppressing warnings about extra files
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37415
diff changeset
731 orig(self, *args, **kwargs)
76d2115cb817 verify: allow suppressing warnings about extra files
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37415
diff changeset
732
76d2115cb817 verify: allow suppressing warnings about extra files
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37415
diff changeset
733 # We don't care that files in the store don't align with what is
76d2115cb817 verify: allow suppressing warnings about extra files
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37415
diff changeset
734 # advertised. So suppress these warnings.
76d2115cb817 verify: allow suppressing warnings about extra files
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37415
diff changeset
735 self.warnorphanstorefiles = False
76d2115cb817 verify: allow suppressing warnings about extra files
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37415
diff changeset
736
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42995
diff changeset
737
37415
c2c8962a9465 simplestore: use a custom store for the simple store repo
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37408
diff changeset
738 def extsetup(ui):
c2c8962a9465 simplestore: use a custom store for the simple store repo
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37408
diff changeset
739 localrepo.featuresetupfuncs.add(featuresetup)
c2c8962a9465 simplestore: use a custom store for the simple store repo
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37408
diff changeset
740
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42995
diff changeset
741 extensions.wrapfunction(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42995
diff changeset
742 localrepo, 'newreporequirements', newreporequirements
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42995
diff changeset
743 )
41157
c4639fdae1b9 simplestorerepo: minimal changes required to get this mostly working again
Augie Fackler <augie@google.com>
parents: 40389
diff changeset
744 extensions.wrapfunction(localrepo, 'makestore', makestore)
37417
76d2115cb817 verify: allow suppressing warnings about extra files
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37415
diff changeset
745 extensions.wrapfunction(verify.verifier, '__init__', verifierinit)