Pierre-Yves David <pierre-yves.david@octobus.net> [Thu, 16 Sep 2021 15:20:28 +0200] rev 48001
dirstate: use `reset_state` instead of `dropfile` in largefile
As `dirstatemap.dropfile` is on its way out.
Differential Revision: https://phab.mercurial-scm.org/D11441
Pierre-Yves David <pierre-yves.david@octobus.net> [Wed, 15 Sep 2021 18:40:25 +0200] rev 48000
dirstate: use `reset_state` in `rebuild` instead of `dropfile`
As `dirstatemap.dropfile` is on its way out.
Differential Revision: https://phab.mercurial-scm.org/D11440
Pierre-Yves David <pierre-yves.david@octobus.net> [Wed, 15 Sep 2021 18:38:24 +0200] rev 47999
dirstate: use `reset_state` to drop file in `update_file_p1`
The `dropfile` function is on its way out.
Differential Revision: https://phab.mercurial-scm.org/D11439
Pierre-Yves David <pierre-yves.david@octobus.net> [Wed, 15 Sep 2021 18:36:59 +0200] rev 47998
dirstate: support file tracked nowhere in `reset_state`
This let the dirstatemap decide when to drop files.
Differential Revision: https://phab.mercurial-scm.org/D11438
Pierre-Yves David <pierre-yves.david@octobus.net> [Wed, 15 Sep 2021 18:30:06 +0200] rev 47997
dirstate: drop dirstatemap.addfile
All users have been migrated.
Differential Revision: https://phab.mercurial-scm.org/D11437
Pierre-Yves David <pierre-yves.david@octobus.net> [Wed, 15 Sep 2021 18:27:57 +0200] rev 47996
dirstate: update the documentation of the dirstatemap API
The API changed so should the documentation.
Differential Revision: https://phab.mercurial-scm.org/D11436
Pierre-Yves David <pierre-yves.david@octobus.net> [Wed, 15 Sep 2021 12:38:56 +0200] rev 47995
dirstate: drop the `_addpath` method
All user have been migrated.
Differential Revision: https://phab.mercurial-scm.org/D11435
Pierre-Yves David <pierre-yves.david@octobus.net> [Wed, 15 Sep 2021 12:33:59 +0200] rev 47994
dirstate: remove the `normallookup` function
All use have been migrated.
Differential Revision: https://phab.mercurial-scm.org/D11434
Pierre-Yves David <pierre-yves.david@octobus.net> [Thu, 16 Sep 2021 14:14:33 +0200] rev 47993
dirstate: stop using `_normallookup` in the adddrop extension
That extension is just trying to produce a "corrupted" dirstate.
Differential Revision: https://phab.mercurial-scm.org/D11433
Pierre-Yves David <pierre-yves.david@octobus.net> [Wed, 15 Sep 2021 18:12:55 +0200] rev 47992
dirstate: replace the use of `_normallookup` in `rebuild`
Normal lookup is a complicated function that we want to get rid of.
Differential Revision: https://phab.mercurial-scm.org/D11432
Pierre-Yves David <pierre-yves.david@octobus.net> [Wed, 15 Sep 2021 18:16:16 +0200] rev 47991
dirstate: replace the use of _normallookup in `setparents`
normal lookup is a complicated function that we want to get rid of.
Differential Revision: https://phab.mercurial-scm.org/D11431
Pierre-Yves David <pierre-yves.david@octobus.net> [Wed, 15 Sep 2021 18:05:39 +0200] rev 47990
dirstate: introduce a set_tracked method on "map" and "item"
This move more implementation details withing the DirstateItem itself, which is
what we have been doing for a while.
Differential Revision: https://phab.mercurial-scm.org/D11430
Pierre-Yves David <pierre-yves.david@octobus.net> [Wed, 15 Sep 2021 11:13:46 +0200] rev 47989
dirstate: fix restoration of "merged" state after a remove
Before this change, "merged" file that get removed and re-added later were
recorded as "from_p2" instead.
This came from
8fe74328f700, a 2014 changeset that start explicitly doing so
for reason I have not been able to fully grasp. The graft test mentioned in
the description are still happy after this changeset.
So this changeset restore what seems to be the intended behavior. Restoring
information as it was before the removal.
Differential Revision: https://phab.mercurial-scm.org/D11429
Pierre-Yves David <pierre-yves.david@octobus.net> [Wed, 15 Sep 2021 10:20:25 +0200] rev 47988
dirstate: inline the last two `_drop` usage
The function is small and having the associated code directly inline help use to cleanup the dirstate API.
Differential Revision: https://phab.mercurial-scm.org/D11428
Pierre-Yves David <pierre-yves.david@octobus.net> [Wed, 15 Sep 2021 10:02:11 +0200] rev 47987
dirstate: make a conditionnal easier to read in `setparents`
By grabing `nullid` in the local space, we get the conditionnal to fit in one
line.
Differential Revision: https://phab.mercurial-scm.org/D11427
Pierre-Yves David <pierre-yves.david@octobus.net> [Wed, 15 Sep 2021 09:50:44 +0200] rev 47986
dirstate: removed the now unused `_add` method
Differential Revision: https://phab.mercurial-scm.org/D11426
Pierre-Yves David <pierre-yves.david@octobus.net> [Wed, 15 Sep 2021 18:18:16 +0200] rev 47985
dirstate: replace `_add` call in `setparent`
Same logic as the previous changeset, it get us closer to removed older API on
the dirstate.
Differential Revision: https://phab.mercurial-scm.org/D11425
Pierre-Yves David <pierre-yves.david@octobus.net> [Wed, 15 Sep 2021 09:41:02 +0200] rev 47984
dirstate: directly call the right function in `set_tracked`
This get use closer to removing some older API on the dirstate.
Differential Revision: https://phab.mercurial-scm.org/D11424
Pierre-Yves David <pierre-yves.david@octobus.net> [Wed, 15 Sep 2021 10:05:25 +0200] rev 47983
dirstate: same logic as what we did for `_drop`
This is part of the dirstatemap so let the dirstatemap deal with it.
Differential Revision: https://phab.mercurial-scm.org/D11423
Pierre-Yves David <pierre-yves.david@octobus.net> [Wed, 15 Sep 2021 09:28:17 +0200] rev 47982
dirstate: use `tracked` property in `_addpath`
It is semantically better.
Differential Revision: https://phab.mercurial-scm.org/D11422
Simon Sapin <simon.sapin@octobus.net> [Fri, 17 Sep 2021 08:57:12 +0200] rev 47981
rust: Update the memmap2 crate to version 0.4.0
This version:
* Optionally implements the `StableDeref` trait, removing the need
for a wrapper type doing that
* Adds support for mapping empty files, which can routinely happen
for dirstate-v2 data files. This was a cause of some failing tests
when running with `run-tests.py --rhg --extra-config-opt rhg.status=1`
Differential Revision: https://phab.mercurial-scm.org/D11446
Pierre-Yves David <pierre-yves.david@octobus.net> [Fri, 17 Sep 2021 21:04:21 +0200] rev 47980
tests: make removeemptydirs more portable
The behavior of pwd change from one system (i.e. default shell/sh) from one
system to another so we use fuzzy matching for the output we do not care and we
use narrower command call to highlight what we are trying to test here.
Differential Revision: https://phab.mercurial-scm.org/D11449
Pierre-Yves David <pierre-yves.david@octobus.net> [Fri, 17 Sep 2021 21:04:17 +0200] rev 47979
check-code: make it possible to ignore the PWD check in some situation
The check-code script does not motivate the banning of $PWD so I am not sure
what it is about. And I will needs to use the env variable in the next tests. So
I am adding a way to make an exception.
Differential Revision: https://phab.mercurial-scm.org/D11450
Raphaël Gomès <rgomes@octobus.net> [Fri, 17 Sep 2021 14:05:56 +0200] rev 47978
relnotes: update next
Differential Revision: https://phab.mercurial-scm.org/D11448
Raphaël Gomès <rgomes@octobus.net> [Fri, 17 Sep 2021 14:05:32 +0200] rev 47977
relnotes: add release notes for 5.9
Differential Revision: https://phab.mercurial-scm.org/D11447
Martin von Zweigbergk <martinvonz@google.com> [Thu, 16 Sep 2021 16:42:16 -0700] rev 47976
dirstate: fix compilation warnings in `dirstate_item_set_possibly_dirty()`
Since https://phab.mercurial-scm.org/D11387 (i.e. the same patch as
mentioned in my previous patch), Clang has also started warning about
`dirstate_item_set_possibly_dirty()` missing an explicit return, and
about its use of the result of an assignment as a condition without
using parentheses. This patch fixes that.
Differential Revision: https://phab.mercurial-scm.org/D11445
Martin von Zweigbergk <martinvonz@google.com> [Thu, 16 Sep 2021 16:29:55 -0700] rev 47975
dirstate: make dirstate flags char be unsigned
Since https://phab.mercurial-scm.org/D11387, `CC='clang -Werror' make
local` has started failing like this:
```
mercurial/cext/util.h:41:50: error: implicit conversion from 'int' to 'char' changes value from 128 to -128 [-Werror,-Wconstant-conversion]
static const char dirstate_flag_rust_special = 1 << 7;
~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~^~~~
```
This patch fixes that by making the flags be an unsigned char. That
also matches the `bool` typedef we have in `util.h`, which seems good
since many of the `dirstate_item_c_*()` functions return a `bool`.
Differential Revision: https://phab.mercurial-scm.org/D11444
Pierre-Yves David <pierre-yves.david@octobus.net> [Thu, 02 Sep 2021 03:59:35 +0200] rev 47974
dirstate: introduce a `set_clean` method on dirstate's map and items
This method is the "reverse" of "set possibly dirty", and can be used to more
accurately other call that the dirstate was making. It is currently heavily
influenced by its origin.
Differential Revision: https://phab.mercurial-scm.org/D11421
Pierre-Yves David <pierre-yves.david@octobus.net> [Thu, 02 Sep 2021 04:03:20 +0200] rev 47973
dirstate: extract the logic to check file/dirname collision when adding a file
Differential Revision: https://phab.mercurial-scm.org/D11420
Pierre-Yves David <pierre-yves.david@octobus.net> [Thu, 02 Sep 2021 02:53:47 +0200] rev 47972
dirstate: make dirstatemap.set_untracked deal with added file
This merge dropfile in set_untracked.
Differential Revision: https://phab.mercurial-scm.org/D11419
Pierre-Yves David <pierre-yves.david@octobus.net> [Thu, 02 Sep 2021 02:48:56 +0200] rev 47971
dirstate: remove some usage of `_drop`
This is a step toward being able to remove the `_drop` method on `dirstate`.
Differential Revision: https://phab.mercurial-scm.org/D11418
Pierre-Yves David <pierre-yves.david@octobus.net> [Thu, 02 Sep 2021 02:44:12 +0200] rev 47970
dirstate: move the copymap drop inside dropfile
Since the copymap is part of the dirstatemap it make more sense for the
dirstatemap to manage it directly.
This is part of a generic effort to move unified logic at lower level and to
clean up higher level API.
Differential Revision: https://phab.mercurial-scm.org/D11417
Simon Sapin <simon.sapin@octobus.net> [Tue, 14 Sep 2021 18:25:51 +0200] rev 47969
rust: Rename get_node methods to data_for_node, get_rev to data_for_rev
These are respective methods of Changelog, Manifestlog, and Filelog;
three Rust structs that that wrap a Revlog struct.
This rename clarifies that node IDs or revision numbers are parameters,
not return values.
Also reword doc-comments in Manifestlog and Filelog to separate node IDs
and revision numbers that are local to a given (non-changelog) revlog
from those of a changeset.
Differential Revision: https://phab.mercurial-scm.org/D11416
Simon Sapin <simon.sapin@octobus.net> [Tue, 14 Sep 2021 18:10:35 +0200] rev 47968
rust: Rename the `Revlog::get_node_rev` method to `rev_from_node`
This better describes the input and outputs of this method.
Also rewrite the doc-comment, which seemed to have been left from copy-paste
of another method.
Differential Revision: https://phab.mercurial-scm.org/D11415
Simon Sapin <simon.sapin@octobus.net> [Tue, 14 Sep 2021 18:07:11 +0200] rev 47967
rust: Make private the `index` field of the `Revlog` struct
To replace the previous use of this field from another module, add a
`node_from_rev` method. This is the same method that already existed on
`Changelog`.
Differential Revision: https://phab.mercurial-scm.org/D11414
Simon Sapin <simon.sapin@octobus.net> [Mon, 26 Jul 2021 10:26:45 +0200] rev 47966
dirstate-v2: Remove the `.d` suffix in data file names
It could cause confusion since `.d` is already used for revlogs.
This suffix is not necessary since there is already a `dirstate.` prefix.
Differential Revision: https://phab.mercurial-scm.org/D11413
Simon Sapin <simon.sapin@octobus.net> [Mon, 13 Sep 2021 18:48:48 +0200] rev 47965
rhg: Don’t compare ambiguous files one byte at a time
Even though the use of `BufReader` reduces the number of syscalls to read
the file from disk, `.bytes()` yields a separate `Result` for every byte.
Creating those results and dispatching on them is most likely costly.
Instead, this commit opts for simplicity by reading the entire file into memory
and comparing a single pair of byte strings. Note that memory already needs to
contain the entire previous contents of the file, as read from the filelog.
So with an extremely large file this doubles memory use but does not make it
grow by orders of magnitude.
At first I wrote code that still avoids reading the entire file into memory
and compares one buffer at a time with `BufReader`. Find this code below for
posterity. However its correctness is subtle. I ended up preferring the
simplicity of the obviously-correct single comparison.
```rust
let mut reader = BufReader::new(fobj);
let mut expected = &contents_in_p1[..];
loop {
let buf = reader.fill_buf().when_reading_file(&fs_path)?;
if buf.is_empty() {
// Found EOF
return Ok(expected.is_empty());
} else if let Some(rest) = expected.drop_prefix(buf) {
// What we read so far matches the expected content, continue reading
let buf_len = buf.len();
reader.consume(buf_len);
expected = rest
} else {
// Found different content
return Ok(false);
}
}
```
Differential Revision: https://phab.mercurial-scm.org/D11412
Simon Sapin <simon.sapin@octobus.net> [Mon, 13 Sep 2021 18:09:10 +0200] rev 47964
rhg: Reuse manifest when checking status of multiple ambiguous files
When `rhg status` cannot determine whether a file is clean based on mtime and
size alone, it needs to compare its contents with those found in the parent
commit. Previously, rhg would find the (same) manifest of that commit again
for every such file. This is lifted out of the loop and reused.
Differential Revision: https://phab.mercurial-scm.org/D11411
Simon Sapin <simon.sapin@octobus.net> [Mon, 13 Sep 2021 18:02:45 +0200] rev 47963
rust: Return HgError instead of RevlogError in revlog constructors
This leaves fewer cases for callers to handle, as RevlogError is more general
Differential Revision: https://phab.mercurial-scm.org/D11410
Simon Sapin <simon.sapin@octobus.net> [Mon, 13 Sep 2021 17:23:42 +0200] rev 47962
rhg: Align with Python on some revset parsing corner cases
In particular:
* A string of ASCII digits can be either an integer on a hex prefix
* The NULL node ID should convert to the NULL revision number
Differential Revision: https://phab.mercurial-scm.org/D11409
Simon Sapin <simon.sapin@octobus.net> [Mon, 13 Sep 2021 15:42:39 +0200] rev 47961
rust: Add a Filelog struct that wraps Revlog
Some filelog-specific logic is moved from code `rhg cat` into this struct
where it can better be reused.
Additionally, a missing end delimiter for metadata causes an error
to be returned instead of being silently ignored.
Differential Revision: https://phab.mercurial-scm.org/D11408
Simon Sapin <simon.sapin@octobus.net> [Mon, 13 Sep 2021 13:45:10 +0200] rev 47960
rust: Add Repo::manifest(revision)
This deduplicates some common code.
Differential Revision: https://phab.mercurial-scm.org/D11407
Simon Sapin <simon.sapin@octobus.net> [Mon, 13 Sep 2021 13:29:55 +0200] rev 47959
rust: Keep lazily-initialized Changelog and Manifest log on the Repo object
That way if one of them is accessed multiple times it won’t be reopened
from the filesystem.
Differential Revision: https://phab.mercurial-scm.org/D11406
Simon Sapin <simon.sapin@octobus.net> [Mon, 13 Sep 2021 13:16:10 +0200] rev 47958
rust: Move lazy initialization of `Repo::dirstate_map` into a generic struct
More components of `Repo` will be added following the same pattern.
Differential Revision: https://phab.mercurial-scm.org/D11405
Simon Sapin <simon.sapin@octobus.net> [Mon, 13 Sep 2021 13:01:25 +0200] rev 47957
rust: Rename Manifest to Manifestlog, ManifestEntry to Manifest
This appears to match the terminology used in Python code
and on https://www.mercurial-scm.org/wiki/Manifest
Differential Revision: https://phab.mercurial-scm.org/D11404
Simon Sapin <simon.sapin@octobus.net> [Thu, 09 Sep 2021 21:04:55 +0200] rev 47956
rust: Add Repo::dirstate_map and use it in `rhg status`
This moves low-level dirstate wrangling out of the status command and into
a more reusable location.
The open dirstate map is lazily initialized and kept on the Repo object,
for reuse by sub-sequent calls.
Differential Revision: https://phab.mercurial-scm.org/D11398
Simon Sapin <simon.sapin@octobus.net> [Fri, 10 Sep 2021 09:53:09 +0200] rev 47955
rust: Switch to the memmap2-rs crate
https://github.com/RazrFalcon/memmap2-rs
This is a fork of the original memmap crate which appears to be unmaintained:
https://github.com/danburkert/memmap-rs/issues/90
This fork is the most popular according to https://crates.io/keywords/mmap
Differential Revision: https://phab.mercurial-scm.org/D11397
Simon Sapin <simon.sapin@octobus.net> [Thu, 09 Sep 2021 18:07:40 +0200] rev 47954
rust: Make OwningDirstateMap generic and move it into hg-core
This will enable using it in rhg too.
The `OwningDirstateMap::new_empty` constructor is generic and accepts a value
of any type that gives acces to a bytes buffer. That buffer must stay valid
as long as the value hasn’t been dropped, and must keep its memory address
even if the value is moved. The `StableDeref` marker trait encodes those
constraints. Previously no trait was needed because the value was always
of type `PyBytes` which we know satisfies those constraints.
The buffer type is ereased in the struct itself through boxing and
dynamic dispatch, in order to simplify other signatures that mention
`OwningDirstateMap`.
Differential Revision: https://phab.mercurial-scm.org/D11396
Simon Sapin <simon.sapin@octobus.net> [Mon, 06 Sep 2021 13:39:54 +0200] rev 47953
rust: Move PyBytesWithData out of copy-tracing code
So we can use it in other places to.
Replace its `.data()` method with the `Deref<Target = [u8]>` trait,
allowing this type to be used in generic contexts.
Rename the type accordingly.
Differential Revision: https://phab.mercurial-scm.org/D11395
Simon Sapin <simon.sapin@octobus.net> [Mon, 06 Sep 2021 11:39:59 +0200] rev 47952
rust: Move VFS code to its own module
It was previously in the hg::repo module, but both repo code and vfs
will likely grow in the future.
Differential Revision: https://phab.mercurial-scm.org/D11394
Simon Sapin <simon.sapin@octobus.net> [Fri, 03 Sep 2021 16:32:35 +0200] rev 47951
rhg: Switch rhg.ignored-extensions config to Python-compatible list syntax
This includes the ability to have an extension name/path that contains a comma,
by double-quoting it.
Differential Revision: https://phab.mercurial-scm.org/D11390
Simon Sapin <simon.sapin@octobus.net> [Wed, 17 Feb 2021 20:49:53 +0100] rev 47950
rhg: Port Python’s `ui.configlist` as `Config::get_list`
This new method is not used yet outside of its own unit tests,
so this changeset should make no observable change.
The Rust parser implementation attempts to exactly replicate the behavior of
the Python one, even in edge cases where that behavior is… surprising.
New unit tests capture some of these edge cases.
This started as a line-by-line port. The main changes are:
* Pass around a parser mode enum instead of parser functions
* Inline the whole parser into one function
* Use `[u8]::get` which returns an `Option`,
instead of indexing after explicitly checking the length.
Differential Revision: https://phab.mercurial-scm.org/D11389
Simon Sapin <simon.sapin@octobus.net> [Fri, 03 Sep 2021 16:37:20 +0200] rev 47949
rust: Generalize the `trim_end_newlines` utility of byte strings
… into `trim_end_matches` that takes a callack.
Also add `trim_start_matches`.
Differential Revision: https://phab.mercurial-scm.org/D11388
Pierre-Yves David <pierre-yves.david@octobus.net> [Mon, 30 Aug 2021 21:18:29 +0200] rev 47948
dirstate-item: move the C implementation to the same logic
Now that we know were we are going, we can update the C implementation.
Differential Revision: https://phab.mercurial-scm.org/D11387
Pierre-Yves David <pierre-yves.david@octobus.net> [Tue, 31 Aug 2021 09:23:50 +0200] rev 47947
dirstate-item: introduce low level C function
Since a lot of logic is about to change, we need to isolate it into bits that
are easy reusable in the rest of the C code.
Especially we need to split the part that do the pure logic from the part that
do the Python wrapping.
Differential Revision: https://phab.mercurial-scm.org/D11386
Pierre-Yves David <pierre-yves.david@octobus.net> [Fri, 27 Aug 2021 20:06:07 +0200] rev 47946
dirstate-item: factor some code in the C implementation
We have both `dirstate_item_from_v1_meth`, a class method, and
`dirstate_item_from_v1_data`, a function taking low level C argument.
Lets implement the former with the later.
Differential Revision: https://phab.mercurial-scm.org/D11385
Pierre-Yves David <pierre-yves.david@octobus.net> [Fri, 27 Aug 2021 19:19:21 +0200] rev 47945
dirstate-item: `dirstate_item_from_v1_data` replaces make_dirstate_item
For different format, we will need multiple capsule anyways.
Differential Revision: https://phab.mercurial-scm.org/D11384
Pierre-Yves David <pierre-yves.david@octobus.net> [Mon, 30 Aug 2021 18:45:54 +0200] rev 47944
pathutil: replace the `skip` argument of `dirs` with a boolean
It is ever only used for `r` file. So we make it a boolean this will give use
more versatility later as we will stop storing the state explicitly.
Differential Revision: https://phab.mercurial-scm.org/D11383
Pierre-Yves David <pierre-yves.david@octobus.net> [Thu, 02 Sep 2021 00:16:37 +0200] rev 47943
dirstate: clarify the message in nonnormal checking
The previous message was quite verbose and hard to understand. The new one
should be friendlier.
Differential Revision: https://phab.mercurial-scm.org/D11382
Augie Fackler <augie@google.com> [Wed, 08 Sep 2021 15:59:48 -0400] rev 47942
merge: with stable