Commit Graph

994 Commits

Author SHA1 Message Date
Jun Wu
b36584e704 configparser: set ui.merge:interactive from ui.merge in user config
Summary:
This restores the compatibility of setting up merge tools using the `ui.merge`
config while still limiting the default `editmerge` tool to interactive
sessions.

Reviewed By: sfilipco

Differential Revision: D24377259

fbshipit-source-id: 3d2befba412b824fc985ddffa131e339644178c2
2020-10-16 18:33:06 -07:00
Jun Wu
122108e46e configparser: move load_user to a testable method
Summary: Make it testable by allowing specifying paths to load as user hgrc.

Reviewed By: sfilipco

Differential Revision: D24377258

fbshipit-source-id: 969028df64d55ad1f1304e35675d84595ed6a2bf
2020-10-16 18:33:06 -07:00
Arun Kulshreshtha
d16a62ce06 edenapi: send user agent string
Summary:
Include a `User-Agent` header in EdenAPI requests from Mercurial. This will allow us to see the version in Scuba, and in the future, will allow us to distinguish between requests send by Mercurial and those sent directly by EdenFS.

Keeping with the current output of `hg version`, the application is specified as "EdenSCM" rather than "Mercurial".

Reviewed By: singhsrb

Differential Revision: D24347021

fbshipit-source-id: e323cfc945c9d95d8b2a0490e22c2b2505a620dc
2020-10-16 11:05:24 -07:00
Jun Wu
e39f3bc233 revisionstore: add mutex for tests related to env vars
Summary:
Rust tests run in multiple threads. Setting environment variables affects other
tests running in other threads and causes random test failures.
Protect env vars using a lock.

Reviewed By: DurhamG

Differential Revision: D24296639

fbshipit-source-id: db0bee85625a7b63e07b95ea76d96029487881d4
2020-10-15 22:48:41 -07:00
Jun Wu
263d1c5a7f hg: reduce flakiness of cargo tests
Summary:
The shell-script cargo tests seem very flaky. Use a dedicated Python script to
run the tests, with a more concise output that only includes failures, and run
tests in parallel.

Reviewed By: DurhamG

Differential Revision: D24296433

fbshipit-source-id: 1d63146c6c84f1035dded24fcd3d79f116c2e740
2020-10-15 22:48:41 -07:00
Thomas Orozco
35ed8fe3dc revisionstore/lfs: retry 429
Summary:
When the server returns a 429, the intention is that the client will wait for a
little bit then try again later (there is no harm in that, as we haven't really
used many server resources for this). However, it turned out that right now we
just abort. Let's fix it!

Note that this changes the behavior a bit for the error cases, in the sense
that we no longer return `Ok(None)` but instead return an `Err`. Xavier noted
this should make sense here.

I've also had the client send its retry attempt via a header, because who
knows, that might be useful.

Reviewed By: kulshrax

Differential Revision: D24308127

fbshipit-source-id: 35639956f36342dfb0056b0d348dc4ad56bd576c
2020-10-15 01:11:32 -07:00
Meyer Jacobs
120fbd3280 trees: port SCS aux data request method to edenapi
Summary: Introduces fetching of child entry IDs, and child file metadata for a specified tree manifest ID. The aux data lookup will only be performed if `with_file_metadata` is set, which is actually kind of wrong. Instead `with_children` from the wire type should be exposed in the API request type, and `with_*_metadata` should be hidden or used for data other than the child entry `Key`s.

Reviewed By: kulshrax

Differential Revision: D23886678

fbshipit-source-id: 0cba72cea7be47ae3348a406d407a19b60976c0c
2020-10-14 11:12:59 -07:00
Arun Kulshreshtha
32c109d955 edenapi: send client correlator to server
Summary:
Include the client correlator string from the `clienttelemetry` extension in each EdenAPI HTTP request via the  `X-Client-Correlator` header.

The `ClientIdentityMiddleware` in `gotham_ext` already understands this header (as it is already used by the LFS server), and `gotham_ext`'s `ScubaMiddleware` will automatically include the provided correlator in the server's Scuba samples.

Reviewed By: farnz

Differential Revision: D24282244

