annotate tests/simplestorerepo.py @ 42985:a45d670c2bfc

flagprocessors: return sidedata map in `_processflagsread` Right now, flag processors does not return sidedata, by they will. So, we prepare the caller to receive it. Differential Revision: https://phab.mercurial-scm.org/D6811
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Tue, 03 Sep 2019 22:55:04 +0200
parents 38c62272f462
children a04b2c010d03
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 (
39259
b41d023a412a repository: establish API for emitting revision deltas
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38548
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,
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
35 revlog,
37415
c2c8962a9465 simplestore: use a custom store for the simple store repo
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37408
diff changeset
36 store,
37417
76d2115cb817 verify: allow suppressing warnings about extra files
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37415
diff changeset
37 verify,
37337
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
38 )
42823
268662aac075 interfaces: create a new folder for interfaces and move repository.py in it
Pulkit Goyal <pulkit@yandex-team.ru>
parents: 42747
diff changeset
39 from mercurial.interfaces import (
268662aac075 interfaces: create a new folder for interfaces and move repository.py in it
Pulkit Goyal <pulkit@yandex-team.ru>
parents: 42747
diff changeset
40 repository,
42824
2c4f656c8e9f interfaceutil: move to interfaces/
Pulkit Goyal <pulkit@yandex-team.ru>
parents: 42823
diff changeset
41 util as interfaceutil,
42823
268662aac075 interfaces: create a new folder for interfaces and move repository.py in it
Pulkit Goyal <pulkit@yandex-team.ru>
parents: 42747
diff changeset
42 )
38548
404eab7ff33f tests: use interfaceutil in simplestorerepo
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37442
diff changeset
43 from mercurial.utils import (
41158
ad51e6117095 simplestorerepo: migrate to in-hg CBOR code
Augie Fackler <augie@google.com>
parents: 41157
diff changeset
44 cborutil,
39882
f8eb71f9e3bd storageutil: new module for storage primitives (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39881
diff changeset
45 storageutil,
38548
404eab7ff33f tests: use interfaceutil in simplestorerepo
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37442
diff changeset
46 )
42747
92ac6b1697a7 flagutil: move REVIDX_KNOWN_FLAGS source of truth in flagutil (API)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 42741
diff changeset
47 from mercurial.revlogutils import (
92ac6b1697a7 flagutil: move REVIDX_KNOWN_FLAGS source of truth in flagutil (API)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 42741
diff changeset
48 flagutil,
92ac6b1697a7 flagutil: move REVIDX_KNOWN_FLAGS source of truth in flagutil (API)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 42741
diff changeset
49 )
37337
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
50
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
51 # 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
52 # 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
53 # 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
54 # leave the attribute unspecified.
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
55 testedwith = 'ships-with-hg-core'
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
56
37415
c2c8962a9465 simplestore: use a custom store for the simple store repo
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37408
diff changeset
57 REQUIREMENT = 'testonly-simplestore'
c2c8962a9465 simplestore: use a custom store for the simple store repo
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37408
diff changeset
58
37337
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
59 def validatenode(node):
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
60 if isinstance(node, int):
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
61 raise ValueError('expected node; got int')
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
62
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
63 if len(node) != 20:
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
64 raise ValueError('expected 20 byte node')
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
65
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
66 def validaterev(rev):
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
67 if not isinstance(rev, int):
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
68 raise ValueError('expected int')
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
69
39793
b63dee7bd0d9 global: replace most uses of RevlogError with StorageError (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39789
diff changeset
70 class simplestoreerror(error.StorageError):
b63dee7bd0d9 global: replace most uses of RevlogError with StorageError (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39789
diff changeset
71 pass
b63dee7bd0d9 global: replace most uses of RevlogError with StorageError (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39789
diff changeset
72
39259
b41d023a412a repository: establish API for emitting revision deltas
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38548
diff changeset
73 @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
74 @attr.s(slots=True)
39259
b41d023a412a repository: establish API for emitting revision deltas
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38548
diff changeset
75 class simplestorerevisiondelta(object):
b41d023a412a repository: establish API for emitting revision deltas
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38548
diff changeset
76 node = attr.ib()
b41d023a412a repository: establish API for emitting revision deltas
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38548
diff changeset
77 p1node = attr.ib()
b41d023a412a repository: establish API for emitting revision deltas
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38548
diff changeset
78 p2node = attr.ib()
b41d023a412a repository: establish API for emitting revision deltas
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38548
diff changeset
79 basenode = attr.ib()
b41d023a412a repository: establish API for emitting revision deltas
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38548
diff changeset
80 flags = attr.ib()
b41d023a412a repository: establish API for emitting revision deltas
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38548
diff changeset
81 baserevisionsize = attr.ib()
b41d023a412a repository: establish API for emitting revision deltas
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38548
diff changeset
82 revision = attr.ib()
b41d023a412a repository: establish API for emitting revision deltas
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38548
diff changeset
83 delta = attr.ib()
41157
c4639fdae1b9 simplestorerepo: minimal changes required to get this mostly working again
Augie Fackler <augie@google.com>
parents: 40389
diff changeset
84 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
85
c4639fdae1b9 simplestorerepo: minimal changes required to get this mostly working again
Augie Fackler <augie@google.com>
parents: 40389
diff changeset
86 @interfaceutil.implementer(repository.iverifyproblem)
c4639fdae1b9 simplestorerepo: minimal changes required to get this mostly working again
Augie Fackler <augie@google.com>
parents: 40389
diff changeset
87 @attr.s(frozen=True)
c4639fdae1b9 simplestorerepo: minimal changes required to get this mostly working again
Augie Fackler <augie@google.com>
parents: 40389
diff changeset
88 class simplefilestoreproblem(object):
c4639fdae1b9 simplestorerepo: minimal changes required to get this mostly working again
Augie Fackler <augie@google.com>
parents: 40389
diff changeset
89 warning = attr.ib(default=None)
c4639fdae1b9 simplestorerepo: minimal changes required to get this mostly working again
Augie Fackler <augie@google.com>
parents: 40389
diff changeset
90 error = attr.ib(default=None)
c4639fdae1b9 simplestorerepo: minimal changes required to get this mostly working again
Augie Fackler <augie@google.com>
parents: 40389
diff changeset
91 node = attr.ib(default=None)
39259
b41d023a412a repository: establish API for emitting revision deltas
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38548
diff changeset
92
38548
404eab7ff33f tests: use interfaceutil in simplestorerepo
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37442
diff changeset
93 @interfaceutil.implementer(repository.ifilestorage)
42880
705428da231f flagutil: use it in simplestorerepo
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 42824
diff changeset
94 class filestorage(flagutil.flagprocessorsmixin):
37337
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
95 """Implements storage for a tracked path.
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 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
98 path.
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 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
101
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
102 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
103 """
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
104
42880
705428da231f flagutil: use it in simplestorerepo
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 42824
diff changeset
105 _flagserrorclass = simplestoreerror
705428da231f flagutil: use it in simplestorerepo
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 42824
diff changeset
106
37337
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
107 def __init__(self, svfs, path):
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
108 self._svfs = svfs
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
109 self._path = path
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._storepath = b'/'.join([b'data', path])
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
112 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
113
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
114 indexdata = self._svfs.tryread(self._indexpath)
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
115 if indexdata:
41158
ad51e6117095 simplestorerepo: migrate to in-hg CBOR code
Augie Fackler <augie@google.com>
parents: 41157
diff changeset
116 indexdata = cborutil.decodeall(indexdata)
37337
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
117
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
118 self._indexdata = indexdata or []
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
119 self._indexbynode = {}
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
120 self._indexbyrev = {}
39865
d9b3cc3d5d07 filelog: drop index attribute (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39849
diff changeset
121 self._index = []
37337
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
122 self._refreshindex()
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
123
42880
705428da231f flagutil: use it in simplestorerepo
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 42824
diff changeset
124 self._flagprocessors = dict(flagutil.flagprocessors)
705428da231f flagutil: use it in simplestorerepo
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 42824
diff changeset
125
37337
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
126 def _refreshindex(self):
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
127 self._indexbynode.clear()
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
128 self._indexbyrev.clear()
39865
d9b3cc3d5d07 filelog: drop index attribute (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39849
diff changeset
129 self._index = []
37337
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
130
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
131 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
132 self._indexbynode[entry[b'node']] = entry
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
133 self._indexbyrev[i] = entry
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
134
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
135 self._indexbynode[nullid] = {
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
136 b'node': nullid,
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
137 b'p1': nullid,
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
138 b'p2': nullid,
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
139 b'linkrev': nullrev,
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
140 b'flags': 0,
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
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
143 self._indexbyrev[nullrev] = {
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
144 b'node': nullid,
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
145 b'p1': nullid,
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
146 b'p2': nullid,
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
147 b'linkrev': nullrev,
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
148 b'flags': 0,
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
149 }
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 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
152 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
153
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
154 # start, length, rawsize, chainbase, linkrev, p1, p2, node
39865
d9b3cc3d5d07 filelog: drop index attribute (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39849
diff changeset
155 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: 39849
diff changeset
156 entry[b'node']))
37337
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
157
39865
d9b3cc3d5d07 filelog: drop index attribute (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39849
diff changeset
158 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
159
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
160 def __len__(self):
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
161 return len(self._indexdata)
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 def __iter__(self):
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
164 return iter(range(len(self)))
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
165
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
166 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
167 step = 1
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
168 if stop is not None:
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
169 if start > stop:
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
170 step = -1
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 stop += step
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
173 else:
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
174 stop = len(self)
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
175
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
176 return range(start, stop, step)
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
177
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
178 def parents(self, node):
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
179 validatenode(node)
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
180
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
181 if node not in self._indexbynode:
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
182 raise KeyError('unknown node')
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
183
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
184 entry = self._indexbynode[node]
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
185
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
186 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
187
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
188 def parentrevs(self, rev):
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
189 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
190 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
191
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
192 def rev(self, node):
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
193 validatenode(node)
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
194
37408
dd2753729853 simplestore: shore up lookup errors
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37346
diff changeset
195 try:
dd2753729853 simplestore: shore up lookup errors
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37346
diff changeset
196 self._indexbynode[node]
dd2753729853 simplestore: shore up lookup errors
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37346
diff changeset
197 except KeyError:
dd2753729853 simplestore: shore up lookup errors
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37346
diff changeset
198 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
199
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
200 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
201 if entry[b'node'] == node:
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
202 return rev
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
203
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
204 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
205
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
206 def node(self, rev):
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
207 validaterev(rev)
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
208
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
209 return self._indexbyrev[rev][b'node']
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
210
41157
c4639fdae1b9 simplestorerepo: minimal changes required to get this mostly working again
Augie Fackler <augie@google.com>
parents: 40389
diff changeset
211 def hasnode(self, node):
c4639fdae1b9 simplestorerepo: minimal changes required to get this mostly working again
Augie Fackler <augie@google.com>
parents: 40389
diff changeset
212 validatenode(node)
c4639fdae1b9 simplestorerepo: minimal changes required to get this mostly working again
Augie Fackler <augie@google.com>
parents: 40389
diff changeset
213 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
214
c4639fdae1b9 simplestorerepo: minimal changes required to get this mostly working again
Augie Fackler <augie@google.com>
parents: 40389
diff changeset
215 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
216 raise NotImplementedError('TODO')
c4639fdae1b9 simplestorerepo: minimal changes required to get this mostly working again
Augie Fackler <augie@google.com>
parents: 40389
diff changeset
217
37337
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
218 def lookup(self, node):
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
219 if isinstance(node, int):
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
220 return self.node(node)
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 len(node) == 20:
37408
dd2753729853 simplestore: shore up lookup errors
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37346
diff changeset
223 self.rev(node)
dd2753729853 simplestore: shore up lookup errors
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37346
diff changeset
224 return node
37337
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
225
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
226 try:
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
227 rev = int(node)
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
228 if '%d' % rev != node:
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
229 raise ValueError
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 rev < 0:
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
232 rev = len(self) + rev
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
233 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
234 raise ValueError
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
235
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
236 return self.node(rev)
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
237 except (ValueError, OverflowError):
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
238 pass
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
239
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
240 if len(node) == 40:
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
241 try:
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
242 rawnode = bin(node)
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
243 self.rev(rawnode)
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
244 return rawnode
37408
dd2753729853 simplestore: shore up lookup errors
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37346
diff changeset
245 except TypeError:
37337
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
246 pass
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
247
37408
dd2753729853 simplestore: shore up lookup errors
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37346
diff changeset
248 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
249
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
250 def linkrev(self, rev):
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
251 validaterev(rev)
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
252
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
253 return self._indexbyrev[rev][b'linkrev']
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
254
39878
2ac4f3e97813 filelog: stop proxying flags() (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39872
diff changeset
255 def _flags(self, rev):
37337
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
256 validaterev(rev)
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
257
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
258 return self._indexbyrev[rev][b'flags']
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
259
39262
3682b49e0213 repository: remove candelta() from ifileindex
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39260
diff changeset
260 def _candelta(self, baserev, rev):
37337
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
261 validaterev(baserev)
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
262 validaterev(rev)
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
263
39878
2ac4f3e97813 filelog: stop proxying flags() (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39872
diff changeset
264 if ((self._flags(baserev) & revlog.REVIDX_RAWTEXT_CHANGING_FLAGS)
2ac4f3e97813 filelog: stop proxying flags() (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39872
diff changeset
265 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
266 return False
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
267
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
268 return True
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
269
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
270 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
271 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
272 p1, p2 = self.parents(node)
39882
f8eb71f9e3bd storageutil: new module for storage primitives (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39881
diff changeset
273 if node != storageutil.hashrevisionsha1(text, p1, p2):
39793
b63dee7bd0d9 global: replace most uses of RevlogError with StorageError (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39789
diff changeset
274 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
275 self._path)
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
276
41157
c4639fdae1b9 simplestorerepo: minimal changes required to get this mostly working again
Augie Fackler <augie@google.com>
parents: 40389
diff changeset
277 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
278 if isinstance(nodeorrev, int):
c4639fdae1b9 simplestorerepo: minimal changes required to get this mostly working again
Augie Fackler <augie@google.com>
parents: 40389
diff changeset
279 node = self.node(nodeorrev)
c4639fdae1b9 simplestorerepo: minimal changes required to get this mostly working again
Augie Fackler <augie@google.com>
parents: 40389
diff changeset
280 else:
c4639fdae1b9 simplestorerepo: minimal changes required to get this mostly working again
Augie Fackler <augie@google.com>
parents: 40389
diff changeset
281 node = nodeorrev
37337
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
282 validatenode(node)
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
283
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
284 if node == nullid:
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
285 return b''
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
286
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
287 rev = self.rev(node)
39878
2ac4f3e97813 filelog: stop proxying flags() (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39872
diff changeset
288 flags = self._flags(rev)
37337
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 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
291 rawtext = self._svfs.read(path)
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
292
42886
38c62272f462 simplestorerepo: stop using `_processflags` directly
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 42882
diff changeset
293 if raw:
38c62272f462 simplestorerepo: stop using `_processflags` directly
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 42882
diff changeset
294 validatehash = self._processflagsraw(rawtext, flags)
38c62272f462 simplestorerepo: stop using `_processflags` directly
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 42882
diff changeset
295 text = rawtext
38c62272f462 simplestorerepo: stop using `_processflags` directly
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 42882
diff changeset
296 else:
42985
a45d670c2bfc flagprocessors: return sidedata map in `_processflagsread`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 42886
diff changeset
297 r = self._processflagsread(rawtext, flags)
a45d670c2bfc flagprocessors: return sidedata map in `_processflagsread`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 42886
diff changeset
298 text, validatehash, sidedata = r
37337
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
299 if validatehash:
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
300 self.checkhash(text, node, rev=rev)
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
301
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
302 return text
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
303
42741
2177133724ab rawdata: implement `rawdata` for `simplestore` too
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 41158
diff changeset
304 def rawdata(self, nodeorrev):
2177133724ab rawdata: implement `rawdata` for `simplestore` too
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 41158
diff changeset
305 return self.revision(raw=True)
2177133724ab rawdata: implement `rawdata` for `simplestore` too
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 41158
diff changeset
306
37337
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
307 def read(self, node):
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
308 validatenode(node)
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
309
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
310 revision = self.revision(node)
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
311
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
312 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
313 return revision
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
314
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
315 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
316 return revision[start + 2:]
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
317
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
318 def renamed(self, node):
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
319 validatenode(node)
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
320
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
321 if self.parents(node)[0] != nullid:
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
322 return False
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
323
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
324 fulltext = self.revision(node)
39883
3e896b51aa5d storageutil: move metadata parsing and packing from revlog (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39882
diff changeset
325 m = storageutil.parsemeta(fulltext)[0]
37337
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 if m and 'copy' in m:
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
328 return m['copy'], bin(m['copyrev'])
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
329
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
330 return False
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 def cmp(self, node, text):
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
333 validatenode(node)
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
334
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
335 t = text
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 if text.startswith(b'\1\n'):
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
338 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
339
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
340 p1, p2 = self.parents(node)
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
341
39882
f8eb71f9e3bd storageutil: new module for storage primitives (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39881
diff changeset
342 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
343 return False
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
344
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
345 if self.iscensored(self.rev(node)):
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
346 return text != b''
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
347
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
348 if self.renamed(node):
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
349 t2 = self.read(node)
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
350 return t2 != text
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 True
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 size(self, rev):
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
355 validaterev(rev)
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 node = self._indexbyrev[rev][b'node']
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 self.renamed(node):
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
360 return len(self.read(node))
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 if self.iscensored(rev):
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
363 return 0
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
364
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
365 return len(self.revision(node))
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 def iscensored(self, rev):
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
368 validaterev(rev)
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
369
40048
8e398628a3f2 repository: define and use revision flag constants
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39998
diff changeset
370 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
371
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
372 def commonancestorsheads(self, a, b):
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
373 validatenode(a)
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
374 validatenode(b)
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 a = self.rev(a)
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
377 b = self.rev(b)
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 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
380 return pycompat.maplist(self.node, ancestors)
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
381
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
382 def descendants(self, revs):
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
383 # 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
384 first = min(revs)
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
385 if first == nullrev:
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
386 for i in self:
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
387 yield i
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
388 return
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
389
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
390 seen = set(revs)
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
391 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
392 for x in self.parentrevs(i):
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
393 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
394 seen.add(i)
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
395 yield i
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
396 break
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 # Required by verify.
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
399 def files(self):
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
400 entries = self._svfs.listdir(self._storepath)
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
401
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
402 # 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
403 # recording.
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
404 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
405
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
406 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
407
41157
c4639fdae1b9 simplestorerepo: minimal changes required to get this mostly working again
Augie Fackler <augie@google.com>
parents: 40389
diff changeset
408 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
409 revisionscount=False, trackedsize=False,
c4639fdae1b9 simplestorerepo: minimal changes required to get this mostly working again
Augie Fackler <augie@google.com>
parents: 40389
diff changeset
410 storedsize=False):
c4639fdae1b9 simplestorerepo: minimal changes required to get this mostly working again
Augie Fackler <augie@google.com>
parents: 40389
diff changeset
411 # 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
412 return {
c4639fdae1b9 simplestorerepo: minimal changes required to get this mostly working again
Augie Fackler <augie@google.com>
parents: 40389
diff changeset
413 'exclusivefiles': [],
c4639fdae1b9 simplestorerepo: minimal changes required to get this mostly working again
Augie Fackler <augie@google.com>
parents: 40389
diff changeset
414 'sharedfiles': [],
c4639fdae1b9 simplestorerepo: minimal changes required to get this mostly working again
Augie Fackler <augie@google.com>
parents: 40389
diff changeset
415 'revisionscount': len(self),
c4639fdae1b9 simplestorerepo: minimal changes required to get this mostly working again
Augie Fackler <augie@google.com>
parents: 40389
diff changeset
416 'trackedsize': 0,
c4639fdae1b9 simplestorerepo: minimal changes required to get this mostly working again
Augie Fackler <augie@google.com>
parents: 40389
diff changeset
417 'storedsize': None,
c4639fdae1b9 simplestorerepo: minimal changes required to get this mostly working again
Augie Fackler <augie@google.com>
parents: 40389
diff changeset
418 }
c4639fdae1b9 simplestorerepo: minimal changes required to get this mostly working again
Augie Fackler <augie@google.com>
parents: 40389
diff changeset
419
c4639fdae1b9 simplestorerepo: minimal changes required to get this mostly working again
Augie Fackler <augie@google.com>
parents: 40389
diff changeset
420 def verifyintegrity(self, state):
c4639fdae1b9 simplestorerepo: minimal changes required to get this mostly working again
Augie Fackler <augie@google.com>
parents: 40389
diff changeset
421 state['skipread'] = set()
c4639fdae1b9 simplestorerepo: minimal changes required to get this mostly working again
Augie Fackler <augie@google.com>
parents: 40389
diff changeset
422 for rev in self:
c4639fdae1b9 simplestorerepo: minimal changes required to get this mostly working again
Augie Fackler <augie@google.com>
parents: 40389
diff changeset
423 node = self.node(rev)
c4639fdae1b9 simplestorerepo: minimal changes required to get this mostly working again
Augie Fackler <augie@google.com>
parents: 40389
diff changeset
424 try:
c4639fdae1b9 simplestorerepo: minimal changes required to get this mostly working again
Augie Fackler <augie@google.com>
parents: 40389
diff changeset
425 self.revision(node)
c4639fdae1b9 simplestorerepo: minimal changes required to get this mostly working again
Augie Fackler <augie@google.com>
parents: 40389
diff changeset
426 except Exception as e:
c4639fdae1b9 simplestorerepo: minimal changes required to get this mostly working again
Augie Fackler <augie@google.com>
parents: 40389
diff changeset
427 yield simplefilestoreproblem(
c4639fdae1b9 simplestorerepo: minimal changes required to get this mostly working again
Augie Fackler <augie@google.com>
parents: 40389
diff changeset
428 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
429 node=node)
c4639fdae1b9 simplestorerepo: minimal changes required to get this mostly working again
Augie Fackler <augie@google.com>
parents: 40389
diff changeset
430 state['skipread'].add(node)
c4639fdae1b9 simplestorerepo: minimal changes required to get this mostly working again
Augie Fackler <augie@google.com>
parents: 40389
diff changeset
431
c4639fdae1b9 simplestorerepo: minimal changes required to get this mostly working again
Augie Fackler <augie@google.com>
parents: 40389
diff changeset
432 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
433 assumehaveparentrevisions=False,
c4639fdae1b9 simplestorerepo: minimal changes required to get this mostly working again
Augie Fackler <augie@google.com>
parents: 40389
diff changeset
434 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
435 # 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
436 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
437 if not nodes:
c4639fdae1b9 simplestorerepo: minimal changes required to get this mostly working again
Augie Fackler <augie@google.com>
parents: 40389
diff changeset
438 return
c4639fdae1b9 simplestorerepo: minimal changes required to get this mostly working again
Augie Fackler <augie@google.com>
parents: 40389
diff changeset
439 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
440 self, nodes, nodesorder, simplestorerevisiondelta,
c4639fdae1b9 simplestorerepo: minimal changes required to get this mostly working again
Augie Fackler <augie@google.com>
parents: 40389
diff changeset
441 revisiondata=revisiondata,
c4639fdae1b9 simplestorerepo: minimal changes required to get this mostly working again
Augie Fackler <augie@google.com>
parents: 40389
diff changeset
442 assumehaveparentrevisions=assumehaveparentrevisions,
c4639fdae1b9 simplestorerepo: minimal changes required to get this mostly working again
Augie Fackler <augie@google.com>
parents: 40389
diff changeset
443 deltamode=deltamode):
c4639fdae1b9 simplestorerepo: minimal changes required to get this mostly working again
Augie Fackler <augie@google.com>
parents: 40389
diff changeset
444 yield delta
c4639fdae1b9 simplestorerepo: minimal changes required to get this mostly working again
Augie Fackler <augie@google.com>
parents: 40389
diff changeset
445
37337
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
446 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
447 if meta or text.startswith(b'\1\n'):
39883
3e896b51aa5d storageutil: move metadata parsing and packing from revlog (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39882
diff changeset
448 text = storageutil.packmeta(meta, text)
37337
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
449
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
450 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
451
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
452 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
453 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
454 validatenode(p1)
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
455 validatenode(p2)
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
456
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
457 if flags:
39882
f8eb71f9e3bd storageutil: new module for storage primitives (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39881
diff changeset
458 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
459
42882
db4af1cb128a flagprocessors: use _processflagswrite for write operation
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 42880
diff changeset
460 rawtext, validatehash = self._processflagswrite(text, flags)
37337
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
461
39882
f8eb71f9e3bd storageutil: new module for storage primitives (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39881
diff changeset
462 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
463
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
464 if node in self._indexbynode:
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
465 return node
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
466
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
467 if validatehash:
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
468 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
469
37436
9d4f09bfe3ec simplestore: correctly implement flag processors
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37424
diff changeset
470 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
471 flags)
9d4f09bfe3ec simplestore: correctly implement flag processors
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37424
diff changeset
472
9d4f09bfe3ec simplestore: correctly implement flag processors
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37424
diff changeset
473 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
474 transaction.addbackup(self._indexpath)
9d4f09bfe3ec simplestore: correctly implement flag processors
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37424
diff changeset
475
37337
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
476 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
477
37436
9d4f09bfe3ec simplestore: correctly implement flag processors
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37424
diff changeset
478 self._svfs.write(path, rawtext)
37337
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
479
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
480 self._indexdata.append({
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
481 b'node': node,
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
482 b'p1': p1,
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
483 b'p2': p2,
37436
9d4f09bfe3ec simplestore: correctly implement flag processors
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37424
diff changeset
484 b'linkrev': link,
37337
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
485 b'flags': flags,
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
486 })
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
487
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
488 self._reflectindexupdate()
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
489
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
490 return node
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
491
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
492 def _reflectindexupdate(self):
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
493 self._refreshindex()
41158
ad51e6117095 simplestorerepo: migrate to in-hg CBOR code
Augie Fackler <augie@google.com>
parents: 41157
diff changeset
494 self._svfs.write(self._indexpath,
ad51e6117095 simplestorerepo: migrate to in-hg CBOR code
Augie Fackler <augie@google.com>
parents: 41157
diff changeset
495 ''.join(cborutil.streamencode(self._indexdata)))
37337
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
496
40389
1b183edbb68e repository: teach addgroup() to receive data with missing parents
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40048
diff changeset
497 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: 40048
diff changeset
498 maybemissingparents=False):
1b183edbb68e repository: teach addgroup() to receive data with missing parents
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40048
diff changeset
499 if maybemissingparents:
1b183edbb68e repository: teach addgroup() to receive data with missing parents
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40048
diff changeset
500 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: 40048
diff changeset
501 'write mode'))
1b183edbb68e repository: teach addgroup() to receive data with missing parents
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40048
diff changeset
502
37337
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
503 nodes = []
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
504
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
505 transaction.addbackup(self._indexpath)
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
506
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
507 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
508 linkrev = linkmapper(linknode)
37436
9d4f09bfe3ec simplestore: correctly implement flag processors
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37424
diff changeset
509 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
510
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
511 nodes.append(node)
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
512
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
513 if node in self._indexbynode:
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
514 continue
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
515
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
516 # 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
517 if deltabase == nullid:
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
518 text = mdiff.patch(b'', delta)
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
519 else:
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
520 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
521
37436
9d4f09bfe3ec simplestore: correctly implement flag processors
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37424
diff changeset
522 self._addrawrevision(node, text, transaction, linkrev, p1, p2,
9d4f09bfe3ec simplestore: correctly implement flag processors
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37424
diff changeset
523 flags)
37337
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
524
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
525 if addrevisioncb:
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
526 addrevisioncb(self, node)
41157
c4639fdae1b9 simplestorerepo: minimal changes required to get this mostly working again
Augie Fackler <augie@google.com>
parents: 40389
diff changeset
527 return nodes
37337
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
528
41157
c4639fdae1b9 simplestorerepo: minimal changes required to get this mostly working again
Augie Fackler <augie@google.com>
parents: 40389
diff changeset
529 def _headrevs(self):
c4639fdae1b9 simplestorerepo: minimal changes required to get this mostly working again
Augie Fackler <augie@google.com>
parents: 40389
diff changeset
530 # 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
531 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
532
c4639fdae1b9 simplestorerepo: minimal changes required to get this mostly working again
Augie Fackler <augie@google.com>
parents: 40389
diff changeset
533 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
534 # 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
535 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
536 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
537
c4639fdae1b9 simplestorerepo: minimal changes required to get this mostly working again
Augie Fackler <augie@google.com>
parents: 40389
diff changeset
538 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
539 if ishead]
37337
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
540
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
541 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
542 # This is copied from revlog.py.
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
543 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
544 if not len(self):
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
545 return [nullid]
41157
c4639fdae1b9 simplestorerepo: minimal changes required to get this mostly working again
Augie Fackler <augie@google.com>
parents: 40389
diff changeset
546 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
547
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
548 if start is None:
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
549 start = nullid
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
550 if stop is None:
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
551 stop = []
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
552 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
553 startrev = self.rev(start)
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
554 reachable = {startrev}
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
555 heads = {startrev}
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
556
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
557 parentrevs = self.parentrevs
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
558 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
559 for p in parentrevs(r):
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
560 if p in reachable:
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
561 if r not in stoprevs:
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
562 reachable.add(r)
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
563 heads.add(r)
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
564 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
565 heads.remove(p)
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
566
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
567 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
568
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
569 def children(self, node):
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
570 validatenode(node)
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
571
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
572 # 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
573 c = []
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
574 p = self.rev(node)
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
575 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
576 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
577 if prevs:
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
578 for pr in prevs:
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
579 if pr == p:
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
580 c.append(self.node(r))
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
581 elif p == nullrev:
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
582 c.append(self.node(r))
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
583 return c
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
584
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
585 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
586 return storageutil.resolvestripinfo(
c4639fdae1b9 simplestorerepo: minimal changes required to get this mostly working again
Augie Fackler <augie@google.com>
parents: 40389
diff changeset
587 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
588 self.parentrevs)
37337
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
589
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
590 def strip(self, minlink, transaction):
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
591 if not len(self):
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
592 return
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 rev, _ignored = self.getstrippoint(minlink)
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
595 if rev == len(self):
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
596 return
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
597
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
598 # 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
599 self._indexdata[rev:] = []
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
600 self._reflectindexupdate()
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
601
37415
c2c8962a9465 simplestore: use a custom store for the simple store repo
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37408
diff changeset
602 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
603 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
604 return False
c2c8962a9465 simplestore: use a custom store for the simple store repo
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37408
diff changeset
605
c2c8962a9465 simplestore: use a custom store for the simple store repo
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37408
diff changeset
606 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
607 return False
c2c8962a9465 simplestore: use a custom store for the simple store repo
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37408
diff changeset
608
c2c8962a9465 simplestore: use a custom store for the simple store repo
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37408
diff changeset
609 # 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
610 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
611 return False
c2c8962a9465 simplestore: use a custom store for the simple store repo
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37408
diff changeset
612
c2c8962a9465 simplestore: use a custom store for the simple store repo
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37408
diff changeset
613 # 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
614 return True
c2c8962a9465 simplestore: use a custom store for the simple store repo
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37408
diff changeset
615
c2c8962a9465 simplestore: use a custom store for the simple store repo
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37408
diff changeset
616 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
617 def datafiles(self):
c2c8962a9465 simplestore: use a custom store for the simple store repo
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37408
diff changeset
618 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
619 yield x
c2c8962a9465 simplestore: use a custom store for the simple store repo
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37408
diff changeset
620
c2c8962a9465 simplestore: use a custom store for the simple store repo
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37408
diff changeset
621 # 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
622 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
623
c2c8962a9465 simplestore: use a custom store for the simple store repo
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37408
diff changeset
624 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
625 try:
c2c8962a9465 simplestore: use a custom store for the simple store repo
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37408
diff changeset
626 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
627 except KeyError:
c2c8962a9465 simplestore: use a custom store for the simple store repo
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37408
diff changeset
628 unencoded = None
c2c8962a9465 simplestore: use a custom store for the simple store repo
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37408
diff changeset
629
c2c8962a9465 simplestore: use a custom store for the simple store repo
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37408
diff changeset
630 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
631
37337
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
632 def reposetup(ui, repo):
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
633 if not repo.local():
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
634 return
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
635
37346
45a4799174a1 tests: disallow using simple store repo with bundlerepo
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37341
diff changeset
636 if isinstance(repo, bundlerepo.bundlerepository):
45a4799174a1 tests: disallow using simple store repo with bundlerepo
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37341
diff changeset
637 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
638
37337
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
639 class simplestorerepo(repo.__class__):
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
640 def file(self, f):
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
641 return filestorage(self.svfs, f)
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
642
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
643 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
644
c2c8962a9465 simplestore: use a custom store for the simple store repo
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37408
diff changeset
645 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
646 supported.add(REQUIREMENT)
c2c8962a9465 simplestore: use a custom store for the simple store repo
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37408
diff changeset
647
41157
c4639fdae1b9 simplestorerepo: minimal changes required to get this mostly working again
Augie Fackler <augie@google.com>
parents: 40389
diff changeset
648 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
649 """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
650 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
651
c2c8962a9465 simplestore: use a custom store for the simple store repo
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37408
diff changeset
652 # 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
653 # 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
654 # 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
655 #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
656 # requirements.remove('fncache')
c2c8962a9465 simplestore: use a custom store for the simple store repo
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37408
diff changeset
657 #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
658 # requirements.remove('dotencode')
c2c8962a9465 simplestore: use a custom store for the simple store repo
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37408
diff changeset
659
c2c8962a9465 simplestore: use a custom store for the simple store repo
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37408
diff changeset
660 requirements.add(REQUIREMENT)
c2c8962a9465 simplestore: use a custom store for the simple store repo
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37408
diff changeset
661
c2c8962a9465 simplestore: use a custom store for the simple store repo
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37408
diff changeset
662 return requirements
c2c8962a9465 simplestore: use a custom store for the simple store repo
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37408
diff changeset
663
c2c8962a9465 simplestore: use a custom store for the simple store repo
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37408
diff changeset
664 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
665 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
666 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
667
c2c8962a9465 simplestore: use a custom store for the simple store repo
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37408
diff changeset
668 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
669
37417
76d2115cb817 verify: allow suppressing warnings about extra files
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37415
diff changeset
670 def verifierinit(orig, self, *args, **kwargs):
76d2115cb817 verify: allow suppressing warnings about extra files
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37415
diff changeset
671 orig(self, *args, **kwargs)
76d2115cb817 verify: allow suppressing warnings about extra files
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37415
diff changeset
672
76d2115cb817 verify: allow suppressing warnings about extra files
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37415
diff changeset
673 # 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
674 # advertised. So suppress these warnings.
76d2115cb817 verify: allow suppressing warnings about extra files
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37415
diff changeset
675 self.warnorphanstorefiles = False
76d2115cb817 verify: allow suppressing warnings about extra files
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37415
diff changeset
676
37415
c2c8962a9465 simplestore: use a custom store for the simple store repo
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37408
diff changeset
677 def extsetup(ui):
c2c8962a9465 simplestore: use a custom store for the simple store repo
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37408
diff changeset
678 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
679
c2c8962a9465 simplestore: use a custom store for the simple store repo
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37408
diff changeset
680 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
681 newreporequirements)
41157
c4639fdae1b9 simplestorerepo: minimal changes required to get this mostly working again
Augie Fackler <augie@google.com>
parents: 40389
diff changeset
682 extensions.wrapfunction(localrepo, 'makestore', makestore)
37417
76d2115cb817 verify: allow suppressing warnings about extra files
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37415
diff changeset
683 extensions.wrapfunction(verify.verifier, '__init__', verifierinit)