Commit Graph

3327 Commits

Author SHA1 Message Date
Jun Wu
3119869537 dag: de-duplicate logic about merging flat segments
Summary:
Move the logic to a common method. A side effect is that
IndexedlogIdDag needs to calculate `last_span.high` again, and
InProcessIdDag needs to calculate `last_store_id` again. But it's
probably okay since the merge is rare and the InProcessIdDag operations should
be considered fast even if it's called frequently.

Reviewed By: sfilipco

Differential Revision: D26504915

fbshipit-source-id: e215ffe9fef7948b7b662dba3ed990e374be989a
2021-02-19 10:30:01 -08:00
Jun Wu
3915e59426 dag: add a few more tests about IdDag segment merging behavior
Summary: Add a few more tests to the generic IdDag tests.

Reviewed By: sfilipco

Differential Revision: D26415514

fbshipit-source-id: 5ef2a1d4e03527b184a07d94de91c64a05427b90
2021-02-19 10:30:00 -08:00
Jun Wu
1503cf6e12 dag: drop merge_commits flag
Summary: It is a constant `true` now. Inline the logic and remove the field.

Reviewed By: sfilipco

Differential Revision: D26414838

fbshipit-source-id: ceace835ecfd263ba16c3dead41ce6ba95087e4f
2021-02-19 10:30:00 -08:00
Jun Wu
7bb35e4356 dag: enable segment merging for IdDag stores
Summary: Turn on the IdDag flat segment merging behavior. Update related tests.

Reviewed By: sfilipco

Differential Revision: D26414843

fbshipit-source-id: f91f4dbd144276e895ad8bc14f37bcc2fa13935e
2021-02-19 10:30:00 -08:00
Jun Wu
34f1ec6959 dag: implement segment merging for inprocess IdDag
Summary:
Similar to the previous diff. Implement the merge behavior for InProcess IdDag.

The feature is not turned on yet for easier review. It is turned on by the
next diff.

Reviewed By: sfilipco

Differential Revision: D26414839

fbshipit-source-id: 2a485e0dffcd9d8e2ad95380159d11342636f9aa
2021-02-19 10:29:59 -08:00
Jun Wu
e5767de7ae dag: implement segment merging for indexedlog IdDag
Summary:
Merge adjacent flat segments to reduce fragmentation.

The merging is done by a special entry that instructs:
- Remove the old segment from index.
- Insert the new segment.

Note: For the parent -> child index we record parent -> child id, not parent ->
segment. So that index does not need to be updated, because the merged segment
has the same "parent -> child id" information.

Note: The merging is a bit expensive (multiple lookups). But most segments are
not mergeable, because their parents are not "span.low - 1". So the slow path
is not hit often.

The feature is not enabled by default in this diff, because it will break IdDag
tests, which assume indexedlog and in-memory IdDags behave the same, and we
haven't updated in-memory IdDag.

Reviewed By: sfilipco

Differential Revision: D26414841

fbshipit-source-id: 6a268bef56b7a56c62bb8ad949f13e503a88b033
2021-02-19 10:29:59 -08:00
Jun Wu
ee97981fd3 dag: extract indexedlog IdDag segment construct to a method
Summary: We'll tweak the construct logic in a future diff.

Reviewed By: sfilipco

Differential Revision: D26414842

fbshipit-source-id: 791bdda8b042b90ff9aeef630cb904a2d9e41cbd
2021-02-19 10:29:59 -08:00
Jun Wu
fa8a04d539 dag: drop max_level state from IdDag
Summary:
With previous refactorings the `max_level` is now maintained by the underlying
IdDag stores. Remove the `max_level` on the wrapper IdDag to simplify the
logic.

Reviewed By: sfilipco

Differential Revision: D26414840

fbshipit-source-id: 084a7f6f75fd53103c45519190607607fef4e161
2021-02-19 10:29:58 -08:00
Jun Wu
04bc45fae0 dag: skip serializing max_level and new_seg_size in IdDag
Summary: We're going to remove the fields. Those add noise to the serialized data.

Reviewed By: sfilipco

Differential Revision: D26504916

