Mercurial > public > mercurial-scm > hg-stable
annotate rust/hg-core/src/revlog/options.rs @ 53040:cdd7bf612c7b stable tip
bundle-spec: properly format boolean parameter (issue6960)
This was breaking automatic clone bundle generation. This changeset fixes it and
add a test to catch it in the future.
author | Pierre-Yves David <pierre-yves.david@octobus.net> |
---|---|
date | Tue, 11 Mar 2025 02:29:42 +0100 |
parents | 8370eb2c72ca |
children |
rev | line source |
---|---|
52286
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 |
52295
84b5802ba7d3
rust: populate mmap by default if available
Rapha?l Gom?s <rgomes@octobus.net>
parents:
52286
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:
52286
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:
52286
diff
changeset
|
108 /// problems. |
84b5802ba7d3
rust: populate mmap by default if available
Rapha?l Gom?s <rgomes@octobus.net>
parents:
52286
diff
changeset
|
109 #[cfg(target_os = "linux")] |
84b5802ba7d3
rust: populate mmap by default if available
Rapha?l Gom?s <rgomes@octobus.net>
parents:
52286
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:
52286
diff
changeset
|
111 true |
84b5802ba7d3
rust: populate mmap by default if available
Rapha?l Gom?s <rgomes@octobus.net>
parents:
52286
diff
changeset
|
112 } |
84b5802ba7d3
rust: populate mmap by default if available
Rapha?l Gom?s <rgomes@octobus.net>
parents:
52286
diff
changeset
|
113 |
84b5802ba7d3
rust: populate mmap by default if available
Rapha?l Gom?s <rgomes@octobus.net>
parents:
52286
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:
52286
diff
changeset
|
115 #[cfg(not(target_os = "linux"))] |
52346
33d8cb64e9da
rust: fix darwin build
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
52295
diff
changeset
|
116 const fn can_populate_mmap() -> bool { |
52295
84b5802ba7d3
rust: populate mmap by default if available
Rapha?l Gom?s <rgomes@octobus.net>
parents:
52286
diff
changeset
|
117 false |
84b5802ba7d3
rust: populate mmap by default if available
Rapha?l Gom?s <rgomes@octobus.net>
parents:
52286
diff
changeset
|
118 } |
84b5802ba7d3
rust: populate mmap by default if available
Rapha?l Gom?s <rgomes@octobus.net>
parents:
52286
diff
changeset
|
119 |
52286
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 |
52295
84b5802ba7d3
rust: populate mmap by default if available
Rapha?l Gom?s <rgomes@octobus.net>
parents:
52286
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:
52286
diff
changeset
|
173 let mmap_index = config |
84b5802ba7d3
rust: populate mmap by default if available
Rapha?l Gom?s <rgomes@octobus.net>
parents:
52286
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:
52286
diff
changeset
|
175 .unwrap_or(can_populate_mmap()); |
84b5802ba7d3
rust: populate mmap by default if available
Rapha?l Gom?s <rgomes@octobus.net>
parents:
52286
diff
changeset
|
176 if mmap_index { |
84b5802ba7d3
rust: populate mmap by default if available
Rapha?l Gom?s <rgomes@octobus.net>
parents:
52286
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:
52286
diff
changeset
|
178 b"storage", |
84b5802ba7d3
rust: populate mmap by default if available
Rapha?l Gom?s <rgomes@octobus.net>
parents:
52286
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:
52286
diff
changeset
|
180 )? { |
84b5802ba7d3
rust: populate mmap by default if available
Rapha?l Gom?s <rgomes@octobus.net>
parents:
52286
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:
52286
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:
52286
diff
changeset
|
183 } |
84b5802ba7d3
rust: populate mmap by default if available
Rapha?l Gom?s <rgomes@octobus.net>
parents:
52286
diff
changeset
|
184 } |
84b5802ba7d3
rust: populate mmap by default if available
Rapha?l Gom?s <rgomes@octobus.net>
parents:
52286
diff
changeset
|
185 |
52286
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
186 let with_sparse_read = |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
187 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
|
188 if let Some(sr_density_threshold) = config |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
189 .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
|
190 { |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
191 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
|
192 } |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
193 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
|
194 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
|
195 .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
|
196 { |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
197 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
|
198 } |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
199 |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
200 data_config.with_sparse_read = |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
201 requirements.contains(SPARSEREVLOG_REQUIREMENT); |
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 Ok(data_config) |
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 |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
207 impl Default for RevlogDataConfig { |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
208 fn default() -> Self { |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
209 Self { |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
210 chunk_cache_size: DEFAULT_CHUNK_CACHE_SIZE, |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
211 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
|
212 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
|
213 try_pending: Default::default(), |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
214 try_split: Default::default(), |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
215 check_ambig: Default::default(), |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
216 mmap_large_index: Default::default(), |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
217 mmap_index_threshold: Default::default(), |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
218 uncompressed_cache_factor: Default::default(), |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
219 uncompressed_cache_count: Default::default(), |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
220 with_sparse_read: Default::default(), |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
221 general_delta: Default::default(), |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
222 } |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
223 } |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
224 } |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
225 |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
226 #[derive(Debug, Clone, Copy, PartialEq)] |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
227 /// 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
|
228 /// |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
229 /// 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
|
230 /// each object self contained. |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
231 pub struct RevlogDeltaConfig { |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
232 /// 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
|
233 pub general_delta: bool, |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
234 /// Allow sparse writing of the revlog data |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
235 pub sparse_revlog: bool, |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
236 /// Maximum length of a delta chain |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
237 pub max_chain_len: Option<u64>, |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
238 /// 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
|
239 pub max_deltachain_span: Option<u64>, |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
240 /// 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
|
241 /// gain from compression for the data content |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
242 pub upper_bound_comp: Option<f64>, |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
243 /// 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
|
244 pub delta_both_parents: bool, |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
245 /// 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
|
246 pub candidate_group_chunk_size: u64, |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
247 /// 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
|
248 pub debug_delta: bool, |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
249 /// Trust incoming deltas by default |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
250 pub lazy_delta: bool, |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
251 /// 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
|
252 pub lazy_delta_base: bool, |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
253 } |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
254 |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
255 impl RevlogDeltaConfig { |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
256 pub fn new( |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
257 config: &Config, |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
258 requirements: &HashSet<String>, |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
259 revlog_type: RevlogType, |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
260 ) -> Result<Self, HgError> { |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
261 let mut delta_config = Self { |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
262 delta_both_parents: config |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
263 .get_option_no_default( |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
264 b"storage", |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
265 b"revlog.optimize-delta-parent-choice", |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
266 )? |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
267 .unwrap_or(true), |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
268 candidate_group_chunk_size: config |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
269 .get_u64( |
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.delta-parent-search.candidate-group-chunk-size", |
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_default(), |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
274 ..Default::default() |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
275 }; |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
276 |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
277 delta_config.debug_delta = |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
278 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
|
279 |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
280 delta_config.general_delta = |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
281 requirements.contains(GENERALDELTA_REQUIREMENT); |
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 let lazy_delta = |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
284 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
|
285 |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
286 if revlog_type == RevlogType::Manifestlog { |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
287 // 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
|
288 // (real life value seems to be 3) |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
289 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
|
290 } |
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 let mut lazy_delta_base = false; |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
293 if lazy_delta { |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
294 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
|
295 b"storage", |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
296 b"revlog.reuse-external-delta-parent", |
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 Some(base) => base, |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
299 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
|
300 }; |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
301 } |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
302 delta_config.lazy_delta = lazy_delta; |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
303 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
|
304 |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
305 delta_config.max_deltachain_span = |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
306 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
|
307 Some(span) => { |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
308 if span < 0 { |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
309 None |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
310 } else { |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
311 Some(span as u64) |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
312 } |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
313 } |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
314 None => None, |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
315 }; |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
316 |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
317 delta_config.sparse_revlog = |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
318 requirements.contains(SPARSEREVLOG_REQUIREMENT); |
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 delta_config.max_chain_len = |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
321 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
|
322 |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
323 Ok(delta_config) |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
324 } |
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 |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
327 impl Default for RevlogDeltaConfig { |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
328 fn default() -> Self { |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
329 Self { |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
330 delta_both_parents: true, |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
331 lazy_delta: true, |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
332 general_delta: Default::default(), |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
333 sparse_revlog: Default::default(), |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
334 max_chain_len: Default::default(), |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
335 max_deltachain_span: Default::default(), |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
336 upper_bound_comp: Default::default(), |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
337 candidate_group_chunk_size: Default::default(), |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
338 debug_delta: Default::default(), |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
339 lazy_delta_base: Default::default(), |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
340 } |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
341 } |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
342 } |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
343 |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
344 #[derive(Debug, Default, Clone, Copy, PartialEq)] |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
345 /// 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
|
346 pub struct RevlogFeatureConfig { |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
347 /// The compression engine and its options |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
348 pub compression_engine: CompressionConfig, |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
349 /// Can we use censor on this revlog |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
350 pub censorable: bool, |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
351 /// 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
|
352 pub has_side_data: bool, |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
353 /// 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
|
354 /// impact |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
355 pub compute_rank: bool, |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
356 /// 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
|
357 /// 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
|
358 /// 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
|
359 /// 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
|
360 /// 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
|
361 pub canonical_parent_order: bool, |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
362 /// Can ellipsis commit be used |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
363 pub enable_ellipsis: bool, |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
364 } |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
365 |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
366 impl RevlogFeatureConfig { |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
367 pub fn new( |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
368 config: &Config, |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
369 requirements: &HashSet<String>, |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
370 ) -> Result<Self, HgError> { |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
371 Ok(Self { |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
372 compression_engine: CompressionConfig::new(config, requirements)?, |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
373 enable_ellipsis: requirements.contains(NARROW_REQUIREMENT), |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
374 ..Default::default() |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
375 }) |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
376 } |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
377 } |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
378 |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
379 /// 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
|
380 /// current config and requirements. |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
381 pub fn default_revlog_options( |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
382 config: &Config, |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
383 requirements: &HashSet<String>, |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
384 revlog_type: RevlogType, |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
385 ) -> Result<RevlogOpenOptions, HgError> { |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
386 let is_changelog = revlog_type == RevlogType::Changelog; |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
387 let version = |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
388 if is_changelog && requirements.contains(CHANGELOGV2_REQUIREMENT) { |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
389 let compute_rank = config |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
390 .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
|
391 RevlogVersionOptions::ChangelogV2 { compute_rank } |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
392 } else if requirements.contains(REVLOGV2_REQUIREMENT) { |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
393 RevlogVersionOptions::V2 |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
394 } else if requirements.contains(REVLOGV1_REQUIREMENT) { |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
395 RevlogVersionOptions::V1 { |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
396 general_delta: requirements.contains(GENERALDELTA_REQUIREMENT), |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
397 inline: !is_changelog, |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
398 } |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
399 } else { |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
400 RevlogVersionOptions::V0 |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
401 }; |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
402 Ok(RevlogOpenOptions { |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
403 version, |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
404 // 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
|
405 // 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
|
406 use_nodemap: requirements.contains(NODEMAP_REQUIREMENT), |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
407 delta_config: RevlogDeltaConfig::new( |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
408 config, |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
409 requirements, |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
410 revlog_type, |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
411 )?, |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
412 data_config: RevlogDataConfig::new(config, requirements)?, |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
413 feature_config: RevlogFeatureConfig::new(config, requirements)?, |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
414 }) |
039b7caeb4d9
rust-revlog: introduce an `options` module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
415 } |