Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
mercurial-devel
Manage
Activity
Members
Labels
Plan
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
mercurial
mercurial-devel
Commits
80bf7b1a
Commit
80bf7b1a
authored
4 years ago
by
Raphaël Gomès
Browse files
Options
Downloads
Patches
Plain Diff
rust-dirstatemap: add #[timed] to dirstatemap read for comparison
Differential Revision:
https://phab.mercurial-scm.org/D9084
parent
2c86b958
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
rust/hg-core/src/dirstate/dirstate_map.rs
+22
-58
22 additions, 58 deletions
rust/hg-core/src/dirstate/dirstate_map.rs
with
22 additions
and
58 deletions
rust/hg-core/src/dirstate/dirstate_map.rs
+
22
−
58
View file @
80bf7b1a
...
...
@@ -13,7 +13,7 @@
files
::
normalize_case
,
hg_path
::{
HgPath
,
HgPathBuf
},
},
CopyMap
,
DirsMultiset
,
DirstateEntry
,
DirstateError
,
DirstateMapError
,
DirstateParents
,
DirstateParseError
,
FastHashMap
,
StateMap
,
CopyMap
,
DirsMultiset
,
DirstateEntry
,
DirstateError
,
DirstateMapError
,
DirstateParents
,
DirstateParseError
,
FastHashMap
,
StateMap
,
};
use
core
::
borrow
::
Borrow
;
...
...
@@ -18,5 +18,6 @@
};
use
core
::
borrow
::
Borrow
;
use
micro_timer
::
timed
;
use
std
::
collections
::
HashSet
;
use
std
::
convert
::
TryInto
;
use
std
::
iter
::
FromIterator
;
...
...
@@ -50,9 +51,7 @@
}
impl
FromIterator
<
(
HgPathBuf
,
DirstateEntry
)
>
for
DirstateMap
{
fn
from_iter
<
I
:
IntoIterator
<
Item
=
(
HgPathBuf
,
DirstateEntry
)
>>
(
iter
:
I
,
)
->
Self
{
fn
from_iter
<
I
:
IntoIterator
<
Item
=
(
HgPathBuf
,
DirstateEntry
)
>>
(
iter
:
I
)
->
Self
{
Self
{
state_map
:
iter
.into_iter
()
.collect
(),
..
Self
::
default
()
...
...
@@ -84,8 +83,7 @@
old_state
:
EntryState
,
entry
:
DirstateEntry
,
)
->
Result
<
(),
DirstateMapError
>
{
if
old_state
==
EntryState
::
Unknown
||
old_state
==
EntryState
::
Removed
{
if
old_state
==
EntryState
::
Unknown
||
old_state
==
EntryState
::
Removed
{
if
let
Some
(
ref
mut
dirs
)
=
self
.dirs
{
dirs
.add_path
(
filename
)
?
;
}
...
...
@@ -122,8 +120,7 @@
old_state
:
EntryState
,
size
:
i32
,
)
->
Result
<
(),
DirstateMapError
>
{
if
old_state
!=
EntryState
::
Unknown
&&
old_state
!=
EntryState
::
Removed
{
if
old_state
!=
EntryState
::
Unknown
&&
old_state
!=
EntryState
::
Removed
{
if
let
Some
(
ref
mut
dirs
)
=
self
.dirs
{
dirs
.delete_path
(
filename
)
?
;
}
...
...
@@ -181,13 +178,9 @@
Ok
(
exists
)
}
pub
fn
clear_ambiguous_times
(
&
mut
self
,
filenames
:
Vec
<
HgPathBuf
>
,
now
:
i32
,
)
{
pub
fn
clear_ambiguous_times
(
&
mut
self
,
filenames
:
Vec
<
HgPathBuf
>
,
now
:
i32
)
{
for
filename
in
filenames
{
let
mut
changed
=
false
;
self
.state_map
.entry
(
filename
.to_owned
())
.and_modify
(|
entry
|
{
...
...
@@ -189,10 +182,9 @@
for
filename
in
filenames
{
let
mut
changed
=
false
;
self
.state_map
.entry
(
filename
.to_owned
())
.and_modify
(|
entry
|
{
if
entry
.state
==
EntryState
::
Normal
&&
entry
.mtime
==
now
{
if
entry
.state
==
EntryState
::
Normal
&&
entry
.mtime
==
now
{
changed
=
true
;
*
entry
=
DirstateEntry
{
mtime
:
MTIME_UNSET
,
...
...
@@ -208,11 +200,8 @@
}
}
pub
fn
non_normal_entries_remove
(
&
mut
self
,
key
:
impl
AsRef
<
HgPath
>
,
)
->
bool
{
pub
fn
non_normal_entries_remove
(
&
mut
self
,
key
:
impl
AsRef
<
HgPath
>
)
->
bool
{
self
.get_non_normal_other_parent_entries
()
.0
.remove
(
key
.as_ref
())
}
...
...
@@ -215,11 +204,8 @@
self
.get_non_normal_other_parent_entries
()
.0
.remove
(
key
.as_ref
())
}
pub
fn
non_normal_entries_union
(
&
mut
self
,
other
:
HashSet
<
HgPathBuf
>
,
)
->
Vec
<
HgPathBuf
>
{
pub
fn
non_normal_entries_union
(
&
mut
self
,
other
:
HashSet
<
HgPathBuf
>
)
->
Vec
<
HgPathBuf
>
{
self
.get_non_normal_other_parent_entries
()
.0
.union
(
&
other
)
...
...
@@ -257,10 +243,7 @@
}
pub
fn
set_non_normal_other_parent_entries
(
&
mut
self
,
force
:
bool
)
{
if
!
force
&&
self
.non_normal_set
.is_some
()
&&
self
.other_parent_set
.is_some
()
{
if
!
force
&&
self
.non_normal_set
.is_some
()
&&
self
.other_parent_set
.is_some
()
{
return
;
}
let
mut
non_normal
=
HashSet
::
new
();
...
...
@@ -276,8 +259,7 @@
if
*
state
!=
EntryState
::
Normal
||
*
mtime
==
MTIME_UNSET
{
non_normal
.insert
(
filename
.to_owned
());
}
if
*
state
==
EntryState
::
Normal
&&
*
size
==
SIZE_FROM_OTHER_PARENT
{
if
*
state
==
EntryState
::
Normal
&&
*
size
==
SIZE_FROM_OTHER_PARENT
{
other_parent
.insert
(
filename
.to_owned
());
}
}
...
...
@@ -291,8 +273,7 @@
/// good idea.
pub
fn
set_all_dirs
(
&
mut
self
)
->
Result
<
(),
DirstateMapError
>
{
if
self
.all_dirs
.is_none
()
{
self
.all_dirs
=
Some
(
DirsMultiset
::
from_dirstate
(
&
self
.state_map
,
None
)
?
);
self
.all_dirs
=
Some
(
DirsMultiset
::
from_dirstate
(
&
self
.state_map
,
None
)
?
);
}
Ok
(())
}
...
...
@@ -307,11 +288,8 @@
Ok
(())
}
pub
fn
has_tracked_dir
(
&
mut
self
,
directory
:
&
HgPath
,
)
->
Result
<
bool
,
DirstateMapError
>
{
pub
fn
has_tracked_dir
(
&
mut
self
,
directory
:
&
HgPath
)
->
Result
<
bool
,
DirstateMapError
>
{
self
.set_dirs
()
?
;
Ok
(
self
.dirs
.as_ref
()
.unwrap
()
.contains
(
directory
))
}
...
...
@@ -314,12 +292,9 @@
self
.set_dirs
()
?
;
Ok
(
self
.dirs
.as_ref
()
.unwrap
()
.contains
(
directory
))
}
pub
fn
has_dir
(
&
mut
self
,
directory
:
&
HgPath
,
)
->
Result
<
bool
,
DirstateMapError
>
{
pub
fn
has_dir
(
&
mut
self
,
directory
:
&
HgPath
)
->
Result
<
bool
,
DirstateMapError
>
{
self
.set_all_dirs
()
?
;
Ok
(
self
.all_dirs
.as_ref
()
.unwrap
()
.contains
(
directory
))
}
...
...
@@ -322,11 +297,8 @@
self
.set_all_dirs
()
?
;
Ok
(
self
.all_dirs
.as_ref
()
.unwrap
()
.contains
(
directory
))
}
pub
fn
parents
(
&
mut
self
,
file_contents
:
&
[
u8
],
)
->
Result
<&
DirstateParents
,
DirstateError
>
{
pub
fn
parents
(
&
mut
self
,
file_contents
:
&
[
u8
])
->
Result
<&
DirstateParents
,
DirstateError
>
{
if
let
Some
(
ref
parents
)
=
self
.parents
{
return
Ok
(
parents
);
}
...
...
@@ -356,10 +328,8 @@
self
.dirty_parents
=
true
;
}
pub
fn
read
(
&
mut
self
,
file_contents
:
&
[
u8
],
)
->
Result
<
Option
<
DirstateParents
>
,
DirstateError
>
{
#[timed]
pub
fn
read
(
&
mut
self
,
file_contents
:
&
[
u8
])
->
Result
<
Option
<
DirstateParents
>
,
DirstateError
>
{
if
file_contents
.is_empty
()
{
return
Ok
(
None
);
}
...
...
@@ -388,8 +358,7 @@
parents
:
DirstateParents
,
now
:
Duration
,
)
->
Result
<
Vec
<
u8
>
,
DirstateError
>
{
let
packed
=
pack_dirstate
(
&
mut
self
.state_map
,
&
self
.copy_map
,
parents
,
now
)
?
;
let
packed
=
pack_dirstate
(
&
mut
self
.state_map
,
&
self
.copy_map
,
parents
,
now
)
?
;
self
.dirty_parents
=
false
;
...
...
@@ -402,6 +371,5 @@
return
file_fold_map
;
}
let
mut
new_file_fold_map
=
FileFoldMap
::
default
();
for
(
filename
,
DirstateEntry
{
state
,
..
})
in
self
.state_map
.borrow
()
{
for
(
filename
,
DirstateEntry
{
state
,
..
})
in
self
.state_map
.borrow
()
{
if
*
state
==
EntryState
::
Removed
{
...
...
@@ -407,6 +375,5 @@
if
*
state
==
EntryState
::
Removed
{
new_file_fold_map
.insert
(
normalize_case
(
filename
),
filename
.to_owned
());
new_file_fold_map
.insert
(
normalize_case
(
filename
),
filename
.to_owned
());
}
}
self
.file_fold_map
=
Some
(
new_file_fold_map
);
...
...
@@ -495,9 +462,6 @@
other_parent
.insert
(
HgPathBuf
::
from_bytes
(
b"f4"
));
let
entries
=
map
.get_non_normal_other_parent_entries
();
assert_eq!
(
(
&
mut
non_normal
,
&
mut
other_parent
),
(
entries
.0
,
entries
.1
)
);
assert_eq!
((
&
mut
non_normal
,
&
mut
other_parent
),
(
entries
.0
,
entries
.1
));
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment