Commit Graph

1458 Commits

Author SHA1 Message Date
Jun Wu
c85c750baa dag: add a remote protocol field to NameDag
Summary:
Makes NameDag own the state (logic) about how to send remote requests.
So NameDag can send requests on its own.

Reviewed By: sfilipco

Differential Revision: D27339282

fbshipit-source-id: 3cb6327dfeaefae45d4e7b88a3535463a84b195b
2021-04-05 12:48:34 -07:00
Jun Wu
79b40c5ce8 dag: define remote protocol
Summary: Define a trait for implementing the remote protocol elsewhere.

Reviewed By: sfilipco

Differential Revision: D27339281

fbshipit-source-id: da5b316d98863507361d3bde4988fd6c9098f48c
2021-04-05 12:48:34 -07:00
Jun Wu
31ab817ba6 dag: make NameDag IdConvert consider overlay IdMap
Summary: This will make the overlay IdMap effective when query against the NameDag.

Reviewed By: sfilipco

Differential Revision: D27339276

fbshipit-source-id: 80712bf651beb6c7e9f23bd4233c6d916101696a
2021-04-05 12:48:34 -07:00
Durham Goode
82f39a44fb checkout: check HgId during resumable checkout
Summary:
We already checked size and mtime, which should allow us to identify if
a file has changed since the last update, but we need to check hgid as well, to
make sure the previously-written content is supposed to be the same as the
about-to-be-written content

Reviewed By: andll

Differential Revision: D26955401

fbshipit-source-id: 859ad35b008e68d699601217f2a4398c6789913e
2021-04-02 12:58:35 -07:00
Durham Goode
d596d1284a checkout: allow resuming an interrupted checkout
Summary:
Updates native checkout to store which files have already been written
in .hg/upgradeprogress. Then enables it to load that file and skip writing those
files if they're already on disk and their mtime and size match the previously
written values. In theory we could record and check file hashes as well, but
that'd likely slow things down quite a bit.

Future diffs will add:
- Recording and checking the hgid that was written before vs what is about to be
  written. Just an hgid comparison, not a full hash computation.
- Some UX to inform the user when hg checkout can be continued, and possibly to
  implement 'hg checkout --continue'.

Reviewed By: andll

Differential Revision: D26830249

fbshipit-source-id: 88a75080966dae5241550ed7eedbc057c65966dd
2021-04-02 12:58:35 -07:00
Alex Hornby
9f9521dd4e rust: update zstd crates to zstd 1.4.8
Summary: Vendor updated zstd crates. Started on this as a prerequisite for vendoring updated async-compression crate, however dependency resolution means this actually updates async-compression as well.

Reviewed By: farnz

Differential Revision: D27467760

fbshipit-source-id: 74ca9e4da9f336cf609cf06c62559c9ef913c9a2
2021-04-01 06:20:12 -07:00
Arun Kulshreshtha
3295f0f1fe hg-http: add support for --insecure flag
Summary:
Add a `set_global_config` function to `hg-http` that gets called prior to command execution. This function can be used to configure the global behavior of all HTTP requests by setting up a callback that modifies every `Request` prior to sending.

Right now, the use case for this is to support the `--insecure` flag, as can be seen in the code.

Reviewed By: quark-zju

Differential Revision: D27243638

fbshipit-source-id: 61a52c1f4b56fffd860c2a7e9c7b03e146b2240a
2021-03-31 12:53:46 -07:00
Arun Kulshreshtha
e26bc3ffa4 clidispatch: add --insecure global flag
Summary: Add the `--insecure` flag to the list of global hg flags. This flag is already supported by Python, and adding it here will make it available to Rust code as well. This is used later in the stack.

Reviewed By: quark-zju

Differential Revision: D27243029