fbshipit-source-id: 7fd13bdab4511ceea50195595514fb89a4169419
2021-02-19 10:29:58 -08:00
Jun Wu
a25f03a545 async-runtime: reduce worker_threads to min(nproc, 8)
Summary:
By default it spawns `nproc` threads, which is an overkill on hosts with many cores.
Data shows the max CPU busy % for tokio threads is 30%, avg is 0.1%.

Testing framework will spawn `nproc` tests, meaning it's `nproc ^ 2` threads, which
seems too many.

The number 8 is picked to match the checkout worker count (worker.numcpus), to
ensure checkout tasks won't have bottleneck on the count of tokio threads doing
work like parsing manifest etc.

Reviewed By: sfilipco

Differential Revision: D26437442

fbshipit-source-id: 4dccef83294e64c432ef5ab4be259d41dd890ece
2021-02-19 10:20:57 -08:00
Johan Schuijt-Li
22c1735c5e mononokepeer: don't concat strings when help message not set
Summary:
Fix for error:
  can only concatenate str (not "NoneType") to str

Reviewed By: quark-zju

Differential Revision: D26523879

fbshipit-source-id: 3d15d72be3444df25fb705ce444d6c3621547551
2021-02-18 18:00:27 -08:00
Liubov Dmitrieva
84280e36c3 remove accessed bookmarks feature
Summary:
Remove selectivepullaccessedbookmarks feature because it contains bugs and causes many undesired issues.

This was added to migrate existing repos to selective pull and is not needed anymore.

Main effects are:

* if you enable selectivepull for an existing repo, it won't reduce number of subscribed bookmarks.
* some operations like `hg push` or `hg pull -r` in their underlying implementation update all subscribed bookmarks, not just accessed like before.
This drives changes to the tests. Reminder, the bookmark has been marked as "accessed" if the repo has been ever updated to that bookmark.

All tests fixed accordingly.

Reviewed By: markbt

Differential Revision: D26460435

fbshipit-source-id: f839b9f207bfc478a0336ec807b720d35a0bb12e
2021-02-18 04:02:06 -08:00
Durham Goode
5b5eec156c treemanifest: remove logic that replaces the stores
Summary:
This was added in D26387205 (ca1249c269) to make the treemanifest store usage look
more like the file store usage, but it appears to cause read-after-write
failures. I'm not sure exactly why, but I think it's because something takes a
reference to the old store and writes to it, then something else reads from the
new store. Or vice versa.

Either way, reverting these three lines fixes it.

Reviewed By: singhsrb

Differential Revision: D26497708

fbshipit-source-id: e9afabed8d5f800260e647d5ed1513eed0bc60cd
2021-02-17 14:36:14 -08:00
Andrey Chursin
ceee768281 pycheckout: register checkout module in populate_module
Reviewed By: DurhamG

Differential Revision: D26470216

fbshipit-source-id: cdfda074256ba7dbf90d807904bab9a3b8142a98
2021-02-17 12:02:44 -08:00
Andrey Chursin
6498f4f892 pycheckout: add checkoutplan::apply
Reviewed By: DurhamG

Differential Revision: D26469704

fbshipit-source-id: 010a12b04b7f6a5d08e1aa248130026341306595
2021-02-17 12:02:43 -08:00
Andrey Chursin
51a29c5d7e pycheckout: implement checkoutplan::__new__
Summary: This diff introduces a Python checkoutplan, which will be used later for Python code to interact with the Rust checkout infrastructure

Reviewed By: DurhamG

Differential Revision: D26437080

fbshipit-source-id: fe3517f4e2f15244a7c2cd290a41394e904db51b
2021-02-17 12:02:43 -08:00
Andrey Chursin
6ae7c785ba pymanifest: make treemanifest public
Summary: This diff exposes treemanifest for public use and introduce method to borrow underlyning manifest for usage in rust

Reviewed By: DurhamG

Differential Revision: D26437079

fbshipit-source-id: d2d6cd2a4d1f108881d985932a36d48fed4b238d
2021-02-17 12:02:43 -08:00
Andrey Chursin
11faa47a7d pycheckout: empty pycheckout crate
Reviewed By: DurhamG