fbshipit-source-id: 13d04e706eda38893cff6e740bd1d7bf104e43dd
2020-10-13 13:25:52 -07:00
Meyer Jacobs
f9958ca35a taggederror: introduce category and transience metadata and precedence
Summary:
This change introduces two new metadata types, Category and Transience, and a mechanism for Category to provide a default Fault and Transience, which can be overriden by the user.

Also introduces a mechanism for attempting to log exceptions which occur during exception logging, falling back to the previous behavior of just swallowing the exception on failure.

Reviewed By: DurhamG

Differential Revision: D22677565

fbshipit-source-id: 1cf75ca1e2a65964a0ede1f072439378a46bd391
2020-10-12 17:17:34 -07:00
Jun Wu
bd5cfe49b2 commitstore: remove it
Summary:
It only has benchmark code that led to the use of mincode. Now hgcommits is the
main crate for commit storage. `commitstore` without `hg` in its name was
initially planned to support other kinds of commits including git and bonsai.
However we don't have immediate goal for that at present. So let's just remove
the commitstore directory.

Reviewed By: singhsrb

Differential Revision: D24263618

fbshipit-source-id: 84b4861ae490817377e69d8c2006c63331e3db1f
2020-10-12 16:42:58 -07:00
Meyer Jacobs
87cc599161 edenapi: add aux data to FileMetadata and DirectoryMetadata, and recursive children field to TreeEntry
Summary: Need to add new quickcheck tests, verify that remove `Serialize` from `TreeEntry` is okay.

Reviewed By: kulshrax

Differential Revision: D23457777

fbshipit-source-id: aa94ed7aa81b41924eba4a8bd1bdc2c737365b77
2020-10-12 14:05:23 -07:00
Arun Kulshreshtha
67aa5455aa edenapi: remove commented out code
Summary: Delete commented out code added in D23455274 (bdff69b747).

Reviewed By: sfilipco

Differential Revision: D24213060

fbshipit-source-id: a017b35241521510c26886505d1de6c7f6538895
2020-10-09 09:35:58 -07:00
Arun Kulshreshtha
66ea4f6677 edenapi: print operation in debug output
Summary:
Print a message for each EdenAPI method call to stderr if the user has `edenapi.debug` set.

These messages are already logged to `tracing`, but also printing them out when `edenapi.debug` is set makes the debug output more useful, since it provides context for the download stats. This is especially useful when reading through EdenFS logs.

Reviewed By: quark-zju

Differential Revision: D24204381

fbshipit-source-id: 37b47eed8b89438cdf510443e917a5c8660eb43b
2020-10-08 16:12:50 -07:00
Arun Kulshreshtha
e924af7ba5 edenapi: store headers in a HashMap
Summary: Use a `HashMap` to store user-specified additional HTTP headers. This allows headers to be set in multiple places (whereas previously, setting new headers would replace all previously set headers).

Reviewed By: quark-zju

Differential Revision: D24200833

fbshipit-source-id: 93147cf334a849c4d2fc4f29849018a4c7565143
2020-10-08 16:12:50 -07:00
Jun Wu
9ed54f1b94 dag: replace 2 panics with non-panic errors
Summary: The panics can happen when the input sets are out of range.

Reviewed By: kulshrax

Differential Revision: D24191789

fbshipit-source-id: efbcbd7f6f69bd262aa979afa4f44acf9681d11e
2020-10-08 13:22:10 -07:00
Stefan Filip
6e2ec8b1ca dag: add serde derives to IdDag and InProcessStore
Summary:
Some sort of serialization for the Dag is useful for saving the IdDag produced
by offline jobs load that when a mononoke server starts.

Reviewed By: quark-zju

Differential Revision: D24096964

fbshipit-source-id: 5fac40f9c10a5815fbf5dc5e2d9855cd7ec88973
2020-10-08 09:43:46 -07:00
Meyer Jacobs
6421dca639 read_res: add --debug flag to cat command for printing entire message
Summary: Add `--debug` flag to `read_res cat` command for debug printing entire entry rather than just the data blob.

Reviewed By: kulshrax

Differential Revision: D23999804

