Mercurial > public > mercurial-scm > hg-stable
annotate rust/hg-core/src/operations/debugdata.rs @ 47992:796206e74b10
rhg: Reuse manifest when checking status of multiple ambiguous files
When `rhg status` cannot determine whether a file is clean based on mtime and
size alone, it needs to compare its contents with those found in the parent
commit. Previously, rhg would find the (same) manifest of that commit again
for every such file. This is lifted out of the loop and reused.
Differential Revision: https://phab.mercurial-scm.org/D11411
author | Simon Sapin <simon.sapin@octobus.net> |
---|---|
date | Mon, 13 Sep 2021 18:09:10 +0200 |
parents | b274aa2f20fd |
children | f2f57724d4eb |
rev | line source |
---|---|
45533
b56df13a0450
hg-core: define a `DebugData` `Operation`
Antoine Cezar <antoine.cezar@octobus.net>
parents:
diff
changeset
|
1 // debugdata.rs |
b56df13a0450
hg-core: define a `DebugData` `Operation`
Antoine Cezar <antoine.cezar@octobus.net>
parents:
diff
changeset
|
2 // |
b56df13a0450
hg-core: define a `DebugData` `Operation`
Antoine Cezar <antoine.cezar@octobus.net>
parents:
diff
changeset
|
3 // Copyright 2020 Antoine Cezar <antoine.cezar@octobus.net> |
b56df13a0450
hg-core: define a `DebugData` `Operation`
Antoine Cezar <antoine.cezar@octobus.net>
parents:
diff
changeset
|
4 // |
b56df13a0450
hg-core: define a `DebugData` `Operation`
Antoine Cezar <antoine.cezar@octobus.net>
parents:
diff
changeset
|
5 // This software may be used and distributed according to the terms of the |
b56df13a0450
hg-core: define a `DebugData` `Operation`
Antoine Cezar <antoine.cezar@octobus.net>
parents:
diff
changeset
|
6 // GNU General Public License version 2 or any later version. |
b56df13a0450
hg-core: define a `DebugData` `Operation`
Antoine Cezar <antoine.cezar@octobus.net>
parents:
diff
changeset
|
7 |
46167
8a4914397d02
rust: introduce Repo and Vfs types for filesystem abstraction
Simon Sapin <simon.sapin@octobus.net>
parents:
46136
diff
changeset
|
8 use crate::repo::Repo; |
45533
b56df13a0450
hg-core: define a `DebugData` `Operation`
Antoine Cezar <antoine.cezar@octobus.net>
parents:
diff
changeset
|
9 use crate::revlog::revlog::{Revlog, RevlogError}; |
b56df13a0450
hg-core: define a `DebugData` `Operation`
Antoine Cezar <antoine.cezar@octobus.net>
parents:
diff
changeset
|
10 |
b56df13a0450
hg-core: define a `DebugData` `Operation`
Antoine Cezar <antoine.cezar@octobus.net>
parents:
diff
changeset
|
11 /// Kind of data to debug |
b56df13a0450
hg-core: define a `DebugData` `Operation`
Antoine Cezar <antoine.cezar@octobus.net>
parents:
diff
changeset
|
12 #[derive(Debug, Copy, Clone)] |
b56df13a0450
hg-core: define a `DebugData` `Operation`
Antoine Cezar <antoine.cezar@octobus.net>
parents:
diff
changeset
|
13 pub enum DebugDataKind { |
b56df13a0450
hg-core: define a `DebugData` `Operation`
Antoine Cezar <antoine.cezar@octobus.net>
parents:
diff
changeset
|
14 Changelog, |
b56df13a0450
hg-core: define a `DebugData` `Operation`
Antoine Cezar <antoine.cezar@octobus.net>
parents:
diff
changeset
|
15 Manifest, |
b56df13a0450
hg-core: define a `DebugData` `Operation`
Antoine Cezar <antoine.cezar@octobus.net>
parents:
diff
changeset
|
16 } |
b56df13a0450
hg-core: define a `DebugData` `Operation`
Antoine Cezar <antoine.cezar@octobus.net>
parents:
diff
changeset
|
17 |
b56df13a0450
hg-core: define a `DebugData` `Operation`
Antoine Cezar <antoine.cezar@octobus.net>
parents:
diff
changeset
|
18 /// Dump the contents data of a revision. |
46136
dca9cb99971c
rust: replace most "operation" structs with functions
Simon Sapin <simon.sapin@octobus.net>
parents:
46037
diff
changeset
|
19 pub fn debug_data( |
46167
8a4914397d02
rust: introduce Repo and Vfs types for filesystem abstraction
Simon Sapin <simon.sapin@octobus.net>
parents:
46136
diff
changeset
|
20 repo: &Repo, |
46501
4b381dbbf8b7
rhg: centralize parsing of `--rev` CLI arguments
Simon Sapin <simon.sapin@octobus.net>
parents:
46499
diff
changeset
|
21 revset: &str, |
45533
b56df13a0450
hg-core: define a `DebugData` `Operation`
Antoine Cezar <antoine.cezar@octobus.net>
parents:
diff
changeset
|
22 kind: DebugDataKind, |
46505
b274aa2f20fd
rust: remove three enums that were identical to `RevlogError`
Simon Sapin <simon.sapin@octobus.net>
parents:
46503
diff
changeset
|
23 ) -> Result<Vec<u8>, RevlogError> { |
46136
dca9cb99971c
rust: replace most "operation" structs with functions
Simon Sapin <simon.sapin@octobus.net>
parents:
46037
diff
changeset
|
24 let index_file = match kind { |
46167
8a4914397d02
rust: introduce Repo and Vfs types for filesystem abstraction
Simon Sapin <simon.sapin@octobus.net>
parents:
46136
diff
changeset
|
25 DebugDataKind::Changelog => "00changelog.i", |
8a4914397d02
rust: introduce Repo and Vfs types for filesystem abstraction
Simon Sapin <simon.sapin@octobus.net>
parents:
46136
diff
changeset
|
26 DebugDataKind::Manifest => "00manifest.i", |
46136
dca9cb99971c
rust: replace most "operation" structs with functions
Simon Sapin <simon.sapin@octobus.net>
parents:
46037
diff
changeset
|
27 }; |
46167
8a4914397d02
rust: introduce Repo and Vfs types for filesystem abstraction
Simon Sapin <simon.sapin@octobus.net>
parents:
46136
diff
changeset
|
28 let revlog = Revlog::open(repo, index_file, None)?; |
46501
4b381dbbf8b7
rhg: centralize parsing of `--rev` CLI arguments
Simon Sapin <simon.sapin@octobus.net>
parents:
46499
diff
changeset
|
29 let rev = |
4b381dbbf8b7
rhg: centralize parsing of `--rev` CLI arguments
Simon Sapin <simon.sapin@octobus.net>
parents:
46499
diff
changeset
|
30 crate::revset::resolve_rev_number_or_hex_prefix(revset, &revlog)?; |
4b381dbbf8b7
rhg: centralize parsing of `--rev` CLI arguments
Simon Sapin <simon.sapin@octobus.net>
parents:
46499
diff
changeset
|
31 let data = revlog.get_rev_data(rev)?; |
46136
dca9cb99971c
rust: replace most "operation" structs with functions
Simon Sapin <simon.sapin@octobus.net>
parents:
46037
diff
changeset
|
32 Ok(data) |
45533
b56df13a0450
hg-core: define a `DebugData` `Operation`
Antoine Cezar <antoine.cezar@octobus.net>
parents:
diff
changeset
|
33 } |