Differential Revision: D26435596

fbshipit-source-id: 013070ff918c7b45105c7abdad0950ee96d46d49
2021-02-17 12:02:43 -08:00
Andrey Chursin
eac8385eff vfs: use &[u8] instead of Bytes for content
Summary: This is most universal/flexible interface

Reviewed By: quark-zju

Differential Revision: D26410641

fbshipit-source-id: cae74675f89c0c1c05c84331c3ce0e78fd0b0b2f
2021-02-17 10:45:46 -08:00
Andrey Chursin
3e29269b99 vfs: update existing permissions instead of setting const value
Summary: This better replicates python's logic

Reviewed By: quark-zju

Differential Revision: D26406416

fbshipit-source-id: 1027004ded63a28aa88b81b087255c4ef212dd6b
2021-02-17 10:45:46 -08:00
Andrey Chursin
0ea63a1eaf checkout: test no empty dirs are left
Reviewed By: quark-zju

Differential Revision: D26406420

fbshipit-source-id: 3a9dc818a4a140f2e532c18b2abd81286cfee1eb
2021-02-17 10:45:46 -08:00
Xavier Deguillard
a24e03f76f rust: update libc crate
Summary: The latest libc has fixes for compiling on the M1 mac, let's update it.

Reviewed By: dtolnay

Differential Revision: D26476625

fbshipit-source-id: d9a997e69c428d53c51fc52353289a6510314c50
2021-02-16 22:31:41 -08:00
Durham Goode
4b2ec1b3cc tests: fix test on osx
Summary:
Sort works differently on OSX. Let's set the locale in this case to get
consistent sorting across platforms.

Reviewed By: quark-zju

Differential Revision: D26438678

fbshipit-source-id: 80a5c758795fd9675b8b2b658521c0e9d6807366
2021-02-16 10:09:04 -08:00
Lukas Piatkowski
87ddbe2f74 autocargo v1: update autocargo field format to allow transition to autocargo v2
Summary:
Autocargo V2 will use a more structured format for autocargo field
with the help of `cargo_toml` crate it will be easy to deserialize and handle
it.