fbshipit-source-id: 150d42ee96e1e3194ff1be6a33d9b36887d86f2c
2021-03-31 12:53:46 -07:00
Gus Wynn
fc46c24e8f update tokio to 1.4.0
Summary:
https://github.com/tokio-rs/tokio/releases/tag/tokio-1.4.0
I want the `biased;` option in `tokio::select!`

Reviewed By: ahornby

Differential Revision: D27435341

fbshipit-source-id: c29ca954c319327f62466131ae04483ad091bf49
2021-03-31 10:44:20 -07:00
Mark Juggurnauth-Thomas
973b785c3b pysptui: a tui using streampager
Summary:
Add bindings for `pysptui`.  This allows using `streampager` as a TUI, using
streampager's controlled file mode to manage the display.

Reviewed By: quark-zju

Differential Revision: D27268252

fbshipit-source-id: d191a09c44ca4ed013647feb81e6f031d553b2f2
2021-03-31 07:59:26 -07:00
Arun Kulshreshtha
e02211f0d9 http-client: factor out version parsing into separate function
Summary: In a later diff, I plan to make this `pub` in order to parse HTTP versions from the user's config.

Reviewed By: quark-zju

Differential Revision: D27449576

fbshipit-source-id: 28a60080393eff73399c65b9e808647b39603719
2021-03-30 18:57:08 -07:00
Jun Wu
a008135ba2 dag: expand IdConvert delegation on NameDag
Summary: Expand the IdConvert implementation so we can change it.

Reviewed By: sfilipco

Differential Revision: D27339280

fbshipit-source-id: eb55c63529c895502a25bb279bcba3c13737452a
2021-03-30 09:58:29 -07:00
Jun Wu
a77579877b dag: add overlay IdMap to NameDag
Summary:
Add an overlay IdMap field for NameDag to store temporary remote IdMap results.
This diff just adds the field. It's not used yet.

Reviewed By: sfilipco

Differential Revision: D27339274

fbshipit-source-id: dbbde227f26de15d10c84f5d7c61ca8054577752
2021-03-30 09:58:29 -07:00
Jun Wu
c8b78b3c03 dag: extract in-memory IdMap to a separate structure
Summary:
In a future diff, AbstractNameDag wants an "overlay" IdMap to store temporary
remote IdMap results. The MemIdMap is suitable but has extra features (next
free id, version). Extract the core in-memory IdMap logic for the "overlay"
purpose.

Reviewed By: sfilipco

Differential Revision: D27339277

fbshipit-source-id: 4e73032b8bc6670264e3fa1dd5515ea3bc853d10
2021-03-30 09:58:29 -07:00
Jun Wu
0df4efa969 dag: asyncize Process::process
Summary:
The `Process::process` contains logic to resolve Id <-> Vertex using remote
service. The remote service is async so let's make `Process` async.

Reviewed By: sfilipco

Differential Revision: D27308798

fbshipit-source-id: 30c2c3eda124d542d0867d278ce56a7a174f33e0
2021-03-30 09:58:29 -07:00
Jun Wu
880f7a6b4c add storage.indexedlog-fsync config to turn on fsync
Summary:
The config turns on fsync for all indexedlog writes. It can be useful in places
where we want reliability more than performance with unknown kernel issues.

Reviewed By: sfilipco

Differential Revision: D27347595

fbshipit-source-id: c0b31928684e8805a9e6441062f96b05ad311ea2
2021-03-30 09:56:46 -07:00
Jun Wu
c12d660aee indexedlog: add a way to set fsync globally
Summary:
Add a global flag, if turned on, ensure all atomic files, and indexes and
primary logs use fsync.

Also enhance fsync so it syncs the directory too.

Reviewed By: sfilipco

Differential Revision: D27347596

fbshipit-source-id: 831e27e494cc343a33ca675619c030ead8023210
2021-03-30 09:56:46 -07:00
Carolyn Busch
40a856f8f0 Use Bookmark request and response type in endpoint
Summary: Use Edenapi book request and response type in bookmarks edenapi endpoint. Serialize the response as cbor.

