annotate tests/simplestorerepo.py @ 37417:76d2115cb817

verify: allow suppressing warnings about extra files The verifier issues warnings when the set of files in .hg/store doesn't align with the set of files that are advertised via repo.file(f).files() for all files seen in ctx.files() changelog traversal. This logic is reasonable for a default implementation. But some stores may have extra files whose presence is harmless. Or those stores may not have the same transaction rollback semantics that unlink files as other stores. This commit adds support for disabling the warning for orphaned files. The simple store extension has been taught to set this flag. Differential Revision: https://phab.mercurial-scm.org/D3097
author Gregory Szorc <gregory.szorc@gmail.com>
date Wed, 04 Apr 2018 14:11:43 -0700
parents c2c8962a9465
children 06674aab2b4c
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 (
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
25 cbor,
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,
37337
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
32 filelog,
37415
c2c8962a9465 simplestore: use a custom store for the simple store repo
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37408
diff changeset
33 localrepo,
37337
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
34 mdiff,
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
35 pycompat,
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
36 revlog,
37415
c2c8962a9465 simplestore: use a custom store for the simple store repo
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37408
diff changeset
37 store,
37417
76d2115cb817 verify: allow suppressing warnings about extra files
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37415
diff changeset
38 verify,
37337
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
39 )
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
40
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
41 # 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
42 # 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
43 # 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
44 # leave the attribute unspecified.
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
45 testedwith = 'ships-with-hg-core'
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
46
37415
c2c8962a9465 simplestore: use a custom store for the simple store repo
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37408
diff changeset
47 REQUIREMENT = 'testonly-simplestore'
c2c8962a9465 simplestore: use a custom store for the simple store repo
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37408
diff changeset
48
37337
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
49 def validatenode(node):
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
50 if isinstance(node, int):
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
51 raise ValueError('expected node; got int')
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
52
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
53 if len(node) != 20:
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
54 raise ValueError('expected 20 byte node')
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
55
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
56 def validaterev(rev):
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
57 if not isinstance(rev, int):
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
58 raise ValueError('expected int')
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
59
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
60 class filestorage(object):
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
61 """Implements storage for a tracked path.
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 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
64 path.
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 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
67
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
68 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
69 """
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
70
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
71 def __init__(self, svfs, path):
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
72 self._svfs = svfs
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
73 self._path = path
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
74
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
75 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
76 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
77
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
78 indexdata = self._svfs.tryread(self._indexpath)
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
79 if indexdata:
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
80 indexdata = cbor.loads(indexdata)
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
81
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
82 self._indexdata = indexdata or []
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
83 self._indexbynode = {}
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
84 self._indexbyrev = {}
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
85 self.index = []
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
86 self._refreshindex()
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
87
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
88 # This is used by changegroup code :/
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
89 self._generaldelta = True
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
90 self.storedeltachains = False
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
91
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
92 self.version = 1
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
93
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
94 def _refreshindex(self):
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
95 self._indexbynode.clear()
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
96 self._indexbyrev.clear()
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
97 self.index = []
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
98
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
99 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
100 self._indexbynode[entry[b'node']] = entry
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
101 self._indexbyrev[i] = entry
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
102
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
103 self._indexbynode[nullid] = {
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
104 b'node': nullid,
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
105 b'p1': nullid,
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
106 b'p2': nullid,
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
107 b'linkrev': nullrev,
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
108 b'flags': 0,
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
109 }
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._indexbyrev[nullrev] = {
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
112 b'node': nullid,
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
113 b'p1': nullid,
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
114 b'p2': nullid,
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
115 b'linkrev': nullrev,
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
116 b'flags': 0,
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
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
119 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
120 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
121
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
122 # start, length, rawsize, chainbase, linkrev, p1, p2, node
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
123 self.index.append((0, 0, 0, -1, entry[b'linkrev'], p1rev, p2rev,
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
124 entry[b'node']))
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
125
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
126 self.index.append((0, 0, 0, -1, -1, -1, -1, nullid))
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
127
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
128 def __len__(self):
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
129 return len(self._indexdata)
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 def __iter__(self):
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
132 return iter(range(len(self)))
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
133
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
134 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
135 step = 1
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
136 if stop is not None:
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
137 if start > stop:
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
138 step = -1
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
139
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
140 stop += step
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
141 else:
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
142 stop = len(self)
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
143
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
144 return range(start, stop, step)
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
145
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
146 def parents(self, node):
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
147 validatenode(node)
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
148
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
149 if node not in self._indexbynode:
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
150 raise KeyError('unknown node')
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
151
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
152 entry = self._indexbynode[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 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
155
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
156 def parentrevs(self, rev):
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
157 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
158 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
159
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
160 def rev(self, node):
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
161 validatenode(node)
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
162
37408
dd2753729853 simplestore: shore up lookup errors
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37346
diff changeset
163 try:
dd2753729853 simplestore: shore up lookup errors
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37346
diff changeset
164 self._indexbynode[node]
dd2753729853 simplestore: shore up lookup errors
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37346
diff changeset
165 except KeyError:
dd2753729853 simplestore: shore up lookup errors
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37346
diff changeset
166 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
167
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
168 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
169 if entry[b'node'] == node:
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
170 return rev
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 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
173
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
174 def node(self, rev):
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
175 validaterev(rev)
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
176
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
177 return self._indexbyrev[rev][b'node']
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
178
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
179 def lookup(self, node):
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
180 if isinstance(node, int):
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
181 return self.node(node)
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
182
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
183 if len(node) == 20:
37408
dd2753729853 simplestore: shore up lookup errors
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37346
diff changeset
184 self.rev(node)
dd2753729853 simplestore: shore up lookup errors
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37346
diff changeset
185 return node
37337
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
186
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
187 try:
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
188 rev = int(node)
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
189 if '%d' % rev != node:
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
190 raise ValueError
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 if rev < 0:
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
193 rev = len(self) + rev
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
194 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
195 raise ValueError
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
196
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
197 return self.node(rev)
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
198 except (ValueError, OverflowError):
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
199 pass
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
200
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
201 if len(node) == 40:
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
202 try:
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
203 rawnode = bin(node)
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
204 self.rev(rawnode)
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
205 return rawnode
37408
dd2753729853 simplestore: shore up lookup errors
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37346
diff changeset
206 except TypeError:
37337
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
207 pass
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
208
37408
dd2753729853 simplestore: shore up lookup errors
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37346
diff changeset
209 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
210
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
211 def linkrev(self, rev):
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
212 validaterev(rev)
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
213
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
214 return self._indexbyrev[rev][b'linkrev']
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
215
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
216 def flags(self, rev):
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
217 validaterev(rev)
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
218
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
219 return self._indexbyrev[rev][b'flags']
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
220
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
221 def deltaparent(self, rev):
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
222 validaterev(rev)
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
223
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
224 p1node = self.parents(self.node(rev))[0]
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
225 return self.rev(p1node)
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
226
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
227 def candelta(self, baserev, rev):
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
228 validaterev(baserev)
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
229 validaterev(rev)
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 ((self.flags(baserev) & revlog.REVIDX_RAWTEXT_CHANGING_FLAGS)
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
232 or (self.flags(rev) & revlog.REVIDX_RAWTEXT_CHANGING_FLAGS)):
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
233 return False
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
234
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
235 return True
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
236
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
237 def rawsize(self, rev):
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
238 validaterev(rev)
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
239 node = self.node(rev)
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
240 return len(self.revision(node, raw=True))
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
241
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
242 def _processflags(self, text, flags, operation, raw=False):
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
243 if flags == 0:
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
244 return text, True
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
245
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
246 validatehash = True
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
247 # Depending on the operation (read or write), the order might be
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
248 # reversed due to non-commutative transforms.
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
249 orderedflags = revlog.REVIDX_FLAGS_ORDER
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
250 if operation == 'write':
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
251 orderedflags = reversed(orderedflags)
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 for flag in orderedflags:
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
254 # If a flagprocessor has been registered for a known flag, apply the
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
255 # related operation transform and update result tuple.
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
256 if flag & flags:
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
257 vhash = True
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
258
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
259 if flag not in revlog._flagprocessors:
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
260 message = _("missing processor for flag '%#x'") % (flag)
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
261 raise revlog.RevlogError(message)
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
262
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
263 processor = revlog._flagprocessors[flag]
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
264 if processor is not None:
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
265 readtransform, writetransform, rawtransform = processor
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
266
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
267 if raw:
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
268 vhash = rawtransform(self, text)
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
269 elif operation == 'read':
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
270 text, vhash = readtransform(self, text)
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
271 else: # write operation
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
272 text, vhash = writetransform(self, text)
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
273 validatehash = validatehash and vhash
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
274
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
275 return text, validatehash
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
276
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
277 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
278 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
279 p1, p2 = self.parents(node)
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
280 if node != revlog.hash(text, p1, p2):
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
281 raise error.RevlogError(_("integrity check failed on %s") %
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
282 self._path)
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 def revision(self, node, raw=False):
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
285 validatenode(node)
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 if node == nullid:
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
288 return b''
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 rev = self.rev(node)
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
291 flags = self.flags(rev)
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
292
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
293 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
294 rawtext = self._svfs.read(path)
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
295
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
296 text, validatehash = self._processflags(rawtext, flags, 'read', raw=raw)
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
297 if validatehash:
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
298 self.checkhash(text, node, rev=rev)
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
299
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
300 return text
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 def read(self, node):
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
303 validatenode(node)
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
304
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
305 revision = self.revision(node)
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
306
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
307 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
308 return revision
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 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
311 return revision[start + 2:]
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
312
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
313 def renamed(self, node):
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
314 validatenode(node)
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
315
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
316 if self.parents(node)[0] != nullid:
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
317 return False
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
318
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
319 fulltext = self.revision(node)
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
320 m = filelog.parsemeta(fulltext)[0]
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
321
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
322 if m and 'copy' in m:
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
323 return m['copy'], bin(m['copyrev'])
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
324
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
325 return False
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 def cmp(self, node, text):
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
328 validatenode(node)
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 t = text
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 if text.startswith(b'\1\n'):
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
333 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
334
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
335 p1, p2 = self.parents(node)
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 revlog.hash(t, p1, p2) == node:
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
338 return False
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 if self.iscensored(self.rev(node)):
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
341 return text != b''
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
342
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
343 if self.renamed(node):
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
344 t2 = self.read(node)
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
345 return t2 != text
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
346
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
347 return True
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
348
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
349 def size(self, rev):
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
350 validaterev(rev)
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 node = self._indexbyrev[rev][b'node']
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
353
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
354 if self.renamed(node):
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
355 return len(self.read(node))
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
356
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
357 if self.iscensored(rev):
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
358 return 0
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
359
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
360 return len(self.revision(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 def iscensored(self, rev):
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
363 validaterev(rev)
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 self.flags(rev) & revlog.REVIDX_ISCENSORED
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 commonancestorsheads(self, a, b):
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
368 validatenode(a)
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
369 validatenode(b)
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
370
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
371 a = self.rev(a)
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
372 b = self.rev(b)
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
373
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
374 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
375 return pycompat.maplist(self.node, ancestors)
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
376
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
377 def descendants(self, revs):
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
378 # 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
379 first = min(revs)
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
380 if first == nullrev:
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
381 for i in self:
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
382 yield i
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
383 return
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
384
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
385 seen = set(revs)
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
386 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
387 for x in self.parentrevs(i):
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
388 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
389 seen.add(i)
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
390 yield i
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
391 break
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
392
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
393 # Required by verify.
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
394 def files(self):
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
395 entries = self._svfs.listdir(self._storepath)
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
396
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
397 # 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
398 # recording.
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
399 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
400
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
401 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
402
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
403 # Required by verify.
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
404 def checksize(self):
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
405 return 0, 0
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
406
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
407 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
408 if meta or text.startswith(b'\1\n'):
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
409 text = filelog.packmeta(meta, text)
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
410
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
411 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
412
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
413 def addrevision(self, text, transaction, linkrev, p1, p2, node=None,
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
414 flags=0):
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
415 validatenode(p1)
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
416 validatenode(p2)
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
417
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
418 if flags:
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
419 node = node or revlog.hash(text, p1, p2)
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
420
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
421 rawtext, validatehash = self._processflags(text, flags, 'write')
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
422
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
423 node = node or revlog.hash(text, p1, p2)
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
424
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
425 if node in self._indexbynode:
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
426 return node
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
427
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
428 if validatehash:
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
429 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
430
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
431 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
432
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
433 self._svfs.write(path, text)
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
434
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
435 self._indexdata.append({
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
436 b'node': node,
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
437 b'p1': p1,
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
438 b'p2': p2,
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
439 b'linkrev': linkrev,
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
440 b'flags': flags,
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
441 })
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
442
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
443 self._reflectindexupdate()
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
444
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
445 return node
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
446
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
447 def _reflectindexupdate(self):
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
448 self._refreshindex()
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
449 self._svfs.write(self._indexpath, cbor.dumps(self._indexdata))
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
450
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
451 def addgroup(self, deltas, linkmapper, transaction, addrevisioncb=None):
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
452 nodes = []
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
453
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
454 transaction.addbackup(self._indexpath)
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
455
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
456 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
457 linkrev = linkmapper(linknode)
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
458
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
459 nodes.append(node)
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
460
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
461 if node in self._indexbynode:
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
462 continue
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 # 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
465 if deltabase == nullid:
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
466 text = mdiff.patch(b'', delta)
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
467 else:
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
468 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
469
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
470 self.addrevision(text, transaction, linkrev, p1, p2, flags)
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
471
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
472 if addrevisioncb:
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
473 addrevisioncb(self, node)
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
474
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
475 return nodes
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
476
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
477 def revdiff(self, rev1, rev2):
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
478 validaterev(rev1)
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
479 validaterev(rev2)
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
480
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
481 node1 = self.node(rev1)
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
482 node2 = self.node(rev2)
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
483
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
484 return mdiff.textdiff(self.revision(node1, raw=True),
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
485 self.revision(node2, raw=True))
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 def headrevs(self):
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
488 # Assume all revisions are heads by default.
37341
d62d2e346acf simplestorerepo: avoid shadowing dict in list comprehension over dict
Augie Fackler <augie@google.com>
parents: 37338
diff changeset
489 revishead = {rev: True for rev in self._indexbyrev}
37337
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
490
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
491 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
492 # Unset head flag for all seen parents.
37341
d62d2e346acf simplestorerepo: avoid shadowing dict in list comprehension over dict
Augie Fackler <augie@google.com>
parents: 37338
diff changeset
493 revishead[self.rev(entry[b'p1'])] = False
d62d2e346acf simplestorerepo: avoid shadowing dict in list comprehension over dict
Augie Fackler <augie@google.com>
parents: 37338
diff changeset
494 revishead[self.rev(entry[b'p2'])] = False
37337
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
495
37341
d62d2e346acf simplestorerepo: avoid shadowing dict in list comprehension over dict
Augie Fackler <augie@google.com>
parents: 37338
diff changeset
496 return [rev for rev, ishead in sorted(revishead.items())
37337
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
497 if ishead]
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
498
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
499 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
500 # This is copied from revlog.py.
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
501 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
502 if not len(self):
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
503 return [nullid]
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
504 return [self.node(r) for r in self.headrevs()]
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
505
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
506 if start is None:
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
507 start = nullid
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
508 if stop is None:
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
509 stop = []
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
510 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
511 startrev = self.rev(start)
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
512 reachable = {startrev}
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
513 heads = {startrev}
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
514
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
515 parentrevs = self.parentrevs
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
516 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
517 for p in parentrevs(r):
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
518 if p in reachable:
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
519 if r not in stoprevs:
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
520 reachable.add(r)
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
521 heads.add(r)
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
522 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
523 heads.remove(p)
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 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
526
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
527 def children(self, node):
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
528 validatenode(node)
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
529
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
530 # 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
531 c = []
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
532 p = self.rev(node)
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
533 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
534 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
535 if prevs:
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
536 for pr in prevs:
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
537 if pr == p:
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
538 c.append(self.node(r))
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
539 elif p == nullrev:
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
540 c.append(self.node(r))
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
541 return c
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
542
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
543 def getstrippoint(self, minlink):
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
544
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
545 # This is largely a copy of revlog.getstrippoint().
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
546 brokenrevs = set()
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
547 strippoint = len(self)
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
548
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
549 heads = {}
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
550 futurelargelinkrevs = set()
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
551 for head in self.headrevs():
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
552 headlinkrev = self.linkrev(head)
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
553 heads[head] = headlinkrev
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
554 if headlinkrev >= minlink:
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
555 futurelargelinkrevs.add(headlinkrev)
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 # This algorithm involves walking down the rev graph, starting at the
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
558 # heads. Since the revs are topologically sorted according to linkrev,
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
559 # once all head linkrevs are below the minlink, we know there are
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
560 # no more revs that could have a linkrev greater than minlink.
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
561 # So we can stop walking.
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
562 while futurelargelinkrevs:
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
563 strippoint -= 1
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
564 linkrev = heads.pop(strippoint)
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
565
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
566 if linkrev < minlink:
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
567 brokenrevs.add(strippoint)
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
568 else:
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
569 futurelargelinkrevs.remove(linkrev)
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
570
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
571 for p in self.parentrevs(strippoint):
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
572 if p != nullrev:
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
573 plinkrev = self.linkrev(p)
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
574 heads[p] = plinkrev
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
575 if plinkrev >= minlink:
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
576 futurelargelinkrevs.add(plinkrev)
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
577
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
578 return strippoint, brokenrevs
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
579
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
580 def strip(self, minlink, transaction):
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
581 if not len(self):
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
582 return
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
583
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
584 rev, _ignored = self.getstrippoint(minlink)
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
585 if rev == len(self):
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
586 return
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
587
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
588 # 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
589 self._indexdata[rev:] = []
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
590 self._reflectindexupdate()
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
591
37415
c2c8962a9465 simplestore: use a custom store for the simple store repo
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37408
diff changeset
592 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
593 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
594 return False
c2c8962a9465 simplestore: use a custom store for the simple store repo
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37408
diff changeset
595
c2c8962a9465 simplestore: use a custom store for the simple store repo
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37408
diff changeset
596 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
597 return False
c2c8962a9465 simplestore: use a custom store for the simple store repo
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37408
diff changeset
598
c2c8962a9465 simplestore: use a custom store for the simple store repo
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37408
diff changeset
599 # 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
600 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
601 return False
c2c8962a9465 simplestore: use a custom store for the simple store repo
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37408
diff changeset
602
c2c8962a9465 simplestore: use a custom store for the simple store repo
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37408
diff changeset
603 # 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
604 return True
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 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
607 def datafiles(self):
c2c8962a9465 simplestore: use a custom store for the simple store repo
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37408
diff changeset
608 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
609 yield x
c2c8962a9465 simplestore: use a custom store for the simple store repo
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37408
diff changeset
610
c2c8962a9465 simplestore: use a custom store for the simple store repo
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37408
diff changeset
611 # 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
612 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
613
c2c8962a9465 simplestore: use a custom store for the simple store repo
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37408
diff changeset
614 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
615 try:
c2c8962a9465 simplestore: use a custom store for the simple store repo
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37408
diff changeset
616 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
617 except KeyError:
c2c8962a9465 simplestore: use a custom store for the simple store repo
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37408
diff changeset
618 unencoded = None
c2c8962a9465 simplestore: use a custom store for the simple store repo
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37408
diff changeset
619
c2c8962a9465 simplestore: use a custom store for the simple store repo
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37408
diff changeset
620 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
621
37337
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
622 def reposetup(ui, repo):
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
623 if not repo.local():
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
624 return
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
625
37346
45a4799174a1 tests: disallow using simple store repo with bundlerepo
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37341
diff changeset
626 if isinstance(repo, bundlerepo.bundlerepository):
45a4799174a1 tests: disallow using simple store repo with bundlerepo
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37341
diff changeset
627 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
628
37337
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
629 class simplestorerepo(repo.__class__):
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
630 def file(self, f):
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
631 return filestorage(self.svfs, f)
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
632
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
633 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
634
c2c8962a9465 simplestore: use a custom store for the simple store repo
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37408
diff changeset
635 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
636 supported.add(REQUIREMENT)
c2c8962a9465 simplestore: use a custom store for the simple store repo
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37408
diff changeset
637
c2c8962a9465 simplestore: use a custom store for the simple store repo
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37408
diff changeset
638 def newreporequirements(orig, repo):
c2c8962a9465 simplestore: use a custom store for the simple store repo
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37408
diff changeset
639 """Modifies default requirements for new repos to use the simple store."""
c2c8962a9465 simplestore: use a custom store for the simple store repo
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37408
diff changeset
640 requirements = orig(repo)
c2c8962a9465 simplestore: use a custom store for the simple store repo
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37408
diff changeset
641
c2c8962a9465 simplestore: use a custom store for the simple store repo
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37408
diff changeset
642 # 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
643 # 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
644 # 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
645 #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
646 # requirements.remove('fncache')
c2c8962a9465 simplestore: use a custom store for the simple store repo
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37408
diff changeset
647 #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
648 # requirements.remove('dotencode')
c2c8962a9465 simplestore: use a custom store for the simple store repo
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37408
diff changeset
649
c2c8962a9465 simplestore: use a custom store for the simple store repo
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37408
diff changeset
650 requirements.add(REQUIREMENT)
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 return requirements
c2c8962a9465 simplestore: use a custom store for the simple store repo
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37408
diff changeset
653
c2c8962a9465 simplestore: use a custom store for the simple store repo
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37408
diff changeset
654 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
655 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
656 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
657
c2c8962a9465 simplestore: use a custom store for the simple store repo
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37408
diff changeset
658 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
659
37417
76d2115cb817 verify: allow suppressing warnings about extra files
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37415
diff changeset
660 def verifierinit(orig, self, *args, **kwargs):
76d2115cb817 verify: allow suppressing warnings about extra files
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37415
diff changeset
661 orig(self, *args, **kwargs)
76d2115cb817 verify: allow suppressing warnings about extra files
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37415
diff changeset
662
76d2115cb817 verify: allow suppressing warnings about extra files
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37415
diff changeset
663 # 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
664 # advertised. So suppress these warnings.
76d2115cb817 verify: allow suppressing warnings about extra files
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37415
diff changeset
665 self.warnorphanstorefiles = False
76d2115cb817 verify: allow suppressing warnings about extra files
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37415
diff changeset
666
37415
c2c8962a9465 simplestore: use a custom store for the simple store repo
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37408
diff changeset
667 def extsetup(ui):
c2c8962a9465 simplestore: use a custom store for the simple store repo
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37408
diff changeset
668 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
669
c2c8962a9465 simplestore: use a custom store for the simple store repo
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37408
diff changeset
670 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
671 newreporequirements)
c2c8962a9465 simplestore: use a custom store for the simple store repo
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37408
diff changeset
672 extensions.wrapfunction(store, 'store', makestore)
37417
76d2115cb817 verify: allow suppressing warnings about extra files
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37415
diff changeset
673 extensions.wrapfunction(verify.verifier, '__init__', verifierinit)