Also the "include" field is apparently obsolete as it is used for cargo-publish (see https://doc.rust-lang.org/cargo/reference/manifest.html#the-exclude-and-include-fields). From what I know this might be often wrong, especially if someone tries to publish a package from fbcode, then the private facebook folders might be shipped. Lets just not set it and in the new system one will be able to set it explicitly via autocargo parameter on a rule.

Reviewed By: ahornby

Differential Revision: D26339606

fbshipit-source-id: 510a01a4dd80b3efe58a14553b752009d516d651
2021-02-12 23:28:25 -08:00
Arun Kulshreshtha
c97db6b042 auth: rename structs
Summary:
Make the struct and method names in this crate more clearly reflective of what they do:

- `Auth` -> `AuthGroup`
- `Auth::try_from` -> `AuthGroup::new`
- `AuthConfig` -> `AuthSection`
- `AuthConfig::new` -> `AuthSection::from_config`
- `AuthConfig::auth_for_url` -> `AuthSection::best_match_for`

Reviewed By: singhsrb

Differential Revision: D26436095

fbshipit-source-id: a5ec5d9c48d3b75a0ee166b74e5340f9c529eeae
2021-02-12 17:52:29 -08:00
Jun Wu
c08f68a05a crdump: use max( instead of last() to optimize a revset query
Summary:
In a non-segmented-chanelog repo, `last`, the revset function has suboptimal
path that makes the following query:

    last(::b8f917d4c & public())

take a long time. Use `max` to fix it.

Reviewed By: singhsrb

Differential Revision: D26435439

fbshipit-source-id: dc854b4c6978d2925cab2cb8f217365ed9c7f146
2021-02-12 14:57:14 -08:00
Arun Kulshreshtha
916956b264 auth: use scheme from URL prefix if present
Summary: Make `AuthConfig::auth_for_url` match the behavior of the Python `httpconnection.readauthforuri` function when an auth group has a URL prefix with a scheme. Previously, the Rust version did not allow schemes to be specified on the prefix, and instead required them to be specified in the "schemes" fields. The Python code allows a scheme in the prefix, which overrides the contents of the "schemes" field for that auth group if present.

Reviewed By: DurhamG

Differential Revision: D26419721

fbshipit-source-id: 909b52a2e37e2fc908d5eb56740dd41dda826033
2021-02-12 14:47:39 -08:00
Zeyi (Rice) Fan
d552144478 configparser: move conversion related to a separated module
Summary:
Move these conversion related function and trait out of `hg` module so EdenFS can use it too. Changes:

* Moved `get_opt`, `get_or` and `get_or_default` directly into `ConfigSet`.
* Moved `FromConfigValue` and `ByteCount` into `configparser::convert`.

Reviewed By: quark-zju

Differential Revision: D26355403

fbshipit-source-id: 9096b7b737bc4a0cccee1a3883e89a323f864fac
2021-02-12 12:33:47 -08:00
Durham Goode
7ab09f1e5f tests: fix broken test
Summary:
The push-pull test was broken by my recent change to make indexedlog
the default. It wasn't caught because the test is disabled in Python 3. It now
passes with Python 3 so let's enable it.

The repack-remove fix is just some flakiness I've seen lately.

Reviewed By: singhsrb

Differential Revision: D26412998

fbshipit-source-id: be4b648f31bd6dfbf6a6e5d2e382acb084461974
2021-02-12 11:38:43 -08:00
Arun Kulshreshtha
8412d537f8 pyauth: add bindings to auth crate
Summary: Add Python bindings to the Rust `auth` crate, with the intention of replacing `httpconnection.readauthforuri`.

Reviewed By: quark-zju

Differential Revision: D26419447

fbshipit-source-id: dd13bea74961137790beb8c96120ebef99e3c313
2021-02-12 10:04:27 -08:00
Arun Kulshreshtha
92bfc3d63d auth: add extra fields to auth groups
Summary: The Python `readauthforuri` method will include *any* fields specified in the `[auth]` section for a given auth group, even if those fields aren't one of the expect ones (such as `cert`, `key`, etc). This is sometimes used in tests to attach additional information to an auth group. To support this in Rust, let's just collect all unknown fields into a `HashMap`.

Reviewed By: quark-zju

Differential Revision: D26416086

fbshipit-source-id: 0252e340e38850a54e24d54810e9abd77c566f63
2021-02-11 21:06:31 -08:00
Arun Kulshreshtha
9fc3b326fb bindings/pyerror: add CertificateError exception
Summary:
The auth crate is now able to check the presence and expiration of client certificates (D26009207 (9f7d4447fd)). When a problem is detected, it emits an `X509Error`, which specifies exactly what the problem is. Since this error always indicates a certificate issue, we can print out the message configured in `help.tlsauthhelp` (which is more specific than `help.tlshelp` from the previous diff).

Previously, Mercurial would attempt to use the certificate anyway, resulting in a difficult to understand error message. Although the previous diffs in this stack improved the error messages on any TLS failure, the `X509Error` messages are even more helpful.

Users can opt in to this certificate validation with `edenapi.validate-certs`. The functionality is gated on a config option to prevent Mercurial from crashing if certificates are misconfigured, but EdenAPI isn't being used.

Reviewed By: quark-zju

Differential Revision: D26385843

fbshipit-source-id: 9809f612f8aab3f2dd442d6dd8dc348f1af45296
2021-02-11 19:29:22 -08:00
Arun Kulshreshtha
8513949bf2 scmutil: print help.tlshelp on TlsError
Summary: Print out the help text configured in `help.tlshelp` upon hitting a `TlsError`. Note that in this case, we use `help.tlshelp` rather than `help.tlsauthhelp` since all we know in this case is that *some* kind of TLS error occurred.

Reviewed By: quark-zju

Differential Revision: D26385844

fbshipit-source-id: 1fb5280195de75107ecdfc9203ef8ddda2a04052
2021-02-11 19:29:21 -08:00
Arun Kulshreshtha
8b9cf7e7cb bindings/pyerror: add TlsError exception type
Summary: Add a new `TlsError` Python exception type corresponding to `HttpClientError::Tls`.

Reviewed By: quark-zju

Differential Revision: D26385846

fbshipit-source-id: c0df543032461de650a4d24c26c6b8aaab1abbb9
2021-02-11 19:29:21 -08:00
Arun Kulshreshtha
5f0a89ca37 http-client: add HttpClientError variant for TLS errors
Summary:
Add a new `HttpClientError::Tls` variant specifically for TLS errors, separating them from other `curl::Error`s from libcurl.

To determine whether a particular `curl::Error` is a TLS error, we check both the error code and the contents of the error message.

Reviewed By: quark-zju

Differential Revision: D26385845

fbshipit-source-id: fd58f86a3a61fcfb845d19e262fdcb132dc7ec9f
2021-02-11 19:29:21 -08:00
Andrey Chursin
0b03898f89 checkout: add genereated test cases
Summary: This diff adds auto-generated test cases to checkout code. It generates partially overlapping trees and tests transitions between them

Reviewed By: quark-zju

Differential Revision: D26384962

fbshipit-source-id: 6140bbb7ff8b87843a2235f8325f57829cdd8cae
2021-02-11 19:10:25 -08:00
Andrey Chursin
c8d54af98e types: limit PathComponentBuf arbitrary characters to a-z only
Summary: Currently PathComponentBuf::arbitrary generates any characters. Those characters are ok for unit tests on hg abstractions where they are currently used, but many of them do not work with real filesystems

Reviewed By: quark-zju

Differential Revision: D26384961

fbshipit-source-id: dde1e9276114b30262bc477a3e0f828645f1f32a
2021-02-11 19:10:25 -08:00
Andrey Chursin
881b03690d vfs: reset permissions when overwriting file
Summary:
Currently if VFS overwrites executable file with regular, it preserves exec bit[see added test].
This diff makes sure that file has correct permissions after overwrite

This diff also slightly optimizes write_executable, by calling set_mode on the file handle, instead of path

TODO - we can check if calling stats() before set_permissions will save some time

Reviewed By: quark-zju

Differential Revision: D26379824

fbshipit-source-id: 42d0b2fb79ed860ac37b2de077388002ade69449
2021-02-11 19:10:24 -08:00
Andrey Chursin
0240026f36 vfs: do not follow symlink when overwriting
Summary:
Before this diff VFS::write_regular did not handle correctly use case when file already existed as as symlink - it would write into symlink location, instead of replacing symlink with a regular file (see updated  test_symlink_overwrite that is failing on old implementation)

This diff adds O_NOFOLLOW option on unix when overwriting the file. When destination is a symlink, attempt to write fails with E_LOOP and triggers clear_conflict that removes symlink and allows retry write to succeed.

This also allows one of test cases in checkout that previously did not work

Reviewed By: quark-zju

Differential Revision: D26378893

fbshipit-source-id: 28bcdaba78db283ac7a25bb232c198d3d8f73e5d
2021-02-11 19:10:24 -08:00
Andrey Chursin
38499b36e0 checkout: introduce file system tests
Summary: This diff contains basic test setup for checkout tests - we compare transition between two trees without dirty changes

Reviewed By: quark-zju

Differential Revision: D26359502

fbshipit-source-id: ef670c944200bae1652863c91ada92c6fecce4ac
2021-02-11 19:10:24 -08:00
Adam Simpkins
8907208651 update dirsync to allow matching individual files
Summary:
Update the dirsync code to allow mirror and exclude rules to match individual
files rather than just directory prefixes.

This simply appends `/` to all filenames when looking for rule matches.  This
allows us to efficiently match individual filenames in addition to directory
prefixes.

Reviewed By: quark-zju

Differential Revision: D26294583

fbshipit-source-id: 83b283f344f6e0bc0fe53b9068e7e0170f53504b
2021-02-11 15:54:28 -08:00
Stefan Filip
93c1231c55 segmented_changelog: update hash_to_location to gracefully handle unknown hashes
Summary:
One of the primary use cases for hash_to_location is translating user provided
hashes. It is then perfectly valid for the hashes that are provided to not
exist.  Where we would previously return an error for the full request if a
hash was invalid, we now omit the hash from the response.

Reviewed By: quark-zju

Differential Revision: D26389472

fbshipit-source-id: c59529d43f44bed7cdb2af0e9babc96160e0c4a7
2021-02-11 12:17:35 -08:00
Stefan Filip
c9f3ae8fa4 edenapi: add commithashtolocation to python client
Summary: Same approach as locationtohash.

Reviewed By: quark-zju

Differential Revision: D26382616

fbshipit-source-id: a06c62c3eebcbe0b07b5c28fce4789a1334d55a4
2021-02-11 12:17:35 -08:00
Stefan Filip
cfed6bb108 edenapi: add commitlocationtohash to python client
Summary:
The approach is very similar to what commitrevlogdata does. You could say
that it's cargo culted.
I am not sure how appropriate it is to return CommitLocationToHashResponse
but I think that it's fine for now.

Reviewed By: quark-zju

Differential Revision: D26374219

fbshipit-source-id: 61d851d5a4fc4223c65078ef434a0c67314a90cd
2021-02-11 12:17:35 -08:00
Durham Goode
d7a4ce4783 py3: remove duplicate constant definition
Summary: This is defined else where in Python 3, so let's get rid of it here.

Reviewed By: quark-zju

Differential Revision: D26381054

fbshipit-source-id: 9746d2c53f83209d9c795ffdd5841d58ef1153ef
2021-02-11 09:50:25 -08:00
Durham Goode
5c6edef11c py3: fix simple Windows py3 issues
Summary: These are just a few one-liners to fix Python 3 on Windows.

Reviewed By: sfilipco

Differential Revision: D26381055

fbshipit-source-id: d9257f2cf35c05f931d74b7d26bdc79f5bf34185
2021-02-11 09:50:25 -08:00
Durham Goode
9c1b611dff indexedlog: make writing to indexedlog the default
Summary:
We've rolled both of these out to 100%. Let's make this the default so
we can delete those configs.

Reviewed By: quark-zju

Differential Revision: D26233645

fbshipit-source-id: cd7a08c404483f78ab714763870f5bf0fa801e7a
2021-02-11 09:34:55 -08:00
Durham Goode
ca1249c269 packs: prevent creating mutable packs when using rust store
Summary:
We're seeing cases where Mercurial is creating unused .tmp pack files
and leaving them around. It looks like there are two places this can happen, 1)
in the treemanifest python code we manually instantiate some mutable packs, and
2) when doing a read from the rust data store, when it does a read against the
mutable pack store it will unnecessarily create the MutableDataPackInner struct,
which creates the temp file.