Reviewed By: kulshrax

Differential Revision: D27174122

fbshipit-source-id: 6bc7295c25bd355db4625da3c1f8c68349e7b0b7
2021-03-29 18:40:00 -07:00
Carolyn Busch
3c1294057d add bookmark to make_req and read_res tools
Summary: Add bookmark request and response to the make_req and read_res edenapi utilities.

Reviewed By: kulshrax

Differential Revision: D27173813

fbshipit-source-id: 51df81c633017b0c3486ea903b525e7fbd01224f
2021-03-29 18:40:00 -07:00
Carolyn Busch
754b7f9888 add Bookmark, BookmarkRequest, and BookmarkResponse
Summary: Add edenapi types for the bookmarks endpoint. Now the endpoint can handle a request for a batch of bookmarks instead of a single bookmark. The request type still needs to be modified at some point to allow for bookmark prefix listing.

Reviewed By: kulshrax

Differential Revision: D27133284

fbshipit-source-id: c3960629cad76504e222f726a151eb3390850276
2021-03-29 18:40:00 -07:00
Jun Wu
e78f7fbd89 progress: flush progress clear sequence
Summary:
Before this change, progress clear wasn't flushed clearly:

  % hg rebase -s ad1bb0e8d -d master --config progress.delay=0
  rebasing ad1bb0e8d7bd "1"
  merging setup3.py             ]  1/10 commits  ad1bb0e8d7bd
  rebasing 1da78a375aee "2"     ]  1/10 commits  ad1bb0e8d7bd
  merging setup3.py=>           ]  2/10 commits  1da78a375aee
  rebasing 57cd9d2ebd1a "3"     ]  2/10 commits  1da78a375aee
  merging setup3.py==>          ]  3/10 commits  57cd9d2ebd1a
  rebasing 25974e253f14 "4"     ]  3/10 commits  57cd9d2ebd1a
  merging setup3.py==>          ]  3/10 commits  57cd9d2ebd1a
  rebasing d5719551c6de "5"     ]  4/10 commits  25974e253f14
  merging setup3.py=====>       ]  5/10 commits  d5719551c6de
  rebasing 7fed88ae552b "6"     ]  5/10 commits  d5719551c6de
  merging setup3.py=======>     ]  6/10 commits  7fed88ae552b
  rebasing f47f8801a3df "7"     ]  6/10 commits  7fed88ae552b
  merging setup3.py========>    ]  7/10 commits  f47f8801a3df
  rebasing cc973be54ce2 "8">    ]  7/10 commits  f47f8801a3df
  merging setup3.py==========>  ]  8/10 commits  cc973be54ce2
  rebasing ad4cf8cfe06c "9"==>  ]  8/10 commits  cc973be54ce2
  merging setup3.py===========> ]  9/10 commits  ad4cf8cfe06c
  rebasing 00695de80a4c "10"==> ]  9/10 commits  ad4cf8cfe06c
  merging setup3.py===========> ]  9/10 commits  ad4cf8cfe06c
  00695de80a4c -> f92addadf761 "10"10/10 commits  00695de80a4c

After this change, it now clears properly:

  % lhg rebase -s bea5186e1 -d tip --config progress.delay=0
  rebasing bea5186e121c "1"
  merging setup3.py
  rebasing cfeade2a7f61 "2"
  merging setup3.py
  rebasing b74d67120010 "3"
  merging setup3.py
  rebasing 764575565711 "4"
  merging setup3.py
  rebasing d46becf867b2 "5"
  merging setup3.py
  rebasing c2256b8e9342 "6"
  merging setup3.py
  rebasing 5e3b42f07e57 "7"
  merging setup3.py
  rebasing f1a897e8aa6b "8"
  merging setup3.py
  rebasing 085d4a259de8 "9"
  merging setup3.py
  rebasing fa32e54c475a "10"
  merging setup3.py