fbshipit-source-id: 6955854edab2643cffbe5fae484a398716b48055
2020-10-06 19:22:14 -07:00
Jun Wu
d103af79df hgcommits: add hybrid backend
Summary:
The hybrid backend is similar to the doublewrite backend, except that it does
not use revlog to read commit data, but uses EdenAPI instead.

Note:
- The non-stream API will not fetch commit data from EdenAPI.
- The commit hashes are not lazy yet.

Reviewed By: sfilipco

Differential Revision: D23924147

fbshipit-source-id: eb2cf8d3a7e1704b4efb13ad3ad86f8b6a1b31d0
2020-10-06 19:13:02 -07:00
Jun Wu
f54efdd04a hgcommits: serde serialize on ParentlessHgCommit
Summary:
This makes it convertible to `PyObject` via `cpython_ext::convert::Serde`
without additional code or dependencies.

Reviewed By: sfilipco

Differential Revision: D23966993

fbshipit-source-id: 74d83524a7c0701cde7aa6d61bb930ff4a1c90f5
2020-10-06 19:13:02 -07:00
Jun Wu
80056bef23 hgcommits: add a streaming data fetching API
Summary:
This API allows us to stream the data. If callsites only use this API, we'll
be more confident that there are no 1-by-1 fetches.

Reviewed By: sfilipco

Differential Revision: D23911865

fbshipit-source-id: 4c7dd8c2b5be33be5a55822845d55345797bacdf
2020-10-06 19:13:02 -07:00
Jun Wu
6defe87dcb streams: add abstraction about downloading missing data from remote
Summary:
The API is basically to resolve `input_stream` to `output_stream`, with a
stateful "resolver" that can resolve locally and remotely.

Reviewed By: sfilipco

Differential Revision: D23915775

fbshipit-source-id: 14a3a37fc897c8229514acac5c91c7e46b270896
2020-10-06 19:13:02 -07:00
Meyer Jacobs
bdff69b747 edenapi: Add file, directory metadata to TreeEntry
Summary:
Introduce `FileMetadata` and `DirectoryMetadata` to `Treeentry`, along with corresponding request API.

Move `metadata.flags` to `file_metadata.revisionstore_flags`, as it is never populated for trees. Do not use `metadata.size` on the wire, as it is never currently populated.

Leaving `DirectoryMetadata` commented out temporarily because serde round trips fail for unit struct. Re-introduced with fields in the next change in this stack.

Reviewed By: DurhamG

Differential Revision: D23455274

fbshipit-source-id: 57f440d5167f0b09eef2ea925484c84f739781e2
2020-10-06 18:36:28 -07:00
Arun Kulshreshtha
7576d60c9c edenapi: skip hash check for LFS files
Summary:
EdenAPI always checks the integrity of filenode hashes before returning file data to the application. In the case of LFS files, this resulted in errors because the filenode hash is computed using the full file content, but the blob from the server only contains an LFS pointer.

Fix the bug by exempting LFS blobs from filenode integrity checks. (If integrity checks for LFS blobs are desired, the LFS code should be able to do this on its own since LFS blobs are content-addressed.)

Reviewed By: quark-zju

Differential Revision: D24145027

fbshipit-source-id: d7d86e2b912f267eba4120d1f5186908c3f4e9e3
2020-10-06 16:18:28 -07:00
Jun Wu
47d5813a17 cpython-ext: add a general From/ToPyObject for serde types
Summary:
This can be used to automate Python/Rust conversions for complex structures
like `CommitRevlogData`.

Reviewed By: kulshrax

Differential Revision: D23966988

fbshipit-source-id: 17a19d38270e6ef0952c13a1cd778487e84a94ff
2020-10-06 16:01:23 -07:00
Jun Wu
b5a22da53c cpython-ext: add a serde deserializer that converts Python objects to Rust values
Summary:
The goal is to implement `FromPyObject` and `ToPyObject` more easily.
Today crates have to dependent on `cpython` to implement `From/ToPyObject`,
which is somewhat unwanted for pure Rust crates.

The `ser` module used to ignore the `variant` field for non-unit enum variants.
They have been fixed so the serialized value can be deserialized correctly.
For example, `enum E { A, B(T) }` will be serialized to `"A"` for `E::A`, and
`{"B": T}` for `E::B`.

