annotate rust/hg-core/src/dirstate_tree/dispatch.rs @ 47511:eaae39894312

dirstate: move most of the `remove` logic with dirstatemap `removefile` This code deal with special logic to preserving "merged" and "from_p2" information when removing a file. These are implementation details that are more suitable for the dirstatemap layer. Since the dirstatemap layer alreaday have most of the information necessary to do so, the move is easy. This move helps us to encapsulate more implementation details within the dirstatemap and its entry. Easing the use of a different storage for dirstate v2. Differential Revision: https://phab.mercurial-scm.org/D10953
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Sat, 03 Jul 2021 19:52:00 +0200
parents 8851acad5906
children abed645b8e96
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
47107
787ff5d21bcd dirstate-tree: Make Rust DirstateMap bindings go through a trait object
Simon Sapin <simon.sapin@octobus.net>
parents:
diff changeset
1 use std::path::PathBuf;
787ff5d21bcd dirstate-tree: Make Rust DirstateMap bindings go through a trait object
Simon Sapin <simon.sapin@octobus.net>
parents:
diff changeset
2
47115
5d62243c7732 rust: Add a Timestamp struct instead of abusing Duration
Simon Sapin <simon.sapin@octobus.net>
parents: 47108
diff changeset
3 use crate::dirstate::parsers::Timestamp;
47343
ed1583a845d2 dirstate-v2: Make more APIs fallible, returning Result
Simon Sapin <simon.sapin@octobus.net>
parents: 47340
diff changeset
4 use crate::dirstate_tree::on_disk::DirstateV2ParseError;
47107
787ff5d21bcd dirstate-tree: Make Rust DirstateMap bindings go through a trait object
Simon Sapin <simon.sapin@octobus.net>
parents:
diff changeset
5 use crate::matchers::Matcher;
787ff5d21bcd dirstate-tree: Make Rust DirstateMap bindings go through a trait object
Simon Sapin <simon.sapin@octobus.net>
parents:
diff changeset
6 use crate::utils::hg_path::{HgPath, HgPathBuf};
787ff5d21bcd dirstate-tree: Make Rust DirstateMap bindings go through a trait object
Simon Sapin <simon.sapin@octobus.net>
parents:
diff changeset
7 use crate::CopyMapIter;
787ff5d21bcd dirstate-tree: Make Rust DirstateMap bindings go through a trait object
Simon Sapin <simon.sapin@octobus.net>
parents:
diff changeset
8 use crate::DirstateEntry;
787ff5d21bcd dirstate-tree: Make Rust DirstateMap bindings go through a trait object
Simon Sapin <simon.sapin@octobus.net>
parents:
diff changeset
9 use crate::DirstateError;
787ff5d21bcd dirstate-tree: Make Rust DirstateMap bindings go through a trait object
Simon Sapin <simon.sapin@octobus.net>
parents:
diff changeset
10 use crate::DirstateMap;
787ff5d21bcd dirstate-tree: Make Rust DirstateMap bindings go through a trait object
Simon Sapin <simon.sapin@octobus.net>
parents:
diff changeset
11 use crate::DirstateParents;
787ff5d21bcd dirstate-tree: Make Rust DirstateMap bindings go through a trait object
Simon Sapin <simon.sapin@octobus.net>
parents:
diff changeset
12 use crate::DirstateStatus;
787ff5d21bcd dirstate-tree: Make Rust DirstateMap bindings go through a trait object
Simon Sapin <simon.sapin@octobus.net>
parents:
diff changeset
13 use crate::EntryState;
787ff5d21bcd dirstate-tree: Make Rust DirstateMap bindings go through a trait object
Simon Sapin <simon.sapin@octobus.net>
parents:
diff changeset
14 use crate::PatternFileWarning;
787ff5d21bcd dirstate-tree: Make Rust DirstateMap bindings go through a trait object
Simon Sapin <simon.sapin@octobus.net>
parents:
diff changeset
15 use crate::StateMapIter;
787ff5d21bcd dirstate-tree: Make Rust DirstateMap bindings go through a trait object
Simon Sapin <simon.sapin@octobus.net>
parents:
diff changeset
16 use crate::StatusError;
787ff5d21bcd dirstate-tree: Make Rust DirstateMap bindings go through a trait object
Simon Sapin <simon.sapin@octobus.net>
parents:
diff changeset
17 use crate::StatusOptions;
787ff5d21bcd dirstate-tree: Make Rust DirstateMap bindings go through a trait object
Simon Sapin <simon.sapin@octobus.net>
parents:
diff changeset
18
47496
8851acad5906 rust: Document the DirstateMapMethods trait
Simon Sapin <simon.sapin@octobus.net>
parents: 47482
diff changeset
19 /// `rust/hg-cpython/src/dirstate/dirstate_map.rs` implements in Rust a
8851acad5906 rust: Document the DirstateMapMethods trait
Simon Sapin <simon.sapin@octobus.net>
parents: 47482
diff changeset
20 /// `DirstateMap` Python class that wraps `Box<dyn DirstateMapMethods + Send>`,
8851acad5906 rust: Document the DirstateMapMethods trait
Simon Sapin <simon.sapin@octobus.net>
parents: 47482
diff changeset
21 /// a trait object of this trait. Except for constructors, this trait defines
8851acad5906 rust: Document the DirstateMapMethods trait
Simon Sapin <simon.sapin@octobus.net>
parents: 47482
diff changeset
22 /// all APIs that the class needs to interact with its inner dirstate map.
8851acad5906 rust: Document the DirstateMapMethods trait
Simon Sapin <simon.sapin@octobus.net>
parents: 47482
diff changeset
23 ///
8851acad5906 rust: Document the DirstateMapMethods trait
Simon Sapin <simon.sapin@octobus.net>
parents: 47482
diff changeset
24 /// A trait object is used to support two different concrete types:
8851acad5906 rust: Document the DirstateMapMethods trait
Simon Sapin <simon.sapin@octobus.net>
parents: 47482
diff changeset
25 ///
8851acad5906 rust: Document the DirstateMapMethods trait
Simon Sapin <simon.sapin@octobus.net>
parents: 47482
diff changeset
26 /// * `rust/hg-core/src/dirstate/dirstate_map.rs` defines the "flat dirstate
8851acad5906 rust: Document the DirstateMapMethods trait
Simon Sapin <simon.sapin@octobus.net>
parents: 47482
diff changeset
27 /// map" which is based on a few large `HgPath`-keyed `HashMap` and `HashSet`
8851acad5906 rust: Document the DirstateMapMethods trait
Simon Sapin <simon.sapin@octobus.net>
parents: 47482
diff changeset
28 /// fields.
8851acad5906 rust: Document the DirstateMapMethods trait
Simon Sapin <simon.sapin@octobus.net>
parents: 47482
diff changeset
29 /// * `rust/hg-core/src/dirstate_tree/dirstate_map.rs` defines the "tree
8851acad5906 rust: Document the DirstateMapMethods trait
Simon Sapin <simon.sapin@octobus.net>
parents: 47482
diff changeset
30 /// dirstate map" based on a tree data struture with nodes for directories
8851acad5906 rust: Document the DirstateMapMethods trait
Simon Sapin <simon.sapin@octobus.net>
parents: 47482
diff changeset
31 /// containing child nodes for their files and sub-directories. This tree
8851acad5906 rust: Document the DirstateMapMethods trait
Simon Sapin <simon.sapin@octobus.net>
parents: 47482
diff changeset
32 /// enables a more efficient algorithm for `hg status`, but its details are
8851acad5906 rust: Document the DirstateMapMethods trait
Simon Sapin <simon.sapin@octobus.net>
parents: 47482
diff changeset
33 /// abstracted in this trait.
8851acad5906 rust: Document the DirstateMapMethods trait
Simon Sapin <simon.sapin@octobus.net>
parents: 47482
diff changeset
34 ///
8851acad5906 rust: Document the DirstateMapMethods trait
Simon Sapin <simon.sapin@octobus.net>
parents: 47482
diff changeset
35 /// The dirstate map associates paths of files in the working directory to
8851acad5906 rust: Document the DirstateMapMethods trait
Simon Sapin <simon.sapin@octobus.net>
parents: 47482
diff changeset
36 /// various information about the state of those files.
47107
787ff5d21bcd dirstate-tree: Make Rust DirstateMap bindings go through a trait object
Simon Sapin <simon.sapin@octobus.net>
parents:
diff changeset
37 pub trait DirstateMapMethods {
47496
8851acad5906 rust: Document the DirstateMapMethods trait
Simon Sapin <simon.sapin@octobus.net>
parents: 47482
diff changeset
38 /// Remove information about all files in this map
47107
787ff5d21bcd dirstate-tree: Make Rust DirstateMap bindings go through a trait object
Simon Sapin <simon.sapin@octobus.net>
parents:
diff changeset
39 fn clear(&mut self);
787ff5d21bcd dirstate-tree: Make Rust DirstateMap bindings go through a trait object
Simon Sapin <simon.sapin@octobus.net>
parents:
diff changeset
40
47496
8851acad5906 rust: Document the DirstateMapMethods trait
Simon Sapin <simon.sapin@octobus.net>
parents: 47482
diff changeset
41 /// Add or change the information associated to a given file.
8851acad5906 rust: Document the DirstateMapMethods trait
Simon Sapin <simon.sapin@octobus.net>
parents: 47482
diff changeset
42 ///
8851acad5906 rust: Document the DirstateMapMethods trait
Simon Sapin <simon.sapin@octobus.net>
parents: 47482
diff changeset
43 /// `old_state` is the state in the entry that `get` would have returned
8851acad5906 rust: Document the DirstateMapMethods trait
Simon Sapin <simon.sapin@octobus.net>
parents: 47482
diff changeset
44 /// before this call, or `EntryState::Unknown` if there was no such entry.
8851acad5906 rust: Document the DirstateMapMethods trait
Simon Sapin <simon.sapin@octobus.net>
parents: 47482
diff changeset
45 ///
8851acad5906 rust: Document the DirstateMapMethods trait
Simon Sapin <simon.sapin@octobus.net>
parents: 47482
diff changeset
46 /// `entry.state` should never be `EntryState::Unknown`.
47107
787ff5d21bcd dirstate-tree: Make Rust DirstateMap bindings go through a trait object
Simon Sapin <simon.sapin@octobus.net>
parents:
diff changeset
47 fn add_file(
787ff5d21bcd dirstate-tree: Make Rust DirstateMap bindings go through a trait object
Simon Sapin <simon.sapin@octobus.net>
parents:
diff changeset
48 &mut self,
787ff5d21bcd dirstate-tree: Make Rust DirstateMap bindings go through a trait object
Simon Sapin <simon.sapin@octobus.net>
parents:
diff changeset
49 filename: &HgPath,
787ff5d21bcd dirstate-tree: Make Rust DirstateMap bindings go through a trait object
Simon Sapin <simon.sapin@octobus.net>
parents:
diff changeset
50 old_state: EntryState,
787ff5d21bcd dirstate-tree: Make Rust DirstateMap bindings go through a trait object
Simon Sapin <simon.sapin@octobus.net>
parents:
diff changeset
51 entry: DirstateEntry,
47343
ed1583a845d2 dirstate-v2: Make more APIs fallible, returning Result
Simon Sapin <simon.sapin@octobus.net>
parents: 47340
diff changeset
52 ) -> Result<(), DirstateError>;
47107
787ff5d21bcd dirstate-tree: Make Rust DirstateMap bindings go through a trait object
Simon Sapin <simon.sapin@octobus.net>
parents:
diff changeset
53
47496
8851acad5906 rust: Document the DirstateMapMethods trait
Simon Sapin <simon.sapin@octobus.net>
parents: 47482
diff changeset
54 /// Mark a file as "removed" (as in `hg rm`).
8851acad5906 rust: Document the DirstateMapMethods trait
Simon Sapin <simon.sapin@octobus.net>
parents: 47482
diff changeset
55 ///
8851acad5906 rust: Document the DirstateMapMethods trait
Simon Sapin <simon.sapin@octobus.net>
parents: 47482
diff changeset
56 /// `old_state` is the state in the entry that `get` would have returned
8851acad5906 rust: Document the DirstateMapMethods trait
Simon Sapin <simon.sapin@octobus.net>
parents: 47482
diff changeset
57 /// before this call, or `EntryState::Unknown` if there was no such entry.
8851acad5906 rust: Document the DirstateMapMethods trait
Simon Sapin <simon.sapin@octobus.net>
parents: 47482
diff changeset
58 ///
8851acad5906 rust: Document the DirstateMapMethods trait
Simon Sapin <simon.sapin@octobus.net>
parents: 47482
diff changeset
59 /// `size` is not actually a size but the 0 or -1 or -2 value that would be
8851acad5906 rust: Document the DirstateMapMethods trait
Simon Sapin <simon.sapin@octobus.net>
parents: 47482
diff changeset
60 /// put in the size field in the dirstate-v1 format.
47107
787ff5d21bcd dirstate-tree: Make Rust DirstateMap bindings go through a trait object
Simon Sapin <simon.sapin@octobus.net>
parents:
diff changeset
61 fn remove_file(
787ff5d21bcd dirstate-tree: Make Rust DirstateMap bindings go through a trait object
Simon Sapin <simon.sapin@octobus.net>
parents:
diff changeset
62 &mut self,
787ff5d21bcd dirstate-tree: Make Rust DirstateMap bindings go through a trait object
Simon Sapin <simon.sapin@octobus.net>
parents:
diff changeset
63 filename: &HgPath,
47511
eaae39894312 dirstate: move most of the `remove` logic with dirstatemap `removefile`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47496
diff changeset
64 in_merge: bool,
47343
ed1583a845d2 dirstate-v2: Make more APIs fallible, returning Result
Simon Sapin <simon.sapin@octobus.net>
parents: 47340
diff changeset
65 ) -> Result<(), DirstateError>;
47107
787ff5d21bcd dirstate-tree: Make Rust DirstateMap bindings go through a trait object
Simon Sapin <simon.sapin@octobus.net>
parents:
diff changeset
66
47496
8851acad5906 rust: Document the DirstateMapMethods trait
Simon Sapin <simon.sapin@octobus.net>
parents: 47482
diff changeset
67 /// Drop information about this file from the map if any, and return
8851acad5906 rust: Document the DirstateMapMethods trait
Simon Sapin <simon.sapin@octobus.net>
parents: 47482
diff changeset
68 /// whether there was any.
8851acad5906 rust: Document the DirstateMapMethods trait
Simon Sapin <simon.sapin@octobus.net>
parents: 47482
diff changeset
69 ///
8851acad5906 rust: Document the DirstateMapMethods trait
Simon Sapin <simon.sapin@octobus.net>
parents: 47482
diff changeset
70 /// `get` will now return `None` for this filename.
8851acad5906 rust: Document the DirstateMapMethods trait
Simon Sapin <simon.sapin@octobus.net>
parents: 47482
diff changeset
71 ///
8851acad5906 rust: Document the DirstateMapMethods trait
Simon Sapin <simon.sapin@octobus.net>
parents: 47482
diff changeset
72 /// `old_state` is the state in the entry that `get` would have returned
8851acad5906 rust: Document the DirstateMapMethods trait
Simon Sapin <simon.sapin@octobus.net>
parents: 47482
diff changeset
73 /// before this call, or `EntryState::Unknown` if there was no such entry.
47107
787ff5d21bcd dirstate-tree: Make Rust DirstateMap bindings go through a trait object
Simon Sapin <simon.sapin@octobus.net>
parents:
diff changeset
74 fn drop_file(
787ff5d21bcd dirstate-tree: Make Rust DirstateMap bindings go through a trait object
Simon Sapin <simon.sapin@octobus.net>
parents:
diff changeset
75 &mut self,
787ff5d21bcd dirstate-tree: Make Rust DirstateMap bindings go through a trait object
Simon Sapin <simon.sapin@octobus.net>
parents:
diff changeset
76 filename: &HgPath,
787ff5d21bcd dirstate-tree: Make Rust DirstateMap bindings go through a trait object
Simon Sapin <simon.sapin@octobus.net>
parents:
diff changeset
77 old_state: EntryState,
47343
ed1583a845d2 dirstate-v2: Make more APIs fallible, returning Result
Simon Sapin <simon.sapin@octobus.net>
parents: 47340
diff changeset
78 ) -> Result<bool, DirstateError>;
47107
787ff5d21bcd dirstate-tree: Make Rust DirstateMap bindings go through a trait object
Simon Sapin <simon.sapin@octobus.net>
parents:
diff changeset
79
47496
8851acad5906 rust: Document the DirstateMapMethods trait
Simon Sapin <simon.sapin@octobus.net>
parents: 47482
diff changeset
80 /// Among given files, mark the stored `mtime` as ambiguous if there is one
8851acad5906 rust: Document the DirstateMapMethods trait
Simon Sapin <simon.sapin@octobus.net>
parents: 47482
diff changeset
81 /// (if `state == EntryState::Normal`) equal to the given current Unix
8851acad5906 rust: Document the DirstateMapMethods trait
Simon Sapin <simon.sapin@octobus.net>
parents: 47482
diff changeset
82 /// timestamp.
47343
ed1583a845d2 dirstate-v2: Make more APIs fallible, returning Result
Simon Sapin <simon.sapin@octobus.net>
parents: 47340
diff changeset
83 fn clear_ambiguous_times(
ed1583a845d2 dirstate-v2: Make more APIs fallible, returning Result
Simon Sapin <simon.sapin@octobus.net>
parents: 47340
diff changeset
84 &mut self,
ed1583a845d2 dirstate-v2: Make more APIs fallible, returning Result
Simon Sapin <simon.sapin@octobus.net>
parents: 47340
diff changeset
85 filenames: Vec<HgPathBuf>,
ed1583a845d2 dirstate-v2: Make more APIs fallible, returning Result
Simon Sapin <simon.sapin@octobus.net>
parents: 47340
diff changeset
86 now: i32,
ed1583a845d2 dirstate-v2: Make more APIs fallible, returning Result
Simon Sapin <simon.sapin@octobus.net>
parents: 47340
diff changeset
87 ) -> Result<(), DirstateV2ParseError>;
47107
787ff5d21bcd dirstate-tree: Make Rust DirstateMap bindings go through a trait object
Simon Sapin <simon.sapin@octobus.net>
parents:
diff changeset
88
47496
8851acad5906 rust: Document the DirstateMapMethods trait
Simon Sapin <simon.sapin@octobus.net>
parents: 47482
diff changeset
89 /// Return whether the map has an "non-normal" entry for the given
8851acad5906 rust: Document the DirstateMapMethods trait
Simon Sapin <simon.sapin@octobus.net>
parents: 47482
diff changeset
90 /// filename. That is, any entry with a `state` other than
8851acad5906 rust: Document the DirstateMapMethods trait
Simon Sapin <simon.sapin@octobus.net>
parents: 47482
diff changeset
91 /// `EntryState::Normal` or with an ambiguous `mtime`.
47343
ed1583a845d2 dirstate-v2: Make more APIs fallible, returning Result
Simon Sapin <simon.sapin@octobus.net>
parents: 47340
diff changeset
92 fn non_normal_entries_contains(
ed1583a845d2 dirstate-v2: Make more APIs fallible, returning Result
Simon Sapin <simon.sapin@octobus.net>
parents: 47340
diff changeset
93 &mut self,
ed1583a845d2 dirstate-v2: Make more APIs fallible, returning Result
Simon Sapin <simon.sapin@octobus.net>
parents: 47340
diff changeset
94 key: &HgPath,
ed1583a845d2 dirstate-v2: Make more APIs fallible, returning Result
Simon Sapin <simon.sapin@octobus.net>
parents: 47340
diff changeset
95 ) -> Result<bool, DirstateV2ParseError>;
47108
e061a1df32a8 dirstate-tree: Abstract "non-normal" and "other parent" sets
Simon Sapin <simon.sapin@octobus.net>
parents: 47107
diff changeset
96
47496
8851acad5906 rust: Document the DirstateMapMethods trait
Simon Sapin <simon.sapin@octobus.net>
parents: 47482
diff changeset
97 /// Mark the given path as "normal" file. This is only relevant in the flat
8851acad5906 rust: Document the DirstateMapMethods trait
Simon Sapin <simon.sapin@octobus.net>
parents: 47482
diff changeset
98 /// dirstate map where there is a separate `HashSet` that needs to be kept
8851acad5906 rust: Document the DirstateMapMethods trait
Simon Sapin <simon.sapin@octobus.net>
parents: 47482
diff changeset
99 /// up to date.
47122
e3cebe96c0fc dirstate-tree: Add "non normal" and "from other parent" sets
Simon Sapin <simon.sapin@octobus.net>
parents: 47115
diff changeset
100 fn non_normal_entries_remove(&mut self, key: &HgPath);
47107
787ff5d21bcd dirstate-tree: Make Rust DirstateMap bindings go through a trait object
Simon Sapin <simon.sapin@octobus.net>
parents:
diff changeset
101
47496
8851acad5906 rust: Document the DirstateMapMethods trait
Simon Sapin <simon.sapin@octobus.net>
parents: 47482
diff changeset
102 /// Return an iterator of paths whose respective entry are either
8851acad5906 rust: Document the DirstateMapMethods trait
Simon Sapin <simon.sapin@octobus.net>
parents: 47482
diff changeset
103 /// "non-normal" (see `non_normal_entries_contains`) or "from other
8851acad5906 rust: Document the DirstateMapMethods trait
Simon Sapin <simon.sapin@octobus.net>
parents: 47482
diff changeset
104 /// parent".
8851acad5906 rust: Document the DirstateMapMethods trait
Simon Sapin <simon.sapin@octobus.net>
parents: 47482
diff changeset
105 ///
8851acad5906 rust: Document the DirstateMapMethods trait
Simon Sapin <simon.sapin@octobus.net>
parents: 47482
diff changeset
106 /// If that information is cached, create the cache as needed.
8851acad5906 rust: Document the DirstateMapMethods trait
Simon Sapin <simon.sapin@octobus.net>
parents: 47482
diff changeset
107 ///
8851acad5906 rust: Document the DirstateMapMethods trait
Simon Sapin <simon.sapin@octobus.net>
parents: 47482
diff changeset
108 /// "From other parent" is defined as `state == Normal && size == -2`.
8851acad5906 rust: Document the DirstateMapMethods trait
Simon Sapin <simon.sapin@octobus.net>
parents: 47482
diff changeset
109 ///
8851acad5906 rust: Document the DirstateMapMethods trait
Simon Sapin <simon.sapin@octobus.net>
parents: 47482
diff changeset
110 /// Because parse errors can happen during iteration, the iterated items
8851acad5906 rust: Document the DirstateMapMethods trait
Simon Sapin <simon.sapin@octobus.net>
parents: 47482
diff changeset
111 /// are `Result`s.
47108
e061a1df32a8 dirstate-tree: Abstract "non-normal" and "other parent" sets
Simon Sapin <simon.sapin@octobus.net>
parents: 47107
diff changeset
112 fn non_normal_or_other_parent_paths(
47107
787ff5d21bcd dirstate-tree: Make Rust DirstateMap bindings go through a trait object
Simon Sapin <simon.sapin@octobus.net>
parents:
diff changeset
113 &mut self,
47343
ed1583a845d2 dirstate-v2: Make more APIs fallible, returning Result
Simon Sapin <simon.sapin@octobus.net>
parents: 47340
diff changeset
114 ) -> Box<dyn Iterator<Item = Result<&HgPath, DirstateV2ParseError>> + '_>;
47107
787ff5d21bcd dirstate-tree: Make Rust DirstateMap bindings go through a trait object
Simon Sapin <simon.sapin@octobus.net>
parents:
diff changeset
115
47496
8851acad5906 rust: Document the DirstateMapMethods trait
Simon Sapin <simon.sapin@octobus.net>
parents: 47482
diff changeset
116 /// Create the cache for `non_normal_or_other_parent_paths` if needed.
8851acad5906 rust: Document the DirstateMapMethods trait
Simon Sapin <simon.sapin@octobus.net>
parents: 47482
diff changeset
117 ///
8851acad5906 rust: Document the DirstateMapMethods trait
Simon Sapin <simon.sapin@octobus.net>
parents: 47482
diff changeset
118 /// If `force` is true, the cache is re-created even if it already exists.
47107
787ff5d21bcd dirstate-tree: Make Rust DirstateMap bindings go through a trait object
Simon Sapin <simon.sapin@octobus.net>
parents:
diff changeset
119 fn set_non_normal_other_parent_entries(&mut self, force: bool);
787ff5d21bcd dirstate-tree: Make Rust DirstateMap bindings go through a trait object
Simon Sapin <simon.sapin@octobus.net>
parents:
diff changeset
120
47496
8851acad5906 rust: Document the DirstateMapMethods trait
Simon Sapin <simon.sapin@octobus.net>
parents: 47482
diff changeset
121 /// Return an iterator of paths whose respective entry are "non-normal"
8851acad5906 rust: Document the DirstateMapMethods trait
Simon Sapin <simon.sapin@octobus.net>
parents: 47482
diff changeset
122 /// (see `non_normal_entries_contains`).
8851acad5906 rust: Document the DirstateMapMethods trait
Simon Sapin <simon.sapin@octobus.net>
parents: 47482
diff changeset
123 ///
8851acad5906 rust: Document the DirstateMapMethods trait
Simon Sapin <simon.sapin@octobus.net>
parents: 47482
diff changeset
124 /// If that information is cached, create the cache as needed.
8851acad5906 rust: Document the DirstateMapMethods trait
Simon Sapin <simon.sapin@octobus.net>
parents: 47482
diff changeset
125 ///
8851acad5906 rust: Document the DirstateMapMethods trait
Simon Sapin <simon.sapin@octobus.net>
parents: 47482
diff changeset
126 /// Because parse errors can happen during iteration, the iterated items
8851acad5906 rust: Document the DirstateMapMethods trait
Simon Sapin <simon.sapin@octobus.net>
parents: 47482
diff changeset
127 /// are `Result`s.
47108
e061a1df32a8 dirstate-tree: Abstract "non-normal" and "other parent" sets
Simon Sapin <simon.sapin@octobus.net>
parents: 47107
diff changeset
128 fn iter_non_normal_paths(
e061a1df32a8 dirstate-tree: Abstract "non-normal" and "other parent" sets
Simon Sapin <simon.sapin@octobus.net>
parents: 47107
diff changeset
129 &mut self,
47343
ed1583a845d2 dirstate-v2: Make more APIs fallible, returning Result
Simon Sapin <simon.sapin@octobus.net>
parents: 47340
diff changeset
130 ) -> Box<
ed1583a845d2 dirstate-v2: Make more APIs fallible, returning Result
Simon Sapin <simon.sapin@octobus.net>
parents: 47340
diff changeset
131 dyn Iterator<Item = Result<&HgPath, DirstateV2ParseError>> + Send + '_,
ed1583a845d2 dirstate-v2: Make more APIs fallible, returning Result
Simon Sapin <simon.sapin@octobus.net>
parents: 47340
diff changeset
132 >;
47107
787ff5d21bcd dirstate-tree: Make Rust DirstateMap bindings go through a trait object
Simon Sapin <simon.sapin@octobus.net>
parents:
diff changeset
133
47496
8851acad5906 rust: Document the DirstateMapMethods trait
Simon Sapin <simon.sapin@octobus.net>
parents: 47482
diff changeset
134 /// Same as `iter_non_normal_paths`, but takes `&self` instead of `&mut
8851acad5906 rust: Document the DirstateMapMethods trait
Simon Sapin <simon.sapin@octobus.net>
parents: 47482
diff changeset
135 /// self`.
8851acad5906 rust: Document the DirstateMapMethods trait
Simon Sapin <simon.sapin@octobus.net>
parents: 47482
diff changeset
136 ///
8851acad5906 rust: Document the DirstateMapMethods trait
Simon Sapin <simon.sapin@octobus.net>
parents: 47482
diff changeset
137 /// Panics if a cache is necessary but does not exist yet.
47108
e061a1df32a8 dirstate-tree: Abstract "non-normal" and "other parent" sets
Simon Sapin <simon.sapin@octobus.net>
parents: 47107
diff changeset
138 fn iter_non_normal_paths_panic(
e061a1df32a8 dirstate-tree: Abstract "non-normal" and "other parent" sets
Simon Sapin <simon.sapin@octobus.net>
parents: 47107
diff changeset
139 &self,
47343
ed1583a845d2 dirstate-v2: Make more APIs fallible, returning Result
Simon Sapin <simon.sapin@octobus.net>
parents: 47340
diff changeset
140 ) -> Box<
ed1583a845d2 dirstate-v2: Make more APIs fallible, returning Result
Simon Sapin <simon.sapin@octobus.net>
parents: 47340
diff changeset
141 dyn Iterator<Item = Result<&HgPath, DirstateV2ParseError>> + Send + '_,
ed1583a845d2 dirstate-v2: Make more APIs fallible, returning Result
Simon Sapin <simon.sapin@octobus.net>
parents: 47340
diff changeset
142 >;
47108
e061a1df32a8 dirstate-tree: Abstract "non-normal" and "other parent" sets
Simon Sapin <simon.sapin@octobus.net>
parents: 47107
diff changeset
143
47496
8851acad5906 rust: Document the DirstateMapMethods trait
Simon Sapin <simon.sapin@octobus.net>
parents: 47482
diff changeset
144 /// Return an iterator of paths whose respective entry are "from other
8851acad5906 rust: Document the DirstateMapMethods trait
Simon Sapin <simon.sapin@octobus.net>
parents: 47482
diff changeset
145 /// parent".
8851acad5906 rust: Document the DirstateMapMethods trait
Simon Sapin <simon.sapin@octobus.net>
parents: 47482
diff changeset
146 ///
8851acad5906 rust: Document the DirstateMapMethods trait
Simon Sapin <simon.sapin@octobus.net>
parents: 47482
diff changeset
147 /// If that information is cached, create the cache as needed.
8851acad5906 rust: Document the DirstateMapMethods trait
Simon Sapin <simon.sapin@octobus.net>
parents: 47482
diff changeset
148 ///
8851acad5906 rust: Document the DirstateMapMethods trait
Simon Sapin <simon.sapin@octobus.net>
parents: 47482
diff changeset
149 /// "From other parent" is defined as `state == Normal && size == -2`.
8851acad5906 rust: Document the DirstateMapMethods trait
Simon Sapin <simon.sapin@octobus.net>
parents: 47482
diff changeset
150 ///
8851acad5906 rust: Document the DirstateMapMethods trait
Simon Sapin <simon.sapin@octobus.net>
parents: 47482
diff changeset
151 /// Because parse errors can happen during iteration, the iterated items
8851acad5906 rust: Document the DirstateMapMethods trait
Simon Sapin <simon.sapin@octobus.net>
parents: 47482
diff changeset
152 /// are `Result`s.
47108
e061a1df32a8 dirstate-tree: Abstract "non-normal" and "other parent" sets
Simon Sapin <simon.sapin@octobus.net>
parents: 47107
diff changeset
153 fn iter_other_parent_paths(
47107
787ff5d21bcd dirstate-tree: Make Rust DirstateMap bindings go through a trait object
Simon Sapin <simon.sapin@octobus.net>
parents:
diff changeset
154 &mut self,
47343
ed1583a845d2 dirstate-v2: Make more APIs fallible, returning Result
Simon Sapin <simon.sapin@octobus.net>
parents: 47340
diff changeset
155 ) -> Box<
ed1583a845d2 dirstate-v2: Make more APIs fallible, returning Result
Simon Sapin <simon.sapin@octobus.net>
parents: 47340
diff changeset
156 dyn Iterator<Item = Result<&HgPath, DirstateV2ParseError>> + Send + '_,
ed1583a845d2 dirstate-v2: Make more APIs fallible, returning Result
Simon Sapin <simon.sapin@octobus.net>
parents: 47340
diff changeset
157 >;
47107
787ff5d21bcd dirstate-tree: Make Rust DirstateMap bindings go through a trait object
Simon Sapin <simon.sapin@octobus.net>
parents:
diff changeset
158
47496
8851acad5906 rust: Document the DirstateMapMethods trait
Simon Sapin <simon.sapin@octobus.net>
parents: 47482
diff changeset
159 /// Returns whether the sub-tree rooted at the given directory contains any
8851acad5906 rust: Document the DirstateMapMethods trait
Simon Sapin <simon.sapin@octobus.net>
parents: 47482
diff changeset
160 /// tracked file.
8851acad5906 rust: Document the DirstateMapMethods trait
Simon Sapin <simon.sapin@octobus.net>
parents: 47482
diff changeset
161 ///
8851acad5906 rust: Document the DirstateMapMethods trait
Simon Sapin <simon.sapin@octobus.net>
parents: 47482
diff changeset
162 /// A file is tracked if it has a `state` other than `EntryState::Removed`.
47107
787ff5d21bcd dirstate-tree: Make Rust DirstateMap bindings go through a trait object
Simon Sapin <simon.sapin@octobus.net>
parents:
diff changeset
163 fn has_tracked_dir(
787ff5d21bcd dirstate-tree: Make Rust DirstateMap bindings go through a trait object
Simon Sapin <simon.sapin@octobus.net>
parents:
diff changeset
164 &mut self,
787ff5d21bcd dirstate-tree: Make Rust DirstateMap bindings go through a trait object
Simon Sapin <simon.sapin@octobus.net>
parents:
diff changeset
165 directory: &HgPath,
47343
ed1583a845d2 dirstate-v2: Make more APIs fallible, returning Result
Simon Sapin <simon.sapin@octobus.net>
parents: 47340
diff changeset
166 ) -> Result<bool, DirstateError>;
47107
787ff5d21bcd dirstate-tree: Make Rust DirstateMap bindings go through a trait object
Simon Sapin <simon.sapin@octobus.net>
parents:
diff changeset
167
47496
8851acad5906 rust: Document the DirstateMapMethods trait
Simon Sapin <simon.sapin@octobus.net>
parents: 47482
diff changeset
168 /// Returns whether the sub-tree rooted at the given directory contains any
8851acad5906 rust: Document the DirstateMapMethods trait
Simon Sapin <simon.sapin@octobus.net>
parents: 47482
diff changeset
169 /// file with a dirstate entry.
47343
ed1583a845d2 dirstate-v2: Make more APIs fallible, returning Result
Simon Sapin <simon.sapin@octobus.net>
parents: 47340
diff changeset
170 fn has_dir(&mut self, directory: &HgPath) -> Result<bool, DirstateError>;
47107
787ff5d21bcd dirstate-tree: Make Rust DirstateMap bindings go through a trait object
Simon Sapin <simon.sapin@octobus.net>
parents:
diff changeset
171
47496
8851acad5906 rust: Document the DirstateMapMethods trait
Simon Sapin <simon.sapin@octobus.net>
parents: 47482
diff changeset
172 /// Clear mtimes that are ambigous with `now` (similar to
8851acad5906 rust: Document the DirstateMapMethods trait
Simon Sapin <simon.sapin@octobus.net>
parents: 47482
diff changeset
173 /// `clear_ambiguous_times` but for all files in the dirstate map), and
8851acad5906 rust: Document the DirstateMapMethods trait
Simon Sapin <simon.sapin@octobus.net>
parents: 47482
diff changeset
174 /// serialize bytes to write the `.hg/dirstate` file to disk in dirstate-v1
8851acad5906 rust: Document the DirstateMapMethods trait
Simon Sapin <simon.sapin@octobus.net>
parents: 47482
diff changeset
175 /// format.
47291
1766130fe9ba dirstate-v2: Change the on-disk format when the requirement is enabled
Simon Sapin <simon.sapin@octobus.net>
parents: 47138
diff changeset
176 fn pack_v1(
1766130fe9ba dirstate-v2: Change the on-disk format when the requirement is enabled
Simon Sapin <simon.sapin@octobus.net>
parents: 47138
diff changeset
177 &mut self,
1766130fe9ba dirstate-v2: Change the on-disk format when the requirement is enabled
Simon Sapin <simon.sapin@octobus.net>
parents: 47138
diff changeset
178 parents: DirstateParents,
1766130fe9ba dirstate-v2: Change the on-disk format when the requirement is enabled
Simon Sapin <simon.sapin@octobus.net>
parents: 47138
diff changeset
179 now: Timestamp,
1766130fe9ba dirstate-v2: Change the on-disk format when the requirement is enabled
Simon Sapin <simon.sapin@octobus.net>
parents: 47138
diff changeset
180 ) -> Result<Vec<u8>, DirstateError>;
1766130fe9ba dirstate-v2: Change the on-disk format when the requirement is enabled
Simon Sapin <simon.sapin@octobus.net>
parents: 47138
diff changeset
181
47496
8851acad5906 rust: Document the DirstateMapMethods trait
Simon Sapin <simon.sapin@octobus.net>
parents: 47482
diff changeset
182 /// Clear mtimes that are ambigous with `now` (similar to
8851acad5906 rust: Document the DirstateMapMethods trait
Simon Sapin <simon.sapin@octobus.net>
parents: 47482
diff changeset
183 /// `clear_ambiguous_times` but for all files in the dirstate map), and
8851acad5906 rust: Document the DirstateMapMethods trait
Simon Sapin <simon.sapin@octobus.net>
parents: 47482
diff changeset
184 /// serialize bytes to write the `.hg/dirstate` file to disk in dirstate-v2
8851acad5906 rust: Document the DirstateMapMethods trait
Simon Sapin <simon.sapin@octobus.net>
parents: 47482
diff changeset
185 /// format.
8851acad5906 rust: Document the DirstateMapMethods trait
Simon Sapin <simon.sapin@octobus.net>
parents: 47482
diff changeset
186 ///
8851acad5906 rust: Document the DirstateMapMethods trait
Simon Sapin <simon.sapin@octobus.net>
parents: 47482
diff changeset
187 /// Note: this is only supported by the tree dirstate map.
47291
1766130fe9ba dirstate-v2: Change the on-disk format when the requirement is enabled
Simon Sapin <simon.sapin@octobus.net>
parents: 47138
diff changeset
188 fn pack_v2(
47107
787ff5d21bcd dirstate-tree: Make Rust DirstateMap bindings go through a trait object
Simon Sapin <simon.sapin@octobus.net>
parents:
diff changeset
189 &mut self,
787ff5d21bcd dirstate-tree: Make Rust DirstateMap bindings go through a trait object
Simon Sapin <simon.sapin@octobus.net>
parents:
diff changeset
190 parents: DirstateParents,
47115
5d62243c7732 rust: Add a Timestamp struct instead of abusing Duration
Simon Sapin <simon.sapin@octobus.net>
parents: 47108
diff changeset
191 now: Timestamp,
47107
787ff5d21bcd dirstate-tree: Make Rust DirstateMap bindings go through a trait object
Simon Sapin <simon.sapin@octobus.net>
parents:
diff changeset
192 ) -> Result<Vec<u8>, DirstateError>;
787ff5d21bcd dirstate-tree: Make Rust DirstateMap bindings go through a trait object
Simon Sapin <simon.sapin@octobus.net>
parents:
diff changeset
193
47496
8851acad5906 rust: Document the DirstateMapMethods trait
Simon Sapin <simon.sapin@octobus.net>
parents: 47482
diff changeset
194 /// Run the status algorithm.
8851acad5906 rust: Document the DirstateMapMethods trait
Simon Sapin <simon.sapin@octobus.net>
parents: 47482
diff changeset
195 ///
8851acad5906 rust: Document the DirstateMapMethods trait
Simon Sapin <simon.sapin@octobus.net>
parents: 47482
diff changeset
196 /// This is not sematically a method of the dirstate map, but a different
8851acad5906 rust: Document the DirstateMapMethods trait
Simon Sapin <simon.sapin@octobus.net>
parents: 47482
diff changeset
197 /// algorithm is used for the flat v.s. tree dirstate map so having it in
8851acad5906 rust: Document the DirstateMapMethods trait
Simon Sapin <simon.sapin@octobus.net>
parents: 47482
diff changeset
198 /// this trait enables the same dynamic dispatch as with other methods.
47107
787ff5d21bcd dirstate-tree: Make Rust DirstateMap bindings go through a trait object
Simon Sapin <simon.sapin@octobus.net>
parents:
diff changeset
199 fn status<'a>(
47126
d5956136d19d dirstate-tree: Give to `status()` mutable access to the `DirstateMap`
Simon Sapin <simon.sapin@octobus.net>
parents: 47124
diff changeset
200 &'a mut self,
47107
787ff5d21bcd dirstate-tree: Make Rust DirstateMap bindings go through a trait object
Simon Sapin <simon.sapin@octobus.net>
parents:
diff changeset
201 matcher: &'a (dyn Matcher + Sync),
787ff5d21bcd dirstate-tree: Make Rust DirstateMap bindings go through a trait object
Simon Sapin <simon.sapin@octobus.net>
parents:
diff changeset
202 root_dir: PathBuf,
787ff5d21bcd dirstate-tree: Make Rust DirstateMap bindings go through a trait object
Simon Sapin <simon.sapin@octobus.net>
parents:
diff changeset
203 ignore_files: Vec<PathBuf>,
787ff5d21bcd dirstate-tree: Make Rust DirstateMap bindings go through a trait object
Simon Sapin <simon.sapin@octobus.net>
parents:
diff changeset
204 options: StatusOptions,
47124
9c6b458a08e1 rust: Move "lookup" a.k.a. "unsure" paths into `DirstateStatus` struct
Simon Sapin <simon.sapin@octobus.net>
parents: 47123
diff changeset
205 ) -> Result<(DirstateStatus<'a>, Vec<PatternFileWarning>), StatusError>;
47107
787ff5d21bcd dirstate-tree: Make Rust DirstateMap bindings go through a trait object
Simon Sapin <simon.sapin@octobus.net>
parents:
diff changeset
206
47496
8851acad5906 rust: Document the DirstateMapMethods trait
Simon Sapin <simon.sapin@octobus.net>
parents: 47482
diff changeset
207 /// Returns how many files in the dirstate map have a recorded copy source.
47107
787ff5d21bcd dirstate-tree: Make Rust DirstateMap bindings go through a trait object
Simon Sapin <simon.sapin@octobus.net>
parents:
diff changeset
208 fn copy_map_len(&self) -> usize;
787ff5d21bcd dirstate-tree: Make Rust DirstateMap bindings go through a trait object
Simon Sapin <simon.sapin@octobus.net>
parents:
diff changeset
209
47496
8851acad5906 rust: Document the DirstateMapMethods trait
Simon Sapin <simon.sapin@octobus.net>
parents: 47482
diff changeset
210 /// Returns an iterator of `(path, copy_source)` for all files that have a
8851acad5906 rust: Document the DirstateMapMethods trait
Simon Sapin <simon.sapin@octobus.net>
parents: 47482
diff changeset
211 /// copy source.
47107
787ff5d21bcd dirstate-tree: Make Rust DirstateMap bindings go through a trait object
Simon Sapin <simon.sapin@octobus.net>
parents:
diff changeset
212 fn copy_map_iter(&self) -> CopyMapIter<'_>;
787ff5d21bcd dirstate-tree: Make Rust DirstateMap bindings go through a trait object
Simon Sapin <simon.sapin@octobus.net>
parents:
diff changeset
213
47496
8851acad5906 rust: Document the DirstateMapMethods trait
Simon Sapin <simon.sapin@octobus.net>
parents: 47482
diff changeset
214 /// Returns whether the givef file has a copy source.
47343
ed1583a845d2 dirstate-v2: Make more APIs fallible, returning Result
Simon Sapin <simon.sapin@octobus.net>
parents: 47340
diff changeset
215 fn copy_map_contains_key(
ed1583a845d2 dirstate-v2: Make more APIs fallible, returning Result
Simon Sapin <simon.sapin@octobus.net>
parents: 47340
diff changeset
216 &self,
ed1583a845d2 dirstate-v2: Make more APIs fallible, returning Result
Simon Sapin <simon.sapin@octobus.net>
parents: 47340
diff changeset
217 key: &HgPath,
ed1583a845d2 dirstate-v2: Make more APIs fallible, returning Result
Simon Sapin <simon.sapin@octobus.net>
parents: 47340
diff changeset
218 ) -> Result<bool, DirstateV2ParseError>;
47107
787ff5d21bcd dirstate-tree: Make Rust DirstateMap bindings go through a trait object
Simon Sapin <simon.sapin@octobus.net>
parents:
diff changeset
219
47496
8851acad5906 rust: Document the DirstateMapMethods trait
Simon Sapin <simon.sapin@octobus.net>
parents: 47482
diff changeset
220 /// Returns the copy source for the given file.
47343
ed1583a845d2 dirstate-v2: Make more APIs fallible, returning Result
Simon Sapin <simon.sapin@octobus.net>
parents: 47340
diff changeset
221 fn copy_map_get(
ed1583a845d2 dirstate-v2: Make more APIs fallible, returning Result
Simon Sapin <simon.sapin@octobus.net>
parents: 47340
diff changeset
222 &self,
ed1583a845d2 dirstate-v2: Make more APIs fallible, returning Result
Simon Sapin <simon.sapin@octobus.net>
parents: 47340
diff changeset
223 key: &HgPath,
ed1583a845d2 dirstate-v2: Make more APIs fallible, returning Result
Simon Sapin <simon.sapin@octobus.net>
parents: 47340
diff changeset
224 ) -> Result<Option<&HgPath>, DirstateV2ParseError>;
47107
787ff5d21bcd dirstate-tree: Make Rust DirstateMap bindings go through a trait object
Simon Sapin <simon.sapin@octobus.net>
parents:
diff changeset
225
47496
8851acad5906 rust: Document the DirstateMapMethods trait
Simon Sapin <simon.sapin@octobus.net>
parents: 47482
diff changeset
226 /// Removes the recorded copy source if any for the given file, and returns
8851acad5906 rust: Document the DirstateMapMethods trait
Simon Sapin <simon.sapin@octobus.net>
parents: 47482
diff changeset
227 /// it.
47343
ed1583a845d2 dirstate-v2: Make more APIs fallible, returning Result
Simon Sapin <simon.sapin@octobus.net>
parents: 47340
diff changeset
228 fn copy_map_remove(
ed1583a845d2 dirstate-v2: Make more APIs fallible, returning Result
Simon Sapin <simon.sapin@octobus.net>
parents: 47340
diff changeset
229 &mut self,
ed1583a845d2 dirstate-v2: Make more APIs fallible, returning Result
Simon Sapin <simon.sapin@octobus.net>
parents: 47340
diff changeset
230 key: &HgPath,
ed1583a845d2 dirstate-v2: Make more APIs fallible, returning Result
Simon Sapin <simon.sapin@octobus.net>
parents: 47340
diff changeset
231 ) -> Result<Option<HgPathBuf>, DirstateV2ParseError>;
47107
787ff5d21bcd dirstate-tree: Make Rust DirstateMap bindings go through a trait object
Simon Sapin <simon.sapin@octobus.net>
parents:
diff changeset
232
47496
8851acad5906 rust: Document the DirstateMapMethods trait
Simon Sapin <simon.sapin@octobus.net>
parents: 47482
diff changeset
233 /// Set the given `value` copy source for the given `key` file.
47107
787ff5d21bcd dirstate-tree: Make Rust DirstateMap bindings go through a trait object
Simon Sapin <simon.sapin@octobus.net>
parents:
diff changeset
234 fn copy_map_insert(
787ff5d21bcd dirstate-tree: Make Rust DirstateMap bindings go through a trait object
Simon Sapin <simon.sapin@octobus.net>
parents:
diff changeset
235 &mut self,
787ff5d21bcd dirstate-tree: Make Rust DirstateMap bindings go through a trait object
Simon Sapin <simon.sapin@octobus.net>
parents:
diff changeset
236 key: HgPathBuf,
787ff5d21bcd dirstate-tree: Make Rust DirstateMap bindings go through a trait object
Simon Sapin <simon.sapin@octobus.net>
parents:
diff changeset
237 value: HgPathBuf,
47343
ed1583a845d2 dirstate-v2: Make more APIs fallible, returning Result
Simon Sapin <simon.sapin@octobus.net>
parents: 47340
diff changeset
238 ) -> Result<Option<HgPathBuf>, DirstateV2ParseError>;
47107
787ff5d21bcd dirstate-tree: Make Rust DirstateMap bindings go through a trait object
Simon Sapin <simon.sapin@octobus.net>
parents:
diff changeset
239
47496
8851acad5906 rust: Document the DirstateMapMethods trait
Simon Sapin <simon.sapin@octobus.net>
parents: 47482
diff changeset
240 /// Returns the number of files that have an entry.
47107
787ff5d21bcd dirstate-tree: Make Rust DirstateMap bindings go through a trait object
Simon Sapin <simon.sapin@octobus.net>
parents:
diff changeset
241 fn len(&self) -> usize;
787ff5d21bcd dirstate-tree: Make Rust DirstateMap bindings go through a trait object
Simon Sapin <simon.sapin@octobus.net>
parents:
diff changeset
242
47496
8851acad5906 rust: Document the DirstateMapMethods trait
Simon Sapin <simon.sapin@octobus.net>
parents: 47482
diff changeset
243 /// Returns whether the given file has an entry.
47343
ed1583a845d2 dirstate-v2: Make more APIs fallible, returning Result
Simon Sapin <simon.sapin@octobus.net>
parents: 47340
diff changeset
244 fn contains_key(&self, key: &HgPath)
ed1583a845d2 dirstate-v2: Make more APIs fallible, returning Result
Simon Sapin <simon.sapin@octobus.net>
parents: 47340
diff changeset
245 -> Result<bool, DirstateV2ParseError>;
47107
787ff5d21bcd dirstate-tree: Make Rust DirstateMap bindings go through a trait object
Simon Sapin <simon.sapin@octobus.net>
parents:
diff changeset
246
47496
8851acad5906 rust: Document the DirstateMapMethods trait
Simon Sapin <simon.sapin@octobus.net>
parents: 47482
diff changeset
247 /// Returns the entry, if any, for the given file.
47343
ed1583a845d2 dirstate-v2: Make more APIs fallible, returning Result
Simon Sapin <simon.sapin@octobus.net>
parents: 47340
diff changeset
248 fn get(
ed1583a845d2 dirstate-v2: Make more APIs fallible, returning Result
Simon Sapin <simon.sapin@octobus.net>
parents: 47340
diff changeset
249 &self,
ed1583a845d2 dirstate-v2: Make more APIs fallible, returning Result
Simon Sapin <simon.sapin@octobus.net>
parents: 47340
diff changeset
250 key: &HgPath,
ed1583a845d2 dirstate-v2: Make more APIs fallible, returning Result
Simon Sapin <simon.sapin@octobus.net>
parents: 47340
diff changeset
251 ) -> Result<Option<DirstateEntry>, DirstateV2ParseError>;
47107
787ff5d21bcd dirstate-tree: Make Rust DirstateMap bindings go through a trait object
Simon Sapin <simon.sapin@octobus.net>
parents:
diff changeset
252
47496
8851acad5906 rust: Document the DirstateMapMethods trait
Simon Sapin <simon.sapin@octobus.net>
parents: 47482
diff changeset
253 /// Returns a `(path, entry)` iterator of files that have an entry.
8851acad5906 rust: Document the DirstateMapMethods trait
Simon Sapin <simon.sapin@octobus.net>
parents: 47482
diff changeset
254 ///
8851acad5906 rust: Document the DirstateMapMethods trait
Simon Sapin <simon.sapin@octobus.net>
parents: 47482
diff changeset
255 /// Because parse errors can happen during iteration, the iterated items
8851acad5906 rust: Document the DirstateMapMethods trait
Simon Sapin <simon.sapin@octobus.net>
parents: 47482
diff changeset
256 /// are `Result`s.
47107
787ff5d21bcd dirstate-tree: Make Rust DirstateMap bindings go through a trait object
Simon Sapin <simon.sapin@octobus.net>
parents:
diff changeset
257 fn iter(&self) -> StateMapIter<'_>;
47357
3b9914b28133 dirstate-v2: Add --dirs to debugdirstate command
Simon Sapin <simon.sapin@octobus.net>
parents: 47343
diff changeset
258
47496
8851acad5906 rust: Document the DirstateMapMethods trait
Simon Sapin <simon.sapin@octobus.net>
parents: 47482
diff changeset
259 /// In the tree dirstate, return an iterator of "directory" (entry-less)
8851acad5906 rust: Document the DirstateMapMethods trait
Simon Sapin <simon.sapin@octobus.net>
parents: 47482
diff changeset
260 /// nodes with the data stored for them. This is for `hg debugdirstate
8851acad5906 rust: Document the DirstateMapMethods trait
Simon Sapin <simon.sapin@octobus.net>
parents: 47482
diff changeset
261 /// --dirs`.
8851acad5906 rust: Document the DirstateMapMethods trait
Simon Sapin <simon.sapin@octobus.net>
parents: 47482
diff changeset
262 ///
8851acad5906 rust: Document the DirstateMapMethods trait
Simon Sapin <simon.sapin@octobus.net>
parents: 47482
diff changeset
263 /// In the flat dirstate, returns an empty iterator.
8851acad5906 rust: Document the DirstateMapMethods trait
Simon Sapin <simon.sapin@octobus.net>
parents: 47482
diff changeset
264 ///
8851acad5906 rust: Document the DirstateMapMethods trait
Simon Sapin <simon.sapin@octobus.net>
parents: 47482
diff changeset
265 /// Because parse errors can happen during iteration, the iterated items
8851acad5906 rust: Document the DirstateMapMethods trait
Simon Sapin <simon.sapin@octobus.net>
parents: 47482
diff changeset
266 /// are `Result`s.
47357
3b9914b28133 dirstate-v2: Add --dirs to debugdirstate command
Simon Sapin <simon.sapin@octobus.net>
parents: 47343
diff changeset
267 fn iter_directories(
3b9914b28133 dirstate-v2: Add --dirs to debugdirstate command
Simon Sapin <simon.sapin@octobus.net>
parents: 47343
diff changeset
268 &self,
3b9914b28133 dirstate-v2: Add --dirs to debugdirstate command
Simon Sapin <simon.sapin@octobus.net>
parents: 47343
diff changeset
269 ) -> Box<
3b9914b28133 dirstate-v2: Add --dirs to debugdirstate command
Simon Sapin <simon.sapin@octobus.net>
parents: 47343
diff changeset
270 dyn Iterator<
3b9914b28133 dirstate-v2: Add --dirs to debugdirstate command
Simon Sapin <simon.sapin@octobus.net>
parents: 47343
diff changeset
271 Item = Result<
3b9914b28133 dirstate-v2: Add --dirs to debugdirstate command
Simon Sapin <simon.sapin@octobus.net>
parents: 47343
diff changeset
272 (&HgPath, Option<Timestamp>),
3b9914b28133 dirstate-v2: Add --dirs to debugdirstate command
Simon Sapin <simon.sapin@octobus.net>
parents: 47343
diff changeset
273 DirstateV2ParseError,
3b9914b28133 dirstate-v2: Add --dirs to debugdirstate command
Simon Sapin <simon.sapin@octobus.net>
parents: 47343
diff changeset
274 >,
3b9914b28133 dirstate-v2: Add --dirs to debugdirstate command
Simon Sapin <simon.sapin@octobus.net>
parents: 47343
diff changeset
275 > + Send
3b9914b28133 dirstate-v2: Add --dirs to debugdirstate command
Simon Sapin <simon.sapin@octobus.net>
parents: 47343
diff changeset
276 + '_,
3b9914b28133 dirstate-v2: Add --dirs to debugdirstate command
Simon Sapin <simon.sapin@octobus.net>
parents: 47343
diff changeset
277 >;
47107
787ff5d21bcd dirstate-tree: Make Rust DirstateMap bindings go through a trait object
Simon Sapin <simon.sapin@octobus.net>
parents:
diff changeset
278 }
787ff5d21bcd dirstate-tree: Make Rust DirstateMap bindings go through a trait object
Simon Sapin <simon.sapin@octobus.net>
parents:
diff changeset
279
787ff5d21bcd dirstate-tree: Make Rust DirstateMap bindings go through a trait object
Simon Sapin <simon.sapin@octobus.net>
parents:
diff changeset
280 impl DirstateMapMethods for DirstateMap {
787ff5d21bcd dirstate-tree: Make Rust DirstateMap bindings go through a trait object
Simon Sapin <simon.sapin@octobus.net>
parents:
diff changeset
281 fn clear(&mut self) {
787ff5d21bcd dirstate-tree: Make Rust DirstateMap bindings go through a trait object
Simon Sapin <simon.sapin@octobus.net>
parents:
diff changeset
282 self.clear()
787ff5d21bcd dirstate-tree: Make Rust DirstateMap bindings go through a trait object
Simon Sapin <simon.sapin@octobus.net>
parents:
diff changeset
283 }
787ff5d21bcd dirstate-tree: Make Rust DirstateMap bindings go through a trait object
Simon Sapin <simon.sapin@octobus.net>
parents:
diff changeset
284
787ff5d21bcd dirstate-tree: Make Rust DirstateMap bindings go through a trait object
Simon Sapin <simon.sapin@octobus.net>
parents:
diff changeset
285 fn add_file(
787ff5d21bcd dirstate-tree: Make Rust DirstateMap bindings go through a trait object
Simon Sapin <simon.sapin@octobus.net>
parents:
diff changeset
286 &mut self,
787ff5d21bcd dirstate-tree: Make Rust DirstateMap bindings go through a trait object
Simon Sapin <simon.sapin@octobus.net>
parents:
diff changeset
287 filename: &HgPath,
787ff5d21bcd dirstate-tree: Make Rust DirstateMap bindings go through a trait object
Simon Sapin <simon.sapin@octobus.net>
parents:
diff changeset
288 old_state: EntryState,
787ff5d21bcd dirstate-tree: Make Rust DirstateMap bindings go through a trait object
Simon Sapin <simon.sapin@octobus.net>
parents:
diff changeset
289 entry: DirstateEntry,
47343
ed1583a845d2 dirstate-v2: Make more APIs fallible, returning Result
Simon Sapin <simon.sapin@octobus.net>
parents: 47340
diff changeset
290 ) -> Result<(), DirstateError> {
47107
787ff5d21bcd dirstate-tree: Make Rust DirstateMap bindings go through a trait object
Simon Sapin <simon.sapin@octobus.net>
parents:
diff changeset
291 self.add_file(filename, old_state, entry)
787ff5d21bcd dirstate-tree: Make Rust DirstateMap bindings go through a trait object
Simon Sapin <simon.sapin@octobus.net>
parents:
diff changeset
292 }
787ff5d21bcd dirstate-tree: Make Rust DirstateMap bindings go through a trait object
Simon Sapin <simon.sapin@octobus.net>
parents:
diff changeset
293
787ff5d21bcd dirstate-tree: Make Rust DirstateMap bindings go through a trait object
Simon Sapin <simon.sapin@octobus.net>
parents:
diff changeset
294 fn remove_file(
787ff5d21bcd dirstate-tree: Make Rust DirstateMap bindings go through a trait object
Simon Sapin <simon.sapin@octobus.net>
parents:
diff changeset
295 &mut self,
787ff5d21bcd dirstate-tree: Make Rust DirstateMap bindings go through a trait object
Simon Sapin <simon.sapin@octobus.net>
parents:
diff changeset
296 filename: &HgPath,
47511
eaae39894312 dirstate: move most of the `remove` logic with dirstatemap `removefile`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47496
diff changeset
297 in_merge: bool,
47343
ed1583a845d2 dirstate-v2: Make more APIs fallible, returning Result
Simon Sapin <simon.sapin@octobus.net>
parents: 47340
diff changeset
298 ) -> Result<(), DirstateError> {
47511
eaae39894312 dirstate: move most of the `remove` logic with dirstatemap `removefile`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47496
diff changeset
299 self.remove_file(filename, in_merge)
47107
787ff5d21bcd dirstate-tree: Make Rust DirstateMap bindings go through a trait object
Simon Sapin <simon.sapin@octobus.net>
parents:
diff changeset
300 }
787ff5d21bcd dirstate-tree: Make Rust DirstateMap bindings go through a trait object
Simon Sapin <simon.sapin@octobus.net>
parents:
diff changeset
301
787ff5d21bcd dirstate-tree: Make Rust DirstateMap bindings go through a trait object
Simon Sapin <simon.sapin@octobus.net>
parents:
diff changeset
302 fn drop_file(
787ff5d21bcd dirstate-tree: Make Rust DirstateMap bindings go through a trait object
Simon Sapin <simon.sapin@octobus.net>
parents:
diff changeset
303 &mut self,
787ff5d21bcd dirstate-tree: Make Rust DirstateMap bindings go through a trait object
Simon Sapin <simon.sapin@octobus.net>
parents:
diff changeset
304 filename: &HgPath,
787ff5d21bcd dirstate-tree: Make Rust DirstateMap bindings go through a trait object
Simon Sapin <simon.sapin@octobus.net>
parents:
diff changeset
305 old_state: EntryState,
47343
ed1583a845d2 dirstate-v2: Make more APIs fallible, returning Result
Simon Sapin <simon.sapin@octobus.net>
parents: 47340
diff changeset
306 ) -> Result<bool, DirstateError> {
47107
787ff5d21bcd dirstate-tree: Make Rust DirstateMap bindings go through a trait object
Simon Sapin <simon.sapin@octobus.net>
parents:
diff changeset
307 self.drop_file(filename, old_state)
787ff5d21bcd dirstate-tree: Make Rust DirstateMap bindings go through a trait object
Simon Sapin <simon.sapin@octobus.net>
parents:
diff changeset
308 }
787ff5d21bcd dirstate-tree: Make Rust DirstateMap bindings go through a trait object
Simon Sapin <simon.sapin@octobus.net>
parents:
diff changeset
309
47343
ed1583a845d2 dirstate-v2: Make more APIs fallible, returning Result
Simon Sapin <simon.sapin@octobus.net>
parents: 47340
diff changeset
310 fn clear_ambiguous_times(
ed1583a845d2 dirstate-v2: Make more APIs fallible, returning Result
Simon Sapin <simon.sapin@octobus.net>
parents: 47340
diff changeset
311 &mut self,
ed1583a845d2 dirstate-v2: Make more APIs fallible, returning Result
Simon Sapin <simon.sapin@octobus.net>
parents: 47340
diff changeset
312 filenames: Vec<HgPathBuf>,
ed1583a845d2 dirstate-v2: Make more APIs fallible, returning Result
Simon Sapin <simon.sapin@octobus.net>
parents: 47340
diff changeset
313 now: i32,
ed1583a845d2 dirstate-v2: Make more APIs fallible, returning Result
Simon Sapin <simon.sapin@octobus.net>
parents: 47340
diff changeset
314 ) -> Result<(), DirstateV2ParseError> {
ed1583a845d2 dirstate-v2: Make more APIs fallible, returning Result
Simon Sapin <simon.sapin@octobus.net>
parents: 47340
diff changeset
315 Ok(self.clear_ambiguous_times(filenames, now))
47107
787ff5d21bcd dirstate-tree: Make Rust DirstateMap bindings go through a trait object
Simon Sapin <simon.sapin@octobus.net>
parents:
diff changeset
316 }
787ff5d21bcd dirstate-tree: Make Rust DirstateMap bindings go through a trait object
Simon Sapin <simon.sapin@octobus.net>
parents:
diff changeset
317
47343
ed1583a845d2 dirstate-v2: Make more APIs fallible, returning Result
Simon Sapin <simon.sapin@octobus.net>
parents: 47340
diff changeset
318 fn non_normal_entries_contains(
ed1583a845d2 dirstate-v2: Make more APIs fallible, returning Result
Simon Sapin <simon.sapin@octobus.net>
parents: 47340
diff changeset
319 &mut self,
ed1583a845d2 dirstate-v2: Make more APIs fallible, returning Result
Simon Sapin <simon.sapin@octobus.net>
parents: 47340
diff changeset
320 key: &HgPath,
ed1583a845d2 dirstate-v2: Make more APIs fallible, returning Result
Simon Sapin <simon.sapin@octobus.net>
parents: 47340
diff changeset
321 ) -> Result<bool, DirstateV2ParseError> {
47108
e061a1df32a8 dirstate-tree: Abstract "non-normal" and "other parent" sets
Simon Sapin <simon.sapin@octobus.net>
parents: 47107
diff changeset
322 let (non_normal, _other_parent) =
e061a1df32a8 dirstate-tree: Abstract "non-normal" and "other parent" sets
Simon Sapin <simon.sapin@octobus.net>
parents: 47107
diff changeset
323 self.get_non_normal_other_parent_entries();
47343
ed1583a845d2 dirstate-v2: Make more APIs fallible, returning Result
Simon Sapin <simon.sapin@octobus.net>
parents: 47340
diff changeset
324 Ok(non_normal.contains(key))
47108
e061a1df32a8 dirstate-tree: Abstract "non-normal" and "other parent" sets
Simon Sapin <simon.sapin@octobus.net>
parents: 47107
diff changeset
325 }
e061a1df32a8 dirstate-tree: Abstract "non-normal" and "other parent" sets
Simon Sapin <simon.sapin@octobus.net>
parents: 47107
diff changeset
326
47122
e3cebe96c0fc dirstate-tree: Add "non normal" and "from other parent" sets
Simon Sapin <simon.sapin@octobus.net>
parents: 47115
diff changeset
327 fn non_normal_entries_remove(&mut self, key: &HgPath) {
47107
787ff5d21bcd dirstate-tree: Make Rust DirstateMap bindings go through a trait object
Simon Sapin <simon.sapin@octobus.net>
parents:
diff changeset
328 self.non_normal_entries_remove(key)
787ff5d21bcd dirstate-tree: Make Rust DirstateMap bindings go through a trait object
Simon Sapin <simon.sapin@octobus.net>
parents:
diff changeset
329 }
787ff5d21bcd dirstate-tree: Make Rust DirstateMap bindings go through a trait object
Simon Sapin <simon.sapin@octobus.net>
parents:
diff changeset
330
47108
e061a1df32a8 dirstate-tree: Abstract "non-normal" and "other parent" sets
Simon Sapin <simon.sapin@octobus.net>
parents: 47107
diff changeset
331 fn non_normal_or_other_parent_paths(
47107
787ff5d21bcd dirstate-tree: Make Rust DirstateMap bindings go through a trait object
Simon Sapin <simon.sapin@octobus.net>
parents:
diff changeset
332 &mut self,
47343
ed1583a845d2 dirstate-v2: Make more APIs fallible, returning Result
Simon Sapin <simon.sapin@octobus.net>
parents: 47340
diff changeset
333 ) -> Box<dyn Iterator<Item = Result<&HgPath, DirstateV2ParseError>> + '_>
ed1583a845d2 dirstate-v2: Make more APIs fallible, returning Result
Simon Sapin <simon.sapin@octobus.net>
parents: 47340
diff changeset
334 {
47108
e061a1df32a8 dirstate-tree: Abstract "non-normal" and "other parent" sets
Simon Sapin <simon.sapin@octobus.net>
parents: 47107
diff changeset
335 let (non_normal, other_parent) =
e061a1df32a8 dirstate-tree: Abstract "non-normal" and "other parent" sets
Simon Sapin <simon.sapin@octobus.net>
parents: 47107
diff changeset
336 self.get_non_normal_other_parent_entries();
47343
ed1583a845d2 dirstate-v2: Make more APIs fallible, returning Result
Simon Sapin <simon.sapin@octobus.net>
parents: 47340
diff changeset
337 Box::new(non_normal.union(other_parent).map(|p| Ok(&**p)))
47107
787ff5d21bcd dirstate-tree: Make Rust DirstateMap bindings go through a trait object
Simon Sapin <simon.sapin@octobus.net>
parents:
diff changeset
338 }
787ff5d21bcd dirstate-tree: Make Rust DirstateMap bindings go through a trait object
Simon Sapin <simon.sapin@octobus.net>
parents:
diff changeset
339
787ff5d21bcd dirstate-tree: Make Rust DirstateMap bindings go through a trait object
Simon Sapin <simon.sapin@octobus.net>
parents:
diff changeset
340 fn set_non_normal_other_parent_entries(&mut self, force: bool) {
787ff5d21bcd dirstate-tree: Make Rust DirstateMap bindings go through a trait object
Simon Sapin <simon.sapin@octobus.net>
parents:
diff changeset
341 self.set_non_normal_other_parent_entries(force)
787ff5d21bcd dirstate-tree: Make Rust DirstateMap bindings go through a trait object
Simon Sapin <simon.sapin@octobus.net>
parents:
diff changeset
342 }
787ff5d21bcd dirstate-tree: Make Rust DirstateMap bindings go through a trait object
Simon Sapin <simon.sapin@octobus.net>
parents:
diff changeset
343
47108
e061a1df32a8 dirstate-tree: Abstract "non-normal" and "other parent" sets
Simon Sapin <simon.sapin@octobus.net>
parents: 47107
diff changeset
344 fn iter_non_normal_paths(
e061a1df32a8 dirstate-tree: Abstract "non-normal" and "other parent" sets
Simon Sapin <simon.sapin@octobus.net>
parents: 47107
diff changeset
345 &mut self,
47343
ed1583a845d2 dirstate-v2: Make more APIs fallible, returning Result
Simon Sapin <simon.sapin@octobus.net>
parents: 47340
diff changeset
346 ) -> Box<
ed1583a845d2 dirstate-v2: Make more APIs fallible, returning Result
Simon Sapin <simon.sapin@octobus.net>
parents: 47340
diff changeset
347 dyn Iterator<Item = Result<&HgPath, DirstateV2ParseError>> + Send + '_,
ed1583a845d2 dirstate-v2: Make more APIs fallible, returning Result
Simon Sapin <simon.sapin@octobus.net>
parents: 47340
diff changeset
348 > {
47108
e061a1df32a8 dirstate-tree: Abstract "non-normal" and "other parent" sets
Simon Sapin <simon.sapin@octobus.net>
parents: 47107
diff changeset
349 let (non_normal, _other_parent) =
e061a1df32a8 dirstate-tree: Abstract "non-normal" and "other parent" sets
Simon Sapin <simon.sapin@octobus.net>
parents: 47107
diff changeset
350 self.get_non_normal_other_parent_entries();
47343
ed1583a845d2 dirstate-v2: Make more APIs fallible, returning Result
Simon Sapin <simon.sapin@octobus.net>
parents: 47340
diff changeset
351 Box::new(non_normal.iter().map(|p| Ok(&**p)))
47107
787ff5d21bcd dirstate-tree: Make Rust DirstateMap bindings go through a trait object
Simon Sapin <simon.sapin@octobus.net>
parents:
diff changeset
352 }
787ff5d21bcd dirstate-tree: Make Rust DirstateMap bindings go through a trait object
Simon Sapin <simon.sapin@octobus.net>
parents:
diff changeset
353
47108
e061a1df32a8 dirstate-tree: Abstract "non-normal" and "other parent" sets
Simon Sapin <simon.sapin@octobus.net>
parents: 47107
diff changeset
354 fn iter_non_normal_paths_panic(
e061a1df32a8 dirstate-tree: Abstract "non-normal" and "other parent" sets
Simon Sapin <simon.sapin@octobus.net>
parents: 47107
diff changeset
355 &self,
47343
ed1583a845d2 dirstate-v2: Make more APIs fallible, returning Result
Simon Sapin <simon.sapin@octobus.net>
parents: 47340
diff changeset
356 ) -> Box<
ed1583a845d2 dirstate-v2: Make more APIs fallible, returning Result
Simon Sapin <simon.sapin@octobus.net>
parents: 47340
diff changeset
357 dyn Iterator<Item = Result<&HgPath, DirstateV2ParseError>> + Send + '_,
ed1583a845d2 dirstate-v2: Make more APIs fallible, returning Result
Simon Sapin <simon.sapin@octobus.net>
parents: 47340
diff changeset
358 > {
47108
e061a1df32a8 dirstate-tree: Abstract "non-normal" and "other parent" sets
Simon Sapin <simon.sapin@octobus.net>
parents: 47107
diff changeset
359 let (non_normal, _other_parent) =
e061a1df32a8 dirstate-tree: Abstract "non-normal" and "other parent" sets
Simon Sapin <simon.sapin@octobus.net>
parents: 47107
diff changeset
360 self.get_non_normal_other_parent_entries_panic();
47343
ed1583a845d2 dirstate-v2: Make more APIs fallible, returning Result
Simon Sapin <simon.sapin@octobus.net>
parents: 47340
diff changeset
361 Box::new(non_normal.iter().map(|p| Ok(&**p)))
47108
e061a1df32a8 dirstate-tree: Abstract "non-normal" and "other parent" sets
Simon Sapin <simon.sapin@octobus.net>
parents: 47107
diff changeset
362 }
e061a1df32a8 dirstate-tree: Abstract "non-normal" and "other parent" sets
Simon Sapin <simon.sapin@octobus.net>
parents: 47107
diff changeset
363
e061a1df32a8 dirstate-tree: Abstract "non-normal" and "other parent" sets
Simon Sapin <simon.sapin@octobus.net>
parents: 47107
diff changeset
364 fn iter_other_parent_paths(
47107
787ff5d21bcd dirstate-tree: Make Rust DirstateMap bindings go through a trait object
Simon Sapin <simon.sapin@octobus.net>
parents:
diff changeset
365 &mut self,
47343
ed1583a845d2 dirstate-v2: Make more APIs fallible, returning Result
Simon Sapin <simon.sapin@octobus.net>
parents: 47340
diff changeset
366 ) -> Box<
ed1583a845d2 dirstate-v2: Make more APIs fallible, returning Result
Simon Sapin <simon.sapin@octobus.net>
parents: 47340
diff changeset
367 dyn Iterator<Item = Result<&HgPath, DirstateV2ParseError>> + Send + '_,
ed1583a845d2 dirstate-v2: Make more APIs fallible, returning Result
Simon Sapin <simon.sapin@octobus.net>
parents: 47340
diff changeset
368 > {
47108
e061a1df32a8 dirstate-tree: Abstract "non-normal" and "other parent" sets
Simon Sapin <simon.sapin@octobus.net>
parents: 47107
diff changeset
369 let (_non_normal, other_parent) =
e061a1df32a8 dirstate-tree: Abstract "non-normal" and "other parent" sets
Simon Sapin <simon.sapin@octobus.net>
parents: 47107
diff changeset
370 self.get_non_normal_other_parent_entries();
47343
ed1583a845d2 dirstate-v2: Make more APIs fallible, returning Result
Simon Sapin <simon.sapin@octobus.net>
parents: 47340
diff changeset
371 Box::new(other_parent.iter().map(|p| Ok(&**p)))
47107
787ff5d21bcd dirstate-tree: Make Rust DirstateMap bindings go through a trait object
Simon Sapin <simon.sapin@octobus.net>
parents:
diff changeset
372 }
787ff5d21bcd dirstate-tree: Make Rust DirstateMap bindings go through a trait object
Simon Sapin <simon.sapin@octobus.net>
parents:
diff changeset
373
787ff5d21bcd dirstate-tree: Make Rust DirstateMap bindings go through a trait object
Simon Sapin <simon.sapin@octobus.net>
parents:
diff changeset
374 fn has_tracked_dir(
787ff5d21bcd dirstate-tree: Make Rust DirstateMap bindings go through a trait object
Simon Sapin <simon.sapin@octobus.net>
parents:
diff changeset
375 &mut self,
787ff5d21bcd dirstate-tree: Make Rust DirstateMap bindings go through a trait object
Simon Sapin <simon.sapin@octobus.net>
parents:
diff changeset
376 directory: &HgPath,
47343
ed1583a845d2 dirstate-v2: Make more APIs fallible, returning Result
Simon Sapin <simon.sapin@octobus.net>
parents: 47340
diff changeset
377 ) -> Result<bool, DirstateError> {
47107
787ff5d21bcd dirstate-tree: Make Rust DirstateMap bindings go through a trait object
Simon Sapin <simon.sapin@octobus.net>
parents:
diff changeset
378 self.has_tracked_dir(directory)
787ff5d21bcd dirstate-tree: Make Rust DirstateMap bindings go through a trait object
Simon Sapin <simon.sapin@octobus.net>
parents:
diff changeset
379 }
787ff5d21bcd dirstate-tree: Make Rust DirstateMap bindings go through a trait object
Simon Sapin <simon.sapin@octobus.net>
parents:
diff changeset
380
47343
ed1583a845d2 dirstate-v2: Make more APIs fallible, returning Result
Simon Sapin <simon.sapin@octobus.net>
parents: 47340
diff changeset
381 fn has_dir(&mut self, directory: &HgPath) -> Result<bool, DirstateError> {
47107
787ff5d21bcd dirstate-tree: Make Rust DirstateMap bindings go through a trait object
Simon Sapin <simon.sapin@octobus.net>
parents:
diff changeset
382 self.has_dir(directory)
787ff5d21bcd dirstate-tree: Make Rust DirstateMap bindings go through a trait object
Simon Sapin <simon.sapin@octobus.net>
parents:
diff changeset
383 }
787ff5d21bcd dirstate-tree: Make Rust DirstateMap bindings go through a trait object
Simon Sapin <simon.sapin@octobus.net>
parents:
diff changeset
384
47291
1766130fe9ba dirstate-v2: Change the on-disk format when the requirement is enabled
Simon Sapin <simon.sapin@octobus.net>
parents: 47138
diff changeset
385 fn pack_v1(
47107
787ff5d21bcd dirstate-tree: Make Rust DirstateMap bindings go through a trait object
Simon Sapin <simon.sapin@octobus.net>
parents:
diff changeset
386 &mut self,
787ff5d21bcd dirstate-tree: Make Rust DirstateMap bindings go through a trait object
Simon Sapin <simon.sapin@octobus.net>
parents:
diff changeset
387 parents: DirstateParents,
47115
5d62243c7732 rust: Add a Timestamp struct instead of abusing Duration
Simon Sapin <simon.sapin@octobus.net>
parents: 47108
diff changeset
388 now: Timestamp,
47107
787ff5d21bcd dirstate-tree: Make Rust DirstateMap bindings go through a trait object
Simon Sapin <simon.sapin@octobus.net>
parents:
diff changeset
389 ) -> Result<Vec<u8>, DirstateError> {
787ff5d21bcd dirstate-tree: Make Rust DirstateMap bindings go through a trait object
Simon Sapin <simon.sapin@octobus.net>
parents:
diff changeset
390 self.pack(parents, now)
787ff5d21bcd dirstate-tree: Make Rust DirstateMap bindings go through a trait object
Simon Sapin <simon.sapin@octobus.net>
parents:
diff changeset
391 }
787ff5d21bcd dirstate-tree: Make Rust DirstateMap bindings go through a trait object
Simon Sapin <simon.sapin@octobus.net>
parents:
diff changeset
392
47291
1766130fe9ba dirstate-v2: Change the on-disk format when the requirement is enabled
Simon Sapin <simon.sapin@octobus.net>
parents: 47138
diff changeset
393 fn pack_v2(
1766130fe9ba dirstate-v2: Change the on-disk format when the requirement is enabled
Simon Sapin <simon.sapin@octobus.net>
parents: 47138
diff changeset
394 &mut self,
1766130fe9ba dirstate-v2: Change the on-disk format when the requirement is enabled
Simon Sapin <simon.sapin@octobus.net>
parents: 47138
diff changeset
395 _parents: DirstateParents,
1766130fe9ba dirstate-v2: Change the on-disk format when the requirement is enabled
Simon Sapin <simon.sapin@octobus.net>
parents: 47138
diff changeset
396 _now: Timestamp,
1766130fe9ba dirstate-v2: Change the on-disk format when the requirement is enabled
Simon Sapin <simon.sapin@octobus.net>
parents: 47138
diff changeset
397 ) -> Result<Vec<u8>, DirstateError> {
1766130fe9ba dirstate-v2: Change the on-disk format when the requirement is enabled
Simon Sapin <simon.sapin@octobus.net>
parents: 47138
diff changeset
398 panic!(
1766130fe9ba dirstate-v2: Change the on-disk format when the requirement is enabled
Simon Sapin <simon.sapin@octobus.net>
parents: 47138
diff changeset
399 "should have used dirstate_tree::DirstateMap to use the v2 format"
1766130fe9ba dirstate-v2: Change the on-disk format when the requirement is enabled
Simon Sapin <simon.sapin@octobus.net>
parents: 47138
diff changeset
400 )
1766130fe9ba dirstate-v2: Change the on-disk format when the requirement is enabled
Simon Sapin <simon.sapin@octobus.net>
parents: 47138
diff changeset
401 }
1766130fe9ba dirstate-v2: Change the on-disk format when the requirement is enabled
Simon Sapin <simon.sapin@octobus.net>
parents: 47138
diff changeset
402
47107
787ff5d21bcd dirstate-tree: Make Rust DirstateMap bindings go through a trait object
Simon Sapin <simon.sapin@octobus.net>
parents:
diff changeset
403 fn status<'a>(
47126
d5956136d19d dirstate-tree: Give to `status()` mutable access to the `DirstateMap`
Simon Sapin <simon.sapin@octobus.net>
parents: 47124
diff changeset
404 &'a mut self,
47107
787ff5d21bcd dirstate-tree: Make Rust DirstateMap bindings go through a trait object
Simon Sapin <simon.sapin@octobus.net>
parents:
diff changeset
405 matcher: &'a (dyn Matcher + Sync),
787ff5d21bcd dirstate-tree: Make Rust DirstateMap bindings go through a trait object
Simon Sapin <simon.sapin@octobus.net>
parents:
diff changeset
406 root_dir: PathBuf,
787ff5d21bcd dirstate-tree: Make Rust DirstateMap bindings go through a trait object
Simon Sapin <simon.sapin@octobus.net>
parents:
diff changeset
407 ignore_files: Vec<PathBuf>,
787ff5d21bcd dirstate-tree: Make Rust DirstateMap bindings go through a trait object
Simon Sapin <simon.sapin@octobus.net>
parents:
diff changeset
408 options: StatusOptions,
47124
9c6b458a08e1 rust: Move "lookup" a.k.a. "unsure" paths into `DirstateStatus` struct
Simon Sapin <simon.sapin@octobus.net>
parents: 47123
diff changeset
409 ) -> Result<(DirstateStatus<'a>, Vec<PatternFileWarning>), StatusError>
9c6b458a08e1 rust: Move "lookup" a.k.a. "unsure" paths into `DirstateStatus` struct
Simon Sapin <simon.sapin@octobus.net>
parents: 47123
diff changeset
410 {
47107
787ff5d21bcd dirstate-tree: Make Rust DirstateMap bindings go through a trait object
Simon Sapin <simon.sapin@octobus.net>
parents:
diff changeset
411 crate::status(self, matcher, root_dir, ignore_files, options)
787ff5d21bcd dirstate-tree: Make Rust DirstateMap bindings go through a trait object
Simon Sapin <simon.sapin@octobus.net>
parents:
diff changeset
412 }
787ff5d21bcd dirstate-tree: Make Rust DirstateMap bindings go through a trait object
Simon Sapin <simon.sapin@octobus.net>
parents:
diff changeset
413
787ff5d21bcd dirstate-tree: Make Rust DirstateMap bindings go through a trait object
Simon Sapin <simon.sapin@octobus.net>
parents:
diff changeset
414 fn copy_map_len(&self) -> usize {
787ff5d21bcd dirstate-tree: Make Rust DirstateMap bindings go through a trait object
Simon Sapin <simon.sapin@octobus.net>
parents:
diff changeset
415 self.copy_map.len()
787ff5d21bcd dirstate-tree: Make Rust DirstateMap bindings go through a trait object
Simon Sapin <simon.sapin@octobus.net>
parents:
diff changeset
416 }
787ff5d21bcd dirstate-tree: Make Rust DirstateMap bindings go through a trait object
Simon Sapin <simon.sapin@octobus.net>
parents:
diff changeset
417
787ff5d21bcd dirstate-tree: Make Rust DirstateMap bindings go through a trait object
Simon Sapin <simon.sapin@octobus.net>
parents:
diff changeset
418 fn copy_map_iter(&self) -> CopyMapIter<'_> {
47343
ed1583a845d2 dirstate-v2: Make more APIs fallible, returning Result
Simon Sapin <simon.sapin@octobus.net>
parents: 47340
diff changeset
419 Box::new(
ed1583a845d2 dirstate-v2: Make more APIs fallible, returning Result
Simon Sapin <simon.sapin@octobus.net>
parents: 47340
diff changeset
420 self.copy_map
ed1583a845d2 dirstate-v2: Make more APIs fallible, returning Result
Simon Sapin <simon.sapin@octobus.net>
parents: 47340
diff changeset
421 .iter()
ed1583a845d2 dirstate-v2: Make more APIs fallible, returning Result
Simon Sapin <simon.sapin@octobus.net>
parents: 47340
diff changeset
422 .map(|(key, value)| Ok((&**key, &**value))),
ed1583a845d2 dirstate-v2: Make more APIs fallible, returning Result
Simon Sapin <simon.sapin@octobus.net>
parents: 47340
diff changeset
423 )
47107
787ff5d21bcd dirstate-tree: Make Rust DirstateMap bindings go through a trait object
Simon Sapin <simon.sapin@octobus.net>
parents:
diff changeset
424 }
787ff5d21bcd dirstate-tree: Make Rust DirstateMap bindings go through a trait object
Simon Sapin <simon.sapin@octobus.net>
parents:
diff changeset
425
47343
ed1583a845d2 dirstate-v2: Make more APIs fallible, returning Result
Simon Sapin <simon.sapin@octobus.net>
parents: 47340
diff changeset
426 fn copy_map_contains_key(
ed1583a845d2 dirstate-v2: Make more APIs fallible, returning Result
Simon Sapin <simon.sapin@octobus.net>
parents: 47340
diff changeset
427 &self,
ed1583a845d2 dirstate-v2: Make more APIs fallible, returning Result
Simon Sapin <simon.sapin@octobus.net>
parents: 47340
diff changeset
428 key: &HgPath,
ed1583a845d2 dirstate-v2: Make more APIs fallible, returning Result
Simon Sapin <simon.sapin@octobus.net>
parents: 47340
diff changeset
429 ) -> Result<bool, DirstateV2ParseError> {
ed1583a845d2 dirstate-v2: Make more APIs fallible, returning Result
Simon Sapin <simon.sapin@octobus.net>
parents: 47340
diff changeset
430 Ok(self.copy_map.contains_key(key))
47107
787ff5d21bcd dirstate-tree: Make Rust DirstateMap bindings go through a trait object
Simon Sapin <simon.sapin@octobus.net>
parents:
diff changeset
431 }
787ff5d21bcd dirstate-tree: Make Rust DirstateMap bindings go through a trait object
Simon Sapin <simon.sapin@octobus.net>
parents:
diff changeset
432
47343
ed1583a845d2 dirstate-v2: Make more APIs fallible, returning Result
Simon Sapin <simon.sapin@octobus.net>
parents: 47340
diff changeset
433 fn copy_map_get(
ed1583a845d2 dirstate-v2: Make more APIs fallible, returning Result
Simon Sapin <simon.sapin@octobus.net>
parents: 47340
diff changeset
434 &self,
ed1583a845d2 dirstate-v2: Make more APIs fallible, returning Result
Simon Sapin <simon.sapin@octobus.net>
parents: 47340
diff changeset
435 key: &HgPath,
ed1583a845d2 dirstate-v2: Make more APIs fallible, returning Result
Simon Sapin <simon.sapin@octobus.net>
parents: 47340
diff changeset
436 ) -> Result<Option<&HgPath>, DirstateV2ParseError> {
ed1583a845d2 dirstate-v2: Make more APIs fallible, returning Result
Simon Sapin <simon.sapin@octobus.net>
parents: 47340
diff changeset
437 Ok(self.copy_map.get(key).map(|p| &**p))
ed1583a845d2 dirstate-v2: Make more APIs fallible, returning Result
Simon Sapin <simon.sapin@octobus.net>
parents: 47340
diff changeset
438 }
ed1583a845d2 dirstate-v2: Make more APIs fallible, returning Result
Simon Sapin <simon.sapin@octobus.net>
parents: 47340
diff changeset
439
ed1583a845d2 dirstate-v2: Make more APIs fallible, returning Result
Simon Sapin <simon.sapin@octobus.net>
parents: 47340
diff changeset
440 fn copy_map_remove(
ed1583a845d2 dirstate-v2: Make more APIs fallible, returning Result
Simon Sapin <simon.sapin@octobus.net>
parents: 47340
diff changeset
441 &mut self,
ed1583a845d2 dirstate-v2: Make more APIs fallible, returning Result
Simon Sapin <simon.sapin@octobus.net>
parents: 47340
diff changeset
442 key: &HgPath,
ed1583a845d2 dirstate-v2: Make more APIs fallible, returning Result
Simon Sapin <simon.sapin@octobus.net>
parents: 47340
diff changeset
443 ) -> Result<Option<HgPathBuf>, DirstateV2ParseError> {
ed1583a845d2 dirstate-v2: Make more APIs fallible, returning Result
Simon Sapin <simon.sapin@octobus.net>
parents: 47340
diff changeset
444 Ok(self.copy_map.remove(key))
47107
787ff5d21bcd dirstate-tree: Make Rust DirstateMap bindings go through a trait object
Simon Sapin <simon.sapin@octobus.net>
parents:
diff changeset
445 }
787ff5d21bcd dirstate-tree: Make Rust DirstateMap bindings go through a trait object
Simon Sapin <simon.sapin@octobus.net>
parents:
diff changeset
446
787ff5d21bcd dirstate-tree: Make Rust DirstateMap bindings go through a trait object
Simon Sapin <simon.sapin@octobus.net>
parents:
diff changeset
447 fn copy_map_insert(
787ff5d21bcd dirstate-tree: Make Rust DirstateMap bindings go through a trait object
Simon Sapin <simon.sapin@octobus.net>
parents:
diff changeset
448 &mut self,
787ff5d21bcd dirstate-tree: Make Rust DirstateMap bindings go through a trait object
Simon Sapin <simon.sapin@octobus.net>
parents:
diff changeset
449 key: HgPathBuf,
787ff5d21bcd dirstate-tree: Make Rust DirstateMap bindings go through a trait object
Simon Sapin <simon.sapin@octobus.net>
parents:
diff changeset
450 value: HgPathBuf,
47343
ed1583a845d2 dirstate-v2: Make more APIs fallible, returning Result
Simon Sapin <simon.sapin@octobus.net>
parents: 47340
diff changeset
451 ) -> Result<Option<HgPathBuf>, DirstateV2ParseError> {
ed1583a845d2 dirstate-v2: Make more APIs fallible, returning Result
Simon Sapin <simon.sapin@octobus.net>
parents: 47340
diff changeset
452 Ok(self.copy_map.insert(key, value))
47107
787ff5d21bcd dirstate-tree: Make Rust DirstateMap bindings go through a trait object
Simon Sapin <simon.sapin@octobus.net>
parents:
diff changeset
453 }
787ff5d21bcd dirstate-tree: Make Rust DirstateMap bindings go through a trait object
Simon Sapin <simon.sapin@octobus.net>
parents:
diff changeset
454
787ff5d21bcd dirstate-tree: Make Rust DirstateMap bindings go through a trait object
Simon Sapin <simon.sapin@octobus.net>
parents:
diff changeset
455 fn len(&self) -> usize {
787ff5d21bcd dirstate-tree: Make Rust DirstateMap bindings go through a trait object
Simon Sapin <simon.sapin@octobus.net>
parents:
diff changeset
456 (&**self).len()
787ff5d21bcd dirstate-tree: Make Rust DirstateMap bindings go through a trait object
Simon Sapin <simon.sapin@octobus.net>
parents:
diff changeset
457 }
787ff5d21bcd dirstate-tree: Make Rust DirstateMap bindings go through a trait object
Simon Sapin <simon.sapin@octobus.net>
parents:
diff changeset
458
47343
ed1583a845d2 dirstate-v2: Make more APIs fallible, returning Result
Simon Sapin <simon.sapin@octobus.net>
parents: 47340
diff changeset
459 fn contains_key(
ed1583a845d2 dirstate-v2: Make more APIs fallible, returning Result
Simon Sapin <simon.sapin@octobus.net>
parents: 47340
diff changeset
460 &self,
ed1583a845d2 dirstate-v2: Make more APIs fallible, returning Result
Simon Sapin <simon.sapin@octobus.net>
parents: 47340
diff changeset
461 key: &HgPath,
ed1583a845d2 dirstate-v2: Make more APIs fallible, returning Result
Simon Sapin <simon.sapin@octobus.net>
parents: 47340
diff changeset
462 ) -> Result<bool, DirstateV2ParseError> {
ed1583a845d2 dirstate-v2: Make more APIs fallible, returning Result
Simon Sapin <simon.sapin@octobus.net>
parents: 47340
diff changeset
463 Ok((&**self).contains_key(key))
47107
787ff5d21bcd dirstate-tree: Make Rust DirstateMap bindings go through a trait object
Simon Sapin <simon.sapin@octobus.net>
parents:
diff changeset
464 }
787ff5d21bcd dirstate-tree: Make Rust DirstateMap bindings go through a trait object
Simon Sapin <simon.sapin@octobus.net>
parents:
diff changeset
465
47343
ed1583a845d2 dirstate-v2: Make more APIs fallible, returning Result
Simon Sapin <simon.sapin@octobus.net>
parents: 47340
diff changeset
466 fn get(
ed1583a845d2 dirstate-v2: Make more APIs fallible, returning Result
Simon Sapin <simon.sapin@octobus.net>
parents: 47340
diff changeset
467 &self,
ed1583a845d2 dirstate-v2: Make more APIs fallible, returning Result
Simon Sapin <simon.sapin@octobus.net>
parents: 47340
diff changeset
468 key: &HgPath,
ed1583a845d2 dirstate-v2: Make more APIs fallible, returning Result
Simon Sapin <simon.sapin@octobus.net>
parents: 47340
diff changeset
469 ) -> Result<Option<DirstateEntry>, DirstateV2ParseError> {
ed1583a845d2 dirstate-v2: Make more APIs fallible, returning Result
Simon Sapin <simon.sapin@octobus.net>
parents: 47340
diff changeset
470 Ok((&**self).get(key).cloned())
47107
787ff5d21bcd dirstate-tree: Make Rust DirstateMap bindings go through a trait object
Simon Sapin <simon.sapin@octobus.net>
parents:
diff changeset
471 }
787ff5d21bcd dirstate-tree: Make Rust DirstateMap bindings go through a trait object
Simon Sapin <simon.sapin@octobus.net>
parents:
diff changeset
472
787ff5d21bcd dirstate-tree: Make Rust DirstateMap bindings go through a trait object
Simon Sapin <simon.sapin@octobus.net>
parents:
diff changeset
473 fn iter(&self) -> StateMapIter<'_> {
47343
ed1583a845d2 dirstate-v2: Make more APIs fallible, returning Result
Simon Sapin <simon.sapin@octobus.net>
parents: 47340
diff changeset
474 Box::new((&**self).iter().map(|(key, value)| Ok((&**key, *value))))
47107
787ff5d21bcd dirstate-tree: Make Rust DirstateMap bindings go through a trait object
Simon Sapin <simon.sapin@octobus.net>
parents:
diff changeset
475 }
47357
3b9914b28133 dirstate-v2: Add --dirs to debugdirstate command
Simon Sapin <simon.sapin@octobus.net>
parents: 47343
diff changeset
476
3b9914b28133 dirstate-v2: Add --dirs to debugdirstate command
Simon Sapin <simon.sapin@octobus.net>
parents: 47343
diff changeset
477 fn iter_directories(
3b9914b28133 dirstate-v2: Add --dirs to debugdirstate command
Simon Sapin <simon.sapin@octobus.net>
parents: 47343
diff changeset
478 &self,
3b9914b28133 dirstate-v2: Add --dirs to debugdirstate command
Simon Sapin <simon.sapin@octobus.net>
parents: 47343
diff changeset
479 ) -> Box<
3b9914b28133 dirstate-v2: Add --dirs to debugdirstate command
Simon Sapin <simon.sapin@octobus.net>
parents: 47343
diff changeset
480 dyn Iterator<
3b9914b28133 dirstate-v2: Add --dirs to debugdirstate command
Simon Sapin <simon.sapin@octobus.net>
parents: 47343
diff changeset
481 Item = Result<
3b9914b28133 dirstate-v2: Add --dirs to debugdirstate command
Simon Sapin <simon.sapin@octobus.net>
parents: 47343
diff changeset
482 (&HgPath, Option<Timestamp>),
3b9914b28133 dirstate-v2: Add --dirs to debugdirstate command
Simon Sapin <simon.sapin@octobus.net>
parents: 47343
diff changeset
483 DirstateV2ParseError,
3b9914b28133 dirstate-v2: Add --dirs to debugdirstate command
Simon Sapin <simon.sapin@octobus.net>
parents: 47343
diff changeset
484 >,
3b9914b28133 dirstate-v2: Add --dirs to debugdirstate command
Simon Sapin <simon.sapin@octobus.net>
parents: 47343
diff changeset
485 > + Send
3b9914b28133 dirstate-v2: Add --dirs to debugdirstate command
Simon Sapin <simon.sapin@octobus.net>
parents: 47343
diff changeset
486 + '_,
3b9914b28133 dirstate-v2: Add --dirs to debugdirstate command
Simon Sapin <simon.sapin@octobus.net>
parents: 47343
diff changeset
487 > {
3b9914b28133 dirstate-v2: Add --dirs to debugdirstate command
Simon Sapin <simon.sapin@octobus.net>
parents: 47343
diff changeset
488 Box::new(std::iter::empty())
3b9914b28133 dirstate-v2: Add --dirs to debugdirstate command
Simon Sapin <simon.sapin@octobus.net>
parents: 47343
diff changeset
489 }
47107
787ff5d21bcd dirstate-tree: Make Rust DirstateMap bindings go through a trait object
Simon Sapin <simon.sapin@octobus.net>
parents:
diff changeset
490 }