Reviewed By: singhsrb

Differential Revision: D27408066

fbshipit-source-id: 2cc0bf456b6b9fcfb4f353538efe561cf53d2d61
2021-03-29 13:10:27 -07:00
Jun Wu
c6ed3839cd io: support nested progress disabling
Summary:
With the mix of external pager and progress suspension, the progress might
be enabled by accident:

    # pager: disable forever
    disable_progress(True)
    # suspension
    with progress.suspend()
        ...
        # on __exit__, re-enables pager

Update the pager disabling logic be nested to avoid the potential issue.

Reviewed By: andll

Differential Revision: D27275016

fbshipit-source-id: 35ca7aef1890a981e6a1f0e5313b6a482ed43368
2021-03-25 16:54:49 -07:00
Meyer Jacobs
ff217c2407 scmstore: introduce new StoreTree type for basic type-safe handling of trees
Summary:
Refactor `scmstore::types` into separate `file` and `tree` modules and introduce a new `StoreTree` type to represent trees in the scmstore API.

Introduce a minimal `StoreTree` type. Importantly, for now this type does not provide any methods for deserializing the tree manifest and inspecting it's contents. This functionality won't be too hard to implement, though - it'll require some revisions to the `manifest-tree` crate and / or moving the `StoreTree` and `StoreFile` types to `revisionstore_types`.

Reviewed By: kulshrax

Differential Revision: D27310878

fbshipit-source-id: 712330fba87f33c49587fa895efea3601ce377af
2021-03-25 01:16:49 -07:00
Meyer Jacobs
943e3beaa1 scmstore: rename newstore to scmstore
Summary:
Rename "newstore" to "scmstore"

The three main options I'm considering are "edenstore", "scmstore", and "hgstore". They all describe the project sufficiently well, in my opinion. "edenstore" might be a stretch, as I have no reals plans for Mononoke to use it, while "hgstore" might be a bit limited, as integration with EdenFS is a core goal, and it'll be used by EdenFS to fetch remote data via EdenApi, not just Mercurial's local storage. I feel like "scmstore" rolls off the tongue the easiest, particularly vs. "hgstore" (both "H.G. Store" and "Mercurial Store"), and is a bit easier to type than "edenstore" (which has "ede" all with the same finger). I don't have a strong opinion on this matter, so If you'd like a different name I'm open to suggestions.

Speak now or forever hold your peace.

Reviewed By: andll

Differential Revision: D27180332

fbshipit-source-id: 19e6972ea0f6527e671792845dcfd339cf1ab767
2021-03-24 12:53:01 -07:00
Meyer Jacobs
b7e4757faa newstore: introduce new StoreFile type with strongly-typed redaction, LFS Pointers, and copy-header support
Summary:
Introduce a new `StoreFile` type for the `revisionstore` crate. This is an enum of `File`, `LfsPointer`, and `RedactedFile`, which represent the different cases the `Entry` type's `content` might actually represent. The `File` variant also handles stripping the copy header, if present, and stores both the `copied_from`, raw unstripped `content`, and stripped `content`, though only the latter can be accessed through the public API right now. Ideally, we'll move copy information into the history API and never actually need to make it public here.

Conversions are provided from `Entry` and EdenApi's `FileEntry` type (which also supports redaction and LFS pointers, but as errors instead of first-class values).

Modify the output type used in the Python bindings to use this new `StoreFile` type.

Currently, the `LfsPointer` variant is unused. This will be used later when we add first-class LFS support.

Reviewed By: kulshrax

Differential Revision: D26862710

fbshipit-source-id: 8326921f3ee43bf2e253847d5735c61f5a50bfa6
2021-03-24 12:53:01 -07:00
Meyer Jacobs
dbc5d45e72 newstore: add ExtStoredPolicy support to new storage backends
Summary: Adds `ExtStoredPolicy` support to the EdenApi and IndexedLog ReadStore implementations. This flag controls how LfsPointers found during a file query are handled (either returned as a result, or treated as "not found").

