D8086: rust-status: refactor options into a `StatusOptions` struct
Closed by commit rHG483fce658e43: rust-status: refactor options into a `StatusOptions` struct (authored by Alphare). This revision was automatically updated to reflect the committed changes. REPOSITORY rHG Mercurial CHANGES SINCE LAST UPDATE https://phab.mercurial-scm.org/D8086?vs=20496=20717 CHANGES SINCE LAST ACTION https://phab.mercurial-scm.org/D8086/new/ REVISION DETAIL https://phab.mercurial-scm.org/D8086 AFFECTED FILES rust/hg-core/src/dirstate/status.rs rust/hg-core/src/lib.rs rust/hg-core/src/matchers.rs CHANGE DETAILS diff --git a/rust/hg-core/src/matchers.rs b/rust/hg-core/src/matchers.rs --- a/rust/hg-core/src/matchers.rs +++ b/rust/hg-core/src/matchers.rs @@ -668,7 +668,11 @@ assert_eq!( roots_dirs_and_parents().unwrap(), -RootsDirsAndParents {roots, dirs, parents} +RootsDirsAndParents { +roots, +dirs, +parents +} ); } diff --git a/rust/hg-core/src/lib.rs b/rust/hg-core/src/lib.rs --- a/rust/hg-core/src/lib.rs +++ b/rust/hg-core/src/lib.rs @@ -13,7 +13,7 @@ dirs_multiset::{DirsMultiset, DirsMultisetIter}, dirstate_map::DirstateMap, parsers::{pack_dirstate, parse_dirstate, PARENT_SIZE}, -status::{status, StatusResult}, +status::{status, StatusOptions, StatusResult}, CopyMap, CopyMapIter, DirstateEntry, DirstateParents, EntryState, StateMap, StateMapIter, }; diff --git a/rust/hg-core/src/dirstate/status.rs b/rust/hg-core/src/dirstate/status.rs --- a/rust/hg-core/src/dirstate/status.rs +++ b/rust/hg-core/src/dirstate/status.rs @@ -83,9 +83,7 @@ entry: DirstateEntry, metadata: HgMetadata, copy_map: , -check_exec: bool, -list_clean: bool, -last_normal_time: i64, +options: StatusOptions, ) -> Dispatch { let DirstateEntry { state, @@ -105,7 +103,7 @@ EntryState::Normal => { let size_changed = mod_compare(size, st_size as i32); let mode_changed = -(mode ^ st_mode as i32) & 0o100 != 0o000 && check_exec; +(mode ^ st_mode as i32) & 0o100 != 0o000 && options.check_exec; let metadata_changed = size >= 0 && (size_changed || mode_changed); let other_parent = size == SIZE_FROM_OTHER_PARENT; if metadata_changed @@ -115,14 +113,14 @@ Dispatch::Modified } else if mod_compare(mtime, st_mtime as i32) { Dispatch::Unsure -} else if st_mtime == last_normal_time { +} else if st_mtime == options.last_normal_time { // the file may have just been marked as normal and // it may have changed in the same second without // changing its size. This can happen if we quickly // do multiple commits. Force lookup, so we don't // miss such a racy file change. Dispatch::Unsure -} else if list_clean { +} else if options.list_clean { Dispatch::Clean } else { Dispatch::Unknown @@ -155,9 +153,7 @@ files: &'a HashSet<>, dmap: &'a DirstateMap, root_dir: impl AsRef + Sync + Send, -check_exec: bool, -list_clean: bool, -last_normal_time: i64, +options: StatusOptions, ) -> impl ParallelIterator> { files.par_iter().filter_map(move |filename| { // TODO normalization @@ -181,9 +177,7 @@ *entry, HgMetadata::from_metadata(meta), _map, -check_exec, -list_clean, -last_normal_time, +options, ), ))); } @@ -206,14 +200,23 @@ }) } +#[derive(Debug, Copy, Clone)] +pub struct StatusOptions { +/// Remember the most recent modification timeslot for status, to make +/// sure we won't miss future size-preserving file content modifications +/// that happen within the same timeslot. +pub last_normal_time: i64, +/// Whether we are on a filesystem with UNIX-like exec flags +pub check_exec: bool, +pub list_clean: bool, +} + /// Stat all entries in the `DirstateMap` and mark them for dispatch into /// the relevant collections. fn stat_dmap_entries( dmap: , root_dir: impl AsRef + Sync + Send, -check_exec: bool, -list_clean: bool, -last_normal_time: i64, +options: StatusOptions, ) -> impl ParallelIterator> { dmap.par_iter().map(move |(filename, entry)| { let filename: = filename; @@ -234,9 +237,7 @@ *entry, HgMetadata::from_metadata(m), _map, -check_exec, -list_clean, -
D8086: rust-status: refactor options into a `StatusOptions` struct
Alphare updated this revision to Diff 20496. REPOSITORY rHG Mercurial CHANGES SINCE LAST UPDATE https://phab.mercurial-scm.org/D8086?vs=20184=20496 BRANCH default CHANGES SINCE LAST ACTION https://phab.mercurial-scm.org/D8086/new/ REVISION DETAIL https://phab.mercurial-scm.org/D8086 AFFECTED FILES rust/hg-core/src/dirstate/status.rs rust/hg-core/src/lib.rs rust/hg-core/src/matchers.rs CHANGE DETAILS diff --git a/rust/hg-core/src/matchers.rs b/rust/hg-core/src/matchers.rs --- a/rust/hg-core/src/matchers.rs +++ b/rust/hg-core/src/matchers.rs @@ -668,7 +668,11 @@ assert_eq!( roots_dirs_and_parents().unwrap(), -RootsDirsAndParents {roots, dirs, parents} +RootsDirsAndParents { +roots, +dirs, +parents +} ); } diff --git a/rust/hg-core/src/lib.rs b/rust/hg-core/src/lib.rs --- a/rust/hg-core/src/lib.rs +++ b/rust/hg-core/src/lib.rs @@ -13,7 +13,7 @@ dirs_multiset::{DirsMultiset, DirsMultisetIter}, dirstate_map::DirstateMap, parsers::{pack_dirstate, parse_dirstate, PARENT_SIZE}, -status::{status, StatusResult}, +status::{status, StatusOptions, StatusResult}, CopyMap, CopyMapIter, DirstateEntry, DirstateParents, EntryState, StateMap, StateMapIter, }; diff --git a/rust/hg-core/src/dirstate/status.rs b/rust/hg-core/src/dirstate/status.rs --- a/rust/hg-core/src/dirstate/status.rs +++ b/rust/hg-core/src/dirstate/status.rs @@ -83,9 +83,7 @@ entry: DirstateEntry, metadata: HgMetadata, copy_map: , -check_exec: bool, -list_clean: bool, -last_normal_time: i64, +options: StatusOptions, ) -> Dispatch { let DirstateEntry { state, @@ -105,7 +103,7 @@ EntryState::Normal => { let size_changed = mod_compare(size, st_size as i32); let mode_changed = -(mode ^ st_mode as i32) & 0o100 != 0o000 && check_exec; +(mode ^ st_mode as i32) & 0o100 != 0o000 && options.check_exec; let metadata_changed = size >= 0 && (size_changed || mode_changed); let other_parent = size == SIZE_FROM_OTHER_PARENT; if metadata_changed @@ -115,14 +113,14 @@ Dispatch::Modified } else if mod_compare(mtime, st_mtime as i32) { Dispatch::Unsure -} else if st_mtime == last_normal_time { +} else if st_mtime == options.last_normal_time { // the file may have just been marked as normal and // it may have changed in the same second without // changing its size. This can happen if we quickly // do multiple commits. Force lookup, so we don't // miss such a racy file change. Dispatch::Unsure -} else if list_clean { +} else if options.list_clean { Dispatch::Clean } else { Dispatch::Unknown @@ -155,9 +153,7 @@ files: &'a HashSet<>, dmap: &'a DirstateMap, root_dir: impl AsRef + Sync + Send, -check_exec: bool, -list_clean: bool, -last_normal_time: i64, +options: StatusOptions, ) -> impl ParallelIterator> { files.par_iter().filter_map(move |filename| { // TODO normalization @@ -181,9 +177,7 @@ *entry, HgMetadata::from_metadata(meta), _map, -check_exec, -list_clean, -last_normal_time, +options, ), ))); } @@ -206,14 +200,23 @@ }) } +#[derive(Debug, Copy, Clone)] +pub struct StatusOptions { +/// Remember the most recent modification timeslot for status, to make +/// sure we won't miss future size-preserving file content modifications +/// that happen within the same timeslot. +pub last_normal_time: i64, +/// Whether we are on a filesystem with UNIX-like exec flags +pub check_exec: bool, +pub list_clean: bool, +} + /// Stat all entries in the `DirstateMap` and mark them for dispatch into /// the relevant collections. fn stat_dmap_entries( dmap: , root_dir: impl AsRef + Sync + Send, -check_exec: bool, -list_clean: bool, -last_normal_time: i64, +options: StatusOptions, ) -> impl ParallelIterator> { dmap.par_iter().map(move |(filename, entry)| { let filename: = filename; @@ -234,9 +237,7 @@ *entry, HgMetadata::from_metadata(m), _map, -check_exec, -list_clean, -last_normal_time, +options, ), )), Err(ref e) @@ -303,31
D8086: rust-status: refactor options into a `StatusOptions` struct
marmoute added a comment. marmoute accepted this revision. looks good to me. thanks for plitting REPOSITORY rHG Mercurial CHANGES SINCE LAST ACTION https://phab.mercurial-scm.org/D8086/new/ REVISION DETAIL https://phab.mercurial-scm.org/D8086 To: Alphare, #hg-reviewers, marmoute Cc: marmoute, kevincox, mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D8086: rust-status: refactor options into a `StatusOptions` struct
Alphare updated this revision to Diff 20184. REPOSITORY rHG Mercurial CHANGES SINCE LAST UPDATE https://phab.mercurial-scm.org/D8086?vs=20164=20184 BRANCH default CHANGES SINCE LAST ACTION https://phab.mercurial-scm.org/D8086/new/ REVISION DETAIL https://phab.mercurial-scm.org/D8086 AFFECTED FILES rust/hg-core/src/dirstate/status.rs rust/hg-core/src/lib.rs rust/hg-core/src/matchers.rs CHANGE DETAILS diff --git a/rust/hg-core/src/matchers.rs b/rust/hg-core/src/matchers.rs --- a/rust/hg-core/src/matchers.rs +++ b/rust/hg-core/src/matchers.rs @@ -669,7 +669,11 @@ assert_eq!( roots_dirs_and_parents().unwrap(), -RootsDirsAndParents {roots, dirs, parents} +RootsDirsAndParents { +roots, +dirs, +parents +} ); } diff --git a/rust/hg-core/src/lib.rs b/rust/hg-core/src/lib.rs --- a/rust/hg-core/src/lib.rs +++ b/rust/hg-core/src/lib.rs @@ -13,7 +13,7 @@ dirs_multiset::{DirsMultiset, DirsMultisetIter}, dirstate_map::DirstateMap, parsers::{pack_dirstate, parse_dirstate, PARENT_SIZE}, -status::{status, StatusResult}, +status::{status, StatusOptions, StatusResult}, CopyMap, CopyMapIter, DirstateEntry, DirstateParents, EntryState, StateMap, StateMapIter, }; diff --git a/rust/hg-core/src/dirstate/status.rs b/rust/hg-core/src/dirstate/status.rs --- a/rust/hg-core/src/dirstate/status.rs +++ b/rust/hg-core/src/dirstate/status.rs @@ -83,9 +83,7 @@ entry: DirstateEntry, metadata: HgMetadata, copy_map: , -check_exec: bool, -list_clean: bool, -last_normal_time: i64, +options: StatusOptions, ) -> Dispatch { let DirstateEntry { state, @@ -105,7 +103,7 @@ EntryState::Normal => { let size_changed = mod_compare(size, st_size as i32); let mode_changed = -(mode ^ st_mode as i32) & 0o100 != 0o000 && check_exec; +(mode ^ st_mode as i32) & 0o100 != 0o000 && options.check_exec; let metadata_changed = size >= 0 && (size_changed || mode_changed); let other_parent = size == SIZE_FROM_OTHER_PARENT; if metadata_changed @@ -115,14 +113,14 @@ Dispatch::Modified } else if mod_compare(mtime, st_mtime as i32) { Dispatch::Unsure -} else if st_mtime == last_normal_time { +} else if st_mtime == options.last_normal_time { // the file may have just been marked as normal and // it may have changed in the same second without // changing its size. This can happen if we quickly // do multiple commits. Force lookup, so we don't // miss such a racy file change. Dispatch::Unsure -} else if list_clean { +} else if options.list_clean { Dispatch::Clean } else { Dispatch::Unknown @@ -155,9 +153,7 @@ files: &'a HashSet<>, dmap: &'a DirstateMap, root_dir: impl AsRef + Sync + Send, -check_exec: bool, -list_clean: bool, -last_normal_time: i64, +options: StatusOptions, ) -> impl ParallelIterator> { files.par_iter().filter_map(move |filename| { // TODO normalization @@ -181,9 +177,7 @@ *entry, HgMetadata::from_metadata(meta), _map, -check_exec, -list_clean, -last_normal_time, +options, ), ))); } @@ -206,14 +200,23 @@ }) } +#[derive(Debug, Copy, Clone)] +pub struct StatusOptions { +/// Remember the most recent modification timeslot for status, to make +/// sure we won't miss future size-preserving file content modifications +/// that happen within the same timeslot. +pub last_normal_time: i64, +/// Whether we are on a filesystem with UNIX-like exec flags +pub check_exec: bool, +pub list_clean: bool, +} + /// Stat all entries in the `DirstateMap` and mark them for dispatch into /// the relevant collections. fn stat_dmap_entries( dmap: , root_dir: impl AsRef + Sync + Send, -check_exec: bool, -list_clean: bool, -last_normal_time: i64, +options: StatusOptions, ) -> impl ParallelIterator> { dmap.par_iter().map(move |(filename, entry)| { let filename: = filename; @@ -234,9 +237,7 @@ *entry, HgMetadata::from_metadata(m), _map, -check_exec, -list_clean, -last_normal_time, +options, ), )), Err(ref e) @@ -303,31
D8086: rust-status: refactor options into a `StatusOptions` struct
Alphare updated this revision to Diff 20164. REPOSITORY rHG Mercurial CHANGES SINCE LAST UPDATE https://phab.mercurial-scm.org/D8086?vs=20155=20164 BRANCH default CHANGES SINCE LAST ACTION https://phab.mercurial-scm.org/D8086/new/ REVISION DETAIL https://phab.mercurial-scm.org/D8086 AFFECTED FILES rust/hg-core/src/dirstate/status.rs rust/hg-core/src/lib.rs rust/hg-core/src/matchers.rs CHANGE DETAILS diff --git a/rust/hg-core/src/matchers.rs b/rust/hg-core/src/matchers.rs --- a/rust/hg-core/src/matchers.rs +++ b/rust/hg-core/src/matchers.rs @@ -669,7 +669,11 @@ assert_eq!( roots_dirs_and_parents().unwrap(), -RootsDirsAndParents {roots, dirs, parents} +RootsDirsAndParents { +roots, +dirs, +parents +} ); } diff --git a/rust/hg-core/src/lib.rs b/rust/hg-core/src/lib.rs --- a/rust/hg-core/src/lib.rs +++ b/rust/hg-core/src/lib.rs @@ -13,7 +13,7 @@ dirs_multiset::{DirsMultiset, DirsMultisetIter}, dirstate_map::DirstateMap, parsers::{pack_dirstate, parse_dirstate, PARENT_SIZE}, -status::{status, StatusResult}, +status::{status, StatusOptions, StatusResult}, CopyMap, CopyMapIter, DirstateEntry, DirstateParents, EntryState, StateMap, StateMapIter, }; diff --git a/rust/hg-core/src/dirstate/status.rs b/rust/hg-core/src/dirstate/status.rs --- a/rust/hg-core/src/dirstate/status.rs +++ b/rust/hg-core/src/dirstate/status.rs @@ -83,9 +83,7 @@ entry: DirstateEntry, metadata: HgMetadata, copy_map: , -check_exec: bool, -list_clean: bool, -last_normal_time: i64, +options: StatusOptions, ) -> Dispatch { let DirstateEntry { state, @@ -105,7 +103,7 @@ EntryState::Normal => { let size_changed = mod_compare(size, st_size as i32); let mode_changed = -(mode ^ st_mode as i32) & 0o100 != 0o000 && check_exec; +(mode ^ st_mode as i32) & 0o100 != 0o000 && options.check_exec; let metadata_changed = size >= 0 && (size_changed || mode_changed); let other_parent = size == SIZE_FROM_OTHER_PARENT; if metadata_changed @@ -115,14 +113,14 @@ Dispatch::Modified } else if mod_compare(mtime, st_mtime as i32) { Dispatch::Unsure -} else if st_mtime == last_normal_time { +} else if st_mtime == options.last_normal_time { // the file may have just been marked as normal and // it may have changed in the same second without // changing its size. This can happen if we quickly // do multiple commits. Force lookup, so we don't // miss such a racy file change. Dispatch::Unsure -} else if list_clean { +} else if options.list_clean { Dispatch::Clean } else { Dispatch::Unknown @@ -155,9 +153,7 @@ files: &'a HashSet<>, dmap: &'a DirstateMap, root_dir: impl AsRef + Sync + Send, -check_exec: bool, -list_clean: bool, -last_normal_time: i64, +options: StatusOptions, ) -> impl ParallelIterator> { files.par_iter().filter_map(move |filename| { // TODO normalization @@ -181,9 +177,7 @@ *entry, HgMetadata::from_metadata(meta), _map, -check_exec, -list_clean, -last_normal_time, +options, ), ))); } @@ -206,14 +200,23 @@ }) } +#[derive(Debug, Copy, Clone)] +pub struct StatusOptions { +/// Remember the most recent modification timeslot for status, to make +/// sure we won't miss future size-preserving file content modifications +/// that happen within the same timeslot. +pub last_normal_time: i64, +/// Whether we are on a filesystem with UNIX-like exec flags +pub check_exec: bool, +pub list_clean: bool, +} + /// Stat all entries in the `DirstateMap` and mark them for dispatch into /// the relevant collections. fn stat_dmap_entries( dmap: , root_dir: impl AsRef + Sync + Send, -check_exec: bool, -list_clean: bool, -last_normal_time: i64, +options: StatusOptions, ) -> impl ParallelIterator> { dmap.par_iter().map(move |(filename, entry)| { let filename: = filename; @@ -234,9 +237,7 @@ *entry, HgMetadata::from_metadata(m), _map, -check_exec, -list_clean, -last_normal_time, +options, ), )), Err(ref e) @@ -303,31
D8086: rust-status: refactor options into a `StatusOptions` struct
Alphare updated this revision to Diff 20155. REPOSITORY rHG Mercurial CHANGES SINCE LAST UPDATE https://phab.mercurial-scm.org/D8086?vs=20044=20155 BRANCH default CHANGES SINCE LAST ACTION https://phab.mercurial-scm.org/D8086/new/ REVISION DETAIL https://phab.mercurial-scm.org/D8086 AFFECTED FILES rust/hg-core/src/dirstate/status.rs rust/hg-core/src/lib.rs rust/hg-core/src/matchers.rs CHANGE DETAILS diff --git a/rust/hg-core/src/matchers.rs b/rust/hg-core/src/matchers.rs --- a/rust/hg-core/src/matchers.rs +++ b/rust/hg-core/src/matchers.rs @@ -704,7 +704,11 @@ assert_eq!( roots_dirs_and_parents().unwrap(), -RootsDirsAndParents {roots, dirs, parents} +RootsDirsAndParents { +roots, +dirs, +parents +} ); } diff --git a/rust/hg-core/src/lib.rs b/rust/hg-core/src/lib.rs --- a/rust/hg-core/src/lib.rs +++ b/rust/hg-core/src/lib.rs @@ -13,7 +13,7 @@ dirs_multiset::{DirsMultiset, DirsMultisetIter}, dirstate_map::DirstateMap, parsers::{pack_dirstate, parse_dirstate, PARENT_SIZE}, -status::{status, StatusResult}, +status::{status, StatusOptions, StatusResult}, CopyMap, CopyMapIter, DirstateEntry, DirstateParents, EntryState, StateMap, StateMapIter, }; diff --git a/rust/hg-core/src/dirstate/status.rs b/rust/hg-core/src/dirstate/status.rs --- a/rust/hg-core/src/dirstate/status.rs +++ b/rust/hg-core/src/dirstate/status.rs @@ -83,9 +83,7 @@ entry: DirstateEntry, metadata: HgMetadata, copy_map: , -check_exec: bool, -list_clean: bool, -last_normal_time: i64, +options: StatusOptions, ) -> Dispatch { let DirstateEntry { state, @@ -105,7 +103,7 @@ EntryState::Normal => { let size_changed = mod_compare(size, st_size as i32); let mode_changed = -(mode ^ st_mode as i32) & 0o100 != 0o000 && check_exec; +(mode ^ st_mode as i32) & 0o100 != 0o000 && options.check_exec; let metadata_changed = size >= 0 && (size_changed || mode_changed); let other_parent = size == SIZE_FROM_OTHER_PARENT; if metadata_changed @@ -115,14 +113,14 @@ Dispatch::Modified } else if mod_compare(mtime, st_mtime as i32) { Dispatch::Unsure -} else if st_mtime == last_normal_time { +} else if st_mtime == options.last_normal_time { // the file may have just been marked as normal and // it may have changed in the same second without // changing its size. This can happen if we quickly // do multiple commits. Force lookup, so we don't // miss such a racy file change. Dispatch::Unsure -} else if list_clean { +} else if options.list_clean { Dispatch::Clean } else { Dispatch::Unknown @@ -155,9 +153,7 @@ files: &'a HashSet<>, dmap: &'a DirstateMap, root_dir: impl AsRef + Sync + Send, -check_exec: bool, -list_clean: bool, -last_normal_time: i64, +options: StatusOptions, ) -> impl ParallelIterator> { files.par_iter().filter_map(move |filename| { // TODO normalization @@ -181,9 +177,7 @@ *entry, HgMetadata::from_metadata(meta), _map, -check_exec, -list_clean, -last_normal_time, +options, ), ))); } @@ -206,14 +200,23 @@ }) } +#[derive(Debug, Copy, Clone)] +pub struct StatusOptions { +/// Remember the most recent modification timeslot for status, to make +/// sure we won't miss future size-preserving file content modifications +/// that happen within the same timeslot. +pub last_normal_time: i64, +/// Whether we are on a filesystem with UNIX-like exec flags +pub check_exec: bool, +pub list_clean: bool, +} + /// Stat all entries in the `DirstateMap` and mark them for dispatch into /// the relevant collections. fn stat_dmap_entries( dmap: , root_dir: impl AsRef + Sync + Send, -check_exec: bool, -list_clean: bool, -last_normal_time: i64, +options: StatusOptions, ) -> impl ParallelIterator> { dmap.par_iter().map(move |(filename, entry)| { let filename: = filename; @@ -234,9 +237,7 @@ *entry, HgMetadata::from_metadata(m), _map, -check_exec, -list_clean, -last_normal_time, +options, ), )), Err(ref e) @@ -303,31
D8086: rust-status: refactor options into a `StatusOptions` struct
Alphare updated this revision to Diff 20044. REPOSITORY rHG Mercurial CHANGES SINCE LAST UPDATE https://phab.mercurial-scm.org/D8086?vs=19943=20044 BRANCH default CHANGES SINCE LAST ACTION https://phab.mercurial-scm.org/D8086/new/ REVISION DETAIL https://phab.mercurial-scm.org/D8086 AFFECTED FILES rust/hg-core/src/dirstate/status.rs rust/hg-core/src/lib.rs rust/hg-core/src/matchers.rs CHANGE DETAILS diff --git a/rust/hg-core/src/matchers.rs b/rust/hg-core/src/matchers.rs --- a/rust/hg-core/src/matchers.rs +++ b/rust/hg-core/src/matchers.rs @@ -704,7 +704,11 @@ assert_eq!( roots_dirs_and_parents().unwrap(), -RootsDirsAndParents {roots, dirs, parents} +RootsDirsAndParents { +roots, +dirs, +parents +} ); } diff --git a/rust/hg-core/src/lib.rs b/rust/hg-core/src/lib.rs --- a/rust/hg-core/src/lib.rs +++ b/rust/hg-core/src/lib.rs @@ -13,7 +13,7 @@ dirs_multiset::{DirsMultiset, DirsMultisetIter}, dirstate_map::DirstateMap, parsers::{pack_dirstate, parse_dirstate, PARENT_SIZE}, -status::{status, StatusResult}, +status::{status, StatusOptions, StatusResult}, CopyMap, CopyMapIter, DirstateEntry, DirstateParents, EntryState, StateMap, StateMapIter, }; diff --git a/rust/hg-core/src/dirstate/status.rs b/rust/hg-core/src/dirstate/status.rs --- a/rust/hg-core/src/dirstate/status.rs +++ b/rust/hg-core/src/dirstate/status.rs @@ -83,9 +83,7 @@ entry: DirstateEntry, metadata: HgMetadata, copy_map: , -check_exec: bool, -list_clean: bool, -last_normal_time: i64, +options: StatusOptions, ) -> Dispatch { let DirstateEntry { state, @@ -105,7 +103,7 @@ EntryState::Normal => { let size_changed = mod_compare(size, st_size as i32); let mode_changed = -(mode ^ st_mode as i32) & 0o100 != 0o000 && check_exec; +(mode ^ st_mode as i32) & 0o100 != 0o000 && options.check_exec; let metadata_changed = size >= 0 && (size_changed || mode_changed); let other_parent = size == SIZE_FROM_OTHER_PARENT; if metadata_changed @@ -115,14 +113,14 @@ Dispatch::Modified } else if mod_compare(mtime, st_mtime as i32) { Dispatch::Unsure -} else if st_mtime == last_normal_time { +} else if st_mtime == options.last_normal_time { // the file may have just been marked as normal and // it may have changed in the same second without // changing its size. This can happen if we quickly // do multiple commits. Force lookup, so we don't // miss such a racy file change. Dispatch::Unsure -} else if list_clean { +} else if options.list_clean { Dispatch::Clean } else { Dispatch::Unknown @@ -155,9 +153,7 @@ files: &'a HashSet<>, dmap: &'a DirstateMap, root_dir: impl AsRef + Sync + Send, -check_exec: bool, -list_clean: bool, -last_normal_time: i64, +options: StatusOptions, ) -> impl ParallelIterator> { files.par_iter().filter_map(move |filename| { // TODO normalization @@ -181,9 +177,7 @@ *entry, HgMetadata::from_metadata(meta), _map, -check_exec, -list_clean, -last_normal_time, +options, ), ))); } @@ -206,14 +200,23 @@ }) } +#[derive(Debug, Copy, Clone)] +pub struct StatusOptions { +/// Remember the most recent modification timeslot for status, to make +/// sure we won't miss future size-preserving file content modifications +/// that happen within the same timeslot. +pub last_normal_time: i64, +/// Whether we are on a filesystem with UNIX-like exec flags +pub check_exec: bool, +pub list_clean: bool, +} + /// Stat all entries in the `DirstateMap` and mark them for dispatch into /// the relevant collections. fn stat_dmap_entries( dmap: , root_dir: impl AsRef + Sync + Send, -check_exec: bool, -list_clean: bool, -last_normal_time: i64, +options: StatusOptions, ) -> impl ParallelIterator> { dmap.par_iter().map(move |(filename, entry)| { let filename: = filename; @@ -234,9 +237,7 @@ *entry, HgMetadata::from_metadata(m), _map, -check_exec, -list_clean, -last_normal_time, +options, ), )), Err(ref e) @@ -303,31
D8086: rust-status: refactor options into a `StatusOptions` struct
Alphare added inline comments. INLINE COMMENTS > kevincox wrote in status.rs:208 > These names aren't very meaningful to me but maybe that is because I'm not > super familiar with the domain. It doesn't hurt to have some documentation. They're not super obvious indeed. REPOSITORY rHG Mercurial CHANGES SINCE LAST ACTION https://phab.mercurial-scm.org/D8086/new/ REVISION DETAIL https://phab.mercurial-scm.org/D8086 To: Alphare, #hg-reviewers Cc: kevincox, mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D8086: rust-status: refactor options into a `StatusOptions` struct
kevincox added inline comments. INLINE COMMENTS > status.rs:208 > +pub list_clean: bool, > +} > + These names aren't very meaningful to me but maybe that is because I'm not super familiar with the domain. REPOSITORY rHG Mercurial CHANGES SINCE LAST ACTION https://phab.mercurial-scm.org/D8086/new/ REVISION DETAIL https://phab.mercurial-scm.org/D8086 To: Alphare, #hg-reviewers Cc: kevincox, mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D8086: rust-status: refactor options into a `StatusOptions` struct
Alphare created this revision. Herald added subscribers: mercurial-devel, kevincox. Herald added a reviewer: hg-reviewers. REPOSITORY rHG Mercurial BRANCH default REVISION DETAIL https://phab.mercurial-scm.org/D8086 AFFECTED FILES rust/hg-core/src/dirstate/status.rs rust/hg-core/src/lib.rs rust/hg-core/src/matchers.rs CHANGE DETAILS diff --git a/rust/hg-core/src/matchers.rs b/rust/hg-core/src/matchers.rs --- a/rust/hg-core/src/matchers.rs +++ b/rust/hg-core/src/matchers.rs @@ -704,7 +704,11 @@ assert_eq!( roots_dirs_and_parents().unwrap(), -RootsDirsAndParents {roots, dirs, parents} +RootsDirsAndParents { +roots, +dirs, +parents +} ); } diff --git a/rust/hg-core/src/lib.rs b/rust/hg-core/src/lib.rs --- a/rust/hg-core/src/lib.rs +++ b/rust/hg-core/src/lib.rs @@ -13,7 +13,7 @@ dirs_multiset::{DirsMultiset, DirsMultisetIter}, dirstate_map::DirstateMap, parsers::{pack_dirstate, parse_dirstate, PARENT_SIZE}, -status::{status, StatusResult}, +status::{status, StatusOptions, StatusResult}, CopyMap, CopyMapIter, DirstateEntry, DirstateParents, EntryState, StateMap, StateMapIter, }; diff --git a/rust/hg-core/src/dirstate/status.rs b/rust/hg-core/src/dirstate/status.rs --- a/rust/hg-core/src/dirstate/status.rs +++ b/rust/hg-core/src/dirstate/status.rs @@ -83,9 +83,7 @@ entry: DirstateEntry, metadata: HgMetadata, copy_map: , -check_exec: bool, -list_clean: bool, -last_normal_time: i64, +options: StatusOptions, ) -> Dispatch { let DirstateEntry { state, @@ -105,7 +103,7 @@ EntryState::Normal => { let size_changed = mod_compare(size, st_size as i32); let mode_changed = -(mode ^ st_mode as i32) & 0o100 != 0o000 && check_exec; +(mode ^ st_mode as i32) & 0o100 != 0o000 && options.check_exec; let metadata_changed = size >= 0 && (size_changed || mode_changed); let other_parent = size == SIZE_FROM_OTHER_PARENT; if metadata_changed @@ -115,14 +113,14 @@ Dispatch::Modified } else if mod_compare(mtime, st_mtime as i32) { Dispatch::Unsure -} else if st_mtime == last_normal_time { +} else if st_mtime == options.last_normal_time { // the file may have just been marked as normal and // it may have changed in the same second without // changing its size. This can happen if we quickly // do multiple commits. Force lookup, so we don't // miss such a racy file change. Dispatch::Unsure -} else if list_clean { +} else if options.list_clean { Dispatch::Clean } else { Dispatch::Unknown @@ -155,9 +153,7 @@ files: &'a HashSet<>, dmap: &'a DirstateMap, root_dir: impl AsRef + Sync + Send, -check_exec: bool, -list_clean: bool, -last_normal_time: i64, +options: StatusOptions, ) -> impl ParallelIterator> { files.par_iter().filter_map(move |filename| { // TODO normalization @@ -181,9 +177,7 @@ *entry, HgMetadata::from_metadata(meta), _map, -check_exec, -list_clean, -last_normal_time, +options, ), ))); } @@ -206,14 +200,19 @@ }) } +#[derive(Debug, Copy, Clone)] +pub struct StatusOptions { +pub last_normal_time: i64, +pub check_exec: bool, +pub list_clean: bool, +} + /// Stat all entries in the `DirstateMap` and mark them for dispatch into /// the relevant collections. fn stat_dmap_entries( dmap: , root_dir: impl AsRef + Sync + Send, -check_exec: bool, -list_clean: bool, -last_normal_time: i64, +options: StatusOptions, ) -> impl ParallelIterator> { dmap.par_iter().map(move |(filename, entry)| { let filename: = filename; @@ -234,9 +233,7 @@ *entry, HgMetadata::from_metadata(m), _map, -check_exec, -list_clean, -last_normal_time, +options, ), )), Err(ref e) @@ -303,31 +300,16 @@ dmap: &'a DirstateMap, matcher: &'b impl Matcher, root_dir: impl AsRef + Sync + Send + Copy, -list_clean: bool, -last_normal_time: i64, -check_exec: bool, +options: StatusOptions, ) -> IoResult<(Vec<&'c HgPath>, StatusResult<'c>)> { let files = matcher.file_set(); let mut results =