Mercurial > hg
annotate tests/simplestorerepo.py @ 39773:2cd93a8d4bde
revlog: drop RevlogError alias (API)
error.RevlogError was moved from revlog.py in 08cabecfa8a8 in
2009. revlog.RevlogError has remained as an alias ever since.
Let's drop the alias and use error.RevlogError directly.
Differential Revision: https://phab.mercurial-scm.org/D4651
author | Gregory Szorc <gregory.szorc@gmail.com> |
---|---|
date | Tue, 18 Sep 2018 16:18:37 -0700 |
parents | 41aa5dced975 |
children | b63dee7bd0d9 |
rev | line source |
---|---|
37337
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1 # simplestorerepo.py - Extension that swaps in alternate repository storage. |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
2 # |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
3 # Copyright 2018 Gregory Szorc <gregory.szorc@gmail.com> |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
4 # |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
5 # This software may be used and distributed according to the terms of the |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
6 # GNU General Public License version 2 or any later version. |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
7 |
37338
cbc4425e81b5
tests: conditionalize tests based on presence of revlogs for files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37337
diff
changeset
|
8 # To use this with the test suite: |
cbc4425e81b5
tests: conditionalize tests based on presence of revlogs for files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37337
diff
changeset
|
9 # |
cbc4425e81b5
tests: conditionalize tests based on presence of revlogs for files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37337
diff
changeset
|
10 # $ HGREPOFEATURES="simplestore" ./run-tests.py \ |
cbc4425e81b5
tests: conditionalize tests based on presence of revlogs for files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37337
diff
changeset
|
11 # --extra-config-opt extensions.simplestore=`pwd`/simplestorerepo.py |
cbc4425e81b5
tests: conditionalize tests based on presence of revlogs for files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37337
diff
changeset
|
12 |
37337
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
13 from __future__ import absolute_import |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
14 |
37415
c2c8962a9465
simplestore: use a custom store for the simple store repo
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37408
diff
changeset
|
15 import stat |
c2c8962a9465
simplestore: use a custom store for the simple store repo
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37408
diff
changeset
|
16 |
37337
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
17 from mercurial.i18n import _ |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
18 from mercurial.node import ( |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
19 bin, |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
20 hex, |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
21 nullid, |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
22 nullrev, |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
23 ) |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
24 from mercurial.thirdparty import ( |
39231
b41d023a412a
repository: establish API for emitting revision deltas
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38547
diff
changeset
|
25 attr, |
37337
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
26 cbor, |
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 from mercurial import ( |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
29 ancestor, |
37346
45a4799174a1
tests: disallow using simple store repo with bundlerepo
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37341
diff
changeset
|
30 bundlerepo, |
37337
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
31 error, |
37415
c2c8962a9465
simplestore: use a custom store for the simple store repo
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37408
diff
changeset
|
32 extensions, |
c2c8962a9465
simplestore: use a custom store for the simple store repo
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37408
diff
changeset
|
33 localrepo, |
37337
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
34 mdiff, |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
35 pycompat, |
37441
a3202fa83aff
filelog: declare that filelog implements a storage interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37436
diff
changeset
|
36 repository, |
37337
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
37 revlog, |
37415
c2c8962a9465
simplestore: use a custom store for the simple store repo
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37408
diff
changeset
|
38 store, |
37417
76d2115cb817
verify: allow suppressing warnings about extra files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37415
diff
changeset
|
39 verify, |
37337
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
40 ) |
38547
404eab7ff33f
tests: use interfaceutil in simplestorerepo
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37442
diff
changeset
|
41 from mercurial.utils import ( |
404eab7ff33f
tests: use interfaceutil in simplestorerepo
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37442
diff
changeset
|
42 interfaceutil, |
404eab7ff33f
tests: use interfaceutil in simplestorerepo
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37442
diff
changeset
|
43 ) |
37337
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
44 |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
45 # 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
|
46 # 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
|
47 # 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
|
48 # leave the attribute unspecified. |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
49 testedwith = 'ships-with-hg-core' |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
50 |
37415
c2c8962a9465
simplestore: use a custom store for the simple store repo
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37408
diff
changeset
|
51 REQUIREMENT = 'testonly-simplestore' |
c2c8962a9465
simplestore: use a custom store for the simple store repo
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37408
diff
changeset
|
52 |
37337
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
53 def validatenode(node): |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
54 if isinstance(node, int): |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
55 raise ValueError('expected node; got int') |
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 if len(node) != 20: |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
58 raise ValueError('expected 20 byte node') |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
59 |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
60 def validaterev(rev): |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
61 if not isinstance(rev, int): |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
62 raise ValueError('expected int') |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
63 |
39231
b41d023a412a
repository: establish API for emitting revision deltas
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38547
diff
changeset
|
64 @interfaceutil.implementer(repository.irevisiondelta) |
b41d023a412a
repository: establish API for emitting revision deltas
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38547
diff
changeset
|
65 @attr.s(slots=True, frozen=True) |
b41d023a412a
repository: establish API for emitting revision deltas
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38547
diff
changeset
|
66 class simplestorerevisiondelta(object): |
b41d023a412a
repository: establish API for emitting revision deltas
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38547
diff
changeset
|
67 node = attr.ib() |
b41d023a412a
repository: establish API for emitting revision deltas
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38547
diff
changeset
|
68 p1node = attr.ib() |
b41d023a412a
repository: establish API for emitting revision deltas
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38547
diff
changeset
|
69 p2node = attr.ib() |
b41d023a412a
repository: establish API for emitting revision deltas
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38547
diff
changeset
|
70 basenode = attr.ib() |
b41d023a412a
repository: establish API for emitting revision deltas
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38547
diff
changeset
|
71 linknode = attr.ib() |
b41d023a412a
repository: establish API for emitting revision deltas
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38547
diff
changeset
|
72 flags = attr.ib() |
b41d023a412a
repository: establish API for emitting revision deltas
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38547
diff
changeset
|
73 baserevisionsize = attr.ib() |
b41d023a412a
repository: establish API for emitting revision deltas
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38547
diff
changeset
|
74 revision = attr.ib() |
b41d023a412a
repository: establish API for emitting revision deltas
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38547
diff
changeset
|
75 delta = attr.ib() |
b41d023a412a
repository: establish API for emitting revision deltas
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38547
diff
changeset
|
76 |
38547
404eab7ff33f
tests: use interfaceutil in simplestorerepo
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37442
diff
changeset
|
77 @interfaceutil.implementer(repository.ifilestorage) |
37337
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
78 class filestorage(object): |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
79 """Implements storage for a tracked path. |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
80 |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
81 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
|
82 path. |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
83 |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
84 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
|
85 |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
86 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
|
87 """ |
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 def __init__(self, svfs, path): |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
90 self._svfs = svfs |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
91 self._path = path |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
92 |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
93 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
|
94 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
|
95 |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
96 indexdata = self._svfs.tryread(self._indexpath) |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
97 if indexdata: |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
98 indexdata = cbor.loads(indexdata) |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
99 |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
100 self._indexdata = indexdata or [] |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
101 self._indexbynode = {} |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
102 self._indexbyrev = {} |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
103 self.index = [] |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
104 self._refreshindex() |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
105 |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
106 # This is used by changegroup code :/ |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
107 self._generaldelta = True |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
108 |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
109 self.version = 1 |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
110 |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
111 def _refreshindex(self): |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
112 self._indexbynode.clear() |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
113 self._indexbyrev.clear() |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
114 self.index = [] |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
115 |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
116 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
|
117 self._indexbynode[entry[b'node']] = entry |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
118 self._indexbyrev[i] = entry |
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 self._indexbynode[nullid] = { |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
121 b'node': nullid, |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
122 b'p1': nullid, |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
123 b'p2': nullid, |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
124 b'linkrev': nullrev, |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
125 b'flags': 0, |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
126 } |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
127 |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
128 self._indexbyrev[nullrev] = { |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
129 b'node': nullid, |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
130 b'p1': nullid, |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
131 b'p2': nullid, |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
132 b'linkrev': nullrev, |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
133 b'flags': 0, |
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 |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
136 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
|
137 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
|
138 |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
139 # 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
|
140 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
|
141 entry[b'node'])) |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
142 |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
143 self.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
|
144 |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
145 def __len__(self): |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
146 return len(self._indexdata) |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
147 |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
148 def __iter__(self): |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
149 return iter(range(len(self))) |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
150 |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
151 def revs(self, start=0, stop=None): |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
152 step = 1 |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
153 if stop is not None: |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
154 if start > stop: |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
155 step = -1 |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
156 |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
157 stop += step |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
158 else: |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
159 stop = len(self) |
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 range(start, stop, step) |
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 parents(self, node): |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
164 validatenode(node) |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
165 |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
166 if node not in self._indexbynode: |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
167 raise KeyError('unknown node') |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
168 |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
169 entry = self._indexbynode[node] |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
170 |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
171 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
|
172 |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
173 def parentrevs(self, rev): |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
174 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
|
175 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
|
176 |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
177 def rev(self, node): |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
178 validatenode(node) |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
179 |
37408
dd2753729853
simplestore: shore up lookup errors
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37346
diff
changeset
|
180 try: |
dd2753729853
simplestore: shore up lookup errors
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37346
diff
changeset
|
181 self._indexbynode[node] |
dd2753729853
simplestore: shore up lookup errors
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37346
diff
changeset
|
182 except KeyError: |
dd2753729853
simplestore: shore up lookup errors
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37346
diff
changeset
|
183 raise error.LookupError(node, self._indexpath, _('no node')) |
37337
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
184 |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
185 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
|
186 if entry[b'node'] == node: |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
187 return rev |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
188 |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
189 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
|
190 |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
191 def node(self, rev): |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
192 validaterev(rev) |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
193 |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
194 return self._indexbyrev[rev][b'node'] |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
195 |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
196 def lookup(self, node): |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
197 if isinstance(node, int): |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
198 return self.node(node) |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
199 |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
200 if len(node) == 20: |
37408
dd2753729853
simplestore: shore up lookup errors
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37346
diff
changeset
|
201 self.rev(node) |
dd2753729853
simplestore: shore up lookup errors
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37346
diff
changeset
|
202 return node |
37337
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
203 |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
204 try: |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
205 rev = int(node) |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
206 if '%d' % rev != node: |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
207 raise ValueError |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
208 |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
209 if rev < 0: |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
210 rev = len(self) + rev |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
211 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
|
212 raise ValueError |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
213 |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
214 return self.node(rev) |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
215 except (ValueError, OverflowError): |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
216 pass |
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 len(node) == 40: |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
219 try: |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
220 rawnode = bin(node) |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
221 self.rev(rawnode) |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
222 return rawnode |
37408
dd2753729853
simplestore: shore up lookup errors
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37346
diff
changeset
|
223 except TypeError: |
37337
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
224 pass |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
225 |
37408
dd2753729853
simplestore: shore up lookup errors
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37346
diff
changeset
|
226 raise error.LookupError(node, self._path, _('invalid lookup input')) |
37337
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
227 |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
228 def linkrev(self, rev): |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
229 validaterev(rev) |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
230 |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
231 return self._indexbyrev[rev][b'linkrev'] |
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 def flags(self, rev): |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
234 validaterev(rev) |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
235 |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
236 return self._indexbyrev[rev][b'flags'] |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
237 |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
238 def deltaparent(self, rev): |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
239 validaterev(rev) |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
240 |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
241 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
|
242 return self.rev(p1node) |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
243 |
39234
3682b49e0213
repository: remove candelta() from ifileindex
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39232
diff
changeset
|
244 def _candelta(self, baserev, rev): |
37337
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
245 validaterev(baserev) |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
246 validaterev(rev) |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
247 |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
248 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
|
249 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
|
250 return False |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
251 |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
252 return True |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
253 |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
254 def rawsize(self, rev): |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
255 validaterev(rev) |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
256 node = self.node(rev) |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
257 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
|
258 |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
259 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
|
260 if flags == 0: |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
261 return text, True |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
262 |
37436
9d4f09bfe3ec
simplestore: correctly implement flag processors
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37424
diff
changeset
|
263 if flags & ~revlog.REVIDX_KNOWN_FLAGS: |
9d4f09bfe3ec
simplestore: correctly implement flag processors
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37424
diff
changeset
|
264 raise error.RevlogError(_("incompatible revision flag '%#x'") % |
9d4f09bfe3ec
simplestore: correctly implement flag processors
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37424
diff
changeset
|
265 (flags & ~revlog.REVIDX_KNOWN_FLAGS)) |
9d4f09bfe3ec
simplestore: correctly implement flag processors
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37424
diff
changeset
|
266 |
37337
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
267 validatehash = True |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
268 # 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
|
269 # reversed due to non-commutative transforms. |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
270 orderedflags = revlog.REVIDX_FLAGS_ORDER |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
271 if operation == 'write': |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
272 orderedflags = reversed(orderedflags) |
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 for flag in orderedflags: |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
275 # 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
|
276 # 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
|
277 if flag & flags: |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
278 vhash = True |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
279 |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
280 if flag not in revlog._flagprocessors: |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
281 message = _("missing processor for flag '%#x'") % (flag) |
39773
2cd93a8d4bde
revlog: drop RevlogError alias (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39546
diff
changeset
|
282 raise error.RevlogError(message) |
37337
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
283 |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
284 processor = revlog._flagprocessors[flag] |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
285 if processor is not None: |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
286 readtransform, writetransform, rawtransform = processor |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
287 |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
288 if raw: |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
289 vhash = rawtransform(self, text) |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
290 elif operation == 'read': |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
291 text, vhash = readtransform(self, text) |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
292 else: # write operation |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
293 text, vhash = writetransform(self, text) |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
294 validatehash = validatehash and vhash |
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 return text, validatehash |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
297 |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
298 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
|
299 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
|
300 p1, p2 = self.parents(node) |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
301 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
|
302 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
|
303 self._path) |
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 def revision(self, node, raw=False): |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
306 validatenode(node) |
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 if node == nullid: |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
309 return b'' |
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 rev = self.rev(node) |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
312 flags = self.flags(rev) |
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 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
|
315 rawtext = self._svfs.read(path) |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
316 |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
317 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
|
318 if validatehash: |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
319 self.checkhash(text, node, rev=rev) |
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 return text |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
322 |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
323 def read(self, node): |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
324 validatenode(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 revision = self.revision(node) |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
327 |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
328 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
|
329 return revision |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
330 |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
331 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
|
332 return revision[start + 2:] |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
333 |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
334 def renamed(self, node): |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
335 validatenode(node) |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
336 |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
337 if self.parents(node)[0] != nullid: |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
338 return False |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
339 |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
340 fulltext = self.revision(node) |
37442
0596d27457c6
revlog: move parsemeta() and packmeta() from filelog (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37441
diff
changeset
|
341 m = revlog.parsemeta(fulltext)[0] |
37337
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 m and 'copy' in m: |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
344 return m['copy'], bin(m['copyrev']) |
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 return False |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
347 |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
348 def cmp(self, node, text): |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
349 validatenode(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 t = text |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
352 |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
353 if text.startswith(b'\1\n'): |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
354 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
|
355 |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
356 p1, p2 = self.parents(node) |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
357 |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
358 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
|
359 return False |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
360 |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
361 if self.iscensored(self.rev(node)): |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
362 return text != b'' |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
363 |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
364 if self.renamed(node): |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
365 t2 = self.read(node) |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
366 return t2 != text |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
367 |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
368 return True |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
369 |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
370 def size(self, rev): |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
371 validaterev(rev) |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
372 |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
373 node = self._indexbyrev[rev][b'node'] |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
374 |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
375 if self.renamed(node): |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
376 return len(self.read(node)) |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
377 |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
378 if self.iscensored(rev): |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
379 return 0 |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
380 |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
381 return len(self.revision(node)) |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
382 |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
383 def iscensored(self, rev): |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
384 validaterev(rev) |
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 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
|
387 |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
388 def commonancestorsheads(self, a, b): |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
389 validatenode(a) |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
390 validatenode(b) |
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 a = self.rev(a) |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
393 b = self.rev(b) |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
394 |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
395 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
|
396 return pycompat.maplist(self.node, ancestors) |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
397 |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
398 def descendants(self, revs): |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
399 # 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
|
400 first = min(revs) |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
401 if first == nullrev: |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
402 for i in self: |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
403 yield i |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
404 return |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
405 |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
406 seen = set(revs) |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
407 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
|
408 for x in self.parentrevs(i): |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
409 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
|
410 seen.add(i) |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
411 yield i |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
412 break |
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 # Required by verify. |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
415 def files(self): |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
416 entries = self._svfs.listdir(self._storepath) |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
417 |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
418 # 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
|
419 # recording. |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
420 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
|
421 |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
422 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
|
423 |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
424 # Required by verify. |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
425 def checksize(self): |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
426 return 0, 0 |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
427 |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
428 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
|
429 if meta or text.startswith(b'\1\n'): |
37442
0596d27457c6
revlog: move parsemeta() and packmeta() from filelog (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37441
diff
changeset
|
430 text = revlog.packmeta(meta, text) |
37337
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 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
|
433 |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
434 def addrevision(self, text, transaction, linkrev, p1, p2, node=None, |
37436
9d4f09bfe3ec
simplestore: correctly implement flag processors
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37424
diff
changeset
|
435 flags=revlog.REVIDX_DEFAULT_FLAGS, cachedelta=None): |
37337
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
436 validatenode(p1) |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
437 validatenode(p2) |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
438 |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
439 if flags: |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
440 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
|
441 |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
442 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
|
443 |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
444 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
|
445 |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
446 if node in self._indexbynode: |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
447 return node |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
448 |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
449 if validatehash: |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
450 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
|
451 |
37436
9d4f09bfe3ec
simplestore: correctly implement flag processors
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37424
diff
changeset
|
452 return self._addrawrevision(node, rawtext, transaction, linkrev, p1, p2, |
9d4f09bfe3ec
simplestore: correctly implement flag processors
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37424
diff
changeset
|
453 flags) |
9d4f09bfe3ec
simplestore: correctly implement flag processors
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37424
diff
changeset
|
454 |
9d4f09bfe3ec
simplestore: correctly implement flag processors
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37424
diff
changeset
|
455 def _addrawrevision(self, node, rawtext, transaction, link, p1, p2, flags): |
9d4f09bfe3ec
simplestore: correctly implement flag processors
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37424
diff
changeset
|
456 transaction.addbackup(self._indexpath) |
9d4f09bfe3ec
simplestore: correctly implement flag processors
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37424
diff
changeset
|
457 |
37337
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
458 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
|
459 |
37436
9d4f09bfe3ec
simplestore: correctly implement flag processors
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37424
diff
changeset
|
460 self._svfs.write(path, rawtext) |
37337
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
461 |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
462 self._indexdata.append({ |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
463 b'node': node, |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
464 b'p1': p1, |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
465 b'p2': p2, |
37436
9d4f09bfe3ec
simplestore: correctly implement flag processors
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37424
diff
changeset
|
466 b'linkrev': link, |
37337
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
467 b'flags': flags, |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
468 }) |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
469 |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
470 self._reflectindexupdate() |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
471 |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
472 return node |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
473 |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
474 def _reflectindexupdate(self): |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
475 self._refreshindex() |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
476 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
|
477 |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
478 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
|
479 nodes = [] |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
480 |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
481 transaction.addbackup(self._indexpath) |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
482 |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
483 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
|
484 linkrev = linkmapper(linknode) |
37436
9d4f09bfe3ec
simplestore: correctly implement flag processors
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37424
diff
changeset
|
485 flags = flags or revlog.REVIDX_DEFAULT_FLAGS |
37337
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
486 |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
487 nodes.append(node) |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
488 |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
489 if node in self._indexbynode: |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
490 continue |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
491 |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
492 # 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
|
493 if deltabase == nullid: |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
494 text = mdiff.patch(b'', delta) |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
495 else: |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
496 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
|
497 |
37436
9d4f09bfe3ec
simplestore: correctly implement flag processors
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37424
diff
changeset
|
498 self._addrawrevision(node, text, transaction, linkrev, p1, p2, |
9d4f09bfe3ec
simplestore: correctly implement flag processors
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37424
diff
changeset
|
499 flags) |
37337
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
500 |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
501 if addrevisioncb: |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
502 addrevisioncb(self, node) |
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 return nodes |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
505 |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
506 def revdiff(self, rev1, rev2): |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
507 validaterev(rev1) |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
508 validaterev(rev2) |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
509 |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
510 node1 = self.node(rev1) |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
511 node2 = self.node(rev2) |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
512 |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
513 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
|
514 self.revision(node2, raw=True)) |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
515 |
39231
b41d023a412a
repository: establish API for emitting revision deltas
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38547
diff
changeset
|
516 def emitrevisiondeltas(self, requests): |
b41d023a412a
repository: establish API for emitting revision deltas
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38547
diff
changeset
|
517 for request in requests: |
b41d023a412a
repository: establish API for emitting revision deltas
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38547
diff
changeset
|
518 node = request.node |
b41d023a412a
repository: establish API for emitting revision deltas
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38547
diff
changeset
|
519 rev = self.rev(node) |
b41d023a412a
repository: establish API for emitting revision deltas
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38547
diff
changeset
|
520 |
b41d023a412a
repository: establish API for emitting revision deltas
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38547
diff
changeset
|
521 if request.basenode == nullid: |
b41d023a412a
repository: establish API for emitting revision deltas
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38547
diff
changeset
|
522 baserev = nullrev |
b41d023a412a
repository: establish API for emitting revision deltas
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38547
diff
changeset
|
523 elif request.basenode is not None: |
b41d023a412a
repository: establish API for emitting revision deltas
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38547
diff
changeset
|
524 baserev = self.rev(request.basenode) |
b41d023a412a
repository: establish API for emitting revision deltas
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38547
diff
changeset
|
525 else: |
b41d023a412a
repository: establish API for emitting revision deltas
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38547
diff
changeset
|
526 # This is a test extension and we can do simple things |
b41d023a412a
repository: establish API for emitting revision deltas
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38547
diff
changeset
|
527 # for choosing a delta parent. |
b41d023a412a
repository: establish API for emitting revision deltas
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38547
diff
changeset
|
528 baserev = self.deltaparent(rev) |
b41d023a412a
repository: establish API for emitting revision deltas
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38547
diff
changeset
|
529 |
39234
3682b49e0213
repository: remove candelta() from ifileindex
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39232
diff
changeset
|
530 if baserev != nullrev and not self._candelta(baserev, rev): |
39231
b41d023a412a
repository: establish API for emitting revision deltas
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38547
diff
changeset
|
531 baserev = nullrev |
b41d023a412a
repository: establish API for emitting revision deltas
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38547
diff
changeset
|
532 |
b41d023a412a
repository: establish API for emitting revision deltas
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38547
diff
changeset
|
533 revision = None |
b41d023a412a
repository: establish API for emitting revision deltas
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38547
diff
changeset
|
534 delta = None |
b41d023a412a
repository: establish API for emitting revision deltas
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38547
diff
changeset
|
535 baserevisionsize = None |
b41d023a412a
repository: establish API for emitting revision deltas
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38547
diff
changeset
|
536 |
b41d023a412a
repository: establish API for emitting revision deltas
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38547
diff
changeset
|
537 if self.iscensored(baserev) or self.iscensored(rev): |
b41d023a412a
repository: establish API for emitting revision deltas
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38547
diff
changeset
|
538 try: |
b41d023a412a
repository: establish API for emitting revision deltas
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38547
diff
changeset
|
539 revision = self.revision(node, raw=True) |
b41d023a412a
repository: establish API for emitting revision deltas
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38547
diff
changeset
|
540 except error.CensoredNodeError as e: |
b41d023a412a
repository: establish API for emitting revision deltas
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38547
diff
changeset
|
541 revision = e.tombstone |
b41d023a412a
repository: establish API for emitting revision deltas
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38547
diff
changeset
|
542 |
b41d023a412a
repository: establish API for emitting revision deltas
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38547
diff
changeset
|
543 if baserev != nullrev: |
b41d023a412a
repository: establish API for emitting revision deltas
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38547
diff
changeset
|
544 baserevisionsize = self.rawsize(baserev) |
b41d023a412a
repository: establish API for emitting revision deltas
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38547
diff
changeset
|
545 |
b41d023a412a
repository: establish API for emitting revision deltas
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38547
diff
changeset
|
546 elif baserev == nullrev: |
b41d023a412a
repository: establish API for emitting revision deltas
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38547
diff
changeset
|
547 revision = self.revision(node, raw=True) |
b41d023a412a
repository: establish API for emitting revision deltas
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38547
diff
changeset
|
548 else: |
b41d023a412a
repository: establish API for emitting revision deltas
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38547
diff
changeset
|
549 delta = self.revdiff(baserev, rev) |
b41d023a412a
repository: establish API for emitting revision deltas
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38547
diff
changeset
|
550 |
b41d023a412a
repository: establish API for emitting revision deltas
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38547
diff
changeset
|
551 extraflags = revlog.REVIDX_ELLIPSIS if request.ellipsis else 0 |
b41d023a412a
repository: establish API for emitting revision deltas
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38547
diff
changeset
|
552 |
b41d023a412a
repository: establish API for emitting revision deltas
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38547
diff
changeset
|
553 yield simplestorerevisiondelta( |
b41d023a412a
repository: establish API for emitting revision deltas
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38547
diff
changeset
|
554 node=node, |
b41d023a412a
repository: establish API for emitting revision deltas
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38547
diff
changeset
|
555 p1node=request.p1node, |
b41d023a412a
repository: establish API for emitting revision deltas
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38547
diff
changeset
|
556 p2node=request.p2node, |
b41d023a412a
repository: establish API for emitting revision deltas
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38547
diff
changeset
|
557 linknode=request.linknode, |
b41d023a412a
repository: establish API for emitting revision deltas
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38547
diff
changeset
|
558 basenode=self.node(baserev), |
b41d023a412a
repository: establish API for emitting revision deltas
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38547
diff
changeset
|
559 flags=self.flags(rev) | extraflags, |
b41d023a412a
repository: establish API for emitting revision deltas
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38547
diff
changeset
|
560 baserevisionsize=baserevisionsize, |
b41d023a412a
repository: establish API for emitting revision deltas
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38547
diff
changeset
|
561 revision=revision, |
b41d023a412a
repository: establish API for emitting revision deltas
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38547
diff
changeset
|
562 delta=delta) |
b41d023a412a
repository: establish API for emitting revision deltas
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38547
diff
changeset
|
563 |
37337
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
564 def headrevs(self): |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
565 # Assume all revisions are heads by default. |
37341
d62d2e346acf
simplestorerepo: avoid shadowing dict in list comprehension over dict
Augie Fackler <augie@google.com>
parents:
37338
diff
changeset
|
566 revishead = {rev: True for rev in self._indexbyrev} |
37337
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
567 |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
568 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
|
569 # Unset head flag for all seen parents. |
37341
d62d2e346acf
simplestorerepo: avoid shadowing dict in list comprehension over dict
Augie Fackler <augie@google.com>
parents:
37338
diff
changeset
|
570 revishead[self.rev(entry[b'p1'])] = False |
d62d2e346acf
simplestorerepo: avoid shadowing dict in list comprehension over dict
Augie Fackler <augie@google.com>
parents:
37338
diff
changeset
|
571 revishead[self.rev(entry[b'p2'])] = False |
37337
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
572 |
37341
d62d2e346acf
simplestorerepo: avoid shadowing dict in list comprehension over dict
Augie Fackler <augie@google.com>
parents:
37338
diff
changeset
|
573 return [rev for rev, ishead in sorted(revishead.items()) |
37337
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
574 if ishead] |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
575 |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
576 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
|
577 # This is copied from revlog.py. |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
578 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
|
579 if not len(self): |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
580 return [nullid] |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
581 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
|
582 |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
583 if start is None: |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
584 start = nullid |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
585 if stop is None: |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
586 stop = [] |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
587 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
|
588 startrev = self.rev(start) |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
589 reachable = {startrev} |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
590 heads = {startrev} |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
591 |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
592 parentrevs = self.parentrevs |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
593 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
|
594 for p in parentrevs(r): |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
595 if p in reachable: |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
596 if r not in stoprevs: |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
597 reachable.add(r) |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
598 heads.add(r) |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
599 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
|
600 heads.remove(p) |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
601 |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
602 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
|
603 |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
604 def children(self, node): |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
605 validatenode(node) |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
606 |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
607 # 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
|
608 c = [] |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
609 p = self.rev(node) |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
610 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
|
611 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
|
612 if prevs: |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
613 for pr in prevs: |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
614 if pr == p: |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
615 c.append(self.node(r)) |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
616 elif p == nullrev: |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
617 c.append(self.node(r)) |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
618 return c |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
619 |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
620 def getstrippoint(self, minlink): |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
621 |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
622 # 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
|
623 brokenrevs = set() |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
624 strippoint = len(self) |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
625 |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
626 heads = {} |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
627 futurelargelinkrevs = set() |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
628 for head in self.headrevs(): |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
629 headlinkrev = self.linkrev(head) |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
630 heads[head] = headlinkrev |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
631 if headlinkrev >= minlink: |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
632 futurelargelinkrevs.add(headlinkrev) |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
633 |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
634 # 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
|
635 # 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
|
636 # 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
|
637 # 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
|
638 # So we can stop walking. |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
639 while futurelargelinkrevs: |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
640 strippoint -= 1 |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
641 linkrev = heads.pop(strippoint) |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
642 |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
643 if linkrev < minlink: |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
644 brokenrevs.add(strippoint) |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
645 else: |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
646 futurelargelinkrevs.remove(linkrev) |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
647 |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
648 for p in self.parentrevs(strippoint): |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
649 if p != nullrev: |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
650 plinkrev = self.linkrev(p) |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
651 heads[p] = plinkrev |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
652 if plinkrev >= minlink: |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
653 futurelargelinkrevs.add(plinkrev) |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
654 |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
655 return strippoint, brokenrevs |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
656 |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
657 def strip(self, minlink, transaction): |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
658 if not len(self): |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
659 return |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
660 |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
661 rev, _ignored = self.getstrippoint(minlink) |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
662 if rev == len(self): |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
663 return |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
664 |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
665 # 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
|
666 self._indexdata[rev:] = [] |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
667 self._reflectindexupdate() |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
668 |
37415
c2c8962a9465
simplestore: use a custom store for the simple store repo
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37408
diff
changeset
|
669 def issimplestorefile(f, kind, st): |
c2c8962a9465
simplestore: use a custom store for the simple store repo
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37408
diff
changeset
|
670 if kind != stat.S_IFREG: |
c2c8962a9465
simplestore: use a custom store for the simple store repo
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37408
diff
changeset
|
671 return False |
c2c8962a9465
simplestore: use a custom store for the simple store repo
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37408
diff
changeset
|
672 |
c2c8962a9465
simplestore: use a custom store for the simple store repo
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37408
diff
changeset
|
673 if store.isrevlog(f, kind, st): |
c2c8962a9465
simplestore: use a custom store for the simple store repo
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37408
diff
changeset
|
674 return False |
c2c8962a9465
simplestore: use a custom store for the simple store repo
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37408
diff
changeset
|
675 |
c2c8962a9465
simplestore: use a custom store for the simple store repo
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37408
diff
changeset
|
676 # Ignore transaction undo files. |
c2c8962a9465
simplestore: use a custom store for the simple store repo
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37408
diff
changeset
|
677 if f.startswith('undo.'): |
c2c8962a9465
simplestore: use a custom store for the simple store repo
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37408
diff
changeset
|
678 return False |
c2c8962a9465
simplestore: use a custom store for the simple store repo
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37408
diff
changeset
|
679 |
c2c8962a9465
simplestore: use a custom store for the simple store repo
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37408
diff
changeset
|
680 # Otherwise assume it belongs to the simple store. |
c2c8962a9465
simplestore: use a custom store for the simple store repo
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37408
diff
changeset
|
681 return True |
c2c8962a9465
simplestore: use a custom store for the simple store repo
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37408
diff
changeset
|
682 |
c2c8962a9465
simplestore: use a custom store for the simple store repo
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37408
diff
changeset
|
683 class simplestore(store.encodedstore): |
c2c8962a9465
simplestore: use a custom store for the simple store repo
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37408
diff
changeset
|
684 def datafiles(self): |
c2c8962a9465
simplestore: use a custom store for the simple store repo
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37408
diff
changeset
|
685 for x in super(simplestore, self).datafiles(): |
c2c8962a9465
simplestore: use a custom store for the simple store repo
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37408
diff
changeset
|
686 yield x |
c2c8962a9465
simplestore: use a custom store for the simple store repo
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37408
diff
changeset
|
687 |
c2c8962a9465
simplestore: use a custom store for the simple store repo
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37408
diff
changeset
|
688 # Supplement with non-revlog files. |
c2c8962a9465
simplestore: use a custom store for the simple store repo
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37408
diff
changeset
|
689 extrafiles = self._walk('data', True, filefilter=issimplestorefile) |
c2c8962a9465
simplestore: use a custom store for the simple store repo
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37408
diff
changeset
|
690 |
c2c8962a9465
simplestore: use a custom store for the simple store repo
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37408
diff
changeset
|
691 for unencoded, encoded, size in extrafiles: |
c2c8962a9465
simplestore: use a custom store for the simple store repo
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37408
diff
changeset
|
692 try: |
c2c8962a9465
simplestore: use a custom store for the simple store repo
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37408
diff
changeset
|
693 unencoded = store.decodefilename(unencoded) |
c2c8962a9465
simplestore: use a custom store for the simple store repo
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37408
diff
changeset
|
694 except KeyError: |
c2c8962a9465
simplestore: use a custom store for the simple store repo
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37408
diff
changeset
|
695 unencoded = None |
c2c8962a9465
simplestore: use a custom store for the simple store repo
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37408
diff
changeset
|
696 |
c2c8962a9465
simplestore: use a custom store for the simple store repo
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37408
diff
changeset
|
697 yield unencoded, encoded, size |
c2c8962a9465
simplestore: use a custom store for the simple store repo
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37408
diff
changeset
|
698 |
37337
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
699 def reposetup(ui, repo): |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
700 if not repo.local(): |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
701 return |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
702 |
37346
45a4799174a1
tests: disallow using simple store repo with bundlerepo
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37341
diff
changeset
|
703 if isinstance(repo, bundlerepo.bundlerepository): |
45a4799174a1
tests: disallow using simple store repo with bundlerepo
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37341
diff
changeset
|
704 raise error.Abort(_('cannot use simple store with bundlerepo')) |
45a4799174a1
tests: disallow using simple store repo with bundlerepo
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37341
diff
changeset
|
705 |
37337
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
706 class simplestorerepo(repo.__class__): |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
707 def file(self, f): |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
708 return filestorage(self.svfs, f) |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
709 |
d257c5f2a940
tests: add test extension implementing custom filelog storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
710 repo.__class__ = simplestorerepo |
37415
c2c8962a9465
simplestore: use a custom store for the simple store repo
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37408
diff
changeset
|
711 |
c2c8962a9465
simplestore: use a custom store for the simple store repo
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37408
diff
changeset
|
712 def featuresetup(ui, supported): |
c2c8962a9465
simplestore: use a custom store for the simple store repo
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37408
diff
changeset
|
713 supported.add(REQUIREMENT) |
c2c8962a9465
simplestore: use a custom store for the simple store repo
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37408
diff
changeset
|
714 |
39546
41aa5dced975
localrepo: pass ui to newreporequirements() (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39234
diff
changeset
|
715 def newreporequirements(orig, ui): |
37415
c2c8962a9465
simplestore: use a custom store for the simple store repo
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37408
diff
changeset
|
716 """Modifies default requirements for new repos to use the simple store.""" |
39546
41aa5dced975
localrepo: pass ui to newreporequirements() (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39234
diff
changeset
|
717 requirements = orig(ui) |
37415
c2c8962a9465
simplestore: use a custom store for the simple store repo
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37408
diff
changeset
|
718 |
c2c8962a9465
simplestore: use a custom store for the simple store repo
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37408
diff
changeset
|
719 # These requirements are only used to affect creation of the store |
c2c8962a9465
simplestore: use a custom store for the simple store repo
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37408
diff
changeset
|
720 # object. We have our own store. So we can remove them. |
c2c8962a9465
simplestore: use a custom store for the simple store repo
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37408
diff
changeset
|
721 # TODO do this once we feel like taking the test hit. |
c2c8962a9465
simplestore: use a custom store for the simple store repo
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37408
diff
changeset
|
722 #if 'fncache' in requirements: |
c2c8962a9465
simplestore: use a custom store for the simple store repo
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37408
diff
changeset
|
723 # requirements.remove('fncache') |
c2c8962a9465
simplestore: use a custom store for the simple store repo
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37408
diff
changeset
|
724 #if 'dotencode' in requirements: |
c2c8962a9465
simplestore: use a custom store for the simple store repo
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37408
diff
changeset
|
725 # requirements.remove('dotencode') |
c2c8962a9465
simplestore: use a custom store for the simple store repo
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37408
diff
changeset
|
726 |
c2c8962a9465
simplestore: use a custom store for the simple store repo
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37408
diff
changeset
|
727 requirements.add(REQUIREMENT) |
c2c8962a9465
simplestore: use a custom store for the simple store repo
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37408
diff
changeset
|
728 |
c2c8962a9465
simplestore: use a custom store for the simple store repo
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37408
diff
changeset
|
729 return requirements |
c2c8962a9465
simplestore: use a custom store for the simple store repo
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37408
diff
changeset
|
730 |
c2c8962a9465
simplestore: use a custom store for the simple store repo
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37408
diff
changeset
|
731 def makestore(orig, requirements, path, vfstype): |
c2c8962a9465
simplestore: use a custom store for the simple store repo
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37408
diff
changeset
|
732 if REQUIREMENT not in requirements: |
c2c8962a9465
simplestore: use a custom store for the simple store repo
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37408
diff
changeset
|
733 return orig(requirements, path, vfstype) |
c2c8962a9465
simplestore: use a custom store for the simple store repo
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37408
diff
changeset
|
734 |
c2c8962a9465
simplestore: use a custom store for the simple store repo
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37408
diff
changeset
|
735 return simplestore(path, vfstype) |
c2c8962a9465
simplestore: use a custom store for the simple store repo
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37408
diff
changeset
|
736 |
37417
76d2115cb817
verify: allow suppressing warnings about extra files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37415
diff
changeset
|
737 def verifierinit(orig, self, *args, **kwargs): |
76d2115cb817
verify: allow suppressing warnings about extra files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37415
diff
changeset
|
738 orig(self, *args, **kwargs) |
76d2115cb817
verify: allow suppressing warnings about extra files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37415
diff
changeset
|
739 |
76d2115cb817
verify: allow suppressing warnings about extra files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37415
diff
changeset
|
740 # We don't care that files in the store don't align with what is |
76d2115cb817
verify: allow suppressing warnings about extra files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37415
diff
changeset
|
741 # advertised. So suppress these warnings. |
76d2115cb817
verify: allow suppressing warnings about extra files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37415
diff
changeset
|
742 self.warnorphanstorefiles = False |
76d2115cb817
verify: allow suppressing warnings about extra files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37415
diff
changeset
|
743 |
37415
c2c8962a9465
simplestore: use a custom store for the simple store repo
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37408
diff
changeset
|
744 def extsetup(ui): |
c2c8962a9465
simplestore: use a custom store for the simple store repo
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37408
diff
changeset
|
745 localrepo.featuresetupfuncs.add(featuresetup) |
c2c8962a9465
simplestore: use a custom store for the simple store repo
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37408
diff
changeset
|
746 |
c2c8962a9465
simplestore: use a custom store for the simple store repo
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37408
diff
changeset
|
747 extensions.wrapfunction(localrepo, 'newreporequirements', |
c2c8962a9465
simplestore: use a custom store for the simple store repo
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37408
diff
changeset
|
748 newreporequirements) |
c2c8962a9465
simplestore: use a custom store for the simple store repo
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37408
diff
changeset
|
749 extensions.wrapfunction(store, 'store', makestore) |
37417
76d2115cb817
verify: allow suppressing warnings about extra files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37415
diff
changeset
|
750 extensions.wrapfunction(verify.verifier, '__init__', verifierinit) |