annotate tests/simplestorerepo.py @ 42415:c767e655ffda

narrow: use narrow_widen wireproto command to widen in case of ellipses Few releases ago, we introduce narrow_widen wireproto command to be used to widen narrow repositories. Before this patch, that was used in non-ellipses cases only. In ellipses cases, we still do exchange.pull() which can pull more data than required. After this patch, the client will first check whether server supports doing ellipses widening using wireproto command or not by checking server's wireproto capability. If the server is upto date and support latest ellipses capability, we call the wireproto command. Otherwise we fallback to exchange.pull() like before. The compat code make sure that things works even if one of the client or server is old. The initial version of this patch does not had this compat code. It's added to help Google release things smoothly internally. I plan to drop the compat code before the upcoming major release. Due to change to wireproto command, the code looks a bit dirty, next patches will clean that up. Differential Revision: https://phab.mercurial-scm.org/D6436
author Pulkit Goyal <7895pulkit@gmail.com>
date Wed, 22 May 2019 02:59:48 +0530
parents ad51e6117095
children 2177133724ab
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 nullid,
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
22 nullrev,
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
23 )
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
24 from mercurial.thirdparty import (
39231
b41d023a412a repository: establish API for emitting revision deltas
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38547
diff changeset
25 attr,
37337
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
26 )
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
27 from mercurial import (
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
28 ancestor,
37346
45a4799174a1 tests: disallow using simple store repo with bundlerepo
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37341
diff changeset
29 bundlerepo,
37337
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
30 error,
37415
c2c8962a9465 simplestore: use a custom store for the simple store repo
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37408
diff changeset
31 extensions,
c2c8962a9465 simplestore: use a custom store for the simple store repo
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37408
diff changeset
32 localrepo,
37337
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
33 mdiff,
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
34 pycompat,
37441
a3202fa83aff filelog: declare that filelog implements a storage interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37436
diff changeset
35 repository,
37337
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
36 revlog,
37415
c2c8962a9465 simplestore: use a custom store for the simple store repo
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37408
diff changeset
37 store,
37417
76d2115cb817 verify: allow suppressing warnings about extra files
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37415
diff changeset
38 verify,
37337
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
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,
38547
404eab7ff33f tests: use interfaceutil in simplestorerepo
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37442
diff changeset
42 interfaceutil,
39877
f8eb71f9e3bd storageutil: new module for storage primitives (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39876
diff changeset
43 storageutil,
38547
404eab7ff33f tests: use interfaceutil in simplestorerepo
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37442
diff changeset
44 )
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.
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
50 testedwith = 'ships-with-hg-core'
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
51
37415
c2c8962a9465 simplestore: use a custom store for the simple store repo
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37408
diff changeset
52 REQUIREMENT = 'testonly-simplestore'
c2c8962a9465 simplestore: use a custom store for the simple store repo
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37408
diff changeset
53
37337
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
54 def validatenode(node):
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
55 if isinstance(node, int):
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
56 raise ValueError('expected node; got int')
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
57
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
58 if len(node) != 20:
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
59 raise ValueError('expected 20 byte node')
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
60
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
61 def validaterev(rev):
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
62 if not isinstance(rev, int):
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
63 raise ValueError('expected int')
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
64
39777
b63dee7bd0d9 global: replace most uses of RevlogError with StorageError (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39773
diff changeset
65 class simplestoreerror(error.StorageError):
b63dee7bd0d9 global: replace most uses of RevlogError with StorageError (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39773
diff changeset
66 pass
b63dee7bd0d9 global: replace most uses of RevlogError with StorageError (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39773
diff changeset
67
39231
b41d023a412a repository: establish API for emitting revision deltas
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38547
diff changeset
68 @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
69 @attr.s(slots=True)
39231
b41d023a412a repository: establish API for emitting revision deltas
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38547
diff changeset
70 class simplestorerevisiondelta(object):
b41d023a412a repository: establish API for emitting revision deltas
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38547
diff changeset
71 node = attr.ib()
b41d023a412a repository: establish API for emitting revision deltas
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38547
diff changeset
72 p1node = attr.ib()
b41d023a412a repository: establish API for emitting revision deltas
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38547
diff changeset
73 p2node = attr.ib()
b41d023a412a repository: establish API for emitting revision deltas
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38547
diff changeset
74 basenode = attr.ib()
b41d023a412a repository: establish API for emitting revision deltas
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38547
diff changeset
75 flags = attr.ib()
b41d023a412a repository: establish API for emitting revision deltas
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38547
diff changeset
76 baserevisionsize = attr.ib()
b41d023a412a repository: establish API for emitting revision deltas
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38547
diff changeset
77 revision = attr.ib()
b41d023a412a repository: establish API for emitting revision deltas
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38547
diff changeset
78 delta = attr.ib()
41157
c4639fdae1b9 simplestorerepo: minimal changes required to get this mostly working again
Augie Fackler <augie@google.com>
parents: 40389
diff changeset
79 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
80
c4639fdae1b9 simplestorerepo: minimal changes required to get this mostly working again
Augie Fackler <augie@google.com>
parents: 40389
diff changeset
81 @interfaceutil.implementer(repository.iverifyproblem)
c4639fdae1b9 simplestorerepo: minimal changes required to get this mostly working again
Augie Fackler <augie@google.com>
parents: 40389
diff changeset
82 @attr.s(frozen=True)
c4639fdae1b9 simplestorerepo: minimal changes required to get this mostly working again
Augie Fackler <augie@google.com>
parents: 40389
diff changeset
83 class simplefilestoreproblem(object):
c4639fdae1b9 simplestorerepo: minimal changes required to get this mostly working again
Augie Fackler <augie@google.com>
parents: 40389
diff changeset
84 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
85 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
86 node = attr.ib(default=None)
39231
b41d023a412a repository: establish API for emitting revision deltas
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38547
diff changeset
87
38547
404eab7ff33f tests: use interfaceutil in simplestorerepo
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37442
diff changeset
88 @interfaceutil.implementer(repository.ifilestorage)
37337
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
89 class filestorage(object):
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
90 """Implements storage for a tracked path.
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
91
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
92 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
93 path.
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
94
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
95 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
96
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
97 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
98 """
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
99
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
100 def __init__(self, svfs, path):
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
101 self._svfs = svfs
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
102 self._path = path
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
103
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
104 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
105 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
106
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
107 indexdata = self._svfs.tryread(self._indexpath)
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
108 if indexdata:
41158
ad51e6117095 simplestorerepo: migrate to in-hg CBOR code
Augie Fackler <augie@google.com>
parents: 41157
diff changeset
109 indexdata = cborutil.decodeall(indexdata)
37337
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
110
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
111 self._indexdata = indexdata or []
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
112 self._indexbynode = {}
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
113 self._indexbyrev = {}
39860
d9b3cc3d5d07 filelog: drop index attribute (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39844
diff changeset
114 self._index = []
37337
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
115 self._refreshindex()
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 def _refreshindex(self):
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
118 self._indexbynode.clear()
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
119 self._indexbyrev.clear()
39860
d9b3cc3d5d07 filelog: drop index attribute (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39844
diff changeset
120 self._index = []
37337
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
121
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
122 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
123 self._indexbynode[entry[b'node']] = entry
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
124 self._indexbyrev[i] = entry
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
125
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
126 self._indexbynode[nullid] = {
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
127 b'node': nullid,
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
128 b'p1': nullid,
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
129 b'p2': nullid,
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
130 b'linkrev': nullrev,
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
131 b'flags': 0,
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
132 }
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 self._indexbyrev[nullrev] = {
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
135 b'node': nullid,
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
136 b'p1': nullid,
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
137 b'p2': nullid,
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
138 b'linkrev': nullrev,
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
139 b'flags': 0,
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
140 }
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
141
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
142 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
143 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
144
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
145 # start, length, rawsize, chainbase, linkrev, p1, p2, node
39860
d9b3cc3d5d07 filelog: drop index attribute (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39844
diff changeset
146 self._index.append((0, 0, 0, -1, entry[b'linkrev'], p1rev, p2rev,
d9b3cc3d5d07 filelog: drop index attribute (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39844
diff changeset
147 entry[b'node']))
37337
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
148
39860
d9b3cc3d5d07 filelog: drop index attribute (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39844
diff changeset
149 self._index.append((0, 0, 0, -1, -1, -1, -1, nullid))
37337
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
150
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
151 def __len__(self):
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
152 return len(self._indexdata)
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 def __iter__(self):
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
155 return iter(range(len(self)))
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 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
158 step = 1
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
159 if stop is not None:
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
160 if start > stop:
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
161 step = -1
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
162
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
163 stop += step
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
164 else:
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
165 stop = len(self)
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 return range(start, stop, step)
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
168
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
169 def parents(self, node):
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
170 validatenode(node)
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
171
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
172 if node not in self._indexbynode:
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
173 raise KeyError('unknown node')
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
174
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
175 entry = self._indexbynode[node]
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
176
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
177 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
178
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
179 def parentrevs(self, rev):
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
180 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
181 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
182
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
183 def rev(self, node):
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
184 validatenode(node)
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
185
37408
dd2753729853 simplestore: shore up lookup errors
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37346
diff changeset
186 try:
dd2753729853 simplestore: shore up lookup errors
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37346
diff changeset
187 self._indexbynode[node]
dd2753729853 simplestore: shore up lookup errors
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37346
diff changeset
188 except KeyError:
dd2753729853 simplestore: shore up lookup errors
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37346
diff changeset
189 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
190
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
191 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
192 if entry[b'node'] == node:
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
193 return rev
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
194
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
195 raise error.ProgrammingError('this should not occur')
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
196
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
197 def node(self, rev):
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
198 validaterev(rev)
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
199
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
200 return self._indexbyrev[rev][b'node']
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
201
41157
c4639fdae1b9 simplestorerepo: minimal changes required to get this mostly working again
Augie Fackler <augie@google.com>
parents: 40389
diff changeset
202 def hasnode(self, node):
c4639fdae1b9 simplestorerepo: minimal changes required to get this mostly working again
Augie Fackler <augie@google.com>
parents: 40389
diff changeset
203 validatenode(node)
c4639fdae1b9 simplestorerepo: minimal changes required to get this mostly working again
Augie Fackler <augie@google.com>
parents: 40389
diff changeset
204 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
205
c4639fdae1b9 simplestorerepo: minimal changes required to get this mostly working again
Augie Fackler <augie@google.com>
parents: 40389
diff changeset
206 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
207 raise NotImplementedError('TODO')
c4639fdae1b9 simplestorerepo: minimal changes required to get this mostly working again
Augie Fackler <augie@google.com>
parents: 40389
diff changeset
208
37337
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
209 def lookup(self, node):
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
210 if isinstance(node, int):
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
211 return self.node(node)
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 if len(node) == 20:
37408
dd2753729853 simplestore: shore up lookup errors
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37346
diff changeset
214 self.rev(node)
dd2753729853 simplestore: shore up lookup errors
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37346
diff changeset
215 return node
37337
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
216
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
217 try:
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
218 rev = int(node)
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
219 if '%d' % rev != node:
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
220 raise ValueError
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
221
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
222 if rev < 0:
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
223 rev = len(self) + rev
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
224 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
225 raise ValueError
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
226
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
227 return self.node(rev)
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
228 except (ValueError, OverflowError):
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
229 pass
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
230
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
231 if len(node) == 40:
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
232 try:
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
233 rawnode = bin(node)
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
234 self.rev(rawnode)
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
235 return rawnode
37408
dd2753729853 simplestore: shore up lookup errors
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37346
diff changeset
236 except TypeError:
37337
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
237 pass
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
238
37408
dd2753729853 simplestore: shore up lookup errors
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37346
diff changeset
239 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
240
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
241 def linkrev(self, rev):
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
242 validaterev(rev)
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 return self._indexbyrev[rev][b'linkrev']
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
245
39873
2ac4f3e97813 filelog: stop proxying flags() (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39867
diff changeset
246 def _flags(self, rev):
37337
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
247 validaterev(rev)
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
248
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
249 return self._indexbyrev[rev][b'flags']
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
250
39234
3682b49e0213 repository: remove candelta() from ifileindex
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39232
diff changeset
251 def _candelta(self, baserev, rev):
37337
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
252 validaterev(baserev)
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
253 validaterev(rev)
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
254
39873
2ac4f3e97813 filelog: stop proxying flags() (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39867
diff changeset
255 if ((self._flags(baserev) & revlog.REVIDX_RAWTEXT_CHANGING_FLAGS)
2ac4f3e97813 filelog: stop proxying flags() (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39867
diff changeset
256 or (self._flags(rev) & revlog.REVIDX_RAWTEXT_CHANGING_FLAGS)):
37337
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
257 return False
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
258
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
259 return True
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
260
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
261 def _processflags(self, text, flags, operation, raw=False):
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
262 if flags == 0:
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
263 return text, True
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
264
37436
9d4f09bfe3ec simplestore: correctly implement flag processors
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37424
diff changeset
265 if flags & ~revlog.REVIDX_KNOWN_FLAGS:
39777
b63dee7bd0d9 global: replace most uses of RevlogError with StorageError (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39773
diff changeset
266 raise simplestoreerror(_("incompatible revision flag '%#x'") %
b63dee7bd0d9 global: replace most uses of RevlogError with StorageError (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39773
diff changeset
267 (flags & ~revlog.REVIDX_KNOWN_FLAGS))
37436
9d4f09bfe3ec simplestore: correctly implement flag processors
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37424
diff changeset
268
37337
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
269 validatehash = True
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
270 # Depending on the operation (read or write), the order might be
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
271 # reversed due to non-commutative transforms.
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
272 orderedflags = revlog.REVIDX_FLAGS_ORDER
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
273 if operation == 'write':
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
274 orderedflags = reversed(orderedflags)
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
275
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
276 for flag in orderedflags:
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
277 # If a flagprocessor has been registered for a known flag, apply the
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
278 # related operation transform and update result tuple.
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
279 if flag & flags:
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
280 vhash = True
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
281
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
282 if flag not in revlog._flagprocessors:
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
283 message = _("missing processor for flag '%#x'") % (flag)
39777
b63dee7bd0d9 global: replace most uses of RevlogError with StorageError (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39773
diff changeset
284 raise simplestoreerror(message)
37337
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
285
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
286 processor = revlog._flagprocessors[flag]
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
287 if processor is not None:
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
288 readtransform, writetransform, rawtransform = processor
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
289
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
290 if raw:
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
291 vhash = rawtransform(self, text)
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
292 elif operation == 'read':
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
293 text, vhash = readtransform(self, text)
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
294 else: # write operation
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
295 text, vhash = writetransform(self, text)
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
296 validatehash = validatehash and vhash
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
297
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
298 return text, validatehash
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
299
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
300 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
301 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
302 p1, p2 = self.parents(node)
39877
f8eb71f9e3bd storageutil: new module for storage primitives (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39876
diff changeset
303 if node != storageutil.hashrevisionsha1(text, p1, p2):
39777
b63dee7bd0d9 global: replace most uses of RevlogError with StorageError (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39773
diff changeset
304 raise simplestoreerror(_("integrity check failed on %s") %
37337
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
305 self._path)
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
306
41157
c4639fdae1b9 simplestorerepo: minimal changes required to get this mostly working again
Augie Fackler <augie@google.com>
parents: 40389
diff changeset
307 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
308 if isinstance(nodeorrev, int):
c4639fdae1b9 simplestorerepo: minimal changes required to get this mostly working again
Augie Fackler <augie@google.com>
parents: 40389
diff changeset
309 node = self.node(nodeorrev)
c4639fdae1b9 simplestorerepo: minimal changes required to get this mostly working again
Augie Fackler <augie@google.com>
parents: 40389
diff changeset
310 else:
c4639fdae1b9 simplestorerepo: minimal changes required to get this mostly working again
Augie Fackler <augie@google.com>
parents: 40389
diff changeset
311 node = nodeorrev
37337
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
312 validatenode(node)
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
313
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
314 if node == nullid:
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
315 return b''
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
316
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
317 rev = self.rev(node)
39873
2ac4f3e97813 filelog: stop proxying flags() (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39867
diff changeset
318 flags = self._flags(rev)
37337
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
319
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
320 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
321 rawtext = self._svfs.read(path)
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
322
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
323 text, validatehash = self._processflags(rawtext, flags, 'read', raw=raw)
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
324 if validatehash:
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
325 self.checkhash(text, node, rev=rev)
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
326
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
327 return text
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
328
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
329 def read(self, node):
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
330 validatenode(node)
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
331
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
332 revision = self.revision(node)
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
333
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
334 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
335 return revision
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
336
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
337 start = revision.index(b'\1\n', 2)
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
338 return revision[start + 2:]
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
339
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
340 def renamed(self, node):
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
341 validatenode(node)
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 self.parents(node)[0] != nullid:
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
344 return False
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 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
347 m = storageutil.parsemeta(fulltext)[0]
37337
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
348
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
349 if m and 'copy' in m:
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
350 return m['copy'], bin(m['copyrev'])
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
351
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
352 return False
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 def cmp(self, node, text):
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
355 validatenode(node)
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
356
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
357 t = text
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
358
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
359 if text.startswith(b'\1\n'):
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
360 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
361
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
362 p1, p2 = self.parents(node)
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
363
39877
f8eb71f9e3bd storageutil: new module for storage primitives (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39876
diff changeset
364 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
365 return False
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
366
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
367 if self.iscensored(self.rev(node)):
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
368 return text != b''
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
369
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
370 if self.renamed(node):
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
371 t2 = self.read(node)
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
372 return t2 != text
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
373
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
374 return True
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
375
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
376 def size(self, rev):
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
377 validaterev(rev)
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
378
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
379 node = self._indexbyrev[rev][b'node']
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
380
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
381 if self.renamed(node):
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
382 return len(self.read(node))
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
383
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
384 if self.iscensored(rev):
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
385 return 0
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
386
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
387 return len(self.revision(node))
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
388
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
389 def iscensored(self, rev):
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
390 validaterev(rev)
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
391
40047
8e398628a3f2 repository: define and use revision flag constants
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39997
diff changeset
392 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
393
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
394 def commonancestorsheads(self, a, b):
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
395 validatenode(a)
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
396 validatenode(b)
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
397
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
398 a = self.rev(a)
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
399 b = self.rev(b)
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
400
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
401 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
402 return pycompat.maplist(self.node, ancestors)
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 def descendants(self, revs):
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
405 # 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
406 first = min(revs)
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
407 if first == nullrev:
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
408 for i in self:
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
409 yield i
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
410 return
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 seen = set(revs)
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
413 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
414 for x in self.parentrevs(i):
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
415 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
416 seen.add(i)
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
417 yield i
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
418 break
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
419
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
420 # Required by verify.
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
421 def files(self):
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
422 entries = self._svfs.listdir(self._storepath)
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
423
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
424 # 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
425 # recording.
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
426 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
427
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
428 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
429
41157
c4639fdae1b9 simplestorerepo: minimal changes required to get this mostly working again
Augie Fackler <augie@google.com>
parents: 40389
diff changeset
430 def storageinfo(self, exclusivefiles=False, sharedfiles=False,
c4639fdae1b9 simplestorerepo: minimal changes required to get this mostly working again
Augie Fackler <augie@google.com>
parents: 40389
diff changeset
431 revisionscount=False, trackedsize=False,
c4639fdae1b9 simplestorerepo: minimal changes required to get this mostly working again
Augie Fackler <augie@google.com>
parents: 40389
diff changeset
432 storedsize=False):
c4639fdae1b9 simplestorerepo: minimal changes required to get this mostly working again
Augie Fackler <augie@google.com>
parents: 40389
diff changeset
433 # 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
434 return {
c4639fdae1b9 simplestorerepo: minimal changes required to get this mostly working again
Augie Fackler <augie@google.com>
parents: 40389
diff changeset
435 'exclusivefiles': [],
c4639fdae1b9 simplestorerepo: minimal changes required to get this mostly working again
Augie Fackler <augie@google.com>
parents: 40389
diff changeset
436 'sharedfiles': [],
c4639fdae1b9 simplestorerepo: minimal changes required to get this mostly working again
Augie Fackler <augie@google.com>
parents: 40389
diff changeset
437 'revisionscount': len(self),
c4639fdae1b9 simplestorerepo: minimal changes required to get this mostly working again
Augie Fackler <augie@google.com>
parents: 40389
diff changeset
438 'trackedsize': 0,
c4639fdae1b9 simplestorerepo: minimal changes required to get this mostly working again
Augie Fackler <augie@google.com>
parents: 40389
diff changeset
439 'storedsize': None,
c4639fdae1b9 simplestorerepo: minimal changes required to get this mostly working again
Augie Fackler <augie@google.com>
parents: 40389
diff changeset
440 }
c4639fdae1b9 simplestorerepo: minimal changes required to get this mostly working again
Augie Fackler <augie@google.com>
parents: 40389
diff changeset
441
c4639fdae1b9 simplestorerepo: minimal changes required to get this mostly working again
Augie Fackler <augie@google.com>
parents: 40389
diff changeset
442 def verifyintegrity(self, state):
c4639fdae1b9 simplestorerepo: minimal changes required to get this mostly working again
Augie Fackler <augie@google.com>
parents: 40389
diff changeset
443 state['skipread'] = set()
c4639fdae1b9 simplestorerepo: minimal changes required to get this mostly working again
Augie Fackler <augie@google.com>
parents: 40389
diff changeset
444 for rev in self:
c4639fdae1b9 simplestorerepo: minimal changes required to get this mostly working again
Augie Fackler <augie@google.com>
parents: 40389
diff changeset
445 node = self.node(rev)
c4639fdae1b9 simplestorerepo: minimal changes required to get this mostly working again
Augie Fackler <augie@google.com>
parents: 40389
diff changeset
446 try:
c4639fdae1b9 simplestorerepo: minimal changes required to get this mostly working again
Augie Fackler <augie@google.com>
parents: 40389
diff changeset
447 self.revision(node)
c4639fdae1b9 simplestorerepo: minimal changes required to get this mostly working again
Augie Fackler <augie@google.com>
parents: 40389
diff changeset
448 except Exception as e:
c4639fdae1b9 simplestorerepo: minimal changes required to get this mostly working again
Augie Fackler <augie@google.com>
parents: 40389
diff changeset
449 yield simplefilestoreproblem(
c4639fdae1b9 simplestorerepo: minimal changes required to get this mostly working again
Augie Fackler <augie@google.com>
parents: 40389
diff changeset
450 error='unpacking %s: %s' % (node, e),
c4639fdae1b9 simplestorerepo: minimal changes required to get this mostly working again
Augie Fackler <augie@google.com>
parents: 40389
diff changeset
451 node=node)
c4639fdae1b9 simplestorerepo: minimal changes required to get this mostly working again
Augie Fackler <augie@google.com>
parents: 40389
diff changeset
452 state['skipread'].add(node)
c4639fdae1b9 simplestorerepo: minimal changes required to get this mostly working again
Augie Fackler <augie@google.com>
parents: 40389
diff changeset
453
c4639fdae1b9 simplestorerepo: minimal changes required to get this mostly working again
Augie Fackler <augie@google.com>
parents: 40389
diff changeset
454 def emitrevisions(self, nodes, nodesorder=None, revisiondata=False,
c4639fdae1b9 simplestorerepo: minimal changes required to get this mostly working again
Augie Fackler <augie@google.com>
parents: 40389
diff changeset
455 assumehaveparentrevisions=False,
c4639fdae1b9 simplestorerepo: minimal changes required to get this mostly working again
Augie Fackler <augie@google.com>
parents: 40389
diff changeset
456 deltamode=repository.CG_DELTAMODE_STD):
c4639fdae1b9 simplestorerepo: minimal changes required to get this mostly working again
Augie Fackler <augie@google.com>
parents: 40389
diff changeset
457 # TODO this will probably break on some ordering options.
c4639fdae1b9 simplestorerepo: minimal changes required to get this mostly working again
Augie Fackler <augie@google.com>
parents: 40389
diff changeset
458 nodes = [n for n in nodes if n != nullid]
c4639fdae1b9 simplestorerepo: minimal changes required to get this mostly working again
Augie Fackler <augie@google.com>
parents: 40389
diff changeset
459 if not nodes:
c4639fdae1b9 simplestorerepo: minimal changes required to get this mostly working again
Augie Fackler <augie@google.com>
parents: 40389
diff changeset
460 return
c4639fdae1b9 simplestorerepo: minimal changes required to get this mostly working again
Augie Fackler <augie@google.com>
parents: 40389
diff changeset
461 for delta in storageutil.emitrevisions(
c4639fdae1b9 simplestorerepo: minimal changes required to get this mostly working again
Augie Fackler <augie@google.com>
parents: 40389
diff changeset
462 self, nodes, nodesorder, simplestorerevisiondelta,
c4639fdae1b9 simplestorerepo: minimal changes required to get this mostly working again
Augie Fackler <augie@google.com>
parents: 40389
diff changeset
463 revisiondata=revisiondata,
c4639fdae1b9 simplestorerepo: minimal changes required to get this mostly working again
Augie Fackler <augie@google.com>
parents: 40389
diff changeset
464 assumehaveparentrevisions=assumehaveparentrevisions,
c4639fdae1b9 simplestorerepo: minimal changes required to get this mostly working again
Augie Fackler <augie@google.com>
parents: 40389
diff changeset
465 deltamode=deltamode):
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
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
474 def addrevision(self, text, transaction, linkrev, p1, p2, node=None,
37436
9d4f09bfe3ec simplestore: correctly implement flag processors
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37424
diff changeset
475 flags=revlog.REVIDX_DEFAULT_FLAGS, cachedelta=None):
37337
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
476 validatenode(p1)
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
477 validatenode(p2)
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
478
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
479 if flags:
39877
f8eb71f9e3bd storageutil: new module for storage primitives (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39876
diff changeset
480 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
481
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
482 rawtext, validatehash = self._processflags(text, flags, 'write')
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
483
39877
f8eb71f9e3bd storageutil: new module for storage primitives (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39876
diff changeset
484 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
485
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
486 if node in self._indexbynode:
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
487 return node
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
488
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
489 if validatehash:
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
490 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
491
37436
9d4f09bfe3ec simplestore: correctly implement flag processors
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37424
diff changeset
492 return self._addrawrevision(node, rawtext, transaction, linkrev, p1, p2,
9d4f09bfe3ec simplestore: correctly implement flag processors
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37424
diff changeset
493 flags)
9d4f09bfe3ec simplestore: correctly implement flag processors
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37424
diff changeset
494
9d4f09bfe3ec simplestore: correctly implement flag processors
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37424
diff changeset
495 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
496 transaction.addbackup(self._indexpath)
9d4f09bfe3ec simplestore: correctly implement flag processors
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37424
diff changeset
497
37337
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
498 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
499
37436
9d4f09bfe3ec simplestore: correctly implement flag processors
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37424
diff changeset
500 self._svfs.write(path, rawtext)
37337
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
501
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
502 self._indexdata.append({
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
503 b'node': node,
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
504 b'p1': p1,
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
505 b'p2': p2,
37436
9d4f09bfe3ec simplestore: correctly implement flag processors
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37424
diff changeset
506 b'linkrev': link,
37337
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
507 b'flags': flags,
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
508 })
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
509
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
510 self._reflectindexupdate()
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
511
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
512 return node
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
513
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
514 def _reflectindexupdate(self):
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
515 self._refreshindex()
41158
ad51e6117095 simplestorerepo: migrate to in-hg CBOR code
Augie Fackler <augie@google.com>
parents: 41157
diff changeset
516 self._svfs.write(self._indexpath,
ad51e6117095 simplestorerepo: migrate to in-hg CBOR code
Augie Fackler <augie@google.com>
parents: 41157
diff changeset
517 ''.join(cborutil.streamencode(self._indexdata)))
37337
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
518
40389
1b183edbb68e repository: teach addgroup() to receive data with missing parents
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40047
diff changeset
519 def addgroup(self, deltas, linkmapper, transaction, addrevisioncb=None,
1b183edbb68e repository: teach addgroup() to receive data with missing parents
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40047
diff changeset
520 maybemissingparents=False):
1b183edbb68e repository: teach addgroup() to receive data with missing parents
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40047
diff changeset
521 if maybemissingparents:
1b183edbb68e repository: teach addgroup() to receive data with missing parents
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40047
diff changeset
522 raise error.Abort(_('simple store does not support missing parents '
1b183edbb68e repository: teach addgroup() to receive data with missing parents
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40047
diff changeset
523 'write mode'))
1b183edbb68e repository: teach addgroup() to receive data with missing parents
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40047
diff changeset
524
37337
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
525 nodes = []
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
526
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
527 transaction.addbackup(self._indexpath)
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
528
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
529 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
530 linkrev = linkmapper(linknode)
37436
9d4f09bfe3ec simplestore: correctly implement flag processors
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37424
diff changeset
531 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
532
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
533 nodes.append(node)
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
534
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
535 if node in self._indexbynode:
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
536 continue
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
537
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
538 # Need to resolve the fulltext from the delta base.
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
539 if deltabase == nullid:
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
540 text = mdiff.patch(b'', delta)
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
541 else:
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
542 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
543
37436
9d4f09bfe3ec simplestore: correctly implement flag processors
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37424
diff changeset
544 self._addrawrevision(node, text, transaction, linkrev, p1, p2,
9d4f09bfe3ec simplestore: correctly implement flag processors
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37424
diff changeset
545 flags)
37337
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
546
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
547 if addrevisioncb:
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
548 addrevisioncb(self, node)
41157
c4639fdae1b9 simplestorerepo: minimal changes required to get this mostly working again
Augie Fackler <augie@google.com>
parents: 40389
diff changeset
549 return nodes
37337
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
550
41157
c4639fdae1b9 simplestorerepo: minimal changes required to get this mostly working again
Augie Fackler <augie@google.com>
parents: 40389
diff changeset
551 def _headrevs(self):
c4639fdae1b9 simplestorerepo: minimal changes required to get this mostly working again
Augie Fackler <augie@google.com>
parents: 40389
diff changeset
552 # 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
553 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
554
c4639fdae1b9 simplestorerepo: minimal changes required to get this mostly working again
Augie Fackler <augie@google.com>
parents: 40389
diff changeset
555 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
556 # 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
557 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
558 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
559
c4639fdae1b9 simplestorerepo: minimal changes required to get this mostly working again
Augie Fackler <augie@google.com>
parents: 40389
diff changeset
560 return [rev for rev, ishead in sorted(revishead.items())
c4639fdae1b9 simplestorerepo: minimal changes required to get this mostly working again
Augie Fackler <augie@google.com>
parents: 40389
diff changeset
561 if ishead]
37337
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
562
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
563 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
564 # This is copied from revlog.py.
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
565 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
566 if not len(self):
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
567 return [nullid]
41157
c4639fdae1b9 simplestorerepo: minimal changes required to get this mostly working again
Augie Fackler <augie@google.com>
parents: 40389
diff changeset
568 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
569
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
570 if start is None:
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
571 start = nullid
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
572 if stop is None:
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
573 stop = []
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
574 stoprevs = set([self.rev(n) for n in stop])
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
575 startrev = self.rev(start)
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
576 reachable = {startrev}
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
577 heads = {startrev}
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
578
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
579 parentrevs = self.parentrevs
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
580 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
581 for p in parentrevs(r):
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
582 if p in reachable:
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
583 if r not in stoprevs:
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
584 reachable.add(r)
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
585 heads.add(r)
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
586 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
587 heads.remove(p)
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
588
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
589 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
590
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
591 def children(self, node):
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
592 validatenode(node)
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
593
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
594 # 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
595 c = []
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
596 p = self.rev(node)
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
597 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
598 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
599 if prevs:
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
600 for pr in prevs:
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
601 if pr == p:
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
602 c.append(self.node(r))
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
603 elif p == nullrev:
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
604 c.append(self.node(r))
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
605 return c
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
606
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
607 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
608 return storageutil.resolvestripinfo(
c4639fdae1b9 simplestorerepo: minimal changes required to get this mostly working again
Augie Fackler <augie@google.com>
parents: 40389
diff changeset
609 minlink, len(self) - 1, self._headrevs(), self.linkrev,
c4639fdae1b9 simplestorerepo: minimal changes required to get this mostly working again
Augie Fackler <augie@google.com>
parents: 40389
diff changeset
610 self.parentrevs)
37337
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 def strip(self, minlink, transaction):
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
613 if not len(self):
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
614 return
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
615
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
616 rev, _ignored = self.getstrippoint(minlink)
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
617 if rev == len(self):
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
618 return
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
619
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
620 # 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
621 self._indexdata[rev:] = []
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
622 self._reflectindexupdate()
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
623
37415
c2c8962a9465 simplestore: use a custom store for the simple store repo
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37408
diff changeset
624 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
625 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
626 return False
c2c8962a9465 simplestore: use a custom store for the simple store repo
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37408
diff changeset
627
c2c8962a9465 simplestore: use a custom store for the simple store repo
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37408
diff changeset
628 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
629 return False
c2c8962a9465 simplestore: use a custom store for the simple store repo
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37408
diff changeset
630
c2c8962a9465 simplestore: use a custom store for the simple store repo
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37408
diff changeset
631 # 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
632 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
633 return False
c2c8962a9465 simplestore: use a custom store for the simple store repo
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37408
diff changeset
634
c2c8962a9465 simplestore: use a custom store for the simple store repo
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37408
diff changeset
635 # 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
636 return True
c2c8962a9465 simplestore: use a custom store for the simple store repo
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37408
diff changeset
637
c2c8962a9465 simplestore: use a custom store for the simple store repo
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37408
diff changeset
638 class simplestore(store.encodedstore):
c2c8962a9465 simplestore: use a custom store for the simple store repo
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37408
diff changeset
639 def datafiles(self):
c2c8962a9465 simplestore: use a custom store for the simple store repo
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37408
diff changeset
640 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
641 yield x
c2c8962a9465 simplestore: use a custom store for the simple store repo
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37408
diff changeset
642
c2c8962a9465 simplestore: use a custom store for the simple store repo
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37408
diff changeset
643 # 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
644 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
645
c2c8962a9465 simplestore: use a custom store for the simple store repo
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37408
diff changeset
646 for unencoded, encoded, size in extrafiles:
c2c8962a9465 simplestore: use a custom store for the simple store repo
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37408
diff changeset
647 try:
c2c8962a9465 simplestore: use a custom store for the simple store repo
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37408
diff changeset
648 unencoded = store.decodefilename(unencoded)
c2c8962a9465 simplestore: use a custom store for the simple store repo
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37408
diff changeset
649 except KeyError:
c2c8962a9465 simplestore: use a custom store for the simple store repo
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37408
diff changeset
650 unencoded = None
c2c8962a9465 simplestore: use a custom store for the simple store repo
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37408
diff changeset
651
c2c8962a9465 simplestore: use a custom store for the simple store repo
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37408
diff changeset
652 yield unencoded, encoded, size
c2c8962a9465 simplestore: use a custom store for the simple store repo
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37408
diff changeset
653
37337
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
654 def reposetup(ui, repo):
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
655 if not repo.local():
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
656 return
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
657
37346
45a4799174a1 tests: disallow using simple store repo with bundlerepo
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37341
diff changeset
658 if isinstance(repo, bundlerepo.bundlerepository):
45a4799174a1 tests: disallow using simple store repo with bundlerepo
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37341
diff changeset
659 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
660
37337
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
661 class simplestorerepo(repo.__class__):
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
662 def file(self, f):
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
663 return filestorage(self.svfs, f)
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
664
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
665 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
666
c2c8962a9465 simplestore: use a custom store for the simple store repo
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37408
diff changeset
667 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
668 supported.add(REQUIREMENT)
c2c8962a9465 simplestore: use a custom store for the simple store repo
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37408
diff changeset
669
41157
c4639fdae1b9 simplestorerepo: minimal changes required to get this mostly working again
Augie Fackler <augie@google.com>
parents: 40389
diff changeset
670 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
671 """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
672 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
673
c2c8962a9465 simplestore: use a custom store for the simple store repo
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37408
diff changeset
674 # 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
675 # 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
676 # TODO do this once we feel like taking the test hit.
c2c8962a9465 simplestore: use a custom store for the simple store repo
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37408
diff changeset
677 #if 'fncache' in requirements:
c2c8962a9465 simplestore: use a custom store for the simple store repo
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37408
diff changeset
678 # requirements.remove('fncache')
c2c8962a9465 simplestore: use a custom store for the simple store repo
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37408
diff changeset
679 #if 'dotencode' in requirements:
c2c8962a9465 simplestore: use a custom store for the simple store repo
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37408
diff changeset
680 # requirements.remove('dotencode')
c2c8962a9465 simplestore: use a custom store for the simple store repo
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37408
diff changeset
681
c2c8962a9465 simplestore: use a custom store for the simple store repo
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37408
diff changeset
682 requirements.add(REQUIREMENT)
c2c8962a9465 simplestore: use a custom store for the simple store repo
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37408
diff changeset
683
c2c8962a9465 simplestore: use a custom store for the simple store repo
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37408
diff changeset
684 return requirements
c2c8962a9465 simplestore: use a custom store for the simple store repo
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37408
diff changeset
685
c2c8962a9465 simplestore: use a custom store for the simple store repo
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37408
diff changeset
686 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
687 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
688 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
689
c2c8962a9465 simplestore: use a custom store for the simple store repo
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37408
diff changeset
690 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
691
37417
76d2115cb817 verify: allow suppressing warnings about extra files
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37415
diff changeset
692 def verifierinit(orig, self, *args, **kwargs):
76d2115cb817 verify: allow suppressing warnings about extra files
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37415
diff changeset
693 orig(self, *args, **kwargs)
76d2115cb817 verify: allow suppressing warnings about extra files
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37415
diff changeset
694
76d2115cb817 verify: allow suppressing warnings about extra files
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37415
diff changeset
695 # 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
696 # advertised. So suppress these warnings.
76d2115cb817 verify: allow suppressing warnings about extra files
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37415
diff changeset
697 self.warnorphanstorefiles = False
76d2115cb817 verify: allow suppressing warnings about extra files
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37415
diff changeset
698
37415
c2c8962a9465 simplestore: use a custom store for the simple store repo
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37408
diff changeset
699 def extsetup(ui):
c2c8962a9465 simplestore: use a custom store for the simple store repo
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37408
diff changeset
700 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
701
c2c8962a9465 simplestore: use a custom store for the simple store repo
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37408
diff changeset
702 extensions.wrapfunction(localrepo, 'newreporequirements',
c2c8962a9465 simplestore: use a custom store for the simple store repo
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37408
diff changeset
703 newreporequirements)
41157
c4639fdae1b9 simplestorerepo: minimal changes required to get this mostly working again
Augie Fackler <augie@google.com>
parents: 40389
diff changeset
704 extensions.wrapfunction(localrepo, 'makestore', makestore)
37417
76d2115cb817 verify: allow suppressing warnings about extra files
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37415
diff changeset
705 extensions.wrapfunction(verify.verifier, '__init__', verifierinit)