Commit Graph

7685 Commits

Author SHA1 Message Date
Kostia Balytskyi
f81061dc45 RFC: [mononoke] make unsafe_sync_commit accept version override
Summary:
Normally, sync logic infers `CommitSyncConfigVersion` to use from parent commits (or from current version for root commits). However, for test purposes it is convenient to force a version override This logic does not change any of the production behaviors, and will be used in a later diff.

TODO: can it ever be needed beyond tests? I've thought about using this for "version boundary" commits, but those would probably just be constructed while completely bypassing the sync logic.

TBH, I am not certain this diff is a good change. But I've spend a very large amount of time crafting the repos used in the `sync_merge` tests later in this stack, so I am proposing to land this, then spend some time refactoring sync tests (and hopefully making it easier to craft test repos), then removing this logic. Obviously, this logic should only be landed if we land the tests in the first place.

Reviewed By: StanislavGlebik

Differential Revision: D24104101

fbshipit-source-id: 0825f04ed74532e89fd5f1fbebeee5f2001fedcd
2020-10-05 02:02:13 -07:00
Kostia Balytskyi
28d0c470e9 fixtures: all fixtures repos should support initrepo
Summary: It is sometimes very convenient to just inject new DAGs into existing repos.

Reviewed By: StanislavGlebik

Differential Revision: D24103164

fbshipit-source-id: abdfa18acb2f2fb1475b601a7eccb57e006982ec
2020-10-05 02:02:13 -07:00
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