Mercurial > public > mercurial-scm > hg
annotate rust/hg-core/src/revlog/options.rs @ 52664:f5091286b10c
packaging: modernize (compat PEP 517) with less distutils and setup.py calls
- setup.py: less distutils imports and setuptools required
distutils is deprecated and one should import commands from setuptools to support
modern workflows depending on PEP 517 and 518.
Moreover, for Python >=3.12, distutils comes from setuptools. It corresponds to old and
unmaintain code that do not support PEP 517.
The PEP 517 frontends (pip, build, pipx, PDM, UV, etc.) are responsible for creating a
venv just for the build. The build dependencies (currently only setuptools) are specified
in the pyproject.toml file. Therefore, there is no reason to support building without
setuptools.
Calling directly setup.py is deprecated and we have to use a PEP 517 frontend.
For this commit we use pip with venv.
- run-tests.py: install with pip instead of direct call of setup.py
Mercurial is then built in an isolated environment.
- Makefile: use venv+pip instead of setup.py
author | paugier <pierre.augier@univ-grenoble-alpes.fr> |
---|---|
date | Wed, 08 Jan 2025 05:07:00 +0100 |
parents | 33d8cb64e9da |
children | 8370eb2c72ca |
rev | line source |
---|---|
52156
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
1 //! Helpers for the revlog config and opening options |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
2 |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
3 use std::collections::HashSet; |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
4 |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
5 use crate::{ |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
6 config::{Config, ResourceProfileValue}, |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
7 errors::HgError, |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
8 requirements::{ |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
9 CHANGELOGV2_REQUIREMENT, GENERALDELTA_REQUIREMENT, NARROW_REQUIREMENT, |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
10 NODEMAP_REQUIREMENT, REVLOGV1_REQUIREMENT, REVLOGV2_REQUIREMENT, |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
11 SPARSEREVLOG_REQUIREMENT, |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
12 }, |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
13 }; |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
14 |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
15 use super::{compression::CompressionConfig, RevlogType}; |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
16 |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
17 const DEFAULT_CHUNK_CACHE_SIZE: u64 = 65536; |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
18 const DEFAULT_SPARSE_READ_DENSITY_THRESHOLD: f64 = 0.50; |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
19 const DEFAULT_SPARSE_READ_MIN_GAP_SIZE: u64 = 262144; |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
20 |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
21 /// The known revlog versions and their options |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
22 #[derive(Debug, Copy, Clone, PartialEq)] |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
23 pub enum RevlogVersionOptions { |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
24 V0, |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
25 V1 { general_delta: bool, inline: bool }, |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
26 V2, |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
27 ChangelogV2 { compute_rank: bool }, |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
28 } |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
29 |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
30 /// Options to govern how a revlog should be opened, usually from the |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
31 /// repository configuration or requirements. |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
32 #[derive(Debug, Copy, Clone)] |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
33 pub struct RevlogOpenOptions { |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
34 /// The revlog version, along with any option specific to this version |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
35 pub version: RevlogVersionOptions, |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
36 /// Whether the revlog uses a persistent nodemap. |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
37 pub use_nodemap: bool, |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
38 pub delta_config: RevlogDeltaConfig, |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
39 pub data_config: RevlogDataConfig, |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
40 pub feature_config: RevlogFeatureConfig, |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
41 } |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
42 |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
43 #[cfg(test)] |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
44 impl Default for RevlogOpenOptions { |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
45 fn default() -> Self { |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
46 Self { |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
47 version: RevlogVersionOptions::V1 { |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
48 general_delta: true, |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
49 inline: false, |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
50 }, |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
51 use_nodemap: true, |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
52 data_config: Default::default(), |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
53 delta_config: Default::default(), |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
54 feature_config: Default::default(), |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
55 } |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
56 } |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
57 } |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
58 |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
59 impl RevlogOpenOptions { |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
60 pub fn new( |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
61 inline: bool, |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
62 data_config: RevlogDataConfig, |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
63 delta_config: RevlogDeltaConfig, |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
64 feature_config: RevlogFeatureConfig, |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
65 ) -> Self { |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
66 Self { |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
67 version: RevlogVersionOptions::V1 { |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
68 general_delta: data_config.general_delta, |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
69 inline, |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
70 }, |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
71 use_nodemap: false, |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
72 data_config, |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
73 delta_config, |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
74 feature_config, |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
75 } |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
76 } |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
77 |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
78 pub fn index_header(&self) -> super::index::IndexHeader { |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
79 super::index::IndexHeader { |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
80 header_bytes: match self.version { |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
81 RevlogVersionOptions::V0 => [0, 0, 0, 0], |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
82 RevlogVersionOptions::V1 { |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
83 general_delta, |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
84 inline, |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
85 } => [ |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
86 0, |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
87 if general_delta && inline { |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
88 3 |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
89 } else if general_delta { |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
90 2 |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
91 } else { |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
92 u8::from(inline) |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
93 }, |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
94 0, |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
95 1, |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
96 ], |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
97 RevlogVersionOptions::V2 => 0xDEADu32.to_be_bytes(), |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
98 RevlogVersionOptions::ChangelogV2 { compute_rank: _ } => { |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
99 0xD34Du32.to_be_bytes() |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
100 } |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
101 }, |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
102 } |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
103 } |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
104 } |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
105 |
52165
84b5802ba7d3
rust: populate mmap by default if available
Rapha?l Gom?s <rgomes@octobus.net>
parents:
52156
diff
changeset
|
106 /// Technically only Linux 2.5.46+ has `MAP_POPULATE` and only `2.6.23` on |
84b5802ba7d3
rust: populate mmap by default if available
Rapha?l Gom?s <rgomes@octobus.net>
parents:
52156
diff
changeset
|
107 /// private mappings, but if you're using such ancient Linux, you have other |
84b5802ba7d3
rust: populate mmap by default if available
Rapha?l Gom?s <rgomes@octobus.net>
parents:
52156
diff
changeset
|
108 /// problems. |
84b5802ba7d3
rust: populate mmap by default if available
Rapha?l Gom?s <rgomes@octobus.net>
parents:
52156
diff
changeset
|
109 #[cfg(target_os = "linux")] |
84b5802ba7d3
rust: populate mmap by default if available
Rapha?l Gom?s <rgomes@octobus.net>
parents:
52156
diff
changeset
|
110 const fn can_populate_mmap() -> bool { |
84b5802ba7d3
rust: populate mmap by default if available
Rapha?l Gom?s <rgomes@octobus.net>
parents:
52156
diff
changeset
|
111 true |
84b5802ba7d3
rust: populate mmap by default if available
Rapha?l Gom?s <rgomes@octobus.net>
parents:
52156
diff
changeset
|
112 } |
84b5802ba7d3
rust: populate mmap by default if available
Rapha?l Gom?s <rgomes@octobus.net>
parents:
52156
diff
changeset
|
113 |
84b5802ba7d3
rust: populate mmap by default if available
Rapha?l Gom?s <rgomes@octobus.net>
parents:
52156
diff
changeset
|
114 /// There is a of populating mmaps for Windows, but it would need testing. |
84b5802ba7d3
rust: populate mmap by default if available
Rapha?l Gom?s <rgomes@octobus.net>
parents:
52156
diff
changeset
|
115 #[cfg(not(target_os = "linux"))] |
52310
33d8cb64e9da
rust: fix darwin build
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
52165
diff
changeset
|
116 const fn can_populate_mmap() -> bool { |
52165
84b5802ba7d3
rust: populate mmap by default if available
Rapha?l Gom?s <rgomes@octobus.net>
parents:
52156
diff
changeset
|
117 false |
84b5802ba7d3
rust: populate mmap by default if available
Rapha?l Gom?s <rgomes@octobus.net>
parents:
52156
diff
changeset
|
118 } |
84b5802ba7d3
rust: populate mmap by default if available
Rapha?l Gom?s <rgomes@octobus.net>
parents:
52156
diff
changeset
|
119 |
52156
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
120 #[derive(Debug, Clone, Copy, PartialEq)] |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
121 /// Holds configuration values about how the revlog data is read |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
122 pub struct RevlogDataConfig { |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
123 /// Should we try to open the "pending" version of the revlog |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
124 pub try_pending: bool, |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
125 /// Should we try to open the "split" version of the revlog |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
126 pub try_split: bool, |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
127 /// When True, `indexfile` should be opened with `checkambig=True` at |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
128 /// writing time, to avoid file stat ambiguity |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
129 pub check_ambig: bool, |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
130 /// If true, use mmap instead of reading to deal with large indexes |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
131 pub mmap_large_index: bool, |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
132 /// How much data is considered large |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
133 pub mmap_index_threshold: Option<u64>, |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
134 /// How much data to read and cache into the raw revlog data cache |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
135 pub chunk_cache_size: u64, |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
136 /// The size of the uncompressed cache compared to the largest revision |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
137 /// seen |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
138 pub uncompressed_cache_factor: Option<f64>, |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
139 /// The number of chunks cached |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
140 pub uncompressed_cache_count: Option<u64>, |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
141 /// Allow sparse reading of the revlog data |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
142 pub with_sparse_read: bool, |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
143 /// Minimal density of a sparse read chunk |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
144 pub sr_density_threshold: f64, |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
145 /// Minimal size of the data we skip when performing sparse reads |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
146 pub sr_min_gap_size: u64, |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
147 /// Whether deltas are encoded against arbitrary bases |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
148 pub general_delta: bool, |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
149 } |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
150 |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
151 impl RevlogDataConfig { |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
152 pub fn new( |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
153 config: &Config, |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
154 requirements: &HashSet<String>, |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
155 ) -> Result<Self, HgError> { |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
156 let mut data_config = Self::default(); |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
157 if let Some(chunk_cache_size) = |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
158 config.get_byte_size(b"format", b"chunkcachesize")? |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
159 { |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
160 data_config.chunk_cache_size = chunk_cache_size; |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
161 } |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
162 |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
163 let memory_profile = config.get_resource_profile(Some("memory")); |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
164 if memory_profile.value >= ResourceProfileValue::Medium { |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
165 data_config.uncompressed_cache_count = Some(10_000); |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
166 data_config.uncompressed_cache_factor = Some(4.0); |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
167 if memory_profile.value >= ResourceProfileValue::High { |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
168 data_config.uncompressed_cache_factor = Some(10.0) |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
169 } |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
170 } |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
171 |
52165
84b5802ba7d3
rust: populate mmap by default if available
Rapha?l Gom?s <rgomes@octobus.net>
parents:
52156
diff
changeset
|
172 // Use mmap if requested, or by default if we can fully populate it |
84b5802ba7d3
rust: populate mmap by default if available
Rapha?l Gom?s <rgomes@octobus.net>
parents:
52156
diff
changeset
|
173 let mmap_index = config |
84b5802ba7d3
rust: populate mmap by default if available
Rapha?l Gom?s <rgomes@octobus.net>
parents:
52156
diff
changeset
|
174 .get_option_no_default(b"storage", b"revlog.mmap.index")? |
84b5802ba7d3
rust: populate mmap by default if available
Rapha?l Gom?s <rgomes@octobus.net>
parents:
52156
diff
changeset
|
175 .unwrap_or(can_populate_mmap()); |
84b5802ba7d3
rust: populate mmap by default if available
Rapha?l Gom?s <rgomes@octobus.net>
parents:
52156
diff
changeset
|
176 if mmap_index { |
84b5802ba7d3
rust: populate mmap by default if available
Rapha?l Gom?s <rgomes@octobus.net>
parents:
52156
diff
changeset
|
177 if let Some(mmap_index_threshold) = config.get_byte_size( |
84b5802ba7d3
rust: populate mmap by default if available
Rapha?l Gom?s <rgomes@octobus.net>
parents:
52156
diff
changeset
|
178 b"storage", |
84b5802ba7d3
rust: populate mmap by default if available
Rapha?l Gom?s <rgomes@octobus.net>
parents:
52156
diff
changeset
|
179 b"revlog.mmap.index:size-threshold", |
84b5802ba7d3
rust: populate mmap by default if available
Rapha?l Gom?s <rgomes@octobus.net>
parents:
52156
diff
changeset
|
180 )? { |
84b5802ba7d3
rust: populate mmap by default if available
Rapha?l Gom?s <rgomes@octobus.net>
parents:
52156
diff
changeset
|
181 // Only mmap if above the requested size threshold |
84b5802ba7d3
rust: populate mmap by default if available
Rapha?l Gom?s <rgomes@octobus.net>
parents:
52156
diff
changeset
|
182 data_config.mmap_index_threshold = Some(mmap_index_threshold); |
84b5802ba7d3
rust: populate mmap by default if available
Rapha?l Gom?s <rgomes@octobus.net>
parents:
52156
diff
changeset
|
183 } |
84b5802ba7d3
rust: populate mmap by default if available
Rapha?l Gom?s <rgomes@octobus.net>
parents:
52156
diff
changeset
|
184 } |
84b5802ba7d3
rust: populate mmap by default if available
Rapha?l Gom?s <rgomes@octobus.net>
parents:
52156
diff
changeset
|
185 |
52156
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
186 if let Some(mmap_index_threshold) = config |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
187 .get_byte_size(b"storage", b"revlog.mmap.index:size-threshold")? |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
188 { |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
189 data_config.mmap_index_threshold = Some(mmap_index_threshold); |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
190 } |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
191 |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
192 let with_sparse_read = |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
193 config.get_bool(b"experimental", b"sparse-read")?; |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
194 if let Some(sr_density_threshold) = config |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
195 .get_f64(b"experimental", b"sparse-read.density-threshold")? |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
196 { |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
197 data_config.sr_density_threshold = sr_density_threshold; |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
198 } |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
199 data_config.with_sparse_read = with_sparse_read; |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
200 if let Some(sr_min_gap_size) = config |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
201 .get_byte_size(b"experimental", b"sparse-read.min-gap-size")? |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
202 { |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
203 data_config.sr_min_gap_size = sr_min_gap_size; |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
204 } |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
205 |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
206 data_config.with_sparse_read = |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
207 requirements.contains(SPARSEREVLOG_REQUIREMENT); |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
208 |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
209 Ok(data_config) |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
210 } |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
211 } |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
212 |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
213 impl Default for RevlogDataConfig { |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
214 fn default() -> Self { |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
215 Self { |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
216 chunk_cache_size: DEFAULT_CHUNK_CACHE_SIZE, |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
217 sr_density_threshold: DEFAULT_SPARSE_READ_DENSITY_THRESHOLD, |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
218 sr_min_gap_size: DEFAULT_SPARSE_READ_MIN_GAP_SIZE, |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
219 try_pending: Default::default(), |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
220 try_split: Default::default(), |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
221 check_ambig: Default::default(), |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
222 mmap_large_index: Default::default(), |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
223 mmap_index_threshold: Default::default(), |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
224 uncompressed_cache_factor: Default::default(), |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
225 uncompressed_cache_count: Default::default(), |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
226 with_sparse_read: Default::default(), |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
227 general_delta: Default::default(), |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
228 } |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
229 } |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
230 } |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
231 |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
232 #[derive(Debug, Clone, Copy, PartialEq)] |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
233 /// Holds configuration values about how new deltas are computed. |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
234 /// |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
235 /// Some attributes are duplicated from [`RevlogDataConfig`] to help having |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
236 /// each object self contained. |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
237 pub struct RevlogDeltaConfig { |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
238 /// Whether deltas can be encoded against arbitrary bases |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
239 pub general_delta: bool, |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
240 /// Allow sparse writing of the revlog data |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
241 pub sparse_revlog: bool, |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
242 /// Maximum length of a delta chain |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
243 pub max_chain_len: Option<u64>, |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
244 /// Maximum distance between a delta chain's start and end |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
245 pub max_deltachain_span: Option<u64>, |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
246 /// If `upper_bound_comp` is not None, this is the expected maximal |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
247 /// gain from compression for the data content |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
248 pub upper_bound_comp: Option<f64>, |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
249 /// Should we try a delta against both parents |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
250 pub delta_both_parents: bool, |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
251 /// Test delta base candidate groups by chunks of this maximal size |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
252 pub candidate_group_chunk_size: u64, |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
253 /// Should we display debug information about delta computation |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
254 pub debug_delta: bool, |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
255 /// Trust incoming deltas by default |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
256 pub lazy_delta: bool, |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
257 /// Trust the base of incoming deltas by default |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
258 pub lazy_delta_base: bool, |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
259 } |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
260 |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
261 impl RevlogDeltaConfig { |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
262 pub fn new( |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
263 config: &Config, |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
264 requirements: &HashSet<String>, |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
265 revlog_type: RevlogType, |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
266 ) -> Result<Self, HgError> { |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
267 let mut delta_config = Self { |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
268 delta_both_parents: config |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
269 .get_option_no_default( |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
270 b"storage", |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
271 b"revlog.optimize-delta-parent-choice", |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
272 )? |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
273 .unwrap_or(true), |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
274 candidate_group_chunk_size: config |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
275 .get_u64( |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
276 b"storage", |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
277 b"revlog.delta-parent-search.candidate-group-chunk-size", |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
278 )? |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
279 .unwrap_or_default(), |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
280 ..Default::default() |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
281 }; |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
282 |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
283 delta_config.debug_delta = |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
284 config.get_bool(b"debug", b"revlog.debug-delta")?; |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
285 |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
286 delta_config.general_delta = |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
287 requirements.contains(GENERALDELTA_REQUIREMENT); |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
288 |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
289 let lazy_delta = |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
290 config.get_bool(b"storage", b"revlog.reuse-external-delta")?; |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
291 |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
292 if revlog_type == RevlogType::Manifestlog { |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
293 // upper bound of what we expect from compression |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
294 // (real life value seems to be 3) |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
295 delta_config.upper_bound_comp = Some(3.0) |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
296 } |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
297 |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
298 let mut lazy_delta_base = false; |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
299 if lazy_delta { |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
300 lazy_delta_base = match config.get_option_no_default( |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
301 b"storage", |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
302 b"revlog.reuse-external-delta-parent", |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
303 )? { |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
304 Some(base) => base, |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
305 None => config.get_bool(b"format", b"generaldelta")?, |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
306 }; |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
307 } |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
308 delta_config.lazy_delta = lazy_delta; |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
309 delta_config.lazy_delta_base = lazy_delta_base; |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
310 |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
311 delta_config.max_deltachain_span = |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
312 match config.get_i64(b"experimental", b"maxdeltachainspan")? { |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
313 Some(span) => { |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
314 if span < 0 { |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
315 None |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
316 } else { |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
317 Some(span as u64) |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
318 } |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
319 } |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
320 None => None, |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
321 }; |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
322 |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
323 delta_config.sparse_revlog = |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
324 requirements.contains(SPARSEREVLOG_REQUIREMENT); |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
325 |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
326 delta_config.max_chain_len = |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
327 config.get_byte_size_no_default(b"format", b"maxchainlen")?; |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
328 |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
329 Ok(delta_config) |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
330 } |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
331 } |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
332 |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
333 impl Default for RevlogDeltaConfig { |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
334 fn default() -> Self { |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
335 Self { |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
336 delta_both_parents: true, |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
337 lazy_delta: true, |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
338 general_delta: Default::default(), |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
339 sparse_revlog: Default::default(), |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
340 max_chain_len: Default::default(), |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
341 max_deltachain_span: Default::default(), |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
342 upper_bound_comp: Default::default(), |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
343 candidate_group_chunk_size: Default::default(), |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
344 debug_delta: Default::default(), |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
345 lazy_delta_base: Default::default(), |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
346 } |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
347 } |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
348 } |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
349 |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
350 #[derive(Debug, Default, Clone, Copy, PartialEq)] |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
351 /// Holds configuration values about the available revlog features |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
352 pub struct RevlogFeatureConfig { |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
353 /// The compression engine and its options |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
354 pub compression_engine: CompressionConfig, |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
355 /// Can we use censor on this revlog |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
356 pub censorable: bool, |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
357 /// Does this revlog use the "side data" feature |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
358 pub has_side_data: bool, |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
359 /// Might remove this configuration once the rank computation has no |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
360 /// impact |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
361 pub compute_rank: bool, |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
362 /// Parent order is supposed to be semantically irrelevant, so we |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
363 /// normally re-sort parents to ensure that the first parent is non-null, |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
364 /// if there is a non-null parent at all. |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
365 /// filelog abuses the parent order as a flag to mark some instances of |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
366 /// meta-encoded files, so allow it to disable this behavior. |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
367 pub canonical_parent_order: bool, |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
368 /// Can ellipsis commit be used |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
369 pub enable_ellipsis: bool, |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
370 } |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
371 |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
372 impl RevlogFeatureConfig { |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
373 pub fn new( |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
374 config: &Config, |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
375 requirements: &HashSet<String>, |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
376 ) -> Result<Self, HgError> { |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
377 Ok(Self { |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
378 compression_engine: CompressionConfig::new(config, requirements)?, |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
379 enable_ellipsis: requirements.contains(NARROW_REQUIREMENT), |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
380 ..Default::default() |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
381 }) |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
382 } |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
383 } |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
384 |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
385 /// Return the default options for a revlog of `revlog_type` according to the |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
386 /// current config and requirements. |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
387 pub fn default_revlog_options( |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
388 config: &Config, |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
389 requirements: &HashSet<String>, |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
390 revlog_type: RevlogType, |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
391 ) -> Result<RevlogOpenOptions, HgError> { |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
392 let is_changelog = revlog_type == RevlogType::Changelog; |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
393 let version = |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
394 if is_changelog && requirements.contains(CHANGELOGV2_REQUIREMENT) { |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
395 let compute_rank = config |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
396 .get_bool(b"experimental", b"changelog-v2.compute-rank")?; |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
397 RevlogVersionOptions::ChangelogV2 { compute_rank } |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
398 } else if requirements.contains(REVLOGV2_REQUIREMENT) { |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
399 RevlogVersionOptions::V2 |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
400 } else if requirements.contains(REVLOGV1_REQUIREMENT) { |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
401 RevlogVersionOptions::V1 { |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
402 general_delta: requirements.contains(GENERALDELTA_REQUIREMENT), |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
403 inline: !is_changelog, |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
404 } |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
405 } else { |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
406 RevlogVersionOptions::V0 |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
407 }; |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
408 Ok(RevlogOpenOptions { |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
409 version, |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
410 // We don't need to dance around the slow path like in the Python |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
411 // implementation since we know we have access to the fast code. |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
412 use_nodemap: requirements.contains(NODEMAP_REQUIREMENT), |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
413 delta_config: RevlogDeltaConfig::new( |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
414 config, |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
415 requirements, |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
416 revlog_type, |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
417 )?, |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
418 data_config: RevlogDataConfig::new(config, requirements)?, |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
419 feature_config: RevlogFeatureConfig::new(config, requirements)?, |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
420 }) |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
421 } |