Commit Graph

7783 Commits

Author SHA1 Message Date
Kostia Balytskyi
d3c43fcc29 cross_repo_sync: avoid an extra allocation
Summary: No need to allocate a new vector if we just need to remove items from the current one.

Reviewed By: StanislavGlebik

Differential Revision: D24088319

fbshipit-source-id: 10804d925f20fe8dd1e2bb8500aa06d30bd367c1
2020-10-05 02:02:13 -07:00
Kostia Balytskyi
081ca3e7d6 common: add iterhelpers
Summary:
This just adds a single fn. I did not come up with a better place/name to put
it, suggestions are welcome. Seems generic enough to belong at the top-level
common location.

I've already needed this twice, so decided to extract. Second callsite will be further in the stack.

Reviewed By: StanislavGlebik

Differential Revision: D24080193

fbshipit-source-id: c3e0646f263562f3eed93f1fdbab9a076729f33c
2020-10-04 23:51:03 -07:00
Kostia Balytskyi
2ea25308ab commit_rewriting: use is_empty() where possible
Summary: `clippy` often complains about the use of `.len() != 0`, `.len() > 0` or `.len() == 0`and proposes to use `.is_empty()` instead. This diff does that across Mononoke.

Reviewed By: aslpavel

Differential Revision: D24099427

fbshipit-source-id: 1bba2f958485b7efb3f41bf3eae820879c92b0e5
2020-10-04 10:03:42 -07:00
John Reese
f42333f17c Apply pyfmt to fbcode/eden
Summary:
Formats a subset of opted-in Python files in fbsource.
Black formatting was applied first, which is guaranteed
safe as the AST will not have changed during formatting.
Pyfmt was then run, which also includes import sorting.
The changes from isort were manually reviewed, and
some potentially dangerous changes were reverted,
and the  directive was added to those
files. A final run of pyfmt shows no more changes to
be applied.

Reviewed By: zertosh

Differential Revision: D24101830

fbshipit-source-id: 0f2616873117a821dbc6cfb6d8e4f64f4420312b
2020-10-04 04:51:00 -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
ddf3eeb94a treemanifest: fix fetching trees with Rust store
Summary:
The bfs fetching path in Rust was broken because it directly called
getdesignatednodes. getdesignatednodes returns False if it wasn't able to
succeed, so we need to be able to fall back in that case. The _prefetchtrees
function is meant for that, so let's just call that.

Reviewed By: singhsrb

Differential Revision: D24090946

fbshipit-source-id: d16c2c8f80f690a22046385f0e95785996a62949
2020-10-02 18:51:11 -07:00
Jun Wu
a684e53a31 phabstatus: wrap all logrevs with PeekaheadRevsetIter
Summary:
Previously, only the first `__iter__` gets wrapped. With D23095468 (34df768136), the first
`__iter__` is used by the "simplify graph" feature, not the main iteration
loop rendering the graph log output, causing the prefetch feature to fail.

  File "edenscm/mercurial/commands/__init__.py", line 4196, in log
    return cmdutil.graphlog(ui, repo, pats, opts)
    # pats = ()
  File "edenscm/mercurial/cmdutil.py", line 3250, in graphlog
    ui, repo, revdag, displayer, graphmod.asciiedges, getrenamed, filematcher
  File "edenscm/mercurial/cmdutil.py", line 3106, in displaygraph
    rustdisplaygraph(ui, repo, dag, displayer, getrenamed, filematcher, props)
  File "edenscm/mercurial/cmdutil.py", line 3208, in rustdisplaygraph
    for (rev, _type, ctx, parents) in dag:
  File "edenscm/mercurial/graphmod.py", line 63, in dagwalker
    rootnodes = cl.tonodes(revs)
    # revs = <baseset- [7408158, 72057594037927936, ...]
  File "edenscm/mercurial/changelog2.py", line 196, in tonodes
    return self.inner.tonodes(revs)
    # revs = <baseset- [7408158, 72057594037927936, ...]
  File "edenscm/hgext/phabstatus.py", line 281, in next
    return self.__next__()

Lift the "first time" limitation for wrapping `__iter__` to solve the problem.

Reviewed By: simpkins

Differential Revision: D24066918

fbshipit-source-id: 6bbd244e729724e5143147bde60bcb4c8ee4bc80
2020-10-02 16:50:42 -07:00
Xavier Deguillard
6a8bb2cb1a build: remove headers target
Summary: Since this is only used in the manifest target, fold it into it.

Reviewed By: DurhamG

Differential Revision: D24062629

fbshipit-source-id: c3241b53bde7abba8a80a2945661d1a24b7e3034
2020-10-02 15:24:49 -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
4b4e58dde9 service: always normalize mount path
Summary:
Less #ifdef is always better, since normalizing a path also works on
non-Windows, there is no reason to special case Windows here.

Reviewed By: fanzeyi

Differential Revision: D24020603

fbshipit-source-id: 114dae3bd9a4743230f4c82d219ff74ffc9379c7
2020-10-02 12:43:02 -07:00
Xavier Deguillard
1457079384 utils: fix zero-initialization in Guid.h
Summary:
In c++, to zero-initialize, empty braces is sufficient for a non-class type.
{0} will only zero-initialize the first field, which is not the intent here.

Reviewed By: wez

Differential Revision: D24068481

fbshipit-source-id: 2de87da983a05f25e0222bf5338533a7b96fb36a
2020-10-02 10:50:54 -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
79b52ef5d1 scm: rename datapack target to manifest
Summary:
This is no longer about datapack, but only about parsing manifest entries, thus
renaming.

Reviewed By: DurhamG

Differential Revision: D24062634

fbshipit-source-id: 5c52b784d20437e87012dd4bc6cb13d879da9cb9
2020-10-02 10:47:23 -07:00
Xavier Deguillard
2b79b77cf4 extlib: remove libmpatch dependency from datapack target
Summary: The code doesn't use anything from libmpatch, we don't need to depend on it.

Reviewed By: DurhamG

Differential Revision: D24055084

fbshipit-source-id: 0f7bac73f1b711da4395e25619577a0a2e0ca959
2020-10-02 10:47:23 -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
Xavier Deguillard
30ef9bdcf1 extlib: remove large parts of cstore/ctreemanifest
Summary:
This code is effectively unused. The only bit still relevant is that EdenFS
still depends on the Manifest class to parse a manifest.

Reviewed By: DurhamG

Differential Revision: D24037723

fbshipit-source-id: 901ae2ffc8960a95ec655a2e14d79afb8d32dcab
2020-10-02 10:47:22 -07:00
Xavier Deguillard
c16ab69c6a build: remove //eden/scm:cstore
Summary: This is unused, let's remove it.

Reviewed By: DurhamG

Differential Revision: D24037722

fbshipit-source-id: bc8a272809cb1f20f54d651a39ee42ff57169534
2020-10-02 10:47:22 -07:00
Xavier Deguillard
5672facb89 store: remove usage of non-Rust datapack store
Summary:
It was used as a fallback path only for a while now. Since Mercurial has
support CMD_CAT_TREE for quite some time, let's get rid of it.

Reviewed By: fanzeyi

Differential Revision: D24037004

fbshipit-source-id: 69887e6d8508419a22d68d062c78676aacba3b24
2020-10-02 10:47:22 -07:00
Xavier Deguillard
908c037e39 store: remove reading from the non-Rust datapackstore
Summary:
If the data isn't found in the Rust one, it can't be found in the non-Rust one.
Since the non-Rust one will issue a filesystem rescan, this is a fairly
expensive operation which shows up in strobelight when trying to walk the
entire repo with: `rg --files`.

There is one last place that still use the non-Rust stores and that's as a
fallack for when Mercurial doesn't support CMD_CAT_TREE. Since this has been
supported for a bit, I'll make a followup change to completely get rid of the
non-Rust stores.

Reviewed By: fanzeyi

Differential Revision: D24035451

fbshipit-source-id: acd9741a16f3786796d329a4cddfe4ee435bcad9
2020-10-02 10:47:22 -07:00
Simon Farnsworth
83801357d4 Make SQLBlob overwrite on put rather than ignoring
Summary:
We want to end up with two `put` behaviours - overwrite and do not overwrite.

Currently, SQLBlob only implements the latter, but some users assume that `put` always overwrites. Change to match Manifold

Reviewed By: aslpavel

Differential Revision: D24079501

fbshipit-source-id: f75cac81acf874337c38f82597aae645c41a319b
2020-10-02 10:41:12 -07:00
Xavier Deguillard
4197dfd689 cli: implement du for Windows
Summary:
On Windows, the du command line application doesn't exist, thus we cannot use
it. Instead, we can simply re-implement the du functionality in Python and use
that on all platforms.

Reviewed By: chadaustin

Differential Revision: D24030269

fbshipit-source-id: e86c1bcdeac7eeca70201f6fde48c20ef7e305a6
2020-10-02 09:57:26 -07:00
Kostia Balytskyi
539e793a0c get rid of synced_commit_mapping::get_one
Summary: Now that there are no more use-cases of `get_one`, let's remove it completely.

Reviewed By: farnz

Differential Revision: D24027990

fbshipit-source-id: 47baa6b1e28eedd94d95808efca0a98007a1d388
2020-10-02 07:44:57 -07:00
Kostia Balytskyi
acc4065966 get rid of synced_commit_mapping::get_one in mononoke_x_repo_sync_job
Summary:
This is a bit of a cargo-cult diff: it replaces the uses of `get_one` with `get` in tests, just to make the same wrong decisions later - use the first item from the produced list of items. So the only thing it does it removes a call site for `get_one`.

The reason it is ok to do `.into_iter().next()` here is because these are tests and we control the situation precisely - we know that there will be one mapping. Same reason we use `.unwrap()` in tests.

Reviewed By: farnz

Differential Revision: D24027785

fbshipit-source-id: 1c11acadfc9f7c6c4af658b414589c32008a6cce
2020-10-02 07:44:57 -07:00
Kostia Balytskyi
496ff1989e get rid of synced_commit_mapping::get_one in admin
Summary:
`get_one` is a deprecated method, because it uses incorrect logic to resolve ambiguities of multi-mapped commits: if just selects the very first of the potentially many mappings.

Correct resolution is to either handle the ambiguity at the caller site, or rely on provided resolution logic in commit_sync_outcome.rs.

Therefore, I am removing the uses of this method in this and a few surrounding commits.

In this case, the simplest thing is to replace it with `.get` and deal with multi-mappings on the client side:
- for `crossrepo map` subcommand we just print all mappings
- for `update_large_repo_bookmarks` we just fail on multi-mapping, as it seems dangerous to proceed without human intervention

Reviewed By: farnz

Differential Revision: D24030033

fbshipit-source-id: c84613579fbf8a5f6bac3c06da0cd4e0ad6c3fb0
2020-10-02 07:44:57 -07:00
Kostia Balytskyi
92a2345c87 get rid of synced_commit_mapping::get_one in push_redirector
Summary:
`get_one` is a deprecated method, because it uses incorrect logic to resolve ambiguities of multi-mapped commits: if just selects the very first of the potentially many mappings.

Correct resolution is to either handle the ambiguity at the caller site, or rely on provided resolution logic in `commit_sync_outcome.rs`.

Therefore, I am removing the uses of this method in this and a few surrounding commits.

In this case, I am changing `get_one` to `CommitSyncer::get_commit_sync_outcome`. There's no functional difference, as this is large-to-small mapping, which is always 1:1. But it allows us to get rid of `get_one` call-site, so let's do that.

Reviewed By: farnz

Differential Revision: D24027130

fbshipit-source-id: e57cb32c37a68e6762da6e2096ba216d251524f4
2020-10-02 07:44:56 -07:00
Kostia Balytskyi
447a7bf399 get rid of synced_commit_mapping::get_one in mononoke_x_repo_sync_job
Summary:
`get_one` is a deprecated method, because it uses incorrect logic to resolve ambiguities of multi-mapped commits: if just selects the very first of the potentially many mappings.

Correct resolution is to either handle the ambiguity at the caller site, or rely on provided resolution logic in `commit_sync_outcome.rs`.

Therefore, I am removing the uses of this method in this and a few surrounding commits.

In this case, we can just rely on a provided `CommitSyncer::commit_sync_outcome_exists` method.

Reviewed By: farnz

Differential Revision: D24026470

fbshipit-source-id: 9f150eb3d6c39a58bb4b0d16d4cf18c324359013
2020-10-02 07:44:56 -07:00
Kostia Balytskyi
191d7142b3 scs: add integration test coverage for candidate selection hint
Summary:
See D23991178 (87f2e4d0f8) for more details on the `CandidateSelectionHint`.

This diff adds integration test coverage for this functionality.

Reviewed By: farnz

Differential Revision: D24025165

fbshipit-source-id: 0ce70fe4c6b7347061a4815e49c0a1311e5964fa
2020-10-02 07:44:56 -07:00
Durham Goode
42b3a1b6bc py3: support outputing bytes via templater
Summary:
The 'diff()' template needs to be able to output non-utf8 patches.
To enable this, let's change the templater to output bytes instead of strings.

Note, the templater supports json output, which requires utf8 encoded values. In
that situation we escape any non-utf8 binary and clients would have to be aware
and unescape them.

Reviewed By: quark-zju

Differential Revision: D24029105

fbshipit-source-id: aa011696c0d97281b91c6871c116037d76c178e0
2020-10-02 07:27:08 -07:00
Durham Goode
c90936941f schemes: remove schemes extension
Summary:
This is unused code. It broke a test while I was doing python 3 work,
so let's just delete this.

Reviewed By: quark-zju

Differential Revision: D24063953

fbshipit-source-id: 323b323ff2b9717c9c16eed54adac467a321e2ae
2020-10-02 07:27:08 -07:00
Jan Mazur
88bf94aacb move interngraph token from disk to keychain service
Summary:
Interngraph token is already stored within keychain service. We should make use of that.

I'll need to remove related config option in convigerator in a separate diff.

Reviewed By: krallin

Differential Revision: D24015463

fbshipit-source-id: 9e8246e2cc252f0c42669140de7b50410a15709c
2020-10-02 06:56:49 -07:00
Thomas Orozco
0ee0f3f383 mononoke: add verify integrity hook to hooks that can access network
Reviewed By: johansglock

Differential Revision: D24075644

fbshipit-source-id: 9371bc8440cc6cc25da0508d4bead22b47658030
2020-10-02 02:10:09 -07:00
Kostia Balytskyi
87f2e4d0f8 scs xrepo-lookup: accept candidate selection hint
Summary:
This diff adds an ability to optionally pass a `CandidateSelectionHint` to `scs` implementation of the `xrepo-lookup` call, which would help in cases when ancestor commits have multiple mappings in the large repo.

Adding this functionality to `scsc xrepo-lookup` is essentially a way to manually fix multi-mapping problems, which could otherwise block Mononoke progress.

For more information on multi-mapping problems, see https://fburl.com/gmywf2d6.

TLDR is that `synced_commit_mapping` is `1:n` with `n` on the large repo side. When syncing commits, we need a way to disambiguate multi-mapped ancestors.  `CandidateSelectionHint` is our way of doing this: it expressed desired properties of the commit we would like Mononoke to choose among the list of multi-mapped candidates.

Reviewed By: markbt

Differential Revision: D23991178

fbshipit-source-id: 29c90b7910ad1b84ff71964d6609521fded2f987
2020-10-01 17:33:23 -07:00
Durham Goode
9d2816baa2 py3: fix more hgsql py3 issues
Summary:
From just scanning through the code I identified a couple more spots
that use "" when they should use b"". I also noticed that
_parsecompressedrevision was producing memoryviews instead of bytes, so it's "u"
check would always fail.

Reviewed By: quark-zju

Differential Revision: D24037437

