annotate tests/simplestorerepo.py @ 37337:d257c5f2a940

tests: add test extension implementing custom filelog storage In order to better support partial clones, we'll need alternate repository storage mechanisms that aren't based on revlogs. Today, the interface for repository storage isn't very well defined. And there are various layering violations and assumptions made throughout the code that storage is backed by revlogs. In order to support alternate storage mechanisms, we'll need to formally declare and adhere to interfaces for storage. This will be a long, arduous process. This commit creates an extension that implements non-revlog storage for files. It defines a custom type that quacks like the existing revlog/filelog API but isn't backed by a revlog. The backing storage is - for simplicity reasons - a CBOR index and per-node files representing fulltext data. The localrepository class is modified so file(f) returns instances of this class instead of filelog instances. The purpose of this extension is to tease out what the actual filelog interface is - based on running the test harness - so we can formalize that interface and then implement a *real* alternate storage backend. Using `run-tests.py --extra-config-opt` to run the test harness with this extension enabled yields 83 failures out of 634 ran tests. The most common test failures are due to: * Issues with `hg verify` * LFS and largefiles (probably flags processing related) * Narrow. * Any test touching or inspecting individual filelog paths. * help and error output that is confused by the presence of an extension. * `hg debug*` commands doing low-level, revlog-y things. An 88% pass rate is pretty good for an initial implementation if you ask me! There is a bit of duplicate code in the new extension. That's by design: a point of this code is to tease out dependencies on revlog. That being said, there is opportunity to consolidate code by moving things out of the revlog API. For example, DAG traversal operations don't necessarily need to be implemented at the storage level. (Although for performance reasons they probably do.) Once we have a more well-defined interface, we could probably define the default implementations in terms of the base interface, pull those in via class inheritance, and have implementations override with faster versions if they so choose. (Or something like that.) But for now, the duplicate code should be acceptable. Differential Revision: https://phab.mercurial-scm.org/D3029
author Gregory Szorc <gregory.szorc@gmail.com>
date Wed, 04 Apr 2018 11:37:07 -0700
parents
children cbc4425e81b5
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
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
8 from __future__ import absolute_import
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
9
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
10 from mercurial.i18n import _
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
11 from mercurial.node import (
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
12 bin,
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
13 hex,
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
14 nullid,
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
15 nullrev,
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
16 )
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
17 from mercurial.thirdparty import (
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
18 cbor,
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
19 )
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
20 from mercurial import (
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
21 ancestor,
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
22 error,
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
23 filelog,
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
24 mdiff,
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
25 pycompat,
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
26 revlog,
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
27 )
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
28
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
29 # 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
30 # 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
31 # 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
32 # leave the attribute unspecified.
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
33 testedwith = 'ships-with-hg-core'
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
34
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
35 def validatenode(node):
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
36 if isinstance(node, int):
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
37 raise ValueError('expected node; got int')
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
38
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
39 if len(node) != 20:
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
40 raise ValueError('expected 20 byte node')
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
41
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
42 def validaterev(rev):
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
43 if not isinstance(rev, int):
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
44 raise ValueError('expected int')
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
45
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
46 class filestorage(object):
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
47 """Implements storage for a tracked path.
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
48
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
49 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
50 path.
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
51
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
52 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
53
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
54 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
55 """
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
56
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
57 def __init__(self, svfs, path):
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
58 self._svfs = svfs
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
59 self._path = path
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
60
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
61 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
62 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
63
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
64 indexdata = self._svfs.tryread(self._indexpath)
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
65 if indexdata:
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
66 indexdata = cbor.loads(indexdata)
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 self._indexdata = indexdata or []
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
69 self._indexbynode = {}
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
70 self._indexbyrev = {}
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
71 self.index = []
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
72 self._refreshindex()
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
73
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
74 # This is used by changegroup code :/
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
75 self._generaldelta = True
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
76 self.storedeltachains = False
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 self.version = 1
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
79
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
80 def _refreshindex(self):
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
81 self._indexbynode.clear()
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
82 self._indexbyrev.clear()
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
83 self.index = []
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
84
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
85 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
86 self._indexbynode[entry[b'node']] = entry
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
87 self._indexbyrev[i] = entry
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
88
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
89 self._indexbynode[nullid] = {
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
90 b'node': nullid,
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
91 b'p1': nullid,
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
92 b'p2': nullid,
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
93 b'linkrev': nullrev,
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
94 b'flags': 0,
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
95 }
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
96
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
97 self._indexbyrev[nullrev] = {
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
98 b'node': nullid,
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
99 b'p1': nullid,
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
100 b'p2': nullid,
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
101 b'linkrev': nullrev,
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
102 b'flags': 0,
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
103 }
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
104
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
105 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
106 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
107
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
108 # 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
109 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
110 entry[b'node']))
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
111
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
112 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
113
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
114 def __len__(self):
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
115 return len(self._indexdata)
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
116
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
117 def __iter__(self):
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
118 return iter(range(len(self)))
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
119
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
120 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
121 step = 1
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
122 if stop is not None:
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
123 if start > stop:
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
124 step = -1
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 stop += step
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
127 else:
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
128 stop = len(self)
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
129
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
130 return range(start, stop, step)
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
131
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
132 def parents(self, node):
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
133 validatenode(node)
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
134
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
135 if node not in self._indexbynode:
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
136 raise KeyError('unknown node')
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
137
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
138 entry = self._indexbynode[node]
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 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
141
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
142 def parentrevs(self, rev):
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
143 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
144 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
145
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
146 def rev(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 # Will raise KeyError.
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
150 self._indexbynode[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 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
153 if entry[b'node'] == node:
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
154 return rev
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 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
157
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
158 def node(self, rev):
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
159 validaterev(rev)
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
160
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
161 return self._indexbyrev[rev][b'node']
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
162
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
163 def lookup(self, node):
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
164 if isinstance(node, int):
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
165 return self.node(node)
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
166
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
167 if len(node) == 20:
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
168 try:
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
169 self.rev(node)
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
170 return node
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
171 except LookupError:
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
172 pass
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 try:
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
175 rev = int(node)
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
176 if '%d' % rev != node:
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
177 raise ValueError
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 if rev < 0:
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
180 rev = len(self) + rev
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
181 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
182 raise ValueError
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
183
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
184 return self.node(rev)
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
185 except (ValueError, OverflowError):
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
186 pass
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
187
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
188 if len(node) == 40:
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
189 try:
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
190 rawnode = bin(node)
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
191 self.rev(rawnode)
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
192 return rawnode
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
193 except (TypeError, LookupError):
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
194 pass
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
195
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
196 raise LookupError(node, self._path, _('invalid lookup input'))
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
197
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
198 def linkrev(self, rev):
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
199 validaterev(rev)
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 return self._indexbyrev[rev][b'linkrev']
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
202
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
203 def flags(self, rev):
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
204 validaterev(rev)
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
205
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
206 return self._indexbyrev[rev][b'flags']
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
207
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
208 def deltaparent(self, rev):
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
209 validaterev(rev)
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 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
212 return self.rev(p1node)
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 def candelta(self, baserev, rev):
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
215 validaterev(baserev)
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
216 validaterev(rev)
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
217
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
218 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
219 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
220 return False
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
221
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
222 return True
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 def rawsize(self, rev):
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
225 validaterev(rev)
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
226 node = self.node(rev)
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
227 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
228
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
229 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
230 if flags == 0:
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
231 return text, True
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
232
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
233 validatehash = True
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
234 # 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
235 # reversed due to non-commutative transforms.
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
236 orderedflags = revlog.REVIDX_FLAGS_ORDER
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
237 if operation == 'write':
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
238 orderedflags = reversed(orderedflags)
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
239
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
240 for flag in orderedflags:
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
241 # 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
242 # 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
243 if flag & flags:
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
244 vhash = 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 if flag not in revlog._flagprocessors:
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
247 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
248 raise revlog.RevlogError(message)
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
249
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
250 processor = revlog._flagprocessors[flag]
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
251 if processor is not None:
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
252 readtransform, writetransform, rawtransform = processor
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
253
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
254 if raw:
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
255 vhash = rawtransform(self, text)
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
256 elif operation == 'read':
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
257 text, vhash = readtransform(self, text)
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
258 else: # write operation
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
259 text, vhash = writetransform(self, text)
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
260 validatehash = validatehash and vhash
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
261
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
262 return text, validatehash
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
263
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
264 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
265 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
266 p1, p2 = self.parents(node)
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
267 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
268 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
269 self._path)
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
270
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
271 def revision(self, node, raw=False):
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
272 validatenode(node)
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
273
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
274 if node == nullid:
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
275 return b''
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 self._indexbynode[node]
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
278
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
279 rev = self.rev(node)
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
280 flags = self.flags(rev)
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
281
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
282 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
283 rawtext = self._svfs.read(path)
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
284
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
285 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
286 if validatehash:
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
287 self.checkhash(text, node, rev=rev)
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
288
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
289 return text
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
290
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
291 def read(self, node):
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
292 validatenode(node)
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
293
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
294 revision = self.revision(node)
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 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
297 return revision
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
298
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
299 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
300 return revision[start + 2:]
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 renamed(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 if self.parents(node)[0] != nullid:
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
306 return False
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
307
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
308 fulltext = self.revision(node)
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
309 m = filelog.parsemeta(fulltext)[0]
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
310
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
311 if m and 'copy' in m:
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
312 return m['copy'], bin(m['copyrev'])
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
313
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
314 return False
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 def cmp(self, node, text):
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
317 validatenode(node)
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 t = text
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
320
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
321 if text.startswith(b'\1\n'):
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
322 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
323
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
324 p1, p2 = self.parents(node)
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
325
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
326 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
327 return False
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
328
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
329 if self.iscensored(self.rev(node)):
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
330 return text != b''
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 self.renamed(node):
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
333 t2 = self.read(node)
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
334 return t2 != text
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
335
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
336 return True
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
337
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
338 def size(self, rev):
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
339 validaterev(rev)
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
340
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
341 node = self._indexbyrev[rev][b'node']
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
342
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
343 if self.renamed(node):
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
344 return len(self.read(node))
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
345
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
346 if self.iscensored(rev):
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
347 return 0
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 return len(self.revision(node))
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
350
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
351 def iscensored(self, rev):
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
352 validaterev(rev)
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 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
355
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
356 def commonancestorsheads(self, a, b):
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
357 validatenode(a)
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
358 validatenode(b)
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 a = self.rev(a)
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
361 b = self.rev(b)
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
362
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
363 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
364 return pycompat.maplist(self.node, ancestors)
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
365
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
366 def descendants(self, revs):
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
367 # 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
368 first = min(revs)
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
369 if first == nullrev:
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
370 for i in self:
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
371 yield i
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
372 return
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 seen = set(revs)
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
375 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
376 for x in self.parentrevs(i):
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
377 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
378 seen.add(i)
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
379 yield i
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
380 break
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
381
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
382 # Required by verify.
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
383 def files(self):
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
384 entries = self._svfs.listdir(self._storepath)
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
385
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
386 # 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
387 # recording.
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
388 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
389
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
390 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
391
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
392 # Required by verify.
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
393 def checksize(self):
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
394 return 0, 0
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
395
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
396 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
397 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
398 text = filelog.packmeta(meta, text)
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
399
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
400 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
401
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
402 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
403 flags=0):
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
404 validatenode(p1)
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
405 validatenode(p2)
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 if flags:
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
408 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
409
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
410 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
411
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
412 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
413
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
414 if node in self._indexbynode:
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
415 return node
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
416
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
417 if validatehash:
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
418 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
419
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
420 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
421
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
422 self._svfs.write(path, text)
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
423
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
424 self._indexdata.append({
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
425 b'node': node,
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
426 b'p1': p1,
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
427 b'p2': p2,
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
428 b'linkrev': linkrev,
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
429 b'flags': flags,
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
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
432 self._reflectindexupdate()
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
433
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
434 return node
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
435
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
436 def _reflectindexupdate(self):
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
437 self._refreshindex()
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
438 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
439
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
440 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
441 nodes = []
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 transaction.addbackup(self._indexpath)
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 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
446 linkrev = linkmapper(linknode)
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
447
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
448 nodes.append(node)
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
449
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
450 if node in self._indexbynode:
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
451 continue
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
452
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
453 # 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
454 if deltabase == nullid:
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
455 text = mdiff.patch(b'', delta)
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
456 else:
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
457 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
458
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
459 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
460
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
461 if addrevisioncb:
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
462 addrevisioncb(self, node)
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 return nodes
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
465
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
466 def revdiff(self, rev1, rev2):
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
467 validaterev(rev1)
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
468 validaterev(rev2)
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 node1 = self.node(rev1)
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
471 node2 = self.node(rev2)
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
472
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
473 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
474 self.revision(node2, raw=True))
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
475
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
476 def headrevs(self):
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
477 # Assume all revisions are heads by default.
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
478 ishead = {rev: True for rev in self._indexbyrev}
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
479
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
480 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
481 # Unset head flag for all seen parents.
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
482 ishead[self.rev(entry[b'p1'])] = False
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
483 ishead[self.rev(entry[b'p2'])] = False
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
484
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
485 return [rev for rev, ishead in sorted(ishead.items())
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
486 if ishead]
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
487
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
488 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
489 # This is copied from revlog.py.
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
490 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
491 if not len(self):
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
492 return [nullid]
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
493 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
494
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
495 if start is None:
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
496 start = nullid
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
497 if stop is None:
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
498 stop = []
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
499 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
500 startrev = self.rev(start)
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
501 reachable = {startrev}
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
502 heads = {startrev}
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
503
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
504 parentrevs = self.parentrevs
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
505 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
506 for p in parentrevs(r):
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
507 if p in reachable:
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
508 if r not in stoprevs:
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
509 reachable.add(r)
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
510 heads.add(r)
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
511 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
512 heads.remove(p)
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
513
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
514 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
515
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
516 def children(self, node):
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
517 validatenode(node)
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
518
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
519 # 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
520 c = []
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
521 p = self.rev(node)
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
522 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
523 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
524 if prevs:
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
525 for pr in prevs:
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
526 if pr == p:
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
527 c.append(self.node(r))
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
528 elif p == nullrev:
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
529 c.append(self.node(r))
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
530 return c
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
531
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
532 def getstrippoint(self, minlink):
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
533
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
534 # 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
535 brokenrevs = set()
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
536 strippoint = len(self)
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
537
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
538 heads = {}
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
539 futurelargelinkrevs = set()
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
540 for head in self.headrevs():
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
541 headlinkrev = self.linkrev(head)
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
542 heads[head] = headlinkrev
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
543 if headlinkrev >= minlink:
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
544 futurelargelinkrevs.add(headlinkrev)
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
545
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
546 # 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
547 # 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
548 # 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
549 # 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
550 # So we can stop walking.
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
551 while futurelargelinkrevs:
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
552 strippoint -= 1
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
553 linkrev = heads.pop(strippoint)
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
554
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
555 if linkrev < minlink:
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
556 brokenrevs.add(strippoint)
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
557 else:
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
558 futurelargelinkrevs.remove(linkrev)
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
559
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
560 for p in self.parentrevs(strippoint):
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
561 if p != nullrev:
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
562 plinkrev = self.linkrev(p)
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
563 heads[p] = plinkrev
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
564 if plinkrev >= minlink:
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
565 futurelargelinkrevs.add(plinkrev)
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
566
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
567 return strippoint, brokenrevs
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
568
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
569 def strip(self, minlink, transaction):
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
570 if not len(self):
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
571 return
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
572
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
573 rev, _ignored = self.getstrippoint(minlink)
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
574 if rev == len(self):
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
575 return
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
576
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
577 # 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
578 self._indexdata[rev:] = []
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
579 self._reflectindexupdate()
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
580
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
581 def reposetup(ui, repo):
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
582 if not repo.local():
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
583 return
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
584
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
585 class simplestorerepo(repo.__class__):
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
586 def file(self, f):
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
587 return filestorage(self.svfs, f)
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
588
d257c5f2a940 tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
589 repo.__class__ = simplestorerepo