Let's fix those.

Reviewed By: quark-zju

Differential Revision: D26387205

fbshipit-source-id: 5a567c886849084bcc8121949dd2fb0f9e66d570
2021-02-11 09:31:00 -08:00
Durham Goode
8c08a42d22 dynamicconfig: introduce configs.allowedconfigs
Summary:
In our upcoming migration away from chef/static rc files, we'll be
marking certain files as "allowed". Our hope is that that list only includes
things like .hg/hgrc, ~/.hgrc, etc.

There are cases however where it's convienent to continue to use chef, for
instance when we condition on machine type. To support this, let's add an
allowed_config option, which will allow configs from non-supported locations.

This will also be useful when remediating issues that come up when we start
enforcing allow_location, without rolling back the entire thing.

Reviewed By: quark-zju

Differential Revision: D26233451

fbshipit-source-id: 71789e0361923a6f80de4aef7f012afc0269440d
2021-02-10 19:30:35 -08:00
Sean Kamath
ae5db40fdd Changing commit hash length to 9 in hg prompt
Summary:
Copied from D17312417 (e1f4dbeb3d), because that did what I needed done, but incremented by 1.

I would like to change the length of the displayed hash in scm-prompt
to 9. Why such an impactful diff? Because hg sl shows 9 characters, and I
always get confused when the hash in my prompt doesn't match hg sl

Reviewed By: kulshrax

Differential Revision: D25934253

fbshipit-source-id: 15f2bc8bc7d666de1a077d2bafd74ab3c9753341
2021-02-10 17:07:35 -08:00