fbshipit-source-id: b4c589e30b5d35a1bcee16e0d6aa37d04f30129d
2020-10-01 09:39:35 -07:00
Durham Goode
908c470f35 eden: fix fallback tree reading
Summary:
The eden extension was hard coding empty string as the path when
reading from the store. This works fine when the data is available in a local
store (since most data stores don't actually use the path component), but
doesn't work when it needs to go to the server.

This wasn't an issue historically because the above fetch did the fetch for it.
A recent code change caused the above fetch to throw an error though, which was
then eaten, which caused the get code path to try to perform the fetch with an
empty path.

Reviewed By: krallin

Differential Revision: D24020467

fbshipit-source-id: cad717618e947fbdca978b45ce2181d46422d456
2020-10-01 09:31:55 -07:00
Lukas Piatkowski
327a1be505 third-party/rust: pin criterion to 0.3.1
Summary: Building criterion in opt mode degradated enormously after moving to 0.3.3, pin it to 0.3.1 for now until we figure out what is the problem.

Reviewed By: ljw1004

Differential Revision: D24046885

fbshipit-source-id: 6373eb06b5f47061cc02597bf82f574511fbec43
2020-10-01 09:29:57 -07:00
Liubov Dmitrieva
d5442f96df join backup states for hg sl command
Summary:
Check a few backup files for `hg cloud sl` command information.

I added a comment explaining why we would need this.

At the moment some commands like for example `hg cloud switch` or the `hg pull -r` goes through mononoke backend and they will update a different backup cache file comparing with the `hg cloud sync` command that goes through the mercurial backend (write path).

As a result, `hg sl` command displays that some commits haven't been backed up.

Reviewed By: markbt

Differential Revision: D24046449

fbshipit-source-id: 56d924bf641833231cda6e6701e67f63c8453894
2020-10-01 09:26:32 -07:00
Johan Schuijt-Li
5cdca923bb tests: allow tests to run without network on @mode/opt
Reviewed By: krallin

Differential Revision: D24015526

fbshipit-source-id: ce8a7b2b9a76f2c7e246f68a6e4f55aad90b5f03
2020-10-01 07:25:03 -07:00
Thomas Orozco
6ff79ca2bb mononoke/hgcli: log hgcli server data to Scuba
Summary:
This will give us the host that hgcli is running on, which is, like, convenient
to know what hg host proxied a request. For comparison, currently, we have to
go through ssh prod logs using the client IP and port, and hope there aren't
too many matches, which is really not a reasonable way to debug things.

Reviewed By: ahornby

Differential Revision: D23994304

fbshipit-source-id: fa5b29aa50e278f0f1b3b60be42f634a1c5c45c1
2020-10-01 05:22:47 -07:00
Liubov Dmitrieva
910d269f35 clean up migration code
Summary:
All the current workspaces should be already populated because the release has
been running for a while. Remove the migration code and also fix a bug with
string to boolean conversion.

Reviewed By: mitrandir77

Differential Revision: D24045272

fbshipit-source-id: 347f0f46d343a13fc1d9f762f912af364813a66f
2020-10-01 04:01:19 -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
Alex Hornby
409a9da79d mononoke: remove assert_present from Blobstore trait
Summary:
Remove assert_present from Blobstore trait as it had only one callsite other than the various blobstore layers/impls.

Replaced that one last call in repo_commit.rs/assert_in_blobstore() with an equivalent call to is_present.

Reviewed By: farnz

Differential Revision: D24016927

fbshipit-source-id: 764fddbebeb4b1192d196078b8824cf8a08e9691
2020-10-01 01:23:52 -07:00
Thomas Orozco
ab5af4b053 mononoke: add a tunable for ratio of master fallbacks
Summary:
Let's make this configurable so we can control how many fallbacks we want to
allow if we're overloaded.

Reviewed By: farnz

Differential Revision: D24017088

fbshipit-source-id: 9bccaf831a28daff9696950ae8aac9d53e0c51c0
2020-10-01 01:06:28 -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
33a380cf56 pyedenapi: add progress bars to EdenAPI client
Summary: Now that we progress bars in Rust, add them to the EdenAPI client bindings and remove any existing progress bars around callsites in the Python code.

Reviewed By: quark-zju

Differential Revision: D24037797

fbshipit-source-id: eb26ccaae35ab23eb76f6f2b2be575a22e1f1e53
2020-09-30 19:53:21 -07:00
Durham Goode
aa93d67cdc py3: fix hgsql syncing large files
Summary: Larges files are chunked and the initial buffer should be bytes.

Reviewed By: quark-zju

Differential Revision: D24034645

fbshipit-source-id: 98156b1901182b345baaeb82c71faeb3cc57b131
2020-09-30 18:58:40 -07:00
Xavier Deguillard
ee771fa740 utils: move multibyteToWideString to a cpp file
Summary:
There is no good reason for this function to be in a header, let's move it to
StringConv.cpp

Reviewed By: genevievehelsel

Differential Revision: D24000882

fbshipit-source-id: 5bb6bc3b9ef37232d38b8e35da693e12c0453ea1
2020-09-30 16:29:13 -07:00
Jun Wu
5048a060d6 localrepo: log changelog backend types
Summary: Log changelog backend types so we can filter commands by type.

Reviewed By: DurhamG

Differential Revision: D24022284

fbshipit-source-id: c402aea0ce3bd20d0f310fea167f24cb1b7a3ae6
2020-09-30 16:21:42 -07:00
Xavier Deguillard
b961901bb9 utils: remove UnixClock::getElapsedTimeInNs
Summary:
Replace it by simply using std::chrono facilities to achieve the exact same
behavior.

Reviewed By: chadaustin

Differential Revision: D24027637

fbshipit-source-id: d22eefec5d408ead0b4cfaa20e716f4c10cce0b5
2020-09-30 15:50:08 -07:00
Xavier Deguillard
f8f265cf4c service: populate uptime on Windows in getDaemonInfo thrift call
Summary:
There is no reason not to populate this on Windows, so let's do it to remove a
handful of #ifdef.

Reviewed By: chadaustin

Differential Revision: D24003912

fbshipit-source-id: 380b37d6d1a91f13cdc711c0055a5437f1184c20
2020-09-30 15:50:08 -07:00
Zeyi (Rice) Fan
c78cf6ca3b hgmain: check if EdenFS is running on Windows
Summary:
On Windows, some Mercurial commands may create files in `.hg` directory even if
EdenFS is not running. As a result, the command itself will fail while the file
still left in the directory. Users typically will then start EdenFS and repeat
the same command.

However, due to the current design of EdenFS, it will not be able to recognize
these files created when it is stopped and return errors for any attempts to
write/remove the file, generate another error. Users then need to stop EdenFS
and manually remove the file in `.hg` directory to recover the repository. This
creates a very bad user experience.

The correct way to fix this is to teach EdenFS to track the modifications
happened when it is not running, however this will take a few weeks to get
there. For a temporary measurement, we teach Mercurial to abort when EdenFS
isn't running to avoid trickier recoveries.

Reviewed By: quark-zju

Differential Revision: D24001090

fbshipit-source-id: abc1ebcdae3819756fe64b5321f52a6e62c0c360
2020-09-30 15:39:34 -07:00
Chad Austin
a07c8f66df update stats local-store column list
Summary:
stats local-store hardcodes the column names and has diverged from the
source of truth in KeySpace.h. Bring it back up to date. Ideally,
there would be a Thrift call to retrieve the column information, but
genevievehelsel might end up replacing this stuff soon.

Reviewed By: genevievehelsel

Differential Revision: D24027548

fbshipit-source-id: 5e5195585025081969865f8d3651e742f721ea09
2020-09-30 15:16:00 -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
Arun Kulshreshtha
2016586fe2 pyprogress: add Python bindings for Rust progress crate
Summary: Add Python bindings to the Rust progress wrappers. This may seem pointless since the Rust code just calls right back into Python, but this is a useful step to get the Rust and Python code to use a common interface for progress. (Which, in turn, will allow switching to a Rust progress implementation down the line.)

Reviewed By: markbt

Differential Revision: D23999816

fbshipit-source-id: 9bca0f23170d3ca474a1cb5d547840e63572ec71
2020-09-30 13:01:15 -07:00
Xavier Deguillard
9640f62409 prjfs: don't silently ignore invalidation errors
Summary:
For the longest time, invalidation errors were simply ignored, and while some
of them are valid to ignore, others just aren't and should be surfaced. One
exemple of a valid error is when a file is opened with no sharing, attempts to
invalidate the file would fail, but not inform the users, who would then be
surprised that the file wouldn't be updated on disk properly.

Instead of ignoring all errors, I've special cased the ones that we may be
expecting to receive, and will treat all the others as errors. A future diff
will attempt to properly not update the parent TreeInode so that a failed
invalidation would then be visible during an `hg update`.

Reviewed By: genevievehelsel

Differential Revision: D23980547

fbshipit-source-id: 2e67bfe817951fd0b497214a6474ff28b953b6e6
2020-09-30 12:28:31 -07:00
Arun Kulshreshtha
31107a525f pyprogress: add Rust wrapper for Python progress bars
Summary: Add Rust wrappers around Mercurial's Python `progress` module, allowing Rust code to create and use Python progress bars. The wrapper types implement the traits from the `progress` crate, so they can be passed to pure Rust crates in `scm/lib`. In typical usage, the Rust bindings will create a `PyProgressFactory`, which will be passed to pure Rust code as a trait object or via generics.

Reviewed By: markbt

Differential Revision: D23982317

fbshipit-source-id: 4c0fde0b2423b6449c7c5155fdfd98f5da042b0d
2020-09-30 11:20:32 -07:00
Arun Kulshreshtha
6dea84a3c9 progress: add Rust progress bar interface
Summary:
This diff introduces a new `progress` crate that provides an abstract interface for progress bars in Rust code:

- The `ProgressFactory` trait can be used to create new progress bars.
- The `ProgressBar` trait allows Rust code to interact with the progress bar.
- The `ProgressSpinner` trait is similar, but for spinner-type progress indicators.

These traits are intended to be used as trait objects, allowing pure Rust code to accept an opaque `ProgressFactory` and use it to report progress. This kind of abstraction, while not common in idiomatic Rust code, allows the progress implementation to be completed decoupled from the pure Rust code, which is important given that Mercurial's progress bars are currently implemented in Python.

Part of the goal of this crate is to allow a smooth transition to pure Rust progress bars (once we eventually implement them). As long as the Rust progress bars implement the above traits, the can be used as drop-in replacements for Python progress bars everywhere.

Reviewed By: markbt

Differential Revision: D23982319

fbshipit-source-id: 9ccf167f18d9518bb0ed66e1606a5b8188d98428
2020-09-30 11:20:31 -07:00
Thomas Orozco
0ddbe4e1a8 remotefilelog: advertise number of bytes, not number of characters
Summary:
The protocol for getpack is length-prefixed. However, we currently advertise
the number of characters in filenames instead of their byte length. So, the
lengths we send don't necessarily correspond to the amount of data we send.

Indeed, if a filename contains multibyte characters, we'll advertise a lower
byte count than what we actually end up sending. This results in the last
byte(s) of the filename being interpreted by Mononoke as the start of another
piece of data, and eventually causes Mononoke to hang as it waits for more data
that the client will never send.

This fixes that bug in reading, and also fixes an identical instance of the bug
on the server side. I also double checked the gettreepack code, which AFAICT
doesn't have this bug.

Reviewed By: ahornby

Differential Revision: D24013599

fbshipit-source-id: af716f2bf9c02d312c0c8d2f449988e8f8858ab8
2020-09-30 09:37:53 -07:00
Liubov Dmitrieva
b78b938fce add option to skip syncing of the current workspace
Summary:
The `hg cloud switch` command could be nicely used to debug other people workspaces by the Source Control Team.

Sometimes broken workspaces. This option would allow us to switch back from a broken workspace to our original workspace.

Mostly useful for the Source Control Team

Reviewed By: markbt

Differential Revision: D24014167

fbshipit-source-id: f2116cc13897149c8ac79790a31ebcce1f18a260
2020-09-30 04:31:32 -07:00
Mark Thomas
ab2234b1de hgcli: shorten session banner
Summary: Make the session banner a single line, and remove the URL.

Reviewed By: krallin

Differential Revision: D23930600

fbshipit-source-id: 1b361b9362f7652a2ad688ad599db2807d9344af
2020-09-30 02:19:23 -07:00
Arun Kulshreshtha
8e94a59c67 hghave: update description of py2 feature
Summary: Description erroneously refers to Python 3.X.

Reviewed By: quark-zju

Differential Revision: D24009652

fbshipit-source-id: be6c90514e68dc12f0b8f6b63e58f98f786558e8
2020-09-29 21:46:02 -07:00
Jun Wu
8dc618b1cd runtests: set tracing level before running tests
Summary:
With the new tracing-core (0.1.10 ->  0.1.16), it's no longer effective
to set EDENSCM_TRACE_LEVEL to more verbose within the test.
Let's set it in run-tests.py which spawns the test process instead.

Reviewed By: kulshrax

Differential Revision: D24004327

fbshipit-source-id: db2cadc7334eb59b25a1e0517e3d1a513e31e0fe
2020-09-29 21:19:20 -07:00
Xavier Deguillard
46ce143dcf build: various fixes to get eden to compile with @mode/win
Summary:
As EdenFS depends on a few bits of Mercurial code, these needs to be able to
compile with Buck.

Reviewed By: chadaustin

Differential Revision: D24000881

fbshipit-source-id: 078a2a958039a63db1b716785f872b4bbde3bab6
2020-09-29 16:10:27 -07:00
Durham Goode
e764fd8932 eden: stop using prefetchtree depth parameter
Summary:
This parameter is gone. Let's stop using it. For now we can achieve the
same result by setting the treemanifest config value. In the long term we'll
probably get rid of depth in favor of smarter algorithms, like bfs traversals.

Reviewed By: genevievehelsel

Differential Revision: D23971898

fbshipit-source-id: cabcf0c088c95557edfe07ae85ce7d07e55a3082
2020-09-29 12:40:03 -07:00
Meyer Jacobs
7f89121cab edenapi: non-key Entry attributes optional
Summary: Make `parents`, `data`, and `metadata` optional, and introduce `WireTreeAttributesRequest` for selecting which attributes to request on the wire.

Reviewed By: kulshrax

Differential Revision: D23406763

fbshipit-source-id: 5edd674d9ba5d37c23b12ab4d7b54bbf6c9ff990
2020-09-29 12:35:19 -07:00
Meyer Jacobs
cecbca5bb7 edenapi: make tree query method extensible
Summary:
Adds a `WireTreeQuery` enum for query method, with a single `ByKeys(WireTreeKeyQuery)` available currently, to request a specific set of keys.

Leave the API struct alone for now.

Reviewed By: kulshrax

Differential Revision: D23402366

fbshipit-source-id: 19cd8066afd9f14c7e5f718f7583d1e2b9ffac02
2020-09-29 12:08:05 -07:00
Jun Wu
d39c632679 zstore: do not test zstd compression size
Summary: The size can change with zstd upgrades. Do not test them.

Reviewed By: sfilipco

Differential Revision: D23976933

fbshipit-source-id: d560061b6e4fefc3bb89513bdb12c770ea0bd881
2020-09-29 10:13:18 -07:00
Mateusz Kwapich
5bd5fca4e9 add setup runbook to README
Reviewed By: krallin

Differential Revision: D23988329

fbshipit-source-id: a4bfa7826f0c2b0f45f6fe73936138e346bbd7b7
2020-09-29 05:37:30 -07:00
Aida Getoeva
40b8353d21 mononoke: integrate mysql client
Summary:
This diff introduces Mysql client for Rust to Mononoke as a one more backend in the same row with raw xdb connections and myrouter. So now Mononoke can use new Mysql client connections instead of Myrouter.

To run Mononoke with the new backend, pass `--use-mysql-client` options (conflicts with `--myrouter-port`).

I also added a new target for integration tests, which runs mysql tests using mysql client.
Now to run mysql tests using raw xdb connections, you can use `mononoke/tests/integration:integration-mysql-raw-xdb` and using mysql client `mononoke/tests/integration:integration-mysql`

Reviewed By: ahornby

Differential Revision: D23213228

fbshipit-source-id: c124ccb15747edb17ed94cdad2c6f7703d3bf1a2
2020-09-29 03:09:05 -07:00
Jun Wu
f833f03ba2 metalog: explicitly use tuple serialization for HgId
Summary:
metalog uses mincode serialization and requires certain bytes layout of the
HgId. Explicitly opt-in tuple serialization so HgId default serialization
change won't affect metalog.

Reviewed By: kulshrax

Differential Revision: D23966991

fbshipit-source-id: 23c217f1e8cb0c8a6cc12f50bb333cdc7bba36ca
2020-09-28 21:32:21 -07:00
Jun Wu
0bb45fcbc4 zstore: explicitly use tuple serialization for HgId
Summary:
zstore uses mincode serialization and requires certain bytes layout of the
HgId. Explicitly opt-in tuple serialization so HgId default serialization
change won't affect zstore.

Reviewed By: kulshrax

Differential Revision: D23966986

fbshipit-source-id: 69a60e26ec4e64c20a0b080288f622e765438ee4
2020-09-28 21:32:21 -07:00
Jun Wu
305b95895a edenapi/types: mark some commit related types to use hgid::bytes serialization
Summary:
This makes it so commit hashes are serialized to bytes instead of tuples in Python:

  In [1]: s,f=api.commitdata(repo.name, list(repo.nodes('master')))
  In [2]: list(s)
  Out[3]: [{'hgid': '...', ...}]

Some `Vec<HgId>`s cannot be changed using this way. It'd be nice if we can change
the default `HgId` serialization to bytes.

Reviewed By: kulshrax

Differential Revision: D23966989

fbshipit-source-id: 4d013525419741d3c5c23621be16e70441bab3c4
2020-09-28 21:32:21 -07:00
Jun Wu
2a2971a4c7 types: add serde(with) functions for HgId
Summary:
`HgId` currently serializes into a tuple of 20 items. This is suboptimal in
CBOR, because the items are untyped. A byte might be serialized into one or two
bytes:

  In [2]: cbor.dumps([1,1,1,1])
  Out[2]: b'\x84\x01\x01\x01\x01'

  In [3]: cbor.dumps([255,255,255,255])
  Out[3]: b'\x84\x18\xff\x18\xff\x18\xff\x18\xff'

CBOR supports "bytes" type to efficiently encode a `[u8]`:

  In [5]: cbor.dumps(b"\x01\x01\x01\x01")
  Out[5]: b'D\x01\x01\x01\x01'

  In [6]: cbor.dumps(b"\xff\xff\xff\xff")
  Out[6]: b'D\xff\xff\xff\xff'

Add `serde_with` with 3 flavors: `bytes`, `tuple`, `hex` to satisfy different
needs. Check the added docstring for details.

Reviewed By: kulshrax

Differential Revision: D23966992

fbshipit-source-id: 704132648f9e50b952ffde0e96ee2106f2f2fbcf
2020-09-28 21:32:21 -07:00
Xavier Deguillard
29922672ee prjfs: add a missing {} in a format string
Summary: The logs would never show what directory was changed to be a placeholder.

Reviewed By: fanzeyi

Differential Revision: D23977719

fbshipit-source-id: b1f7f539457956510638a31ca3e49c4cee641fd8
2020-09-28 18:49:49 -07:00
Xavier Deguillard
1fef8cbc1a prjfs: remove FsChannel.h
Summary: This is not needed, we can use the PrjfsChannel class directly where needed.

Reviewed By: chadaustin

Differential Revision: D23946259

fbshipit-source-id: eafcd38c0927fa282d62ada0986a7ef8b612174b
2020-09-28 18:14:30 -07:00
generatedunixname89002005307016
aa6146bfa8 suppress errors in eden - batch 1
Differential Revision: D23968620

fbshipit-source-id: dd9b816be7304511ae69b265d9b650313c799c1f
2020-09-28 16:03:43 -07:00
Mark Thomas
9720cccbe5 test-hooks: use hyphens for bypass string
Summary: We use hyphens in other bypass strings.  Make this consistent in `test-hooks.t` to avoid confusion.

Reviewed By: mitrandir77

Differential Revision: D23964799

fbshipit-source-id: e300bad091aa6c50f5921507117c1019b9863bd5
2020-09-28 11:19:20 -07:00
Kostia Balytskyi
9981ab8454 mononoke: use parent config version if it's available for a single-parent case
Summary:
Let's start actually fixing what commit sync config version is used to remap a commit i.e. we
should use a commit sync config version that was used to remap a parent instead
of using a current version. See more details in
https://fb.quip.com/VYqAArwP0nr1

This diff fixes one particular case and also leaves a few TODOs that we need to
do later

Reviewed By: krallin

Differential Revision: D23953213

fbshipit-source-id: 021da04b0f431767fec5d1c4408287870cb83de1
2020-09-28 10:20:16 -07:00
Kostia Balytskyi
0f47188bd8 mononoke: change TestLiveCommitSyncConfig logic
Summary:
TestLiveCommitSyncConfig is supposed to be a test replacement of
CfgrLiveCommitSyncConfig, however it was quite a different semantic. In
particular, it wasn't even possible to have two versions of the mapping for the
single repo.

This diff changes that. Now we'll have a method to add commit sync config
version, and mark/remove a version as current

Reviewed By: krallin

Differential Revision: D23951202

fbshipit-source-id: 242b4f088f67dac504544987e484cc290ee4e400
2020-09-28 10:20:16 -07:00
Kostia Balytskyi
6690d13a40 mononoke: remove usage of get_current_mover_DEPRECATED method
Summary: Instead of always fetching the current version name to verify working copy let's instead fetch whatever the version was actually used to create this commit.

Reviewed By: krallin

Differential Revision: D23936503

fbshipit-source-id: 811e427eb62741401b866970b4a0de0c1753edb3
2020-09-28 10:20:16 -07:00
Kostia Balytskyi
4c1e9c8538 mononoke: fix verify_working_copy method
Summary:
Turned out validation didn't report an error if source repo contained an entry
that was supposed to be present in target repo but was actually missing.

This diff fixes it.

Reviewed By: krallin

Differential Revision: D23949909

fbshipit-source-id: 17813b4ad924470c2e8dcd9d3dc0852c79473c61
2020-09-28 10:20:16 -07:00
Kostia Balytskyi
3eb00ff939 mononoke: add version to CommitSyncOutcome:: EquivalentWorkingCopyAncestor
Summary: Since now we store it in the db, let's also expose it in CommitSyncOutcome enum

Reviewed By: krallin

Differential Revision: D23936502

fbshipit-source-id: a0758143ceaa8f5706f1d9cfe3040ac91c7bac49
2020-09-28 10:20:15 -07:00
Kostia Balytskyi
d829595d86 sparse: be explicit about the role of -r
Summary: This just adds some explanation of `-r` to the `hg sparse list` docstring.

Reviewed By: markbt

Differential Revision: D23961027

fbshipit-source-id: 64ab406b07fe5d66fd53d4e520935aad3b0b351b
2020-09-28 10:03:55 -07:00
Durham Goode
37f47b452a dynamicconfig: fix reponame detection during synchronous config generation
Summary:
Dynamicconfig can generate configs two ways, 1) via `hg
debugdynamicconfig` and 2) synchronously in-process in an hg command when it
detects that the dynamicconfig is completely missing or has the wrong version
number.

In the first case, dynamicconfig gets the repo name from the standard config
object loaded by the hg dispatch.  In the second case, the standard config
object isn't even loaded yet, so dynamicconfig does a mini-load of the user and
repo hgrcs so it can get the repo name and user name (needed for dynamic
conditions).