Reviewed By: kulshrax

Differential Revision: D27171814

fbshipit-source-id: 14dda47f32184c3ee703fbc77106885ca4d3ea27
2021-03-24 12:53:01 -07:00
Arun Kulshreshtha
1e34440f74 http-client: allow on_new_request to configure Request
Summary:
Make the `RequestCreationEventListeners::new_request` event listener take an `&mut Request` instead of an `&mut RequestContext` as a parameter.

In the existing code (particularly in the `hg-http` crate), this event listener is used to configure the `RequestContext` for reporting progress. This diff just generalizes this idea, allowing the listener to modify the entire `Request`.

This is useful when we need to hijack request creation in `hg-http` to do Mercurial-specific configuration. The specific use case here is to disable TLS certificate checking when the global `--insecure` flag is set.

(Note that `http-client` itself is application-agnostic, so Mercurial specific configuration should not happen in this crate. This is why `hg-http` exists at all.)

Reviewed By: quark-zju

Differential Revision: D27242947

fbshipit-source-id: 019e19037642fe24acaa8c2917d446b91e7bcb26
2021-03-23 23:31:10 -07:00
Arun Kulshreshtha
b12c140f6f http-client: add options to disable TLS verification
Summary: Add `verify_tls_cert` and `verify_tls_host` settings to `http-client::Request` that are equivalent to [`CURLOPT_SSL_VERIFYPEER`](https://curl.se/libcurl/c/CURLOPT_SSL_VERIFYPEER.html) and [`CURLOPT_SSL_VERIFYHOST`](https://curl.se/libcurl/c/CURLOPT_SSL_VERIFYHOST.html). These will be used to allow skipping cert validation with the `--insecure` flag.

Reviewed By: quark-zju, sfilipco

Differential Revision: D27242946

fbshipit-source-id: cfa0fe800d0d132ca10ec0203bfd20b53c68b814
2021-03-23 23:31:10 -07:00
Arun Kulshreshtha
573d86268d clidispatch: expose global options from Dispatcher
Summary: Used later in stack.

Reviewed By: quark-zju

Differential Revision: D27255244

fbshipit-source-id: 3630dfaa0e5513d4ab9de91d5a6867c859061685
2021-03-23 23:31:10 -07:00
Arun Kulshreshtha
bfc1eea7dd http-client: add non-consuming versions of Request builder methods
Summary:
The `Request` builder's methods currently take `self` by value, which was intended to make it easy to create new `Request`s in a fluent style without assignment. Unfortunately, it turns out that this complicates situations where we need to modify a `Request` in-place.

The ideal solution would be to change `Request`'s builder methods to take `&mut self` instead [1]. I tried doing this, but unfortunately there are too many other parts of the current design that rely on the existing behavior in ways that are difficult to change (particularly around the creation of streaming and async requests).

As a workaround, this diff simply adds matching `fn set_X(&mut self, ...) -> &mut Self` methods for each builder method on `Request`. The existing consuming methods have been rewritten in terms of those methods to prevent duplication of the actual method contents.

Given that all of the consuming builders now contain essentially the same body, it seems like we could reduce the verbosity here by using a macro. Unfortunately, I'm not sufficiently experienced with writing nontrivial macros to come up with something quickly, but I do think that it would be a good idea to eventually use a macro here.

 ---

[1]: In fact, it turns out that [this is considered a better practice](https://github.com/rust-lang/api-guidelines/discussions/81) when designing builders in Rust -- as long as the terminal method of the builder chain returns the built struct by value, it is still possible to create a new instance without assignment. This does mean, however, that we cannot easily move things from the builder to the final struct without using tricks like `Option::take` and `mem::swap`, since the signature of the terminal method would be `(&mut self) -> Self`).

Reviewed By: andll

Differential Revision: D27256048

fbshipit-source-id: 14f770a87abc839d358e5ba211a096226d3e0dc6
2021-03-23 16:37:42 -07:00
Jun Wu
151698a7fe indexedlog: be compatible with MultiLog changes written by older software (2)
Summary:
This is a follow-up to D27093942 (59b8287c85). But D27093942 (59b8287c85) forgot one `read_log` spot, making it
possible to lose data.

Reviewed By: andll

Differential Revision: D27265233

fbshipit-source-id: ab1e73cdcfd3cc9da2e19000ee5fd5761977dc4a
2021-03-23 10:57:27 -07:00
Jun Wu
af420423eb indexedlog: add a test showing mixed old/new read/write is problematic
Summary:
Turns out D27093942 (59b8287c85) was not a complete fix. It misses a `read_log`. Add a
test showing the problem.

Reviewed By: andll

Differential Revision: D27265232

fbshipit-source-id: 103e543abacbb2cbaf10aa3fe3d9693922d9daad
2021-03-23 10:57:27 -07:00
Jun Wu
adb24ca54d do not show Rust progress in curses interface
Summary: Rust progress bar renderer wasn't aware of the curses interface.

Reviewed By: kulshrax

Differential Revision: D27266773

fbshipit-source-id: 66294c8fef50d01f327642beeec03fc414173d5e
2021-03-23 10:52:56 -07:00
Thomas Orozco
9057903c3d revisionstore: lfs: separate download & upload paths
Summary:
There are a few abstractions in this that make it a little hard to
have different behavior between the download & upload paths.

This makes it hard to have different behavior for the two. It's a bit of a
problem right now in the sense that we end up doing things like sending a
Content-Length on a GET, but the reason I'm changing it is because I want to
chunk downloads and that requires having different logic in the upload &
download paths.

As part of doing this, I also moved a bunch of parameters away from
HttpLfsRemote and into HttpOptions, which makes the function signatures a
little more manageable.

Reviewed By: quark-zju

Differential Revision: D27191593

fbshipit-source-id: c332229bb3c5a4c1eaedb54dc12c3ddc19205050
2021-03-23 03:20:35 -07:00
Alex Hornby
617489bdc5 eden/scm/lib: default to python3-sys
Summary:
eden/scm/lib: default cpython_ext to python3
```

CI internally,  try a PR on github once its landed.

Reviewed By: quark-zju

Differential Revision: D27237636

fbshipit-source-id: 1768f778d75b5d6c62dfd5641f911604a37d3163
2021-03-23 01:13:08 -07:00
Arun Kulshreshtha
9e251b0dce clidispatch: remove unused dispatch function
Reviewed By: quark-zju

Differential Revision: D27243030

fbshipit-source-id: 82fe0940658e760b96d0ce318415434003597d2e
2021-03-22 22:09:15 -07:00
Arun Kulshreshtha
c13c6cb4fd hg-http: tidy up imports and doc comment
Summary: Fix malformed module-level doc comment and rearrange import groups (based on the de facto Rust style conventions at FB).

Reviewed By: quark-zju

Differential Revision: D27243739

fbshipit-source-id: 21614d16e5fbfecd793939325ef52819db9a4cb8
2021-03-22 22:09:14 -07:00
Meyer Jacobs
2e5bc61498 newstore: remove #[async_trait] use in new storage APIs
Summary:
Remove use of `#[async_trait]` in the new storage API, and eliminate the outer Future on the `fetch_stream` and `write_stream` methods, which was not used. The methods are now normal trait methods, which accept and return a stream.

It's possible we'll want to make these methods `async` again in the future, but until this this is more ergonomic, faster (one less layer of indirection), and avoids some of the type system limitations of `#[async_trait]`.

Reviewed By: andll

Differential Revision: D26695517

fbshipit-source-id: 2db60a3f37d594b0b9d1e1a2708532ef0ddaf585
2021-03-22 19:36:49 -07:00
Meyer Jacobs
bc28d0a94e newstore: Introduce FilterMapStore combinator
Summary:
Introduce `FilterMapStore` combinator to support cases like LFS, where values of the same type may or may not be supported by a given store implementation.

Use `FilterMapStore` in Python bindings to prevent LFS files from being accidentally written to the non-LFS indexedlog.

With this change, the new storage API should be safe to use without corrupting local storage.

Reviewed By: kulshrax

Differential Revision: D26651254

fbshipit-source-id: 629cb43d85f43117a32b577777e13ff8fb801d57
2021-03-22 19:36:49 -07:00
Meyer Jacobs
6d20cd3b1e newstore: HashMap-based in-memory ReadStore / WriteStore implementations for testing
Summary:
Introduce `HashMapStore`, a HashMap-based, generic, in-memory `ReadStore` / `WriteStore` implementation for testing purposes (and perhaps other uses in the future).

Introduce a minimal `KeyedValue` trait so that `HashMapStore` can determine the key to be associated with a written value in a generic way.

Reviewed By: kulshrax

Differential Revision: D26859235

fbshipit-source-id: 66032f072148796bde7a3a176fb2bb6707b95287
2021-03-22 19:36:48 -07:00
Meyer Jacobs
b51e7a510f newstore: introduce WriteError error enum and ReadWriteStore store trait
Summary:
Introduce `WriteError` type (similar to `FetchError` for reads) to support strongly-typed write errors. Eventually we'll probably want this type to carry the value that we tried to write (to allow write fallbacks, retries, etc) and perhaps add more enum variants (rejects, unavailable, etc).

Introduce `ReadWriteStore` trait for stores that support both reading and writing. This trait is automatically implemented for types which implement `ReadStore` and `WriteStore` with the same key and value types. This trait is intended to be used via the `BoxedRWStore` trait object. This type will be used in the Python bindings when `FallbackCache` is extended to implement `WriteStore` (in a future change).

Reviewed By: kulshrax

Differential Revision: D26646393

fbshipit-source-id: 96058cf1e826fdb6076a4162389829b3fe053686
2021-03-22 19:36:48 -07:00
Meyer Jacobs
c4dd06e57d newstore: python bindings for constructing newstore objects
Summary:
Introduce newfilestore class in pyrevisionstore, which constructs a newfilestore (BoxedReadStore for files) and a corresponding `ContentStore` which share the underlying IndexedLog object and EdenApi client.

Modify remotefilelog to construct ContentStore via this new class.

Currently, no methods are provided for the newfilestore - it is meant to be passed back into Rust code, where you may call it's Rust methods as shown in the `test_newstore` method (which will be removed in the future).

Currently the `util` module is made public for access from pyrevisionstore. In the future, this will be replaced in favor of a `NewFileStoreBuilder` which handles these concerns internally.

Reviewed By: DurhamG

Differential Revision: D26526331

fbshipit-source-id: c0f439fbee4c303db4a82171c866a3f3a5fc2324
2021-03-22 19:36:48 -07:00
Meyer Jacobs
c2366a0991 newstore: refactor FallbackStore to FallbackCache and Fallback
Summary:
Split `FallbackStore` (which supports writing fallback fetches) into `FallbackCache` (which behaves the same) and `Fallback` (which doesn't support writing fallback fetches). This eliminates the `From<>` bound on `Fallback` which is nonsensical in some cases where we don't want writing.

Replace `write_store` and `write` fields with a single `Option<>` `write_store` in `FallbackCache`, which cleans up the code a bit.

Separate the "fallback value type", "preferred value type", "write value type", and "output value type" separately control the output value type independent of the preferred store.

Reviewed By: kulshrax

Differential Revision: D26526149

fbshipit-source-id: aa9f25f5efb8a9ddab03a7d86a7a007f24d156ce
2021-03-22 19:36:47 -07:00
Arun Kulshreshtha
b06906d542 io: regenerate Cargo.toml
Summary: Ran autocargo on `eden/scm/lib`.

Reviewed By: quark-zju

Differential Revision: D27241613

fbshipit-source-id: 5dafc97fc104643d67368a05ced36f91ca582241
2021-03-22 14:09:45 -07:00
Arun Kulshreshtha
31d7561887 edenapi: add option to log requests
Summary:
Add an `edenapi.logdir` config option, which, when set, will cause the EdenAPI client to write a JSON version of every request it sends to the specified directory. This is intended for use when reproducing user issues (so that the developer can inspect and replay the requests that were sent).

The JSON request files can be directly given to the `edenapi_cli` or converted to CBOR using the `make_req` tool for manual testing with `curl`.

The approach right now is a bit simplistic, in that we just write a JSON file whenever the EdenAPI client makes a request. I'm open to suggestions on how to improve this. (For example, if there were a way for us to always have a record of the last N requests, that would be helpful for debugging user issues.)

Reviewed By: DurhamG

Differential Revision: D27145093

fbshipit-source-id: 3834c2052b0c5efa05d1d209962953b29f545a3f
2021-03-22 11:56:53 -07:00
Alex Hornby
9fce86450a fix rust warnings
Summary: noticed these in passing while working on previous diff

Reviewed By: mitrandir77

Differential Revision: D27227682

fbshipit-source-id: e7858c81951b780722b0836ecf6ee72aeb1ffa09
2021-03-22 11:47:55 -07:00
Jun Wu
a2a588d53a hgcommands: avoid creating a new IO struct if possible
Summary:
When testing "disable_progress" with chg (next diff) I found it was not
effective because there are 2 separate IO structs. The one we disable
from Python is different from the one the Rust progress thread uses.

I traced it down here. Since the Python IOs are just wrappers of
Rust IOs in the chg use-case. There is no need to recreate an IO
struct.

The "creating IO" struct is still useful, for things like "-t.py" testing where
the output needs to be captured into different Python variables per different
commands.

Reviewed By: DurhamG

Differential Revision: D27149243

fbshipit-source-id: 6e27adcc9f48b21fc24fba120be8c4a8fef1f909
2021-03-18 13:00:23 -07:00
Jun Wu
5e412629ee io: provide a way to disable progress rendering
Summary:
In some cases (ex. using an external pager). The IO states are changed outside
the IO struct's control. Ideally we should implement the external pager logic
on IO too but for now let's just add an API so the Python external pager logic
can disable progress output after starting an external pager.

Reviewed By: kulshrax

Differential Revision: D27149242

fbshipit-source-id: ff51fc153d3cc211cfa8ef697923d36f7c0f0d9b
2021-03-18 13:00:23 -07:00
Durham Goode
560bb0bfbd dynamicconfigs: fix prod check for Windows
Summary:
Detecting prod on Windows wasn't working because we used a posix path.
Let's add the Windows equivalent.

Also moves us to use the new hostcaps crate.

Reviewed By: chadaustin

Differential Revision: D27126497

fbshipit-source-id: 4035012fb7701378fb6e2e902c0efcd54ef42ea9
2021-03-18 11:26:06 -07:00
Thomas Orozco
21e170f6de thrift/rust: pass service_name and fn_name to call() on clients
Summary:
I'd like to add support for event handlers in the Rust ServiceRouter client (I
need this in order to inject CATs in calls made by the SMC client). To do so, I
need to be able to instantiate a `ContextStack`, and to do so, I need a static
c-string representing the service name & function name, which is what this diff
does.

Note that we actually do the same thing for Rust servers already.

#forcetdhashing

Reviewed By: farnz

Differential Revision: D27088187

fbshipit-source-id: be2ad541d5123b31f0dab73da16b35dbfd308d6f
2021-03-18 10:19:40 -07:00