Mercurial > public > mercurial-scm > hg-stable
annotate mercurial/revlogutils/__init__.py @ 49791:05db41701ece
find-delta: pass the cache-delta usage policy alongside the cache-delta
The idea is to give higher level code more control to what will happens with
the cache delta passed. This should help with controling how we treat delta's
from different sources.
The final goal of this change is to allow for server modes where the client can
blindly accept any server delta without regards to any local constraints. This
will be implemented in later changesets.
author | Pierre-Yves David <pierre-yves.david@octobus.net> |
---|---|
date | Mon, 07 Nov 2022 22:12:59 -0500 |
parents | 642e31cb55f0 |
children | 398a105b16a0 |
rev | line source |
---|---|
43572
a7c0c5b5a50f
revlog: introduce an explicit NodeMap class for pure code
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
39356
diff
changeset
|
1 # mercurial.revlogutils -- basic utilities for revlog |
a7c0c5b5a50f
revlog: introduce an explicit NodeMap class for pure code
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
39356
diff
changeset
|
2 # |
a7c0c5b5a50f
revlog: introduce an explicit NodeMap class for pure code
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
39356
diff
changeset
|
3 # Copyright 2019 Pierre-Yves David <pierre-yves.david@octobus.net> |
a7c0c5b5a50f
revlog: introduce an explicit NodeMap class for pure code
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
39356
diff
changeset
|
4 # |
a7c0c5b5a50f
revlog: introduce an explicit NodeMap class for pure code
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
39356
diff
changeset
|
5 # This software may be used and distributed according to the terms of the |
a7c0c5b5a50f
revlog: introduce an explicit NodeMap class for pure code
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
39356
diff
changeset
|
6 # GNU General Public License version 2 or any later version. |
a7c0c5b5a50f
revlog: introduce an explicit NodeMap class for pure code
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
39356
diff
changeset
|
7 |
47400
ac60a1366a49
revlog: move `offset_type` to `revlogutils`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44035
diff
changeset
|
8 |
47405
34cc102c73f5
revlog: move `revisioninfo` in `revlogutils`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47401
diff
changeset
|
9 from ..thirdparty import attr |
47400
ac60a1366a49
revlog: move `offset_type` to `revlogutils`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44035
diff
changeset
|
10 from ..interfaces import repository |
ac60a1366a49
revlog: move `offset_type` to `revlogutils`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44035
diff
changeset
|
11 |
47401
a669404f0f4a
revlog: add a function to build index entry tuple
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47400
diff
changeset
|
12 # See mercurial.revlogutils.constants for doc |
a669404f0f4a
revlog: add a function to build index entry tuple
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47400
diff
changeset
|
13 COMP_MODE_INLINE = 2 |
48536
52034c42c09d
rank: add a "rank" value to the revlog-entry tuple
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47405
diff
changeset
|
14 RANK_UNKNOWN = -1 |
47401
a669404f0f4a
revlog: add a function to build index entry tuple
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47400
diff
changeset
|
15 |
47400
ac60a1366a49
revlog: move `offset_type` to `revlogutils`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44035
diff
changeset
|
16 |
ac60a1366a49
revlog: move `offset_type` to `revlogutils`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44035
diff
changeset
|
17 def offset_type(offset, type): |
ac60a1366a49
revlog: move `offset_type` to `revlogutils`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44035
diff
changeset
|
18 if (type & ~repository.REVISION_FLAGS_KNOWN) != 0: |
ac60a1366a49
revlog: move `offset_type` to `revlogutils`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44035
diff
changeset
|
19 raise ValueError(b'unknown revlog index flags: %d' % type) |
ac60a1366a49
revlog: move `offset_type` to `revlogutils`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44035
diff
changeset
|
20 return int(int(offset) << 16 | type) |
47401
a669404f0f4a
revlog: add a function to build index entry tuple
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47400
diff
changeset
|
21 |
a669404f0f4a
revlog: add a function to build index entry tuple
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47400
diff
changeset
|
22 |
a669404f0f4a
revlog: add a function to build index entry tuple
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47400
diff
changeset
|
23 def entry( |
a669404f0f4a
revlog: add a function to build index entry tuple
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47400
diff
changeset
|
24 data_offset, |
a669404f0f4a
revlog: add a function to build index entry tuple
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47400
diff
changeset
|
25 data_compressed_length, |
a669404f0f4a
revlog: add a function to build index entry tuple
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47400
diff
changeset
|
26 data_delta_base, |
a669404f0f4a
revlog: add a function to build index entry tuple
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47400
diff
changeset
|
27 link_rev, |
a669404f0f4a
revlog: add a function to build index entry tuple
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47400
diff
changeset
|
28 parent_rev_1, |
a669404f0f4a
revlog: add a function to build index entry tuple
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47400
diff
changeset
|
29 parent_rev_2, |
a669404f0f4a
revlog: add a function to build index entry tuple
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47400
diff
changeset
|
30 node_id, |
a669404f0f4a
revlog: add a function to build index entry tuple
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47400
diff
changeset
|
31 flags=0, |
a669404f0f4a
revlog: add a function to build index entry tuple
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47400
diff
changeset
|
32 data_uncompressed_length=-1, |
a669404f0f4a
revlog: add a function to build index entry tuple
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47400
diff
changeset
|
33 data_compression_mode=COMP_MODE_INLINE, |
a669404f0f4a
revlog: add a function to build index entry tuple
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47400
diff
changeset
|
34 sidedata_offset=0, |
a669404f0f4a
revlog: add a function to build index entry tuple
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47400
diff
changeset
|
35 sidedata_compressed_length=0, |
a669404f0f4a
revlog: add a function to build index entry tuple
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47400
diff
changeset
|
36 sidedata_compression_mode=COMP_MODE_INLINE, |
48536
52034c42c09d
rank: add a "rank" value to the revlog-entry tuple
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47405
diff
changeset
|
37 rank=RANK_UNKNOWN, |
47401
a669404f0f4a
revlog: add a function to build index entry tuple
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47400
diff
changeset
|
38 ): |
a669404f0f4a
revlog: add a function to build index entry tuple
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47400
diff
changeset
|
39 """Build one entry from symbolic name |
a669404f0f4a
revlog: add a function to build index entry tuple
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47400
diff
changeset
|
40 |
a669404f0f4a
revlog: add a function to build index entry tuple
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47400
diff
changeset
|
41 This is useful to abstract the actual detail of how we build the entry |
a669404f0f4a
revlog: add a function to build index entry tuple
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47400
diff
changeset
|
42 tuple for caller who don't care about it. |
a669404f0f4a
revlog: add a function to build index entry tuple
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47400
diff
changeset
|
43 |
a669404f0f4a
revlog: add a function to build index entry tuple
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47400
diff
changeset
|
44 This should always be called using keyword arguments. Some arguments have |
a669404f0f4a
revlog: add a function to build index entry tuple
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47400
diff
changeset
|
45 default value, this match the value used by index version that does not store such data. |
a669404f0f4a
revlog: add a function to build index entry tuple
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47400
diff
changeset
|
46 """ |
a669404f0f4a
revlog: add a function to build index entry tuple
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47400
diff
changeset
|
47 return ( |
a669404f0f4a
revlog: add a function to build index entry tuple
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47400
diff
changeset
|
48 offset_type(data_offset, flags), |
a669404f0f4a
revlog: add a function to build index entry tuple
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47400
diff
changeset
|
49 data_compressed_length, |
a669404f0f4a
revlog: add a function to build index entry tuple
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47400
diff
changeset
|
50 data_uncompressed_length, |
a669404f0f4a
revlog: add a function to build index entry tuple
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47400
diff
changeset
|
51 data_delta_base, |
a669404f0f4a
revlog: add a function to build index entry tuple
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47400
diff
changeset
|
52 link_rev, |
a669404f0f4a
revlog: add a function to build index entry tuple
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47400
diff
changeset
|
53 parent_rev_1, |
a669404f0f4a
revlog: add a function to build index entry tuple
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47400
diff
changeset
|
54 parent_rev_2, |
a669404f0f4a
revlog: add a function to build index entry tuple
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47400
diff
changeset
|
55 node_id, |
a669404f0f4a
revlog: add a function to build index entry tuple
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47400
diff
changeset
|
56 sidedata_offset, |
a669404f0f4a
revlog: add a function to build index entry tuple
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47400
diff
changeset
|
57 sidedata_compressed_length, |
a669404f0f4a
revlog: add a function to build index entry tuple
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47400
diff
changeset
|
58 data_compression_mode, |
a669404f0f4a
revlog: add a function to build index entry tuple
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47400
diff
changeset
|
59 sidedata_compression_mode, |
48536
52034c42c09d
rank: add a "rank" value to the revlog-entry tuple
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47405
diff
changeset
|
60 rank, |
47401
a669404f0f4a
revlog: add a function to build index entry tuple
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47400
diff
changeset
|
61 ) |
47405
34cc102c73f5
revlog: move `revisioninfo` in `revlogutils`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47401
diff
changeset
|
62 |
34cc102c73f5
revlog: move `revisioninfo` in `revlogutils`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47401
diff
changeset
|
63 |
34cc102c73f5
revlog: move `revisioninfo` in `revlogutils`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47401
diff
changeset
|
64 @attr.s(slots=True, frozen=True) |
49037
642e31cb55f0
py3: use class X: instead of class X(object):
Gregory Szorc <gregory.szorc@gmail.com>
parents:
48966
diff
changeset
|
65 class revisioninfo: |
47405
34cc102c73f5
revlog: move `revisioninfo` in `revlogutils`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47401
diff
changeset
|
66 """Information about a revision that allows building its fulltext |
34cc102c73f5
revlog: move `revisioninfo` in `revlogutils`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47401
diff
changeset
|
67 node: expected hash of the revision |
34cc102c73f5
revlog: move `revisioninfo` in `revlogutils`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47401
diff
changeset
|
68 p1, p2: parent revs of the revision |
34cc102c73f5
revlog: move `revisioninfo` in `revlogutils`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47401
diff
changeset
|
69 btext: built text cache consisting of a one-element list |
49791
05db41701ece
find-delta: pass the cache-delta usage policy alongside the cache-delta
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49037
diff
changeset
|
70 cachedelta: (baserev, uncompressed_delta, usage_mode) or None |
47405
34cc102c73f5
revlog: move `revisioninfo` in `revlogutils`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47401
diff
changeset
|
71 flags: flags associated to the revision storage |
34cc102c73f5
revlog: move `revisioninfo` in `revlogutils`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47401
diff
changeset
|
72 |
34cc102c73f5
revlog: move `revisioninfo` in `revlogutils`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47401
diff
changeset
|
73 One of btext[0] or cachedelta must be set. |
34cc102c73f5
revlog: move `revisioninfo` in `revlogutils`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47401
diff
changeset
|
74 """ |
34cc102c73f5
revlog: move `revisioninfo` in `revlogutils`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47401
diff
changeset
|
75 |
34cc102c73f5
revlog: move `revisioninfo` in `revlogutils`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47401
diff
changeset
|
76 node = attr.ib() |
34cc102c73f5
revlog: move `revisioninfo` in `revlogutils`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47401
diff
changeset
|
77 p1 = attr.ib() |
34cc102c73f5
revlog: move `revisioninfo` in `revlogutils`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47401
diff
changeset
|
78 p2 = attr.ib() |
34cc102c73f5
revlog: move `revisioninfo` in `revlogutils`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47401
diff
changeset
|
79 btext = attr.ib() |
34cc102c73f5
revlog: move `revisioninfo` in `revlogutils`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47401
diff
changeset
|
80 textlen = attr.ib() |
34cc102c73f5
revlog: move `revisioninfo` in `revlogutils`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47401
diff
changeset
|
81 cachedelta = attr.ib() |
34cc102c73f5
revlog: move `revisioninfo` in `revlogutils`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47401
diff
changeset
|
82 flags = attr.ib() |