Unfortunately the second code path computed the wrong path (it had two .hg/'s)
which meant the reponame and user name were always none. This meant that the
dynamicconfig on disk could randomly be either computed with or without a
reponame.

Let's fix the path computation, and add a test.  We may want to make
dynamicconfig fail if no repo name is passed, but I'm not sure if we'll want to
support no-repo configuration at some point.

This didn't cause a problem for most people, since it would only happen during a
hg version number change, and 15 minutes later the background 'hg
debugdynamiconfig' process would fix it up. It did affect sandcastle though,
since it often creates new repositories and acts on them immediately.

Reviewed By: quark-zju

Differential Revision: D23955628

fbshipit-source-id: c922f4b523d19df9223aa28c97700b7011fc03eb
2020-09-28 09:14:05 -07:00
Durham Goode
040ee1b744 revisionstore: fix default pending data pack limit
Summary:
The old code tried to express 4GB by using ^ to do an exponent. That
operator is actually the bitwise xor, so this was producing a limit closer to 4
bytes. It doesn't seem to have mattered much since a later diff overrode the
default via dynamicconfig. But let's fix this anyway.

Reviewed By: krallin

Differential Revision: D23955629

fbshipit-source-id: 6abebcb7e84b7a47f70ac501fa11b0dc60dfda7b
2020-09-28 09:14:04 -07:00
Aida Getoeva
0ba6f9ff35 mononoke/sql_ext: add mysql connections
Summary: The diff adds API to create a set of connections: read, read master and write.

Reviewed By: ahornby

Differential Revision: D23568561

fbshipit-source-id: b3ee954604557497ed56c6b369256b6f76a1e042
2020-09-28 08:13:35 -07:00
Aida Getoeva
77c2ae3673 mononoke/blobstore_healer: use myadmin replication lag
Summary:
This diff makes blobstore healer to use MyAdmin to get replication lag for a DB shard and removes "laggable" interface for connections.

The old "laggable" API worked this way: we maintained potential connections to each possible region, then tried to query replica status on all of them. If there was no replica hosts in some of the regions, we just wanted to ignore it by handling a specific error type.

This is legacy and makes the logic more complicated. We want for the new code to use Myadmin instead.

Reviewed By: krallin

Differential Revision: D23767442

fbshipit-source-id: 9f85f07bd318ad020d203d2bcd1c8898061f7572
2020-09-28 07:19:31 -07:00
Lukas Piatkowski
c807e08a58 mononoke/integration tests: publicize hook and megarepo tests (#61)
Summary: Pull Request resolved: https://github.com/facebookexperimental/eden/pull/61

Reviewed By: farnz

Differential Revision: D23818467

fbshipit-source-id: 72857a4193ee9f218cda06ec98717ea6ecf97dbe
2020-09-28 04:26:09 -07:00
Thomas Orozco
ee9ecf63bb gotham_ext: ^ is not **
Summary:
I spotted D23955629 recently, and it turns out I made the same mistake in LFS.
Let's fix it. In order to keep the same semantics (yield on every chunk from
the filestore), I lowered the threshold a bit from what it was intended to be.

Reviewed By: johansglock

Differential Revision: D23960152

fbshipit-source-id: 4d384752228fd125ade7e032a477648798e7fa44
2020-09-28 03:41:24 -07:00
Arun Kulshreshtha
d3b39542f0 revisionstore: use async_runtime in EdenAPI stores
Summary: Now that the `async_runtime` crate exists, use Mercurial's global `tokio::Runtime` instead of creating one for each EdenAPI store.

Reviewed By: quark-zju

Differential Revision: D23945569

fbshipit-source-id: 7d7ef6efbb554ca80131daeeb2467e57bbda6e72
2020-09-26 16:50:06 -07:00
Lukas Piatkowski
3615a09d6f remove fbsource version, import github version
Summary:
This is (I think) the last step required to make rust-partial-io be github-first.

The diff was created using:
* `zbgs partial-io` and remove all instances of it in fbsource
* `hg rm common/rust/partial-io`
* add `partial-io` to `third-party/rust/Cargo.toml`
* `common/rust/tools/reindeer/vendor` to vendor
* `buck build eden/mononoke/mercurial/...` to check that it builds correctly
* `buck run //common/rust/cargo_from_buck:cargo_from_buck` to run autocargo

Reviewed By: aslpavel

Differential Revision: D23849634

fbshipit-source-id: 339fc3976cc9a0b6f10a0538d643b87797e2bc3c
2020-09-26 09:25:29 -07:00
Lukasz Piatkowski
772676a23f third-party/rust: bump third-party code versions
Reviewed By: aslpavel

Differential Revision: https://phabricator.intern.facebook.com/D23930000

fbshipit-source-id: d2f7a926e0a188694254a6f1f77f8408c4b1a0dd
2020-09-26 18:13:40 +02:00
Mark Edson
86c6025e20 change comment to jf authenticate
Summary:
`arc install-certificate` is going away, so let's reference the replacement

Created from Diffusion's 'Open in Editor' feature.

Differential Revision: D23948479

fbshipit-source-id: e629458ed2be1e1c09d9674935e3bcc890b05ad9
2020-09-25 22:31:17 -07:00
Stanislau Hlebik
b4cf040ef5 mononoke: add version name to working copy equivalence
Summary:
See motivation for the change in D23845720 (5de500bb99).

We'll need to store version name even for commits that weren't rewritten, but that have an equivalent working copy in another repo.

Reviewed By: ikostia

Differential Revision: D23864571

fbshipit-source-id: 408b68c3b0aa9885a9cd248b0b4abc2b87cd4cca
2020-09-25 14:53:13 -07:00
Stanislau Hlebik
4f0b3b3eb5 mononoke: replace a few usages of get_source_target_mover
Summary:
get_source_target_mover likely awaits the same fate as
get_current_mover_DEPRECATED functions i.e. get_source_target_mover will likely
be removed.

This diff just removes a few intances of this function.

Reviewed By: ikostia

Differential Revision: D23929748

fbshipit-source-id: 2ac09da164de3916a552757acf0c39387f6126e4
2020-09-25 14:21:07 -07:00
Stanislau Hlebik
1063f8e44a mononoke: make get_mover and get_reverse_mover functions deprecated
Summary:
get_mover() and get_reverse_mover() functions return the mover for the
"current" version of the commit sync config, which means these are movers for the version
of the config that's used to create the latest commits on master branch.

So this function returns correct mover only for the latest master commit, but
for all other commits it returns an incorrect mover! This is wrong and it
happened to work just by change, and that's why these functions are marked as deprecated
now, and later we'll add functions 'get_mover_by_version()' which could be used to
replace deprecated functions.

Note that the story for get_bookmark_renamer()/get_reverse_bookmark_renamer()
functions seems to be different. If we can always figure out what's the correct
mover for a commit by e.g. look at its parent we can't really do the same for
bookmarks. Because of that I suggest to keep using the current version for
get_bookmark_renamer() function.

Reviewed By: ikostia

Differential Revision: D23929582

fbshipit-source-id: 3e5e9b46224aca0b75cf2d981ea21c4f9a378ba9
2020-09-25 14:21:07 -07:00
Stanislau Hlebik
092875e01d mononoke: remove version from CommitSyncRepos
Summary: Finally remove version_name from CommitSyncRepos. Note that this diff adds a few TODOs that we'd need to fix later.

Reviewed By: ikostia

Differential Revision: D23929010

fbshipit-source-id: c72130af548ac7b26bc20ddaac9a59562cc75e0b
2020-09-25 14:21:07 -07:00
Stanislau Hlebik
99cfa9dcd7 mononoke: remove bookmark_renamer from CommitSyncRepos
Summary: Just as in the previous diff, but this time remove bookmark_renamers from CommitSyncRepos

Reviewed By: ikostia

Differential Revision: D23910295

fbshipit-source-id: 0c2d147057c8d3e0749d5b31ef98ab5022255d95
2020-09-25 11:14:45 -07:00
Stanislau Hlebik
d073b1528d mononoke: remove reverse_mover
Summary: Just as the previous diff, but this time it removes reverse_mover

Reviewed By: ikostia

Differential Revision: D23879509

fbshipit-source-id: ed111ca2d106120229c4facc0bb2435913c27966
2020-09-25 11:14:44 -07:00
Stanislau Hlebik
e05cee0352 mononoke: remove mover from CommitSyncRepos
Summary:
This diff starts to use CommitSyncDataProvider introduced in the previous diff
and removes Mover from CommitSyncRepos struct.

Reviewed By: ikostia

Differential Revision: D23878683

fbshipit-source-id: 0d54f889781aebe4726b3388343a87df783c17d4
2020-09-25 11:14:44 -07:00
Stanislau Hlebik
f2a7850686 mononoke: add CommitSyncDataProvider
Summary:
As described in D23845720 (5de500bb99) we are doing a pretty significant change in the
CommitSyncer. Previously it stored static Movers and BookmarkRenamers, but it
needs to change and they would need to fetch config from LiveCommitSyncConfig.

Unfortunately we already have a bunch of tests that create weird movers that
would be very hard to model via LiveCommitSyncConfig. So we have 2 options:

1) delete or rewrite all these tests
2) Create a wrapper that would return a mover/bookmark renamers.

Option #2 is preferable, and that's what this diff does. In production it would
use LiveCommitSyncConfig, but it also let's tests specify whatever weird movers
they need.

Reviewed By: ikostia

Differential Revision: D23909432

fbshipit-source-id: 83fb627812f625e07f7e40044e2f69274cd2d768
2020-09-25 11:14:44 -07:00
Durham Goode
5d6dfacb7a phases: make public calculation lazy
Summary:
Now that public phases are separated from draft, hidden behind the
ispublic() api, and no consumers require the entire set anymore, let's make them
lazy by testing commits against a lazy ancestor collection.

Reviewed By: quark-zju

Differential Revision: D23921326

fbshipit-source-id: 7c53345f41ff89d2d0ec11b1c09bbb2f89529c21
2020-09-25 09:28:30 -07:00
Durham Goode
5c755e5130 dagop: move cutfunc to walkrevtree
Summary:
Previously, _genrevancestor applied it's cutfunc function (which is
usually used to bound an ancestor traversal from processing public nodes) when
producing the parents of the current rev. In the walkrevtree function this means
we have to invoke cutfunc before we enqueue new parents onto the heap. This can
mean we have to process very old commits, even though walkrevtree might never
get to them.

Let's move the cutfunc to be at the deque stage instead of enque. When we make
public phases lazy, this will let us avoid looking up really old commits and
speed things up a lot.

Reviewed By: quark-zju

Differential Revision: D23921324

fbshipit-source-id: 8b520e9184441b9bd7581cdb71414f406cf9b544
2020-09-25 09:28:30 -07:00
Durham Goode
f8543d78b0 phases: switch revset to not require entire public set
Summary:
Unfortunately the current add operator implementation for nameset sorts
the result, which causes lazy namesets to be evaluated. Let's change the phase
revset to avoid that operator for now.

In a future diff we'll make publicrevs lazy, which will require this change to
be performant.

Reviewed By: quark-zju

Differential Revision: D23921325

fbshipit-source-id: c3477c30c1c5061b641c14b8aa73d07da6f7f398
2020-09-25 09:28:30 -07:00
Durham Goode
0131d47746 phases: make draftrevs use only()
Summary:
In a future diff we'll be changing the way public phase computation
works. Let's start by moving the draft phase computation out to belong to
draftrevs(), so then we can change publicrevs() without worrying about draft. In
the process, let's simplify draftrevs to just be an only() query.

Reviewed By: quark-zju

Differential Revision: D23921327

fbshipit-source-id: 255eab4b796bf7bc4467544cf8231b3ed98c08c8
2020-09-25 09:28:29 -07:00
Durham Goode
c05bd0a51c phases: move headbased phase calculation to it's own function
Summary:
In an upcoming diff we'll be splitting draft and public calculations
apart when in headbased repositories. To make this cleaner, let's stop using
loadphaserevs and start using draftrevs and publicrevs accessors.

Reviewed By: quark-zju

Differential Revision: D23921328

fbshipit-source-id: 26a2a6fdc1201416bf61c7d32e3ede62d9579546
2020-09-25 09:28:29 -07:00
Stanislau Hlebik
eb6326c176 mononoke: update live commit sync config tests
Summary:
Our configerator configs store both "current" mapping version and also they
store all versions that were used before.
These integration tests were updating just current version, but weren't
updating "all" versions. This is incorrect but it worked by accident.
But it will stop working in the next diffs, so  this diff fixes it

Reviewed By: ikostia

Differential Revision: D23908970

fbshipit-source-id: 10f96bd02987d9195aff4855241efbd9a065a761
2020-09-25 06:54:22 -07:00
Kostia Balytskyi
a68af80723 commit_rewriting: make sync_commit accept CandidateSelectionHint
Summary:
A higher-level goal is to provide an interface for the manual remediation of
various xrepo-sync blockages. The nature of a candidate selection is such that
it may fail if the hint is not sufficient to decide which remapping changeset
is the best candidate. This is especially true about the `Only` hint variant:
it is designed to fail when there's more than one candidate. But even with
bookmark ancestorship hints, there are corner cases when the algorithm cannot
make a decision (as well as there may just be bugs in the algorithm). These
cases should be **extremely** rare. Nevertheless, we want to be able to unblock
ourselves. To do so, it is proposed to acccept parent selection hints in the `xrepo-lookup` scs
method. By default, it will use `Only` as a hint and be semantically equivalent
to the current behavior. But we'll provide CLI options to select other hints.

In order to make this work, we need the `sync_commit` method of the
`CommitSyncer` to accept hints too.

Reviewed By: StanislavGlebik

Differential Revision: D23913216

fbshipit-source-id: 05e1ff99cd2c6522829a6e8569040b226600af60
2020-09-25 06:42:29 -07:00
Durham Goode
eb5acf9222 tests: disable flakey tests
Summary:
These tests rely on sleep to simulate race conditions. They are the
largest source of hgbuild breakages. Let's just disable them. Most of this code
is going away in a couple months anyway when Mononoke takes over and revlogs go
away.

Also fixes a failure in test-bookmarks-strip.t that showed up.

Reviewed By: singhsrb

Differential Revision: D23922660

fbshipit-source-id: 35cacc19de03c031c84c1ebf2124884f4b4248e6
2020-09-24 21:32:23 -07:00
Arun Kulshreshtha
825ebe35a8 edenapi: print response headers in debug output
Summary: Print relevant HTTP response headers in the debug output for debugging client-server issues.

Reviewed By: quark-zju

Differential Revision: D23923168

fbshipit-source-id: c9fda57c53fb25b15c450f0afd14e539de43cfcb
2020-09-24 21:05:21 -07:00
Arun Kulshreshtha
29b855b256 edenapi: add server load to ResponseMeta
Summary: Now that the EdenAPI server is using the `LoadMiddleware` from `gotham_ext`, each response will contain an `X-Load` header that contains the number of active requests that the server is currently handling.

Reviewed By: quark-zju

Differential Revision: D23922809