Reviewed By: kulshrax

Differential Revision: D23966994

fbshipit-source-id: c50d57bf313caeec65a604ed9b05a5729f3b3635
2020-10-06 16:01:22 -07:00
Jun Wu
ab88771161 types: support multi-format deserialization for HgId
Summary:
Switch from the default tuple deserialization which only understands the tuple
format, to "bytes" deserialization, which understands not only the existing
"tuple" format (therefore compatible with old data), but also "bytes" and "hex"
formats (for CBOR).

This will unblock us from switching to bytes serialization in the future.

Note: This is a breaking change for mincode serialization. Mincode + HgId users
(zsotre, metalog) have switched to explicit tuple serialization so they don't use
the default deserializaiton and remain unaffected.

Reviewed By: kulshrax

Differential Revision: D23966995

fbshipit-source-id: 83dd53f57bd4e6098de054f46a1d47f8b48133d0
2020-10-06 15:44:42 -07:00
Jun Wu
9c5d20904d revisionstore: explicitly mark how to serialize HgId, Sha256, Key, NodeInfo
Summary: This will unblock us from switching HgId to bytes serialization by default.

Reviewed By: kulshrax

Differential Revision: D24009039

fbshipit-source-id: a277869ec24652af428cda581faffa62c25d32c4
2020-10-06 15:44:42 -07:00
Jun Wu
aa8bc2afda types: add serde(with) support for Key, NodeInfo, and derived types
Summary: Similar to D23966992 (2a2971a4c7), add support to serialize Key differently.

Reviewed By: DurhamG

Differential Revision: D24009041

fbshipit-source-id: 2ecf1610b989a04083196d180bc62307b5162c2f
2020-10-06 15:44:42 -07:00
Jun Wu
bb07129c2d types: add serde(with) support for Sha256
Summary: Similar to D23966992 (2a2971a4c7), add support to serialize Sha256 differently.

Reviewed By: DurhamG

Differential Revision: D24009040

fbshipit-source-id: b77f6732802f95507e1540f0bbde4d5a92d13cac
2020-10-06 15:44:42 -07:00
Arun Kulshreshtha
720bad11ac progress: fix typo in comment
Reviewed By: singhsrb

Differential Revision: D24130363

fbshipit-source-id: 6505f51f892dffb90c89b3c18e981e55721b6106
2020-10-05 22:26:16 -07:00
Arun Kulshreshtha
0ad6c1229b edenapi: return no-op Fetch on empty request
Summary: Instead of returning an error upon receiving an empty request, just return a `Fetch` object that does nothing. This prevents Mercurial from crashing in situations where an empty request somehow makes it to the EdenAPI remote store.

Reviewed By: quark-zju

Differential Revision: D24119632

fbshipit-source-id: cf4ec707b4097656c76d7084a55b2d0b3150b679
2020-10-05 15:16:33 -07:00
Arun Kulshreshtha
1556c10e28 edenapi: add edenapi.debug option
Summary:
Previously, EdenAPI was using `remotefilelog.debug` to determine whether to print things like download stats. Let's give EdenAPI its own `debug` option that can be configured independently of remotefilelog.

One notable benefit of this change is that download stats will always be printed immediately after the HTTP request completes. This can help rule out network or server issues in situations where Mercurial appears to be hanging during data fetching. (e.g, if hg had downloaded all of the data but was taking a while to process it, the debug output would show this.)

Reviewed By: DurhamG

Differential Revision: D24097942

fbshipit-source-id: bf9b065e7b97fc7ffe50ab74b1b13e2fe364755c
2020-10-05 15:16:33 -07:00
Durham Goode
10248e54b3 phases: make public phase calculation more efficient
Summary:
Previously phase calculation was done via a simple ancestor check. This
was very slow in cases that required going far back into the graph. Going a year
back could take a number of seconds.

To fix it, let's take the Rust phaseset logic and rework it to make only_both
produce an incremental public nodes set. In a later diff we can switch the
phaseset function to use this as well, but right now phaseset returns IdSet, and
that would need to be changed to Set, which may have consequences. So I'll do it
later.

Reviewed By: quark-zju

Differential Revision: D24096539

fbshipit-source-id: 5730ddd45b08cc985ecd9128c25021b6e7d7bc89
2020-10-05 14:40:53 -07:00
Lukas Piatkowski
e7d9e6f6da eden/scm: fix build by regenerating thrift files after D24070707 was landed
Summary: D24070707: `[Thrift] Provide sorted fields to read_field_begin` made a change to the generated rust thrift files, so the eden/scm thrift files have to be regenerated to fix the build.

Reviewed By: farnz

Differential Revision: D24109655

fbshipit-source-id: e8575a76642673a11514fdce8e30f13ca28151f0
2020-10-05 04:44:07 -07:00
Arun Kulshreshtha
b16d724844 http-client: fix typo in comment
Reviewed By: singhsrb

Differential Revision: D24097983

fbshipit-source-id: 4f218a2bc9d3dc1413b18f9741e630ac6261ad7c
2020-10-02 22:03:14 -07:00
Jun Wu
ecbc2abb70 cpython-ext: add a general From/ToPyObject for bytes-like Rust structs
Summary: This can be used by dag::Vertex and minibytes::Bytes.

Reviewed By: kulshrax

Differential Revision: D23966985

fbshipit-source-id: 3b4b29648e038ef49f26ce2b500119e148544d9e
2020-10-02 21:51:49 -07:00
Jun Wu
833ac3fb4c cpython-async: drop py_stream_class macro
Summary:
The py_stream_class causes the code to be more verbose. It basically enforces
the bindings crate to define new types wrapping pure Rust types, and then
define py_stream_class.

In a future diff, I'm adding FromPyObject/ToPyObject support for types that
implements serde Deserialize/Serialize. py_stream_class gets in the way,
because the blanket type from cpython-ext cannot be used in the py_stream_class
macro. cpython-ext is not the proper place to define business-related stream
types.

Therefore, define a type-erased Python class, and implement
FromPyObject/ToPyObject automatically for TStream<anyhow::Result<T>> where
T implements FromPyObject or ToPyObject.

The FromPyObject now converts a Python iterator back to a stream. It's
no longer zero-cost. However, I'd imagine such usecases can be short-cut
using pure Rust code.

Background: Initially, I added some FromPyObject/ToPyObject impls to pure
Rust crates gated by a "pytypes" feature. While that works fine with cargo
build, buck does not support dynamic features and the fact that we support
both py2 and py3 makes it extremely hard to support cleanly in buck build.
For example, if minibytes::Bytes defines ToPyObject for Bytes, then any
crate using minibytes would have 2 different versions: a py2 version, a
py3 version, and they both depend on python. That seems to be a bad approach.

Reviewed By: sfilipco

Differential Revision: D23966984

fbshipit-source-id: eafb31ad458dcbdd8e970d8e419a10fbbe30595f
2020-10-02 21:51:49 -07:00
Arun Kulshreshtha
b101b19d45 http-client: shorten download stats
Summary:
Per the feedback on D23920367 (318f5683a5), let's make the human-readable download stats shorter. Example:

```
Downloaded 10.59 MiB in 12.35s over 5 requests (7.19 Mb/s, latency: 123ms)
```
The amount downloaded is now reported in binary-prefixed bytes (so that it can be directly compared to file sizes) whereas the transfer rate is reported in decimal-prefixed bits per second (so that it can be directly compared to a user's measured network speed).

Additionally, we now use the default formatting available from `std::time::Duration`, which will automatically choose the appropriate display units.

Reviewed By: quark-zju

Differential Revision: D24096525

fbshipit-source-id: 39c49f1b08135bbae7a7544b1ffe2bdbfe1533a1
2020-10-02 19:54:11 -07:00
Durham Goode
2a9263cfe2 memcache: add progress bar to Rust memcachestore
Summary: We now get progress bar output when fetching from memcache!

Reviewed By: kulshrax

Differential Revision: D24060663

fbshipit-source-id: ff5efa08bced2dac12f1e16c4a55fbc37fbc0837
2020-10-02 15:03:17 -07:00
Xavier Deguillard
24f28191f3 mman-win32: remove
Summary: This is unused, remove it.

Reviewed By: DurhamG

Differential Revision: D24062631

fbshipit-source-id: 2c0b758866881986d3454ddb2941cd04d44861f3
2020-10-02 10:47:24 -07:00
Xavier Deguillard
0967eafcba build: remove portability headers
Summary: These aren't included anywhere, we can remove them.

Reviewed By: DurhamG

Differential Revision: D24062627

fbshipit-source-id: 9ff101eb44965ac3502ada3265ffcc8acc09d2e5
2020-10-02 10:47:24 -07:00
Xavier Deguillard
8cc2738aec clib: remove buffer.[ch]
Summary: These are unused, no need to keep the code around.

Reviewed By: DurhamG

Differential Revision: D24055085

fbshipit-source-id: 6246d746983a575c051ddcb51ae02582a764a814
2020-10-02 10:47:23 -07:00
Xavier Deguillard
a4e27d898d lib: remove portability/dirent.h
Summary: This is unused.

Reviewed By: DurhamG

Differential Revision: D24055083

fbshipit-source-id: bc6bbcf765ccb8c277e4a06e9fc3f033cd01733a
2020-10-02 10:47:23 -07:00
Xavier Deguillard
dc97cebe7c lib: remove cdatapack
Summary: This is unused, no need to keep it around.

Reviewed By: DurhamG

Differential Revision: D24054164

fbshipit-source-id: 161b294eb952c6b4584aa0d49d8ff46cd63ee30f
2020-10-02 10:47:23 -07:00
Ivan Murashko
2374b860a2 lint-ignore processing for clang-tidy (fbcode)
Summary: Disable CLANGTIDY checks for several places at the code.

Reviewed By: zertosh, benoitsteiner

Differential Revision: D24018176

fbshipit-source-id: b2d294f9efd64b2e2c72b11b18d8033f9928e826
2020-10-01 03:27:25 -07:00
Jun Wu
ea60810732 async-runtime: support multi-thread block_on_future
Summary:
This would have been easier if we can upgrade tokio (D24011447).
For now, let's just solve it by using a channel so the mutex is not held for long.

The implementation has some side effects, though:
- panic message is not preserved.
- 'static lifetime is required on Future.

The `'static` lifetime is incompatible with some existing code. The old function
is preserved as `block_on_exclusive` and is used in places where a future does
not have `'static` lifetime.

Reviewed By: sfilipco

Differential Revision: D24033134

fbshipit-source-id: 7b35d1ff636d2a289db9b04e60419c31bdea9453
2020-09-30 20:31:34 -07:00
Jun Wu
3c5c6bf5af async-runtime: add iter_to_stream
Summary: `iter_to_stream` converts a blocking iterator to a stream.

Reviewed By: sfilipco

Differential Revision: D24033135

fbshipit-source-id: da5b1f8e6768124ef7c915e1bb17216fde00a55a
2020-09-30 20:16:40 -07:00
Arun Kulshreshtha
f1bdf9aadf edenapi: improve debug messages
Summary: Minor tweaks to debug messages.

Reviewed By: quark-zju

Differential Revision: D24039535

fbshipit-source-id: 950c984f72ff7652f79c346f88273ee7e6c9f926
2020-09-30 19:53:21 -07:00
Arun Kulshreshtha
dfbe53cf11 revisionstore: add progress bars to EdenAPI stores
Summary: Make EdenAPI data stores optionally show progress bars.

Reviewed By: markbt

Differential Revision: D23982320

fbshipit-source-id: b3affd3b630258f15c3cdc64c213df8aa28af589
2020-09-30 13:01:15 -07:00
Arun Kulshreshtha
b5a36de8cd progress: add null progress bar
Summary:
Add a null progress bar implementation that just keeps track of state, similar to the `progress.nullbar` in hg's Python code.

A benefit of this is that code that optionally shows progress can unconditionally update the progress bar rather than wrapping it in an `Option` and checking for presence each time.

Reviewed By: markbt

Differential Revision: D23982318

fbshipit-source-id: ffd762b59cc0c9bd2ad0c67c3ca785350db4850f
2020-09-30 13:01:15 -07:00