fbshipit-source-id: 973143de5ddccf074d28aa3ef38d73f9fc1501b6
2020-09-24 21:05:21 -07:00
Arun Kulshreshtha
318f5683a5 http-client: report download speed as Mbit/s and MiB/s
Summary:
Network speeds are usually reported in megabits per second (Mb/s), whereas file sizes are usually reported in [mebibytes](https://en.wikipedia.org/wiki/Binary_prefix) per second (MiB/s). Previously, the HTTP client reported neither of those and instead reported megabytes per second (MB/s).

This diff changes the latter to the former so that the numbers are more immediately useful. As a bonus, the speeds are now directly comparable to those reported by `hg debugnetwork`.

Reviewed By: quark-zju

Differential Revision: D23920367

fbshipit-source-id: 46500a42681ab83fc7c4ead82980e8ed620a4d5a
2020-09-24 21:05:20 -07:00
Arun Kulshreshtha
f1aeffd67a hg-http: remove stats logging
Summary: Now that stats are logged to `tracing` by the `HttpClient` directly, we no longer need to log them here. This commit backs out D23858077 (613fbc858f) which added the logging.

Reviewed By: quark-zju

Differential Revision: D23919308

fbshipit-source-id: 23d3a12c5307bc4b84dd9ffd25bd376718e3cc91
2020-09-24 21:05:20 -07:00
Arun Kulshreshtha
45e8c3377c http-client: improve log messages
Summary:
Improve the log output of the HTTP client to avoid spewing redundant debug messages.

As part of this change, logging now uses the `tracing` crate instead of the `log` crate for better integration with the rest of Mercurial's logging infrastructure. Right now, `tracing` is just being used as a drop-in replacement for `log`, but now that it's in use we can start using its full capabilities (such as defining tracing spans) in later diffs.

Reviewed By: quark-zju

Differential Revision: D23919310

fbshipit-source-id: 95555ad083ead805ceece39c6e30aaf879bdf2bc
2020-09-24 21:05:20 -07:00
Adam Simpkins
475318252f fix hg mv and hg cp to wait for the lock if the repo is locked
Summary:
Fix the `hg mv` and `hg cp` commands to wait for the lock if the repository is
locked, instead of immediately failing.

The current behavior is quite annoying as `hg mv` can easily fail due to
commitcloud sync commands running in the background and holding the lock.

I can't see any good reason why this command should not wait for the lock to
be held.  The current behavior of failing when the lock is held dates back to
2006, in rFBSf5b6e7d2f591, when locking was first added to this command.

Reviewed By: DurhamG

Differential Revision: D23896302

fbshipit-source-id: 29bfeb8fd356abd31b6e1eb30c8f211a31fb044b
2020-09-24 19:05:33 -07:00
Xavier Deguillard
dc19397ccc doctor: use the right indexedlog config
Summary:
The remotefilelog.indexedlog{data,history}store configs are no longer in use,
so we shouldn't use them as a way to test whether the indexedlog are present.

Reviewed By: quark-zju

Differential Revision: D23918133

fbshipit-source-id: 902a369f5e1774b8e2fa1e4b3280fbb7cc377775
2020-09-24 16:58:36 -07:00
Arun Kulshreshtha
3a5b6d2958 http-client: fix curl_multi_wait timeout
Summary:
We were using the timeout parameter on `Multi::wait` (equivalent to `curl_multi_wait` in C) incorrectly. Previously, we were passing in the timeout provided by `curl_multi_timeout`.

This is incorrect usage because the value returned by `curl_multi_timeout` is the current value of libcurl's internal timeout (based on the state of the transfers), which will always be respected. The actual intention of the timeout parameter is to allow the caller to specify a hard cap on curl's internal timeout, so we should just pass some reasonable default value here. ([See explanation here.](https://github.com/curl/curl/issues/2996))

The purpose of `curl_multi_timeout` is to allow libcurl to tell the application what its desired timeout is in situations where the application itself is waiting for socket activity (using something like `epoll`), which is not the case when using `curl_multi_wait`.

Reviewed By: DurhamG

Differential Revision: D23914093

fbshipit-source-id: 76a25d7c59a4b08437c8d7be3d24708fb37b9172
2020-09-24 16:46:39 -07:00
Arun Kulshreshtha
621bb70089 treemanifest: add HTTP fetching
Summary: Add appropriate EdenAPI calls to allow for HTTP tree fetching in `treemanifest`. Enabling `remotefilelog.http` essentially reroutes `_prefetch` and `getdesignatednodes` to their HTTP equivalents.

Reviewed By: DurhamG

Differential Revision: D23877319

fbshipit-source-id: 8a71934b47d07d2655fa46c103a14fb99e2f7b1f
2020-09-24 16:46:39 -07:00
Arun Kulshreshtha
5bac6466e2 edenapi: add timeout option
Summary: Use the functionality from D23910534 (721f5af278) to set a timeout for EdenAPI requests, configured via the `edenapi.timeout` option.

Reviewed By: DurhamG

Differential Revision: D23911552

fbshipit-source-id: 4a6e3de1094d0faa1daaf6fe4b9b7aafb37a25a8
2020-09-24 16:46:39 -07:00
Arun Kulshreshtha
ac3dbcb84e treemanifest: cast names and nodes to lists
Summary:
Cast `names` and `nodes` to lists. The reason that they are sets is deduplication, but otherwise the code doesn't rely on them being sets (and in fact casts them to lists at multiple points later).

The main motivation for this is to allow these to be passed to Rust code later. The Rust bindings make a distinction between sequence types and unordered types, so passing a set in place of a list would result in a type error.

Reviewed By: DurhamG

Differential Revision: D23893108

fbshipit-source-id: 9ce2addb824867bcb2d24ba14c589b8791a156e8
2020-09-24 16:46:39 -07:00
Arun Kulshreshtha
721f5af278 http-client: add ability to set timeout
Summary: Add the ability to set a timeout on HTTP requests. Equivalent to [`CURLOPT_TIMEOUT_MS`](https://curl.haxx.se/libcurl/c/CURLOPT_TIMEOUT_MS.html).

Reviewed By: DurhamG

Differential Revision: D23910534

fbshipit-source-id: a7aec792ec3c122a01aa44fcfe2e2df6e3a111fc
2020-09-24 12:59:42 -07:00
Durham Goode
24aa3b50ca py3: fix traceprof
Summary: Fixes it for python 3

Reviewed By: kulshrax

Differential Revision: D23907996

fbshipit-source-id: 1347a1adb80ef643bdb581fea83362558d94e058
2020-09-24 11:56:21 -07:00
Kostia Balytskyi
759d9778a4 commit_rewriting: make unsafe_sync_commit[_pushrebase] use CandidateSelectionHints
Summary:
This diff adds the use of candidate selection hints to `cross_repo_sync` code sights, which need to query `CommitSyncOutcome` in the small-to-large direction. Specifically: `unsafe_sync_commit` and `unsafe_sync_commit_pushrebase` are the two main functions.

One will now get `CandidateSelectionHint` from the callsight (most notably: `push_redirector`), the other one will build a bookmark-based hint itself.

Reviewed By: StanislavGlebik

Differential Revision: D23715259

fbshipit-source-id: 3f4924f1337b09f3762cc050c4017c5d2bd6cab6
2020-09-24 11:32:07 -07:00
Durham Goode
2c790a0331 py3: fix crecord 'a' and 'r' commands
Summary: These concatenated strings and bytes and needed to be fixed.

Reviewed By: kulshrax

Differential Revision: D23907301

fbshipit-source-id: 0008d7d54469266ecbae8ddaaa7625820f62cb7e
2020-09-24 11:22:33 -07:00
Arun Kulshreshtha
183fff1b9f http-client: fail loudly on non-fatal errors
Summary:
There are several places in the HTTP client where we log and discard errors. (Typically, these are "this should never happen" type situations.)

Previously, these were logged at the `trace` log level, meaning that in practice no one would ever know if we did hit these errors.

Let's upgrade them to `error` so that they'll be printed out. (In theory, users should never see these error messages unless something has gone horribly wrong.)

Reviewed By: DurhamG

Differential Revision: D23888268

fbshipit-source-id: 9007205f946ebb0127238c76812cf62524878047
2020-09-24 11:19:36 -07:00
Durham Goode
eb5ac5b0fc tests: remove flakey test
Summary:
This test relies on precise timing of racing processes. This is flakey
in our automated tests. Since this is mainly about revlog based repos, and we
only have that on the servers now, and we're going to delete them soon, let's
delete this test to make our tests more stable.

Reviewed By: kulshrax

Differential Revision: D23908316

fbshipit-source-id: 3fd110a8267d3bc16bbcb4545b9ff921274f7588
2020-09-24 11:10:07 -07:00
Katie Mancini
38015ad652 move prefetch_profile out of debug
Summary:
Prefetch profile can now be used in automation to register profiles and to fetch
them. Since it will be used out side of the team it seems like this should be
moved out from under debug.

Reviewed By: genevievehelsel

Differential Revision: D23773337

fbshipit-source-id: b7f646ec202653233ed82528380d91f583a8341e
2020-09-24 09:55:08 -07:00
Katie Mancini
19bf16b234 CLI to deactivate a prefetch profile
Summary:
This will allow us (and maybe users) to remove a users active profiles
easily when investigating issues. (And also will be useful for testing.)

Reviewed By: genevievehelsel

Differential Revision: D23517409

fbshipit-source-id: d57e595770b5a60726e2efe9cbf21c89dd694cc0
2020-09-24 09:55:08 -07:00
Katie Mancini
061b3a9cfd CLI to activate a prefetch profile
Summary:
This will allow tools to activate prefetch profiles relavant to their workflow.
Eventually this should also cause eden to prefetch the profile for the current
commit, but for now it just activates the profile.

Reviewed By: genevievehelsel

Differential Revision: D23517412

fbshipit-source-id: 172a844ca00bf3bcf14f4b94c25e8256e516b737
2020-09-24 09:55:08 -07:00
Katie Mancini
7ccb3693f3 CLI to list active prefetch profiles
Summary:
This will allow us (and maybe users) to see a users active profiles
easily when investigating issues. (And also will be useful for testing.)

Reviewed By: genevievehelsel

Differential Revision: D23517410

fbshipit-source-id: 7a592f7b39c887600307a4f08668ca1ee9b982bf
2020-09-24 09:55:08 -07:00
Katie Mancini
c28b6f0417 enable cli to parse active prefetch profiles
Summary:
Assuming the format for active prefetch profiles as discussed here:
https://fb.quip.com/v8yFAzeGx8TU

This allows the cli to read in and write out active profiles, allowing the cli
to manipulate them in the following changes. This will allow tools to activate
profiles useful for that workflow. Additionally, it will allow us (and maybe
users) to see/remove a users active profiles easily when investigating issues.

Reviewed By: genevievehelsel

Differential Revision: D23517411

fbshipit-source-id: 8ab18a1aeccf8dcdd04aca826d61070fa0aedd33
2020-09-24 09:55:08 -07:00
Durham Goode
3fa03cf52c treemanifest: stop passing around linkrevs during recent tree discovery
Summary: Linkrevs are on their way out. Let's switch to linknodes.

Reviewed By: quark-zju

Differential Revision: D23765176

fbshipit-source-id: 0dc1e0db11d732ce1edd24d863f32f08a5a5ce42
2020-09-24 09:47:00 -07:00
Durham Goode
490468403b treemanifest: fix bundle usage with Rust contentstore
Summary:
The rust contentstore doesn't allow runtime manipulation of the list of
stores, which is required in order to insert the bundle store into the store.
Let's continue using the old python union store in these cases. This still let's
us delete the python pack code later, but we'll have to keep around the python
union store until we come up with a better solution.

Reviewed By: quark-zju

Differential Revision: D23689630

fbshipit-source-id: 0c60e6f268e81804149afa24409f64b5303e1e34
2020-09-24 09:46:59 -07:00
Durham Goode
c80cdf1f49 treemanifest: enable treemanifest.useruststore=True for most tests
Summary:
The remaining test failures are mostly around bundle support, which
I'll fix in a later diff.

Reviewed By: quark-zju

Differential Revision: D23664037

fbshipit-source-id: 2bdde3cb4fcded6e0cf3afdc23269662544821df
2020-09-24 09:46:59 -07:00
Durham Goode
9274720931 treemanifest: remove depth parameter from high level prefetch trees
Summary:
The high level prefetch trees API had a depth parameter, but the Rust
prefetch path doesn't support that. In the long run we probably want to get rid
of the depth parameter (or make it more useful), so for now let's get rid of it
from the function signature. You can still set the depth via config, and the few
places that needed depth are changed to use the config.

Reviewed By: quark-zju

Differential Revision: D23772384

fbshipit-source-id: a037d7207d4076a47368366ef7fd2dc1cfbf5cfb
2020-09-24 09:46:59 -07:00
Durham Goode
46d0991cd0 revisionstore: expose shared mutable stores to Python
Summary:
Treemanifest needs to be able to write to the shared stores from paths
other than just prefetch (like when it receives certain trees via a standard
pull). To make this possible we need to expose the Rust shared mutable stores.
This will also make just general integration with Python cleaner.

In the future we can get rid of the non-prefetch download paths and remove this.

Reviewed By: quark-zju

Differential Revision: D23772385

fbshipit-source-id: c1e67e3d21b354b85895dba8d82a7a9f0ffc5d73
2020-09-24 09:46:59 -07:00
Jan Mazur
40cfc97379 adding per repo ACL checking
Summary:
ConnectionSecurityChecker now supports per repository ACL checking.

PermissionCheckers are created in constructor for each repo.
Later when there is a need to check permissions, they're retrieved using a hash map.

Reviewed By: HarveyHunt

Differential Revision: D23678515

fbshipit-source-id: 3d2880fc9df137872ea64a47636f1142d0b36fc1
2020-09-24 08:12:35 -07:00
Stanislau Hlebik
4a1351f333 mononoke: configure TestLiveCommitSyncConfig
Summary:
Previously we had just an empty TestLiveCommitSyncConfig in tests. Since we are
not using it at all right now, it was fine, but we are planning to start using
it later. To do that let's configure TestLiveCommitSyncConfig so that it's not
empty but actually stores a real content.

Reviewed By: ikostia

Differential Revision: D23903579

fbshipit-source-id: af05a377f730c1824b03327749e6f824361e23e2
2020-09-24 07:58:30 -07:00
Stanislau Hlebik
93b2919443 mononoke: use live_commit_sync_config in crossrepo admin
Summary:
At the moment we have a weird setup where cross repo sync configuration is
stored in both live commit sync configuration and in normal mononoke config.
The latter is deprecated, however there are still a few parts of the codebase
that rely on that. This diff fixes one place

Reviewed By: ikostia

Differential Revision: D23903578

fbshipit-source-id: 2bf4b3d17c34fe2eb6330cd862f7b0f5cd6ffa40
2020-09-24 07:58:30 -07:00
Stanislau Hlebik
fc47d6089b mononoke: remove get_mover() usage from commit_validator
Summary:
In D23845720 (5de500bb99) I described what changes we need to make in our commit syncer. One
part of it is that we should remove get_mover() method, as this method always
uses current version of commit sync map even, and that's incorrect.

This diff removes it from commit validator

Reviewed By: ikostia

Differential Revision: D23864350

fbshipit-source-id: 3f650a32835dda9f82949002d63b52cc36cf04e0
2020-09-24 07:58:30 -07:00
Stanislau Hlebik
609c2ac257 mononoke: add another optimization for getbundle
Summary:
D23599866 (54d43b7f95) added an optimization for getbundle that reduces cpu usage when a new
commit with log generation number is added. I.e. the case like this

```
O
|
O
..
   O <- new commit, low generation number
   |
  ...
```

Unfortunately this optimization doesn't help with the case where a new repo is
merged into master

```
O  <- also new commit, but generationo number is high!
| \
..  O <- new commit, low generation number, but it's not in "heads" parameter
    |
    |
    O
  ...
```

The merge commit actually has a high generation number, but it's p2 has a low
generation number, so it causes the same issue with high cpu usage.

This diff adds a second optimization ( :( ) that should help with the shortcoming of the first one. See comments for more details.

Reviewed By: ikostia

Differential Revision: D23824204

fbshipit-source-id: 8f647f1813d2662e41325829d05def633372c140
2020-09-24 07:52:40 -07:00
Thomas Orozco
c4ea8bb15a mononoke: never block when writing to logger() server-side & remove hgcli/fdio
Summary:
This takes johansglock's D23757705 one step further, and gets rid of the
`Wait<...>` wrapper we use to synchronously write to stderr in our logging on
the Mononoke Server side.

This should be fine because We send very little logs to the client, so just
buffering them seems like it won't really hurt, and even if we were writing a
log, it certainly would hurt less than blocking our runtime threads into an
interruptible wait.

A problem is that we actually use this in hgcli, where we want to read from our
stdin and write to our stdout / stderr. Rather than port all this stuff, this
diff updates hgcli to just use Tokio's abstractions for stdink, stdout, and
stderr. I ported the various buffer sizes we use to use there in here (I think
we should buffer less from the server though — 50000 buffers is a lot).

I did however update this to write to `std::io::stderr()` instead of an async
stream for this. I think it's fine considering:

- Internally, Tokio also uses `std:io::stderr()` which has a lock on writing.
- We hardly write anything anyway

Reviewed By: StanislavGlebik

Differential Revision: D23762062

fbshipit-source-id: c8d5330b0735d47b6de00e1a54aee4fed97db6b0
2020-09-24 06:58:34 -07:00
Stanislau Hlebik
f6d3fc1fd7 mononoke: bump the timeouts for getpack
Summary:
There were a few instances of timed out getpack requests on ovrsource.
Example: https://fburl.com/sandcastle/yylr1w3v
Let's bump the timeout to unblock them.

Reviewed By: krallin

Differential Revision: D23900374

fbshipit-source-id: 3ee6e2d4f6b6ed12cd0c1516c686a03c87fa7cb4
2020-09-24 06:23:23 -07:00
Stanislau Hlebik
5de500bb99 mononoke: passing LiveCommitSyncConfig all the way to CommitSyncer
Summary:
CommitSyncer is a struct that we use to remap a commit from one repo to another. It uses commit sync map to figure out which paths need to be changed. Commit sync mapping might change, and each commit sync mapping has a version associated with it.

At the moment CommitSyncer doesn't work correctly if a commit sync mapping is changed. Consider the following DAG

```
large repo

A' <- remapped with mapping V1
|
O  B' <- remapped with mapping V1
|  /
...

small repo

A
|
O  B
|  /
...
```

We have commit A and B from a small repo remapped into a large repo into commits A' and B'. They were remapped with commit sync mapping V1, which for example remaps files in "dir/" into "smallrepo/dir".

Now let's say we start to use a new mapping v2 which remaps "dir/" into "otherdir/". After this point every commit will be created with new mapping. But this is incorrect - if we create a commit on top of B in a small repo that touches "dir/file.txt" then it will be remapped into "otherdir/file.txt" in the large repo, even though every other file is still in "smallrepo/dir"!

The fix for this issue is to always use the same mapping as commit parent was using (there are a few tricky cases with merge commits and commits with no parents, but those will be dealt with separately).

This diff is the first step - it threads through LiveCommitSyncConfig all the way to the CommitSyncer object, so that CommitSyncer can always fetch whatever mapping it needs.

Reviewed By: ikostia

Differential Revision: D23845720

fbshipit-source-id: 555cc31fd4ce09f0a6fa2869bfcee2c7cdfbcc61
2020-09-24 05:58:24 -07:00
Stanislau Hlebik
0754074f63 mononoke: do not read common bookmarks from commit sync config
Summary:
Our current megarepo configuration is in a bit of a mess:
1) We have LiveCommitSyncConfig, which fetches the latest version of configs
from configerator and should be used in all cases
2) However we still have an old commit that's stored in mononoke config. It
shouldn't really be used at all.

Unfortunately there are a few places where #2 is still used. This diff removes
one of them.

Reviewed By: ikostia

Differential Revision: D23845297

fbshipit-source-id: aa2d591223cc4b8fe5ef264147457fcb3d1faad7
2020-09-24 03:31:45 -07:00
Xavier Deguillard
18c93e4ffd eden: use fmt::format instead of folly::to
Summary:
It looks like clang in mode/win choke on the code otherwise: P143369452. It's
definitively not clear to me why. Since fmt::format should pretty much
similarly to folly::to<std::string>, just use that instead.

Reviewed By: chadaustin, fanzeyi

Differential Revision: D23884978

fbshipit-source-id: f4a7e47169c8b78011340ec0a41871c9fa4b7181
2020-09-23 21:14:20 -07:00
Katie Mancini
fa180ad585 check multiple locations for x509 certs
Summary:
This stack updates eden to be able to check all of the locations that able
users certificate may reside.

There can be multiple places where a cert may reside (we cant always
definitively choose one place to look based on the platform). Thus we
need to be able to configure multiple locations for certs in our eden
config.

This makes the switch over in eden from using one place for the client
cert to use and using the first available client cert from a list.

NOTE: most of this diff is fixing unit tests take a look at `EdenConfig.h` and `EdenConfig.cpp` first

Reviewed By: wez

Differential Revision: D23359939

fbshipit-source-id: 44beecce3ef098a734dbd7c5eb3fa5f0aad6b50b
2020-09-23 19:58:52 -07:00
Zeyi (Rice) Fan
9041ed077a doctor: repair indexedlog data store when running doctor without a repo
Reviewed By: xavierd

Differential Revision: D23873218

fbshipit-source-id: e0999a4fd5bd6d53e9b28a8c9e175a995f92efa2
2020-09-23 17:51:57 -07:00
Meyer Jacobs
75105421ce edenapi: Hide edenapi wire types from externally visible API
Summary:
Introduce separate wire types to allow protocol evolution and client API changes to happen independently.

* Duplicate `*Request`, `*Entry`, `Key`, `Parents`, `RepoPathBuf`, `HgId`, and `revisionstore_types::Metadata` types into the `wire` module. The versions in the `wire` module are required to have proper `serde` annotations, `Serialize` / `Deserialize` implementations, etc. These have been removed from the original structs.
* Introduce infallible conversions from "API types" to "wire types" with the `ToWire` trait and fallible conversions from "wire types" to "API types" with the `ToApi`. API -> wire conversions should never fail in a binary that builds succesfully, but wire -> API conversions can fail in the case that the server and client are using different versions of the library. This will cause, for instance, a newly-introduced enum variant used by the client to be deserialized into the catch-all `Unknown` variant on the server, which won't generally have a corresponding representation in the API type.
* Cleanup: remove `*Response` types, which are no longer used anywhere.
* Introduce a `map` method on `Fetch` struct which allows a fallible conversion function to be used to convert a `Fetch<T>` to a `Fetch<U>`. This function is used in the edenapi client implementation to convert from wire types to API types.
* Modify `edenapi_server` to convert from API types to wire types.
* Modify `edenapi_cli` to convert back to wire types before serializing responses to disk.
* Modify `make_req` to use `ToWire` for converting API structs from the `json` module to wire structs.
* Modify `read_res` to use `ToApi` to convert deserialized wire types to API types with the necessary methods for investigating the contents (`.data()`, primarily). It will print an error message to stderr if it encounters a wire type which cannot be converted into the corresponding API type.
* Add some documentation about protocol conventions to the root of the `wire` module.

Reviewed By: kulshrax

Differential Revision: D23224705

fbshipit-source-id: 88f8addc403f3a8da3cde2aeee765899a826446d
2020-09-23 17:27:08 -07:00
Arun Kulshreshtha
a745a145b1 edenapi: optionally print log messages
Summary: Add log messages for debugging using the `tracing` crate, which allows them to be enabled via `env_logger`.

Reviewed By: quark-zju

Differential Revision: D23858076

fbshipit-source-id: a8ef1afac6c9ecbfb5d6d78232aa0d03a2fe2054
2020-09-23 17:19:28 -07:00
Arun Kulshreshtha
613fbc858f hg-http: optionally print stats
Summary: Log HTTP stats to stderr to assist with ad-hoc debugging. Will not be printed unless `RUST_LOG` is set appropriately.

Reviewed By: quark-zju

Differential Revision: D23858077

fbshipit-source-id: 39acf3de3fd0ca4403a986eb5373a6a79f1d004a
2020-09-23 17:19:28 -07:00
Arun Kulshreshtha
31ceb7f0d1 hg-http: use autocargo
Summary: Onboard the crate onto autocargo.

Reviewed By: quark-zju

Differential Revision: D23858075

fbshipit-source-id: 7179ae0f9ca8a1d4e664d7eb5cb614940e2b2c30
2020-09-23 16:40:49 -07:00
Jun Wu
2f5752eda5 util: raise with traceback in Python 2
Summary: Similar to D23819023 (c96de76ac0) but works on Python 2, too.

Reviewed By: DurhamG

Differential Revision: D23858273

fbshipit-source-id: b15be07c8657bc8cb37960b631f2b31e4a78892b
2020-09-23 12:37:44 -07:00
Xavier Deguillard
f7ea4e2747 inodes: fix signed comparison warning
Summary:
These shows up on Windows when building with mode/win, silencing them is easy,
so let's do it.

Reviewed By: wez

Differential Revision: D23871727

fbshipit-source-id: 7d7ea9504c397b72903e98967188a5295f2f1040
2020-09-23 12:20:42 -07:00
Xavier Deguillard
695c24f493 fs: ifdef linux/macos only files
Summary:
These don't compile on Windows, and in order to get mode/win to compile, we
need to avoid compiling their contents. Ideally, we could do that in the
TARGETS files with the select statement, but that's not available in fbcode.
Thus, we do the next best thing: ifdef the file entirely.

Reviewed By: wez

Differential Revision: D23871728

fbshipit-source-id: b4d9df6503eaa008e649afd7bdc665cd37a9585d
2020-09-23 12:20:41 -07:00
Durham Goode
58667a3fe7 tests: fix test-commitcloud-sync.t and test-common-commands-fb.t
Summary:
test-commitcloud-sync.t is a new change and just needs to be made cross
platform.

I have no idea how test-common-commands-fb.t ever worked.  When HGRCPATH is set,
I expect the system hgrc to not be loaded, and therefore we can't run hg-clone.
Let's just unset it, since this is meant to test if the new Mercurial can
execute a clone. Ideally we'd redirect the system hgrc to the in-repo
staticfiles, but that's more effort.

Reviewed By: singhsrb

Differential Revision: D23869645

fbshipit-source-id: 66669d9fd9c3a23b01bc43b365723185b7b2ed33
2020-09-23 10:58:19 -07:00
Wez Furlong
1c716a1575 edenfs: fixup PathMap copy and move ctor for case sensitivity
Summary:
*shakes fist at C++ copy-constructors*

We weren't guaranteeing that case-insensitive status was being propagated on
copies or moves, which meant that eg: `lookup("workspace")` would be treated as
case-sensitive when mounted case insensitively.

Reviewed By: xavierd

Differential Revision: D23857218

fbshipit-source-id: 67e33a8455a0a85e5885389b5bb38b20ef043894
2020-09-23 09:46:57 -07:00
Xavier Deguillard
65a19aadfe inodes: always include SqliteOverlay.h
Summary: This can be included in all the supported platforms, thus don't #ifdef it.

Reviewed By: wez

Differential Revision: D23858664

fbshipit-source-id: e61da33a97d87cbfab5bb96d2bdaa865d2c01801
2020-09-23 09:43:35 -07:00
Xavier Deguillard
4c2019197a prjfs: add TARGETS file
Summary:
This enables autodeps, and brings us one step closer to building EdenFS with
Buck on Windows.

Reviewed By: fanzeyi

Differential Revision: D23857794

fbshipit-source-id: c8587a6f7b9e4d9575a62f592c1d0737dff2a8f0
2020-09-23 09:43:35 -07:00
Xavier Deguillard
eaa270730f inodes: move prjfs/EdenDispatcher to inodes/
Summary:
Now that prjfs/EdenDispatcher is no longer directly tied to ProjectedFS (sort
of, this is still a bit WIP), we can move it out of the prjfs directory onto
the inodes one. This allows breaking the circular dependency cycle mentioned in
the previous diff where prjfs and inodes depend on each other.

For now, this is merely a copy/paste of the code enclosed in big #ifdef _WIN32,
we might be able to do better later, but for now this is properly good enough.

Reviewed By: wez

Differential Revision: D23857539

fbshipit-source-id: 77c620bac1656d01d7daee4dbf8b10694a589751
2020-09-23 09:43:34 -07:00
Xavier Deguillard
3291feac91 prjfs: add an abstract Dispatcher class
Summary:
If we are to look at the dependency graph for EdenFS on Windows, we would
notice that the eden_prjfs target depends on eden_inodes, and vice versa,
causing a cycle. While CMake is perfectly happy with that, Buck doesn't like
that. The solution to removing this cycle is to move the code that needs the
dependency to eden_inodes into the eden_inodes target, and that's the
EdenDispatcher. However, since PrjfsChannel needs to hold a dispatcher to call
into it, it needs to know the methods exposed by the dispatcher. To achieve
this, a simple abstract class is added, this is the same as what is done for
FUSE.

Reviewed By: wez

Differential Revision: D23857540

fbshipit-source-id: c495c67d43724f648e5ffa17776e4d5d4513698a
2020-09-23 09:43:34 -07:00
Xavier Deguillard
d75fdba6ae win: remove folly/Format.h dependency
Summary: The Windows code is now free of sformat, and only depends on fmt::format.

Reviewed By: fanzeyi

Differential Revision: D23786940

fbshipit-source-id: 4c9d4a8c30e5a3d5eb7971cdc3139539c5893a8d
2020-09-23 09:43:34 -07:00
Xavier Deguillard
ec9241415b win: remove unecessary PrjfsRequestContext.h from EdenDispatcher.cpp
Summary:
Now that all the logic is in PrjfsChannel.cpp, this header no longer needs to
be included. This helps in making this file as free as possible from Windows
specific bits which will allow it to be moved into the inodes top level
directory.

Reviewed By: fanzeyi

Differential Revision: D23786941

fbshipit-source-id: a4a3a47ea00808ca7a839709068efab06436167f
2020-09-23 09:43:34 -07:00
Xavier Deguillard
36f4a1246a inodes: thread an ObjectFetchContext in getInode()
Summary:
Most of the non-tests callers have an ObjectFetchContext available, let's use
it instead of a static null context. This will help in understanding why some
files/trees are being fetched.

Reviewed By: chadaustin

Differential Revision: D23745752

fbshipit-source-id: b2e145d9e559bde0542adbc5b20ff56ccfc59ece
2020-09-23 09:43:34 -07:00
Xavier Deguillard
77ab04daf2 win: thread the request context to readdir
Summary:
This allows removal of a NullContext which will provide more details as to why
fetches are triggered.

Reviewed By: chadaustin

Differential Revision: D23745755

fbshipit-source-id: c26f648b8695b86caf8fe15c4bc6c4128d345aa1
2020-09-23 09:43:34 -07:00
Xavier Deguillard
436a847a79 win: make read callback fully asynchronous
Summary:
Similarly to the other callbacks, this makes the main function return to
ProjectedFS as soon as the future is created which will allow for it to be
interrupted in a subsequent diff.

Reviewed By: fanzeyi

Differential Revision: D23745754

fbshipit-source-id: 2d77d0eacfe0d37eb9075bf9f0660e4f4af77e8f
2020-09-23 09:43:34 -07:00
Xavier Deguillard
495cc257b4 win: make EdenDispatcher::read asynchronous
Summary:
This merely moves Windows bits outside of the EdenDispatcher and into the
PrjfsChannel, making the former less dependant on Windows, and paving the way
to handling this callback fully asynchronous.

One caveat currently is that while the callback supports specifying an offset
and length, the underlying backing store only allows reading the entire file at
once, thus these arguments are simply ignored in the dispatcher.

Reviewed By: fanzeyi

Differential Revision: D23745753

fbshipit-source-id: 266e1f448f9db536d746da1462a2a590ffad19a6
2020-09-23 09:43:34 -07:00
Liubov Dmitrieva
c5328d9d0e move some operations under read path
Summary:
Move some commit cloud operations under infinitepush read path:

those are:
*  `hg cloud check` command
*  `hg cloud sync` command when the local repo is clean
* `hg cloud switch` command will normally use the read path for the dest workspace because we clean up the repo before performing the switch
*  `hg cloud rejoin` command we use in fbclone will normally go through the read path as it runs in a fresh repo

If something is broken, there is always a way to rerun any of these command with '--dest' flag pointing it to the write path.

```
./hg cloud check -r 0c9596fd1 --remote --dest infinitepush-write
./hg cloud sync --dest infinitepush-write
./hg cloud switch -w other --dest infinitepush-write
```

Those use cases are limited and the lag of forward filler shouldn't be noticeable for them but we will be able to collect more signal how Mononoke performs with Commit Cloud.

Sitevar to control the routing of read traffic:
https://www.internalfb.com/intern/sv/HG_SSH_WRAPPER_MONONOKE_ROLLOUT/#revisions_list

Reviewed By: mitrandir77

Differential Revision: D23840914

fbshipit-source-id: 40fbe2e72756e7a4cf8bc5be6a0b94f6cf4906b4
2020-09-23 08:42:13 -07:00
Lukas Piatkowski
eea2b564a8 mononoke/s3blob: remove it from OSS (#62)
Summary:
Pull Request resolved: https://github.com/facebookexperimental/eden/pull/62

This diff fixes OSS Mononoke build.

Reviewed By: HarveyHunt

Differential Revision: D23852016

fbshipit-source-id: 90371149a3566efdd5653b4ba5098dad81357ef2
2020-09-23 06:38:03 -07:00
Stanislau Hlebik
a47464f60d mononoke: remove create_commit_syncer_from_matches
Summary:
At the moment CommitSyncConfig can be set in two ways:
1) Set in the normal mononoke config. That means that config can be updated
only after a service is restarted. This is an outdated way, and won't be used
in prod.
2) Set in separate config which can be updated on demand. This is what we are
planning to use in production.

create_commit_syncer_from_matches was used to build a CommitSyncer object via
normal mononoke config (i.e. outdated option #1). According to the comments it
was done so that we can read configs from the disk instead of configerator, but
this doesn't make sense because you already can read configerator configs
from disk. So create_commit_syncer_from_matches doesn't look particularly
useful, and besides it also make further refactorings harder. Let's remove it.

Reviewed By: ikostia

Differential Revision: D23811090

fbshipit-source-id: 114d88d9d9207c831d98dfa1cbb9e8ede5adeb1d
2020-09-23 04:30:41 -07:00
Jun Wu
1b7c3b6a13 localrepo: cache headnodes instead of headrevs
Summary:
With segmented changelog backend, the revs can be changed, even if len(repo)
didn't change. Caching revs might not get invalidated properly. Let's cache
head nodes instead.

Reviewed By: DurhamG

Differential Revision: D23856176

fbshipit-source-id: c5154c536298c348b847a12de8c4f582f877f96e
2020-09-22 18:11:05 -07:00
Genevieve Helsel
1b5807f7bd log prefetch_profile fetches independent of log-object-fetch-path logging
Reviewed By: kmancini

Differential Revision: D23793270

fbshipit-source-id: 9917d212622c027e8dc0cdc1250c0bc0233f547b
2020-09-22 15:35:22 -07:00
Jun Wu
27f4f7e94c test-commitcloud-sync: fix test on Ubuntu
Summary:
On Ubuntu the output is a bit different:

```
   $ hg cloud sync --use-bgssh
   commitcloud: synchronizing 'server' with 'user/test/default'
-  remote: /bin/sh: trashssh: command not found
-  abort: no suitable response from remote hg!
+  remote: /bin/sh: 1: trashssh: not found
+  abort: no suitable response from remote hg: '[Errno 32] Broken pipe'!
```

Glob them out to make the test pass.

Reviewed By: DurhamG

Differential Revision: D23824735

fbshipit-source-id: 7f96149ee16daff31fd0a1c68975b5edfa27cc46
2020-09-22 15:21:56 -07:00
Jun Wu
bcbacfebf4 dispatch: ensure SIGINT triggers KeyboardInterrupt
Summary:
It seems OSX python2 has SIGINT handler set to SIG_IGN by default when running
inside tests. Detect that and reset SIGINT handler to raise KeyboardInterrupt.

This fixes test-ctrl-c.t on OSX.

As we're here, improve test-ctrl-c.t so it checks a bit more things and run
quicker.

Reviewed By: DurhamG

Differential Revision: D23853455

fbshipit-source-id: 05c47650bc80f9880f724828d307c32786265e2c
2020-09-22 15:10:12 -07:00
Kostia Balytskyi
c56f417c60 commit_rewriting: add new CommitSyncOutcome queries
Summary:
There's a [flaw](https://fb.workplace.com/groups/scm.mononoke/permalink/1220069065022333) in the current `synced_commit_mapping` data model. In a nutshell, the flaw is in the assumption that the `RewrtittenAs` relationship is `1:1`, while in fact it is `1:n` with `n` on the large repo side.

To address this flaw I propose to:
- relax the DB constraints to represent the semantically correct model
- select all the synced candidates from the DB
- for places in code, which require a single mapping for a candidate, use the provided hint to resolve any ambiguity

More concretely:
- instead of a single `CommitSyncOutcome` struct, I propose to have the "canonical" `PluralCommitSyncOutcome` and the "resolved" `CommitSyncOutcome`
- every variant of `PluralCommitSyncOutcome` that is not `RewrittenAs` just maps to an identical variant of `CommitSyncOutcome`
- have a `CandidateSelectionHint` passed from the clients, which would help resolve `PluralCommitSyncOutcome::RewrittenAs` into a `CommitSyncOutcome::RewrittenAs`
- if the hint does not help to resolve `PluralCommitSyncOutcome::RewrittenAs` into an unambiguous `CommitSyncOutcome::RewrittenAs`, just fail the request and require human intervention to deal with things
- within the hint, have for the following variants for the resolution algorithm:
  - `Only` which fails the resolution if there's more than one candidate
  - `Exact` behaves like `Only` if there's one candidate, otherwise selects a provided candidate
  - `OnlyOr(Ancestor|Descendant)Of(Commit|Bookmark)` behave like `Only` if there's one candidate, otherwise select a candidate in the expected topological relationship

Note some important decisions, that may be surprising at first:
- if there's just one candidate, resolutions with all types of hints succeed, even if this candidate does not fit the hint otherwise (for example, if the hint is `Exact(A)`, and the list of candidates is `[B]`, the resolution succeeds.
- for bookmark-related hints, if the bookmark does not exist at the time of resolution, the hint just "downgrades" itself to be `Only`

Both of these emphasize the fact that if the mapping has only one `RewrittenAs` candidate for a given changeset, the behavior does not change.

Reviewed By: StanislavGlebik

Differential Revision: D23670180

fbshipit-source-id: 1cee1f65fc8020e0ae8a7da789b2532d2e436b77
2020-09-22 10:27:27 -07:00
Alex Hornby
d107b28d52 mononoke: SomeFailedOthersNone should not consider write mostly blobstores None if all other stores Error
Summary: SomeFailedOthersNone should not consider write mostly blobstores None if all other stores Error

Reviewed By: farnz

Differential Revision: D23840334

fbshipit-source-id: 9838bead6fec0d5f920e4a788387025d0dacf80b
2020-09-22 09:35:38 -07:00
Alex Hornby
d3a94e0a70 mononoke: Add a test for SomeFailedOthersNone when write mostly blobstore is None
Summary: Add a test for SomeFailedOthersNone when write mostly blobstore is None

Reviewed By: farnz

Differential Revision: D23840685

fbshipit-source-id: 81834663169b3a522b9c08e0a36f0b91354916c7
2020-09-22 09:35:38 -07:00
Xavier Deguillard
a4f6a1abe0 prjfs: move win/mount into prjfs
Summary:
Now that the win directory only contains the mount directory, we can rename it
to be more faithful to its intent. Since this is about ProjectedFS, let's
rename it "prjfs".

Reviewed By: chadaustin

Differential Revision: D23828561

fbshipit-source-id: cb31fe4652fd4356dc2579028d3ae2c7935371a7
2020-09-22 09:09:56 -07:00
Xavier Deguillard
c6b9788af8 win: move win/utils onto utils/
Summary: This will make it easier to build with Buck.

Reviewed By: fanzeyi

Differential Revision: D23827754

fbshipit-source-id: bf3bf4d607a08b9831f9dfea172b2e923a219561
2020-09-22 09:09:56 -07:00
Xavier Deguillard
65d98e2b30 sqliteoverlay: add the proper dependencies to it
Summary:
Now that sqliteoverlay has a TARGETS file, we can remove the manual, and use
autodeps to have the right dependencies in the TARGETS files. This will help in
getting EdenFS to build on Windows with buck.

Reviewed By: chadaustin

Differential Revision: D23820312

fbshipit-source-id: 34bfd13d2ae6d11a404a9b913562c7d45a4b3de7
2020-09-22 09:09:56 -07:00
Mark Thomas
ee0299cda0 phabstatus: batch peekahead for smartlog
Summary:
Phabstatus for smartlog uses `PeekeaheadList` rather than `PeekaheadRevsetIterator` as
all of the commits are known ahead of time, and we don't need to collect together
batches as we iterate across the revset.

However, we should still batch up requests to Phabricator, as users with very high
numbers of commits in their smartlog may hit timeouts.

Add a batching mechanism to `PeekaheadList` that splits the list into chunks to
return with each peekahead.

Reviewed By: liubov-dmitrieva

Differential Revision: D23840071

fbshipit-source-id: 68596c7eb4f7404ce6109e69914f328565e34582
2020-09-22 07:26:18 -07:00
Liubov Dmitrieva
c68e928d6f add --fource option to hg cloud backup command to reinitialise the local cache of backed up heads from the server
Summary:
This provides a way to fix the local cache of backed up heads if it is in an
invalid state.

The most important, it will allow early dogfooding of write traffic from Mononoke
without the reverse filler in place for developers or for the team.

You could just run `hg cloud backup -f` assuming the repo is backfilled to fix
any inconsistency when switch between the two backends

Reviewed By: markbt

Differential Revision: D23840162

fbshipit-source-id: bbd331162d65ba193c4774e37324f15ed0635f82
2020-09-22 07:12:28 -07:00
Stanislau Hlebik
9e05331b1c mononoke: add validation subcommand for megarepo tooling
Summary:
Let's add a command that validates that the created catchup commit is correct.
For now it validates that unodes are the same between catchup commit and commit
that we are merging in.

Later we can add more invariants that we want to check.

Reviewed By: krallin

Differential Revision: D23782369

fbshipit-source-id: 61d19aa73777d5fbb3e1b127bdcf39f5e6309b52
2020-09-22 06:10:39 -07:00
Alex Hornby
d3a32701a6 mononoke: add error context to file content scrub
Summary: Add error context to file content scrub so that we can tell if an Error has propagated via the scrub stream loading.

Reviewed By: StanislavGlebik

Differential Revision: D23838144

fbshipit-source-id: 40a8a090510959cab1020182c19076b8a3317b1b
2020-09-22 05:26:23 -07:00
Egor Tkachenko
4d0ae8ae41 Added S3 blobstore
Summary:
Implemented S3 blobstore
Isilon implements S3 as 1:1 mapping into filesystem, and it limits the maximum number of blobs in the single directory. To overcome it lets shard the keys using base64 encoding and making 2 level dir structure with 2 chars dir names.

Reviewed By: krallin

Differential Revision: D23562541

fbshipit-source-id: c87aca2410381a07babb191cbd8cf28233556e03
2020-09-22 04:15:34 -07:00
Mark Thomas
c55cb1914a cmdutil: ensure rust graph renderer messages are unicode
Summary:
For Python 3 we must ensure that the displayer messages have all been converted
to unicode before providing them to the Rust graph renderer.

The is because the Python 3 version of `encoding.unifromlocal` is a no-op, so
the result may still be `bytes` that need to be converted to `str`.

Reviewed By: quark-zju

Differential Revision: D23827233

fbshipit-source-id: 8f2b707ceceb210c0a2b5b589b99d4016452c61c
2020-09-22 04:04:12 -07:00
Durham Goode
737c07ca24 tests: fix test-fb-hgext-extutil.py on OSX
Summary:
D23759711 (be51116cf4) changed the way signal handlers work, which apparently causes
this test to fail. The SIGCHLD signal of the child changing state is received
during os.waitpid, which apparently counts as a signal during a system call,
which throws an OSError.

I'm not sure what the real fix should be. Sleeping gets us past the issue, since
presumably the signal is handled before the system call.

Reviewed By: quark-zju

Differential Revision: D23832606

fbshipit-source-id: 70fca19e419da55bbf546b8530406c9b3a9a6d77
2020-09-22 03:37:28 -07:00
Viet Hung Nguyen
d94fae3c4d mononoke/repo_import: add check for additional setup steps
Summary:
When running the repo import tool, it's possible that we need to do additional setup steps before being able to run the tool, which otherwise would only come up when we run it.
Firstly, if the repo we import into doesn't have a callsign (e.g. FBS, WWW...), but we want to check Phabricator, our tool would hang when checking Phabricator, because we need the callsign for checking. Therefore, we need to inform the user to set the callsign for the repo.
Secondly, in case the repo push-redirects to a larger repo, we generate a bookmark for the commits imported into the large. However, we need to inform the Phabricator team to include the large repo's bookmark before we can import the commits, because this bookmark publishes the imported commits on Phabricator.
This diff adds a subcommand to check these additional steps, so we wouldn't find these out during the actual import run.

Reviewed By: StanislavGlebik

Differential Revision: D23783462

fbshipit-source-id: 3cdf4035548213d8cee9717fb985c22741a6749b
2020-09-22 01:24:10 -07:00
Stanislau Hlebik
ff6237ba4a mononoke: refactor cross_repo_sync_test a bit
Summary:
In the later diffs we are going to change how CommitSyncer is initialized. In
order to make it simpler let's refactor cross_repo_sync_test to move
CommitSyncer creation in a single function.

There are a few tests that have very peculiar initialization - for example they
have movers that fail. For those tests I combined the new function for creation
of CommitSyncer with manual initialization of CommitSyncRepos struct.

Reviewed By: krallin

Differential Revision: D23811507

fbshipit-source-id: 682ab30aa09c9189fcd02850a19f1ddf021c0329
2020-09-22 01:13:28 -07:00
Jun Wu
ebf708e17a pyedenapi: switch to async_runtime::block_on_future
Summary:
This simplifies the code a bit, and avoids creating tokio Runtime multiple
times.

Reviewed By: kulshrax

Differential Revision: D23799642

fbshipit-source-id: 21cee6124ef6f9ab6e165891d9ee87b2feb553ac
2020-09-21 13:28:07 -07:00
Jun Wu
186151e8f9 pyedenapi: return commit data in a stream fashion
Summary:
Exercises the PyStream type from cpython-async.

`hg dbsh`:

  In [1]: s,f=api._rustclient.commitdata('fbsource', list(repo.nodes('master^^::master')))

  In [2]: s
  Out[2]: <stream at 0x7ff2db700690>

  In [3]: it=iter(s)

  In [4]: next(it)
  Out[4]: ('6\xf9\x18\xe4\x1c\x05\xfc\xb0\xd3\xb2\xe9\xec\x18E\xec\x0f\x1a:\xb7\xcd', ...)

  In [5]: next(it)
  Out[5]: ('}\x1f(\xe1o\xf1a\x9b\x81\xb9\x83}\x1b\xbbt\xd2e\xb1\xedb',...)

  In [6]: next(it)
  Out[6]: ('\xf1\xf0f\x97<\xf3\xdd\xe41w>\x92\xd1\xc0\x9ah\xdd\x87~^',...)

  In [7]: next(it)
  StopIteration:

  In [8]: f.wait()
  Out[8]: <bindings.edenapi.stats at 0x7ff2e006a3d8>

  In [9]: str(Out[8])
  Out[9]: '2.42 kB downloaded in 165 ms over 1 request (0.01 MB/s; latency: 165 ms)'

  In [10]: iter(s)
  ValueError: stream was consumed

Reviewed By: kulshrax

Differential Revision: D23799645

fbshipit-source-id: 732a5da4ccdee4646386b6080408c0d8958dd67f
2020-09-21 13:28:07 -07:00
Jun Wu
cd7f831c6c pyedenapi: return a Future of Stats for commitdata
Summary:
Exercises the PyFuture type from cpython-async.

`hg dbsh`:

    In [1]: api._rustclient.commitdata('fbsource', list(repo.nodes('master^^::master')))
    Out[1]:
    ([...], <future at 0x7f7b65d05060>)

    In [2]: f=Out[1][-1]

    In [3]: f.wait()
    Out[3]: <bindings.edenapi.stats at 0x7f7b665e8228>

    In [4]: f.wait()
    ValueError: future was awaited

    In [5]: str(Out[3])
    Out[5]: '2.42 kB downloaded in 172 ms over 1 request (0.01 MB/s; latency: 171 ms)'

Reviewed By: kulshrax

Differential Revision: D23799643

fbshipit-source-id: d4fcef7dca58bc4902bb0809adc065493bb94bd3
2020-09-21 13:28:07 -07:00
Jun Wu
7f1c05dd74 cpython-async: expose Rust Future to Python
Summary:
Add a `PyFuture<F>` type that can be used as return type in binding function.
It converts Rust Future to a Python object with an `await` method so Python
can access the value stored in the future.

Unlike `TStream`, it's currently only designed to support Rust->Python one
way conversion so it looks simpler.

Reviewed By: kulshrax

Differential Revision: D23799644

fbshipit-source-id: da4a322527ad9bb4c2dbaa1c302147b784d1ee41
2020-09-21 13:28:07 -07:00
Jun Wu
41b200c8d8 cpython-async: expose Rust Stream to Python
Summary:
The exposed type can be used as a Python iterator:

  for value in stream:
      ...

The Python type can be used as input and output parameters in binding functions:

  # Rust
  type S = TStream<anyhow::Result<X>>;
  def f1() -> PyResult<S> { ... }
  def f2(x: S) -> PyResult<S> { Ok(x.stream().map_ok(...).into()) }

  # Python
  stream1 = f1()
  stream2 = f2(stream1)

This crate is similar to `cpython-ext`: it does not define actual business
logic exposed by `bindings` module. So it's put in `lib`, not
`bindings/modules`.

Reviewed By: markbt

Differential Revision: D23799641

fbshipit-source-id: c13b0c788a6465679b562976728f0002fd872bee
2020-09-21 13:28:07 -07:00
Jun Wu
71e99bf8e7 dispatch: run ipdb in the command thread
Summary:
See the previous diff for context.  Move the error handling and ipdb logic to
the background thread so it can show proper traceback.

Reviewed By: kulshrax

Differential Revision: D23819022

fbshipit-source-id: 8ddae019ab939d8fb2c89afca2a7769094ebe26a
2020-09-21 13:15:15 -07:00
Jun Wu
c96de76ac0 util: set traceback if error happens in threaded execution
Summary:
With D23759710 (34d8dca79a), the main command was moved to a background thread, but the
error handling isn't. That can cause less useful traceback like:

  Traceback (most recent call last):
    File "dispatch.py", line 698, in _callcatch
      return scmutil.callcatch(ui, func)
    File "scmutil.py", line 147, in callcatch
      return func()
    File "util.py", line 4358, in wrapped
      raise value

Set `e.__traceback__` so `raise e` preserves the traceback information.
This only works on Python 3. On Python 2 it is possible to use
`raise exctype, excvalue, tb`. But that's invalid Python 3 code. I'm
going to fix Python 2 traceback differently.

Reviewed By: kulshrax

Differential Revision: D23819023

fbshipit-source-id: 953ac8bd6108f4c0dae193607bee3f931c2bd13e
2020-09-21 13:15:15 -07:00
Jun Wu
15fb0f4f51 util: fix mtime used in gcdir
Summary:
The parameter `mtimethreshold` should be used instead of a constant of 14 days.
This fixes an issue where sigtrace output takes a lot of space in hg rage
output.

Reviewed By: DurhamG

Differential Revision: D23819021

fbshipit-source-id: e639b01d729463a4822fa93604ce3a038fbd4a9a
2020-09-21 13:15:15 -07:00
Liubov Dmitrieva
2b0829b9f5 fix ussue with incorrent update reference request in some cases
Summary:
filter returns a filter object, so the second time we iterate, it is empty

This is only in Python3 I believe, so migration to py3 broke it.

Reviewed By: markbt

Differential Revision: D23815206

fbshipit-source-id: 1a6503b2bbfd44959307c189d17dec9b5d5ff991
2020-09-21 13:15:15 -07:00
Xavier Deguillard
e2a4bcf917 tests: enable all doctor tests on Windows
Summary:
Now that `hg whereami` properly reads the SNAPSHOT file on Windows, the doctor
tests properly detect that Mercurial and EdenFS disagree about the current
commit, thus we can enable the remaining 2 tests.

Reviewed By: genevievehelsel

Differential Revision: D23819924

fbshipit-source-id: 21be19aff913e5e485d72e8cd730e6851ecaba2e
2020-09-21 13:12:11 -07:00
Durham Goode
63d19e1eca workers: bulk fetch data in worker thread
Summary:
During an hg update we first prefetch all the data, then write all the
data to disk. There are cases where the prefetched data is not available during
the writing phase, in which case we fall back to fetching the files one-by-one.
This has truly atrocious performance.

Let's allow the worker threads to check for missing data then do bulk fetching
of it. In the case where the cache was completely lost for some reason, this
would reduce the number of serial fetches by 100x.

Note, the background workers already spawn their own ssh connection's, so
they're already getting some level of parallelism even when they're doing 1-by-1
fetching. That's why we aren't seeing a 100x improvement in performance.

Reviewed By: xavierd

Differential Revision: D23766424

fbshipit-source-id: d88a1e55b1c21e9cea7e50fc6dbfd8a27bd97bb0
2020-09-21 11:27:12 -07:00
Lukas Piatkowski
0f8e20df5b mononoke/integration tests: fix returning different output in OSS cases in tests (#60)
Summary:
Pull Request resolved: https://github.com/facebookexperimental/eden/pull/60

For the tests that output different data to stdout in OSS vs FB create helpers that remove the differences.

Reviewed By: farnz

Differential Revision: D23814134

fbshipit-source-id: c6656528021c9a90b98e3c89a9bbe8c5178c6919
2020-09-21 09:39:18 -07:00
Mark Thomas
2600860e69 scsc: implement land-stack and test stack landing via the service
Summary:
Add `scsc land-stack` to facilitate testing of stack landing via the source control service.
Use this to test that landing of stacks works.

Reviewed By: aslpavel

Differential Revision: D23813366

fbshipit-source-id: 1f7b682fa5e33a232cb1da5c702a703223658942
2020-09-21 08:39:13 -07:00
Mark Thomas
78b943019a mononoke_api: most bookmark movements errors are request errors
Summary:
Update the conversion of `BookmarkMovementError` to `MononokeError` to reflect
that most movement errors are caused by invalid requests.

Reviewed By: aslpavel

Differential Revision: D23814794

fbshipit-source-id: 48503353aaae7b3cd03e5221a8ad014eef2e9414
2020-09-21 08:39:12 -07:00
Mark Thomas
644aaa75a7 scs_server: implement repo_land_stack
Summary:
Implement the `repo_land_stack` method by working out which commits are in the
stack to be landed, and then pushrebasing them onto the target bookmark.

Reviewed By: aslpavel

Differential Revision: D23813370

fbshipit-source-id: babe34f0e9f1db055adb2e5d1debefd8ebcf6f86
2020-09-21 08:39:12 -07:00
Mark Thomas
c6a7a35c2a scs_server: add AsyncIntoResponseWith trait
Summary:
Sometimes the `AsyncIntoResponse` trait needs additional data (e.g. the set of commit
identity schemes the client is interested in) to convert the item into the response
type.

Currently we use a tuple of `(item, &additional_data)` to work around this, however
this will become less readable as we add new items with more additional data.

Split this use-case out into a new trait: `AsyncIntoResponseWith`.  This defines
an associated type which is the type of the additional data needed, and provides a
new method `into_response_with`, where a reference to the additional data can be
provided.

Note that conversions for tuple types that are logical `(name, value)` or `(id,
value)` pairs are still ok.  It is specifically the case where we have `(item,
&additional_data)` that we are converting here (i.e. the additional data merely
informs the conversion, it is not part of the resulting response value).

Reviewed By: aslpavel

Differential Revision: D23813371

fbshipit-source-id: c0dcfe826288ad53ad572ae4dd956540605998f5
2020-09-21 08:39:12 -07:00
Mark Thomas
b6a6882d10 improve error messages for mapping length errors
Summary: Make it clear which error is which, and what the number of expected and actual items are.

Reviewed By: StanislavGlebik

Differential Revision: D23813369

fbshipit-source-id: 5b94c5a67438c475235876669ec2be3fd1866700
2020-09-21 08:39:12 -07:00
Alex Hornby
779c42d5c0 mononoke: intern ids to reduce space used
Summary: Intern ids to reduce space used in the walk state.  This is significant on large repos.

Reviewed By: farnz

Differential Revision: D23691524

fbshipit-source-id: b42f926d88083d06ffc44508db44747f9a14e0a5
2020-09-21 06:26:28 -07:00
Stanislau Hlebik
58160ae16c mononoke: add a --wait-secs parameter to catchup-head-delete subcommand
Reviewed By: ikostia

Differential Revision: D23812854

fbshipit-source-id: 6225072b3aa25c2054ffae6d0ec37d8c7ef04763
2020-09-21 06:07:57 -07:00
Stanislau Hlebik
4d46a332f6 mononoke: remove unnecessary option from into_push_redirector
Summary:
Passing option is not necessary since live_commit_sync_config is always
available.

Reviewed By: ahornby

Differential Revision: D23811021

fbshipit-source-id: ee11f88d57814d9abac8650e52febd9e431770da
2020-09-21 06:00:24 -07:00
Liubov Dmitrieva
584de33443 fix workspace name for fbclone
Summary:
Automigration gets messed up with `hg cloud rejoin` command in fbclone code because it triggered by the pull command.

As a result fbclone ends up to join a hostname workspace instead of the default for some cases.

* make sure that the migration never runs if background commit cloud operations are disabled
* also, add skip the migration in the pull command in fbclone

Once of those would be enough to fix the issue but I prefer to make both
changes.

Reviewed By: markbt

Differential Revision: D23813184

fbshipit-source-id: 3b49a3f079e889634e3c4f98b51557ca0679090b
2020-09-21 05:09:40 -07:00
Stanislau Hlebik
9fc2a01f0b mononoke: bump memcache key for blobstore
Summary:
I've re-backfilled some of blame values for configerator. But old values might
still be in memcache. To make sure that's not the case let's bump the memcache
key.

Reviewed By: krallin

Differential Revision: D23810971

fbshipit-source-id: c333a51ffb2babf7da808b276f9cfa31baaa105c
2020-09-21 01:47:01 -07:00
Durham Goode
7b4bbc2f64 revset: avoid full repo scan in children revset
Summary:
The children revset iterated over everything in the subset, which in
many cases was the entire repo. This can take hundreds of milliseconds. Let's
use the new _makerangeset to only iterate over descendants of the parentset.

Reviewed By: quark-zju

Differential Revision: D23794344

fbshipit-source-id: 9ac9bc014d56a95b5ac65534769389167b0f4508
2020-09-20 21:43:50 -07:00
Arun Kulshreshtha
683520106e edenapi: remove python wrapper
Summary:
Now that Mercurial itself can properly handle SIGINT, there isn't a need for a Python wrapper around the Rust EdenAPI client (since the main purpose of the wrapper was to ensure proper SIGINT handling--something that could only be done in Python).

Note that while this does remove some code that prints out certificate warnings, that code was actually broken after the big refactor of the Rust bindings. (The exception types referenced no longer exist, so the code would simple result in a `NameError` if it actually tried to catch an exception from the Rust client.)

Reviewed By: singhsrb

Differential Revision: D23801363

fbshipit-source-id: 3359c181fd05dbec24d77fa1b7d9c8bd821b49a6
2020-09-19 14:23:55 -07:00
Alex Hornby
4db4161974 mononoke: simplify walkers check that children are valid
Summary: Small change to make it more readable and reduce likelihood of allocation (although the collect might be optimized away anyway)

Reviewed By: farnz

Differential Revision: D23760762

fbshipit-source-id: 5c47352386de128b65052d63b3f3ff1081a462e3
2020-09-19 08:49:55 -07:00
Lukasz Piatkowski
e8098beff0 mononoke/integration tests: fix issue with missing dulwich for hggit ext (#59)
Summary: Pull Request resolved: https://github.com/facebookexperimental/eden/pull/59

Reviewed By: farnz

Differential Revision: D23783095

Pulled By: lukaspiatkowski

fbshipit-source-id: cb6a72ae3d8856a92945c28e4162c1808539206a
2020-09-19 05:47:30 -07:00
Arun Kulshreshtha
3078f346f8 gotham_ext: make StreamBody take an infallible byte stream
Summary: Make `StreamBody` accept a `Stream` of `Bytes` instead of a `TryStream` of `Bytes`. This means that applications returning streaming responses will be forced to deal with errors prior to returning the response.

Reviewed By: krallin

Differential Revision: D23780216

fbshipit-source-id: dbad61947ef23bbfc4edf3d286ad0218c1859d87
2020-09-18 22:49:55 -07:00
Arun Kulshreshtha
980406cea8 lfs_server: log errors from streaming responses
Summary:
Using the `EndOnErr` combinator introduced in the previous diff, log any errors that occur during a streaming response to stderr.

Note that **the intent of this diff is to implement the most basic possible example of doing something with these errors**, with the goal of allowing us to modify `StreamBody` to only accept infallible `Stream`s.

I'd imagine that in all likelihood we'd want to do something smarter with the errors than just print them, but I figure that can be added in later diffs since it seems like doing something else (like logging the error to Scuba or adding to the RequestContext) might require additional changes that are beyond the scope of this diff.

At the very least, this seems like an improvement from before, where these errors would just get passed straight through to Hyper.

Reviewed By: krallin

Differential Revision: D23780217

fbshipit-source-id: 2f885f9fdc6af3dd28d95be1daa1d82c732453fa
2020-09-18 22:49:55 -07:00
Arun Kulshreshtha
3435319e52 gotham_ext: add EndOnErr TryStream combinator
Summary: Add a new `EndOnErr` combinator for `TryStream`s (exposed via the `GothamTryStreamExt::end_on_err` method) which fuses the underlying `TryStream` upon hitting an error, and passes the error to the user-provided callback. This is useful for contexts like the LFS server, where mid-stream errors are considered unrecoverable and must result in termination of the response.

Reviewed By: krallin

Differential Revision: D23778490

fbshipit-source-id: 05caa52ca62d085cc63cc8feb4619188fe0fac61
2020-09-18 22:37:42 -07:00
Arun Kulshreshtha
71674d87c5 edenapi_server: log errors during streaming responses
Summary: Use the new `ForwardErr` stream combinator to log errors that occur during a streaming response. Right now, they are just printed to stderr, but in the future we should also do other things such as logging them to Scuba. This diff supersedes the approach from D22720957.

Reviewed By: krallin

Differential Revision: D23780215

fbshipit-source-id: 8d2267f1166e665a62a167a6d95bb0b1797b5767
2020-09-18 22:37:42 -07:00
Arun Kulshreshtha
7f803818ee gotham_ext: implement ContentMeta for ForwardErr
Summary: Implement `ContentMeta` for streams wrapped with the `ForwardErr` combinator, so that they may be used as input to `StreamBody`. (Presently, this won't actually work since `StreamBody` expects a `TryStream`, but this will change later in the stack.)

Reviewed By: krallin

Differential Revision: D23777842

fbshipit-source-id: 234bcdf104afbf2c9832fbe54d85744bfb470363
2020-09-18 22:37:42 -07:00
Arun Kulshreshtha
26ff321006 gotham_ext: add ForwardErr combinator for TryStreams
Summary:
This diff adds a new `ForwardErr` combinator that allows redirecting the errors from a `TryStream` into a channel, allowing them to be processed asynchronously without disrupting the stream itself. This effectively splits the `TryStream` into two `Stream`s containing the successful items and errors respectively.

To make it easy to use the combinator, I've added a new `GothamTryStreamExt` extension trait (in the vein of the old `futures_ext` crate) that allows the user to simply call `forward_err` on any `TryStream`. The trait name is a bit of a misnomer (suggestions welcome!) in that there isn't anything Gotham-specific about it, but the name `TryStreamExt` is taken and I didn't want to set up a successor to `futures_ext` just for the sake of one combinator. (Though we will likely expand the trait in the future.)

Reviewed By: krallin

Differential Revision: D23777501

fbshipit-source-id: 8628cdc2e104cd9b972afda745858f9cb9e85245
2020-09-18 22:37:42 -07:00
Jun Wu
34d8dca79a dispatch: run command in non-main thread
Summary:
This extends the Ctrl+C special handling from edenapi to the entire Python
command so Ctrl+C should be able to exit the program even if it's running
some blocking Rust functions.

`edenapi` no longer needs to spawn threads for fetching.

Reviewed By: singhsrb

Differential Revision: D23759710

fbshipit-source-id: cbaaa8e5f93d8d74a8692117a00d9de20646d232
2020-09-18 18:47:24 -07:00
Wez Furlong
b39f678b85 edenfs: remove use of fork from StartupLogger
Summary:
on macOS we cannot safely use `fork`.

This commit replaces the use of `fork` in the startup logger subsystem.
This was a little tricky to untangle; originally (prior to any of
the `fork` removal efforts in this diff stack), the startup flow was
to spawn a set of processes via fork:

```
edenfs (setuid)
 \-----edenfs (privhelper, as root)
  \------edenfs (daemonized)
```

The forked children take advantage of being able to implicitly pass state to
the child processes from the parent.  That data flow needs to become explicit
when removing the fork which makes some things a little awkward.

With fork removed:

* `edenfs` unconditionally spawns `edenfs_privhelper` while it has
  root privs and before most of the process has been initialized.
* That same `edenfs` process will then spawn a child `edenfs`
  process which starts from scratch, but that which needs to
  run as the real server instance
* The original `edenfs` instance needs to linger for a while
  to remain connected to the controlling tty to pass back the
  startup state to the user, before terminating.

This commit deletes the check that `edenfs` is started originally
as root; previously the logic relied on the forked startup logger
continuing past the `daemonizeIfRequested` call and simply deferring
the check until after folly::init.  With these changes we can't
easily perform such a check without adding some extra gymnastics
to pass the state around; the place where that is checked is in
the spawned child of the original edenfs, which is not a privileged
process and doesn't know the original euid.  I don't believe this
to be a great loss as we tuck `edenfs` away under the libexec dir.

Reviewed By: chadaustin

Differential Revision: D23696569

fbshipit-source-id: 55b95daf022601a4699274d696af419f0a11f6f2
2020-09-18 17:22:39 -07:00
Wez Furlong
2941822299 eden: use SpawnedProcess to start privhelper
Summary:
On macOS we cannot safely use `fork` to spawn processes while other threads may initialize objc classes.

This commit replaces the use of `fork` in the privhelper startup with
`SpawnedProcess` instead.  We need to take care with this as we are generally
installed setuid root and we'd like to avoid being tricked into running an
arbitrary child process as root.

This commit defines a separate executable called `edenfs_privhelper` that
contains just the privhelper server code.

We need to be careful about locating this executable; to avoid invoking an
arbitrary process while we have root privileges we require that the privhelper
be a sibling to the edenfs executable and carry out some additional ownership
verification so that we can tell that the owner of edenfs also controls
edenfs_privhelper.

To facilitate this, I've added an `executablePath` function to PathFuncs; it
returns the path to the current executable image.

To make the integration test scenario simpler, I've added the edenfs_executable
binary definition alongside that of the edenfs binary in the buck and cmake
build systems.  This causes the binaries to be siblings in-situ in the build
tree and avoids the need to move things into place in the test harness.

Reviewed By: chadaustin

Differential Revision: D23653343

fbshipit-source-id: 3c2539a5e0e11cee88960db49c885ce0366d314e
2020-09-18 17:22:39 -07:00
Zeyi (Rice) Fan
5fedaa71b8 enable redirection tests
Summary: This diff fixes the eden redirection tests so it runs on Windows.

Reviewed By: xavierd

Differential Revision: D22958766

fbshipit-source-id: 45d26587831ed74d6bd7912b22c7c955b077f571
2020-09-18 16:39:52 -07:00
Zeyi (Rice) Fan
506ba2cbf3 remove resolve_path
Reviewed By: xavierd

Differential Revision: D23766446

fbshipit-source-id: 3f8238de7c8e93ce8d76f201de9eff0984365979
2020-09-18 16:39:52 -07:00
Liubov Dmitrieva
01615ae4de improve scm daemon checks and check workspace name as well
Summary:
Move bunch of code into a separate file (scm daemon related options). Move them
out of cloud sync.

Also introduce additional check that the `hg cloud sync` command scm daemon
runs is intended for the current connected workspace

In theory when we switch a subscription, the SCM daemon gets notified but races possible and it is better to have this additional check, so SCM daemon triggers cloud sync where it is supposed to.

Reviewed By: markbt

Differential Revision: D23783616

fbshipit-source-id: b91a8b79189b7810538c15f8e61080b41abde386
2020-09-18 14:01:11 -07:00
Jun Wu
664fa0b8ec config: remove experimental.head-based-commit-transaction
Summary:
The config is not actually used any more (with rust-commits, it is forced on, without rust-commits,
there is no point to keep it on). Therefore removed.

Reviewed By: singhsrb

Differential Revision: D23771570

fbshipit-source-id: ad3e89619ac5e193ef552c25fc064ca9eddba0c6
2020-09-18 13:28:34 -07:00
Jun Wu
6d3f17bb16 codemod: signal.signal -> util.signal
Summary:
See the previous diff for context. This allows the code to run from non-main
thread.

Reviewed By: singhsrb

Differential Revision: D23759712

fbshipit-source-id: 044193a9d7193488c700d769da9ad68987356d69
2020-09-18 13:28:34 -07:00
Jun Wu
be51116cf4 util: add util.signal that works for non-main threads
Summary:
The idea is to extend D22703916 (61712e381c)'s way of calling functions from just edenapi to
the entire command for better Ctrl+C handling. Some code paths (ex. pager,
crecord) use `signal.signal` and `signal.signal` does not work from non-main
thread.

To workaround the `signal.signal` limitation, we pre-register all signals we care
about in the main thread to a special handler. The special handler reads a
global variable to decide what to do. Other threads can modify that global
variable to affect what the special signal handler does, therefore indirectly
"register" their handles.

Reviewed By: kulshrax

Differential Revision: D23759711

fbshipit-source-id: 8ba389072433e68a36360db6a1b17638e40faefa
2020-09-18 13:28:34 -07:00
Jun Wu
b5a01b9c05 util: improve interruption handling for 'threaded'
Summary:
Before this change, for a long-running function wrapped by 'threaded',
it might:

  background thread> start
  main thread> receive SIGINT, raise KeyboardInterrupt
  main thread> raise at 'thread.join(1)'
  main thread> exiting, but wait for threads to complete (Py_Finalize)
  background thread> did not receive KeyboardInterrupt, continue running
  main thread> continue waiting for background thread

Teach `thread.join(1)` to forward the `KeyboardInterrupt` (or its subclass
`error.SignalInterrupt`) to the background thread, so the background thread
_might_ stop. Besides, label the background thread as daemon so it won't
be waited upon exit.

Reviewed By: kulshrax

Differential Revision: D23759713

fbshipit-source-id: 91893d034f1ad256007ab09b7a8b974325157ea5
2020-09-18 13:28:34 -07:00
Jun Wu
51a9d37730 edenapi: edenapi._spawnthread -> util.threaded
Summary:
Move the wrapper to util.py. It'll be used in dispatch.py to make the entire
command Ctrl+C friendly.

Reviewed By: singhsrb

Differential Revision: D23759715

fbshipit-source-id: fa2098362413dcfd0b68e05455aad543a6980907
2020-09-18 13:28:33 -07:00
Jun Wu
c4e2f5cb0f bindings: add sleep for testing blocking Rust functions
Summary: This will be used to test Ctrl+C handling with native code.

Reviewed By: kulshrax

Differential Revision: D23759714

fbshipit-source-id: 50da40d475b80da26b7dbc654e010d77cb0ad2d1
2020-09-18 13:28:33 -07:00
Jun Wu
6cb78fa90c pyedenapi: expose API querying hg commit data
Summary: This makes it easier to test the API via debugshell.

Reviewed By: kulshrax

Differential Revision: D23750677

fbshipit-source-id: e29284395f03c9848cf90dd2df187e437890c56e
2020-09-18 13:28:33 -07:00
Jun Wu
80bf264e24 debugshell: add "api" object
Summary: It is handy to test edenapi methods directly.

Reviewed By: kulshrax

Differential Revision: D23750709

fbshipit-source-id: 33c15cecaa0372ba9e4688502e7d8f3fdda7c3b8
2020-09-18 13:28:33 -07:00
Jun Wu
478e1fe524 commands: add debugrebuildchangelog
Summary:
Add a command to rebuild the changelog without recloning other parts of the
repo. This can be used as a way to recover from corrupted changelog. It
currently uses revlog because revlog is still the only supported format during
streamclone.

In the future this can be used for defragmentation.

Reviewed By: DurhamG

Differential Revision: D23720215

fbshipit-source-id: 6db0453d18dbf553660d55d528f990a4029d9da4
2020-09-18 13:28:33 -07:00
Wez Furlong
0f2f5b9330 edenfs: change PathMap CaseSensitivity to runtime option
Summary:
This commit moves a compile-time template parameter
to be a runtime boolean parameter.

There's a bit of fan-out that, while I don't think it is
super awesome, isn't super terrible either.

The case sensitivity value is read from the checkout config
added in the prior diff in this stack.

Reviewed By: xavierd

Differential Revision: D23751192

fbshipit-source-id: 46f6fe25bfa6666305096ad9c416b510cd3aac8f
2020-09-18 08:43:14 -07:00
Wez Furlong
7b6868f452 edenfs: add per-checkout case sensitivity setting
Summary:
This diff teaches the CheckoutConfig how to determine
whether a given checkout should be case-sensitive (the default)
or case-insensitive-case-preserving.

This option is passed through to the fuse channel initialization,
so that the kernel will respect it, however, our DirEntry layer
doesn't yet know that it should respect this.

There's currently no UI to set this option.  My game plan
is to suggest the following steps to folks that want to try
this out:

```
$ eden stop
$ vim ~/local/.eden/clients/ovrsource/config.toml
```

and then add this line to the `[repository]` section:

```
case-sensitive = false
```

and finally:

```
$ eden start
```

Reviewed By: xavierd

Differential Revision: D23751184

fbshipit-source-id: 6facb23c460cfff6e37d0091b51b97ab06f62c91
2020-09-18 08:43:14 -07:00
Liubov Dmitrieva
70dc57f48b improve help
Summary:
Improve help to reflect that the system is also meant for managing backups

add missing commands
reshuffle a bit

Reviewed By: markbt

Differential Revision: D23782794

fbshipit-source-id: d7fd3fa06ca7acd649cef557f3fe020295259e3d
2020-09-18 07:03:25 -07:00
Thomas Orozco
f93426a8c8 mononoke/gotham_ext: force compressed streams to send data every so often
Summary:
Compressed responses from LFS are slower than they should right now. Normally,
we'd expect something along the lines of normal response time + compression
time, but right now it's a lot more than this.

The reason for this is that our compressed streams are eager, i.e. they will
consume and compress as much of the underlying stream as possible before
sending off the data. This is problematic for LFS, because we try very hard to
serve everything out of RAM directly (and very often succeed), so that means
we compress the whole stream before sending it off.

This means we might spend e.g. 500ms compressing (this is how long it takes
zstd to compress the object I was testing on, which is a ~80MiB binary that
compresses down to 33% of that), and _then_ we'll spend some time transferring
the compressed data, when we could have started transferring immediately while
we were compressing.

To achieve this, let's simply tell our compressed stream to stop waiting for
more data once in a while (every 4 MiB, which seems very frequent but actually
really isn't).

Reviewed By: StanislavGlebik

Differential Revision: D23782756

fbshipit-source-id: a0d523d84f92e215eb366f551063383fc835fdd6
2020-09-18 05:39:38 -07:00
Thomas Orozco
05e9fa3a29 mononoke/gotham_ext: remove Brotli support
Summary:
I saw this throw the LFS server into an infinite loop when I tested it. We're
not using this right now, so I'm not investing time into root-causing the
issue, and instead let's just take this out.

Reviewed By: StanislavGlebik

Differential Revision: D23782757

fbshipit-source-id: f320fc72c3ff279042c2fe9fcb9c4904e9e1bfdf
2020-09-18 05:39:38 -07:00
Lukas Piatkowski
78d30ad17f eden/edenapi and mononoke integration tests: add edenapi/tools to getdeps and use them in tests (#51)
Summary:
Pull Request resolved: https://github.com/facebookexperimental/eden/pull/51

This diff extends capabilities of CargoBuilder in getdeps so that individual manifests can be build even without workspaces. Thanks to that a build for edenapi/tools can be made and its artifacts can be used in mononoke integration tests.

Reviewed By: StanislavGlebik

Differential Revision: D23574887

fbshipit-source-id: 8a974a6b5235d36a44fe082aad55cd380d84dd09
2020-09-18 04:20:56 -07:00
Liubov Dmitrieva
d94f354708 implement a command to reclaim workspaces
Summary: The command will be provided as hint if username changes has been detected in configuration.

Reviewed By: markbt

Differential Revision: D23769942

fbshipit-source-id: 3e84ecef6dd68267022b92bf10f5e68dfc07f270
2020-09-18 04:18:11 -07:00
Stanislau Hlebik
2848d92b48 mononoke: sort paths in premerge delete
Summary:
This makes deletion commits a bit less confusing, but it also have another
benefit.
Without the sort some directories might have been changed multiple times in
deletion commits e.g. if a directory had 5 files, and these files were deleted
in 5 different deletion commits then the directory would be changed 5 times.
This was not good, because it made some data derivation slower (in particular,
fastlog), because it had to regenerate the same data over and over again.

Reviewed By: ikostia

Differential Revision: D23780066

fbshipit-source-id: d5c52b13f58dcaf2012d9c12bf77398561cf10ef
2020-09-18 04:04:51 -07:00
Alex Hornby
753c986a93 mononoke: remove get_fsnode_id
Summary:
Spotted a TODO in fsnode get_fsnode_id.  There was only one user of the function, which didn't really need to call it as it had the blob already.

As well as being a bit tidier this also saves a clone of the fsnode.

Reviewed By: StanislavGlebik

Differential Revision: D23758689

fbshipit-source-id: e0a8c124c929fda3af4c96a76d441a79e5bfbd5b
2020-09-18 02:52:47 -07:00
Alex Hornby
0f5809ad16 mononoke: save memory in walker state by not memoing hash
Summary:
Save memory in walker state tracking by not memoing hash values. For large repos this is significant.

I was expecting a small slowdown from this, but so far looks pretty much the same walk rate. Speculation: this may be due to the num cpus lock sharding fix in dashmap 3.11.10 which means there are many more shards than when the memo was tested with 3.11.9, so saving time inside locks is less significant.

Reviewed By: StanislavGlebik

Differential Revision: D23680550

fbshipit-source-id: 351b5ec39885fc30996207c7dccc22c749e30321
2020-09-18 02:52:47 -07:00
Arun Kulshreshtha
6e5f95067a gotham_ext: move content streams into separate module
Summary:
The `gotham_ext::response` module was getting a bit large, so this diff moves `ContentMeta`, `ContentStream`, and `CompressedContentStream` into a new submodule, alongside the contents of the old `content_encoding` module. This way, the `response` module remains entirely centered around the `TryIntoResponse` trait (and the various body structs that implement that trait).

Later diffs in this stack will be adding an additional layer between the content streams and the body structs, at which point it probably doesn't make sense to have these right next to each other. Splitting them out now will allow for better code organization going forward.

Reviewed By: krallin

Differential Revision: D23777492

fbshipit-source-id: 86e598dcb37578d3b22217a2a65f1bde84d72215
2020-09-18 01:34:04 -07:00
Saurabh Singh
a703572183 fb-scratch: stop building the package
Summary:
`scratch` provided by `fb-scratch` was replaced by `mkscratch` provided by
the Mercurial package. See linked task for details.

Reviewed By: quark-zju

Differential Revision: D23773840

fbshipit-source-id: de0582069ce1a09c3cd9fc6b02d2d149f70d0d78
2020-09-17 18:32:19 -07:00
Durham Goode
41b0cf71e8 mutation: remove exponential algorithm from obsoletenodes
Summary:
Computing all successorsets is exponential with the number of splits
that have happened. This can slow things down tremendously.

The obsoletenodes path only needs to know "is there a visible successor" in
order to determine if a draft commit is obsolete. Let's use allsuccessors
instead of successorset.

Reviewed By: quark-zju

Differential Revision: D23771025

fbshipit-source-id: 666875e681c2e3306fc301357c95f1ab5bb40a87
2020-09-17 18:29:40 -07:00
Zeyi (Rice) Fan
923bac59b2 allow disabling kerberos check via configuration
Reviewed By: wez

Differential Revision: D23717373

fbshipit-source-id: a65106852d995974b557f058bec9ef4774ee01ea
2020-09-17 18:04:48 -07:00
Liubov Dmitrieva
57e4688aa4 introduce commands for renaming workspaces and rehost workspace
Summary:
`hg cloud join --merge` doesn't really solve rename problem because it doesn't
preserve:

1. old heads
2. history

I added a proper API in Commit Cloud Service for renaming workspaces and now we
can use it to provide a rename command and 'rehost' command which is a version
of renaming to bind the current workspace to the current devserver.
Rehost command is meant to be used after dev server migration. I am plannig to
add this to the dev server migration wiki.

Next diff will cover how we can use the rename command to fix a username in workspaces names after username has been changed.

Reviewed By: markbt

Differential Revision: D23757722

fbshipit-source-id: dc11cb226eb76d347cdab70b3c72566448dcd098
2020-09-17 17:45:05 -07:00
Durham Goode
f68177a983 treemanifest: flush shared stores when flushing local stores
Summary:
The Rust contentstore has no way to flush the shared stores, except
when the object is destructed. In treemanifest, the lifetime of the shared store
seems to be different from with files and we're not seeing them flushes
appropriately during certain commands. Let's make the flush api also flush the
shared stores.

Reviewed By: quark-zju

Differential Revision: D23662976

fbshipit-source-id: a542c3e45d5b489fcb5faf2726854cb49df16f4c
2020-09-17 14:27:50 -07:00
Durham Goode
84f72950ad treemanifest: make Python repack work with Rust treemanifest stores
Summary:
Now that treemanifests can use Rust stores, we need to update the
Python repack code to support that.

Reviewed By: quark-zju

Differential Revision: D23662361

fbshipit-source-id: c802852c476425eef74181ead04f70b11ff9a27c
2020-09-17 14:27:50 -07:00
Durham Goode
7aca64d8f9 treemanifest: integrate treemanifest prefetch with Rust store prefetch
Summary:
This makes Rust contentstore prefetch route through the remotetreestore
prefetch logic to reach the lower level tree fetching, and makes the higher
level Python fetching route through the Rust contentstore to do prefetching. The
consequence of this is that there's a relatively unified code path for both
Python and Rust, and hopefully we can delete the janky Python bits once we're
completely migrated to Rust.

The way this diff works is pretty hacky. The code comment explains it, but the
tl;dr is that Rust prefetch works by providing references to the mutable stores,
while Python prefetch assumes they are stored and accessible on the repository.
Inorder for the old python tree fetching logic to work with both models, we
monkey patch the Rust mutable store references we receive into the function that
will later be called to request the repositories mutable stores. This is awful.

A cleaner fix might be to thread the mutable stores all the way through the
python fetching logic, then move the Python accessing of the repositories
mutable stores to the higher layer, near where Rust would provide it. That's a
lot of code churn though, so I'd like to do that in a later diff once we stop
using the non-rust logic entirely.

Reviewed By: quark-zju

Differential Revision: D23662351

fbshipit-source-id: 76007b6089ddf0e558581cd179a112311f8b58e3
2020-09-17 14:27:49 -07:00
Durham Goode
c268c02298 treemanifest: refactor remotetreestore prefetching
Summary:
As part of moving treemanifest to use the Rust tree store, we need to
move prefetch to be able to be initiated from Rust. Rust requires a certain
signature for the prefetch function which accepts multiple keys.

In preparation for this requirement, let's refactor the current remotetreestore
fetching path to have a separate function. In a later diff we'll route Rust
prefetch requests through this function so the python and rust code shares the
same base tree discovery logic.

Reviewed By: quark-zju

Differential Revision: D23662196

fbshipit-source-id: 127045c279dc22914f7e1f3a619f6620586010ba
2020-09-17 14:27:49 -07:00
Durham Goode
a88287fd45 rebase: move inmemory fallback outside of except
Summary:
Python 3 reports exceptions in except clauses by showing the original
exception, then saying another exception happened during the original exception
and hiding the second exception stack trace.

To make update exceptions more debuggable, let's move the handling outside the
except clause.

Reviewed By: quark-zju

Differential Revision: D23761667

fbshipit-source-id: bec758a3c7c0b88a5a569f794730058bf6f1eaad
2020-09-17 14:21:49 -07:00
Chad Austin
fdc83eaa75 rename EdenInstance.get_thrift_client to get_thrift_client_legacy
Summary:
Rather than switch all of Eden at once to the thrift-py3 client,
rename get_thrift_client to get_thrift_client_legacy so uses of the
new client can be introduced piecemeal.

(I did try migrating everything at once but it's been quite painful.)

Reviewed By: fanzeyi

Differential Revision: D22423399

fbshipit-source-id: 9e6d938b90fff9fc3266ba20bc77e880e7f5b1aa
2020-09-17 13:25:00 -07:00
Liubov Dmitrieva
94761154da reduce repetitions in the http client code
Summary: Better engineering: reduce repetitions in the http client code

Reviewed By: markbt

Differential Revision: D23731119

fbshipit-source-id: cf1cb939231fa38ae23f4a2d86a867c3881d16b4
2020-09-17 11:07:07 -07:00
Liubov Dmitrieva
62c2bd52c9 detect changed usernames in configs
Summary:
This is the initial step to track username when the workspace has been created and provide users an appropriate advice how to fix their workspace names if the username in configuration has been changed

in another diff I will provide the advice itself

I will build rename workspace command based on D23703790

Reviewed By: markbt

Differential Revision: D23730312

fbshipit-source-id: a49dabba7ec4acf35f6ff99ed23cff5d6f46e2e4
2020-09-17 11:07:06 -07:00
Jun Wu
813647f917 template: remove rev:node legacy template
Summary:
`experimental.template-new-builtin = true` has been rolled out to 100%
and seems to work fine. Therefore, remove code that supports
`template-new-builtin = false`.

Reviewed By: singhsrb

Differential Revision: D23745353

fbshipit-source-id: 178af269381c9d3e20522ba4484d63051589342b
2020-09-17 10:58:39 -07:00
Durham Goode
7c8f9167e1 tests: avoid turning $TESTTMP into a repo
Summary:
Some tests run `hg init` right inside the test directory, turning the
entire $TESTTMP into a repo. In future diffs we'll start to rely more on hgcache
being present during tests, which creates a directory in $TESTTMP. Let's make
sure all repos are created as sub-directories of $TESTTMP.

Reviewed By: kulshrax

Differential Revision: D23662077

fbshipit-source-id: 2b2b974ebfd1bd19ad6acd1ebe3e68dd03a09869
2020-09-17 10:16:03 -07:00
Durham Goode
cbe4499da8 treemanifest: add option for instantiating a Rust treemanifest store
Summary:
Adds the initial condition and creation logic for creating a Rust
treemanifest store. Fetching and some other code paths don't work just yet, but
subsequent diffs enable more and more functionality.

Reviewed By: quark-zju

Differential Revision: D23662052

fbshipit-source-id: a0e7090c9a3bf27a7738bf093f2d4eb6098b1ed6
2020-09-17 10:16:03 -07:00
Durham Goode
556ae539fa repack: prevent Rust repack from repacking an entry twice
Summary: The old logic would just double pack some bits. Let's prevent that.

Reviewed By: xavierd

Differential Revision: D23661933

fbshipit-source-id: 155291fa08ec2c060619329bd1cb6040769feb63
2020-09-17 10:16:03 -07:00
Durham Goode
6ae1cf9619 revisionstore: add refresh function
Summary:
The rust pack stores currently have logic to refresh their list of
packs if there's a key miss and if it's been a while since we last loaded the
list of packs. In some cases we want to manually trigger this refresh, like if
we're in the middle of a histedit and it invokes an external command that
produces pack files that the histedit should later consume (like an external
amend, that histedit then needs to work on top of).

Python pack stores solve this by allowing callers to mark the store for a
refresh. Let's add the same logic for rust stores. Once pack files are gone we
can delete this.

This will be useful for the upcoming migration of treemanifest to Rust
contentstore. Filelog usage of the Rust contentstore avoided this issue by
recreating the entire contentstore object in certain situations, but refresh
seems useful and less expensive.

Reviewed By: quark-zju

Differential Revision: D23657036

fbshipit-source-id: 7c6438024c3d642bd22256a8e58961a6ee4bc867
2020-09-17 10:16:03 -07:00
Durham Goode
055fc0d20b packstore: avoid substracting from an Instant
Summary:
Instants do not represent actual time and can only be compared against
each other. When we subtracted arbitrary Durations from them, we run the risk of
overflowing the underlying storage, since the Instant may be represented by a
low number (such as the age of the process).

This caused crashes in test_refresh (in the next diff) on Windows.

Let's instead represent the "must rescan" state as a None last_scanned time, and avoid any arbitrary subtraction. It's generally much cleaner too.

Reviewed By: quark-zju

Differential Revision: D23752511

fbshipit-source-id: db89b14a701f238e1c549e497a5d751447115fb2
2020-09-17 10:16:03 -07:00
Viet Hung Nguyen
dae0b4aadc mononoke/repo_import: include small repo call sign in SmallRepoBackSyncVars struct
Summary: Previously, we used the call sign of the repo we import when checking any of the if the commits are parsed by Phabricator. However, we also use this callsign for other repos when checking Phabricator, which is an incorrect implementation. E.g. if fbsource back-syncs to ovsource, we would have used FBS callsign when checking Phabricator for both fbsource and ovrsource, but we should use OVRSOURCE callsign for repo ovrsource. This diff corrects this implementation by saving the callsigns of the small repos in their SmallRepoBackSyncVars.

Reviewed By: StanislavGlebik

Differential Revision: D23758355

fbshipit-source-id: b322acb2ec589eabed5362bfd6b963e2dd1d6ea9
2020-09-17 09:23:27 -07:00
Wez Furlong
ec25f05c6d eden: allow ECHILD to be non-fatal in SpawnedProcess
Summary:
I had originally make the logic around ECHILD very strict,
thinking it impossible to have a situation where it may arise,
but it turns out that our daemonization makes this happen all
the time.

This commit treats an ECHILD return from waitpid as equivalent
to a success waitpid result and success child process termination.

Reviewed By: chadaustin

Differential Revision: D23683107

fbshipit-source-id: 7867d636afd8ee79b9f100454f84e7ef480109d8
2020-09-17 09:08:58 -07:00
Wez Furlong
745d047762 edenfs: move WinError to eden/fs/utils
Summary: This resolves a dependency cycle introduced in D23037325 (f4f159537f) and D23480435 (34821976e0)

Reviewed By: xavierd

Differential Revision: D23735176

fbshipit-source-id: a4849d512e4181afbb007d7e850aadf092c6eb90
2020-09-17 09:08:58 -07:00
Lukas Piatkowski
30aad29a1e mononoke/commitcloud_bookmarks_filler: make it public (#58)
Summary:
Pull Request resolved: https://github.com/facebookexperimental/eden/pull/58

This makes the test-bookmarks-filler.t pass. Additionally remove few tests from exclusion lists as they started to pass.

Reviewed By: ikostia

Differential Revision: D23757401

fbshipit-source-id: eddcda5fd1806d77d0046b6ced3695df6b3d775d
2020-09-17 07:38:53 -07:00
Lukasz Piatkowski
64da367e63 mononoke/integration CI: try to free up some space before running tests (#57)
Summary:
We are running out of space on integration tests runs on Linux. In order to avoid that this change is adding some cleanups.

1. Adding `docker rmi $(docker image ls -aq)` frees up 4 GB.
2. Cleaning up `eden_scm` build directory frees up 3 GB.
3. Cleaning up `mononoke` build directory frees up 1 GB.

This diff also includes a fix for run_tests_getdeps.py where we run all the "PASSING" tests when --rerun flag is passed instead of only the failed ones.

Pull Request resolved: https://github.com/facebookexperimental/eden/pull/57

Reviewed By: krallin

Differential Revision: D23742159

Pulled By: lukaspiatkowski

fbshipit-source-id: 3b5e89ad29c753d585c1a6f01a9a1d6c1e616fbf
2020-09-17 07:38:53 -07:00
Lukas Piatkowski
9d17ba2078 mononoke: fix OSS build after deprecating preamble in favor of metadata
Summary: fixes build and test errors on OSS introduced by D23596262 (deb57a25ed)

Reviewed By: ikostia

Differential Revision: D23757086

fbshipit-source-id: 7973ce36b3589cbe21590bd7e19a9828be72128f
2020-09-17 07:38:53 -07:00
Viet Hung Nguyen
c8b4a796ec mononoke/repo_import: add process recoverability
Summary: Since repo_import tool is automated, we need a way to recover the process when the tool break without restarting the whole process. To do this, I defined a new struct (RecoveryFields) that allows us to keep track of the state. The most important fields are the import_stage (ImportStage) we need for keeping track of the process and to indicate the first stage of recovery, and the cs_ids we use throughout the process. For each stage in importing, we save the state after we have finished that part. This way we can also recover from interrupts. To do process recovery, we only need to use `recover-process <file_path>` subcommand, where file_path stores the saved state of importing. For normal run we will use `import [<args>]` subcommand.

Reviewed By: krallin

Differential Revision: D23678367

fbshipit-source-id: c0e0b270ea2ccc499368e54f37550cfa58c03970
2020-09-17 05:58:08 -07:00
Stanislau Hlebik
5cd80b2584 mononoke: use skip warm bookmark cache for external sync job
Summary:
This change allows us to use warm bookmark cache for all clients except
for external sync job (i.e. the job we use to keep configerator-hg in sync with
configerator-git).
This is useful we'd like to use warm bookmark cache for configerator but it
doesn't work with external sync job. We'd like to use it because warm bookmark
cache doesn't advance a bookmark until this revision showed up in
configerator-hg - this proved to be useful when rolling out configerator for
devservers since there were tools that talked to hg, and they were failing if
hg was behind.
Currently hg external sync job doesn't work with warm bookmark cache because it
tries to incorrect move a master. What I mean by that is that hg external sync
job sends unbundle request which contains a pushkey part which says "move
master from commit A to commit B". If commit A is outdated because of warm
bookmark cache then this update will just fail, because master bookmark
actually points to commit C.

Let's just not ever use warm bookmark cache for external sync job

Reviewed By: aslpavel

Differential Revision: D23754603

fbshipit-source-id: c8eec54bca2224688d4a829ded372c6fc4d7930f
2020-09-17 05:12:22 -07:00
Alex Hornby
75efb46fa3 mononoke: reduce allocation in MPath::get_path_hash()
Summary:
Pass the elements to the hasher to avoid needing to alloc a vec from them.

This saves building the vec inside MPathElement, and when used on top of smallvec based MPathElement also saves allocation of a Vec from the SmallVec for each element.

Reviewed By: aslpavel

Differential Revision: D23703342

fbshipit-source-id: dd81c6d69b90f128d697ba847dde34058ad1ea6e
2020-09-17 00:54:42 -07:00
Alex Hornby
2b9f44ebdb mononoke: use smallvec for MPathElement
Summary:
Use smallvec for the internal storage of MPathElement.

The previous Bytes had a stack size of 32 bytes plus the text it pointed to.

Using SmallVec we can store up to 24 bytes without allocation keeping the same space as the previous Bytes object.

Given most path elements are  directory names and directory names are usually short it is expected that this will save both space and allocations.

Reviewed By: farnz

Differential Revision: D23703344

fbshipit-source-id: 39ffc3bd3bb765bd1dbb757b4b1a7782382db909
2020-09-17 00:54:42 -07:00
Durham Goode
d832ea7afa treemanifest: change local tree sending to depend on phases
Summary:
When sending trees and files we try to avoid sending trees that are
available from the main server. To do so, we currently check to see if the
tree/file is from the local store (i.e. .hg/store instead of $HGCACHE).

In a future diff we'll be moving trees to use the Rust store, which doesn't
expose the difference between shared and local stores. So we need to stop
depending on logic to test the local store.

Instead we can test if the commit is public or not, and only send the tree/file
is the commit is not public. This is technically a revert of the 2018 D7992502 (5e95b0e32e)
diff, which stopped depending on phases because we'd receive public commits from
svn there were not public on the server yet. Since svn is gone, I think it's
safe go back to that way.

This code was usually to help when the client was further ahead than another
client and in some commit cloud edge cases, but 1) we don't do much/any p2p
exchange anymore, and 2) we did some work this year to ensure clients have more
up-to-date remote bookmarks during exchange (as a way of making phases and
discovery more reliable), so hopefully we can rely on phases more now.

Reviewed By: quark-zju

Differential Revision: D23639017

fbshipit-source-id: 34c13aa2b5ef728ea53ffe692081ef443e7e57b8
2020-09-16 21:39:25 -07:00
Durham Goode
dd387dd0d1 mutablepacks: only create mutable history packs when needed
Summary:
Previously the MetadataStore would always construct a mutable pack, even
if the operation was readonly. This meant all read commands required write
access. It also means that random .tmp files get scattered all over the place
when the rust structures are not properly destructed (like if python doesn't
bother doing the final gc to call destructors for the Rust types).

Let's just only create mutable packs when we actually need them.

Reviewed By: quark-zju

Differential Revision: D23219961

fbshipit-source-id: a47f3d94f70adac1f2ee763f3170ed582ef01a14
2020-09-16 21:39:25 -07:00
Durham Goode
1f5835e70a mutablepacks: only create mutable data packs when needed
Summary:
Previously the ContentStore would always construct a mutable pack, even
if the operation was readonly. This meant all read commands required write
access. It also means that random .tmp files get scattered all over the place
when the rust structures are not properly destructed (like if python doesn't
bother doing the final gc to call destructors for the Rust types).

Let's just only create mutable packs when we actually need them.

Reviewed By: quark-zju

Differential Revision: D23219962

fbshipit-source-id: 573844f81966d36ad324df03eecec3711c14eafe
2020-09-16 21:39:25 -07:00
Durham Goode
57b422b49a py3: fix hg when there's no stdin
Summary:
Some tools, like ShipIt, close stdin before they launch the subprocess.
This causes sys.stdin to be None, which breaks our pycompat buffer read. Let's
handle that.

Reviewed By: quark-zju

Differential Revision: D23734233

fbshipit-source-id: 0adc23cd5a8040716321f6ede0157bc8362d56e0
2020-09-16 19:41:04 -07:00
Xavier Deguillard
ff7238e841 win: move some code around for closedir
Summary: This moves the Windows specific bits outside of the dispatcher code.

Reviewed By: chadaustin

Differential Revision: D23655613

fbshipit-source-id: 05b5bb9ed124ae37b6ae43c2a646967724337962
2020-09-16 18:59:26 -07:00
Xavier Deguillard
49e13b3db6 win: make the queryFileName callback asynchronous
Summary: Similarly to the other one, this will make it possible to interrupt.

Reviewed By: fanzeyi

Differential Revision: D23643100

fbshipit-source-id: 0daab1cec94d0e177bb707d97bf928b05d5d24a3
2020-09-16 18:59:26 -07:00
Xavier Deguillard
5512d7c09f win: make the getPlaceholder callback asynchronous
Summary: Similarly to the other callback, this will make it possible to interrupt.

Reviewed By: fanzeyi

Differential Revision: D23643101

fbshipit-source-id: 9f9a48e752a850c63255b8867b980163cb6a92c9
2020-09-16 18:59:26 -07:00
Xavier Deguillard
ff16c758d2 win: make the opendir callback asynchronous
Summary:
The opendir callback tend to be the most expensive of all due to having to
fetch the content of all the files. This leads to some frustrating UX as the
`ls` operation cannot be interrupted. By making this asynchronous, the slow
operation can be interrupted. The future isn't cancelled and thus it will
continue to fetch in the background, this will be tackled in a future diff.

Reviewed By: fanzeyi

Differential Revision: D23630462

fbshipit-source-id: f1c4a9fbd9daa18ca4b8f4837c5241a37ccfbcf9
2020-09-16 18:59:25 -07:00
Xavier Deguillard
4b73387ef8 win: refactor some code in RequestContext
Summary:
Previously, the notification callback code was pretty ad-hoc in how it dealt
with the request context and handling asynchronous callbacks, in order to share
more code with FUSE, let's add a catchErrors method to the PrjfsRequestContext
similarly to what is done in the FUSE code. Once timeouts and notifications
will be added, the catchErrors code will be moved into the parent class and all
of this code will be common between ProjectedFS and FUSE.

Reviewed By: fanzeyi

Differential Revision: D23626748

fbshipit-source-id: 70fae3d4a276be374f58559cc1fb05c8e56e5c2d
2020-09-16 18:59:25 -07:00
Xavier Deguillard
4a34910cdd win: handle the notification callback asynchronously
Summary:
Completing callbacks asynchronously is as simple as using PrjCompleteCommand
instead of returning the result from the callback. This allows callbacks to be
interrupted/cancelled, which will lead to a better user experience.

For now, the code in the notifaction callback is very ad-hoc, but most of it
will be refactored to be re-used by the other callbacks.

Reviewed By: fanzeyi

Differential Revision: D23611372

fbshipit-source-id: 17d1b8a4cd05706141abbf1e861d74f471537fba
2020-09-16 18:59:25 -07:00
Xavier Deguillard
4d21632c49 win: move the windows specific bits of the notifaction callback to the channel
Summary:
This removes a bunch of Windows specific code from the dispatcher which brings
us closer to moving it to a non-Windows specific directory. It also makes the
code more ready to use async notification handling as the dispatcher no longer
waits on future to complete before returning.

Reviewed By: fanzeyi

Differential Revision: D23611371

fbshipit-source-id: b1a2a6ce0a0be4747423ed75bc8a7aa4b5fa99f4
2020-09-16 18:59:24 -07:00
Xavier Deguillard
0904c05535 win: plumb PrjfsRequestContext in the notification callback
Summary:
Now that all the pieces are in place, we can plumb the request context in. For
now, this adds it to only one callback as I figure out more about it and tweak
it until I have something satisfactory. There are some rough edges with it that
I'm not entirely happy about, but as I change the notification callback to be
more async, I'm hoping to make more convenient to use and less clanky.

Reviewed By: fanzeyi

Differential Revision: D23505508

fbshipit-source-id: d5f12e22a8f67dfa061b8ad82ea718582c323b45
2020-09-16 18:59:24 -07:00
Chad Austin
e8e9d906fa remove fallback for old open source builds
Summary:
There was a time when getRegexExportedValues was not in open source
fb303, but that time has long passed.

Reviewed By: kmancini

Differential Revision: D23745295

fbshipit-source-id: 4702068f0bb7350467e42439444b3f4d75aeec76
2020-09-16 17:48:32 -07:00
Xavier Deguillard
2ff478ea62 utils: move win/utils/Stub.h to utils/NotImplemented.h
Summary:
Since the Stub.h now only contains NOT_IMPLEMENTED, let's move it to its own
header outside of the win directory.

Reviewed By: genevievehelsel

Differential Revision: D23696244

fbshipit-source-id: 2dfc3204707e043ee6c89595668c484e0fa8c0d0
2020-09-16 12:31:46 -07:00
Xavier Deguillard
18084befa0 win: remove fuse_init_out from Stub.h
Summary:
With this gone, we will be able to rename and move Stub.h outside of the win
directory.

Reviewed By: genevievehelsel

Differential Revision: D23696243

fbshipit-source-id: ea05b10951fa38a77ce38cd6a09a293364dbeec9
2020-09-16 12:31:46 -07:00
Xavier Deguillard
d48209e3ed build: compile takeover/ on Windows
Summary:
While the code isn't compiled, this makes the thrift definition available to
the rest of the code, eliminating the need for having a stub for
SerializedInodeMap on Windows.

Reviewed By: genevievehelsel

Differential Revision: D23696242

fbshipit-source-id: 8a42dd2ed16887f3b7d161511e07aaa35fd1b968
2020-09-16 12:31:46 -07:00
Xavier Deguillard
3b11bc9096 portability: define uid_t and gid_t
Summary:
The getuid and getgid are defined as returning uid_t and gid_t. Defining these
types here will prevent downstream consumer from having to redefine these
types for Windows.

(Note: this ignores all push blocking failures!)

Reviewed By: yfeldblum, Orvid

Differential Revision: D23693492

fbshipit-source-id: 1ec9221509bffdd5f6d241c4bc08d7809cdb6162
2020-09-16 11:13:54 -07:00