Commit Graph

408 Commits

Author SHA1 Message Date
Andrey Chursin
36b6bb98d3 checkout: bindings for check_unknown_files
Reviewed By: DurhamG

Differential Revision: D27667154

fbshipit-source-id: 0bdfb74761b01c1fe41ca8fd519c065a28381e74
2021-04-13 11:47:54 -07:00
Andrey Chursin
5cc082a2d4 checkout: py binding for filescmstore
Summary: This introduces apply_scmstore method in pycheckout bindings

Reviewed By: DurhamG

Differential Revision: D27658751

fbshipit-source-id: c09e27483bd4ecbecf9ae7193d8d030702b07315
2021-04-12 14:45:10 -07:00
Jun Wu
0d764cf718 auth: configparser::ConfigSet -> configmodel::Config
Summary: The latter is more lightweight.

Reviewed By: DurhamG

Differential Revision: D27641669

fbshipit-source-id: d907407f5a6e868862fe37f1f67fbe99ee378156
2021-04-12 14:29:45 -07:00
Stefan Filip
d64c9b479d edenapi: update commit_hash_to_location to use a list of master heads
Summary:
We want to handle the case where the client has multiple heads for master. For
example when master is moved backwards (or when it get moved on the client by
force). Updating the client code to thread the list of master commits to the
EdenApi client.

Reviewed By: quark-zju

Differential Revision: D27523868

fbshipit-source-id: db4148a3f1d0e8b0b162e0ecc934e07f041c5511
2021-04-09 17:10:57 -07:00
Andrey Chursin
a540d6fc5c checkout: basic py binding for MergeResult
Reviewed By: DurhamG

Differential Revision: D27482908

fbshipit-source-id: c8c9ae3a48f5ba2ee18df056e556bd17da26ba7b
2021-04-07 19:07:31 -07:00
Durham Goode
6d9f0b1f06 clone: make resumable checkout optional
Summary:
Since we're rolling out native checkout and resumable checkout around
the same time, let's make resumable checkout optional so we can turn it off it
causes issues, without turning off native checkout.

Reviewed By: quark-zju

Differential Revision: D27481986

fbshipit-source-id: a0a3e68567ca2a468e852dce95c03c4b606aaf22
2021-04-05 15:35:08 -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
Meyer Jacobs
b6bae3550c scmstore: python bindings for constructing treescmstore object
Summary: Basic python constructor bindings for tree scmstore.

Reviewed By: DurhamG

Differential Revision: D27246806

fbshipit-source-id: 169adef7f01e8b6d96f35614b414f8190a40ab8c
2021-04-01 18:07:31 -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
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
Andrey Chursin
6c9f208eb1 pyprogress: do not panic on __exit__
Summary:
Currently dropping progress bar panics if `__exit__` returns error
This happens, for example, when handling interrupts. Best course of actions just do not panic in this case

Reviewed By: sfilipco

Differential Revision: D27334897

fbshipit-source-id: c879fb14cfd4c16c0f9caede552129f8117defdc
2021-03-25 15:27:29 -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
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
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
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
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
Jun Wu
b573e1b866 pydag: add API to repair NameDag
Summary: This will be used by `doctor` command.

Reviewed By: sfilipco

Differential Revision: D27053349

fbshipit-source-id: bc33e25997f30107f919a090ff68693bfdd7199d
2021-03-15 18:45:07 -07:00
Andrey Chursin
e1ce22be1e async-runtime: introduce (try_)block_unless_interrupted
Summary: This method should be preferred to use from python binding. It is similar to block_on but allow to interrupt future on Ctrl+C

Reviewed By: quark-zju

Differential Revision: D26894586

fbshipit-source-id: 02d8fbb2f9c4d9e585f8fbee51bfc400c402d0d2
2021-03-12 09:04:04 -08:00
Jun Wu
44df77ef6b pyprogress: expose Rust progress model and render
Summary: Expose Rust's progress model so Python can operate on them.

Reviewed By: andll

Differential Revision: D26886283

fbshipit-source-id: 843de4cd2d8d22aba014ee097b0fee2feeb6ee43
2021-03-11 17:19:14 -08:00
Durham Goode
addb3c4e81 dynamicconfig: move validation into pure Rust
Summary:
Pure Rust commands weren't loading dynamicconfigs correctly because the
validation was happening in Python. This diff moves it down into Rust so that
all config loading gets the same validation.

Also removes the hard coded list of files to validate. I'll add this to
configerator to make it easier for us to edit.

Also removes the configs.validatedynamicconfig option. Validation is on
everywhere and should just be on by default.

Reviewed By: kulshrax

Differential Revision: D26680075

fbshipit-source-id: f206198154801f655b4b277cdb22a728d0004b5f
2021-03-11 10:13:36 -08:00
Lukas Piatkowski
ad106958f2 eden/scm/lib: autogenerate all Cargo.toml files with autocargo
Summary: This diff removes the split between manually managed and autocargo managed Cargo.toml files in `eden/scm/lib`, now all files are autogenerated.

Reviewed By: quark-zju

Differential Revision: D26830884

fbshipit-source-id: 3a5d8409a61347c7650cc7d8192fa426c03733dc
2021-03-05 04:29:49 -08:00
Andrey Chursin
be0b48333b checkout: wrap record_updates with allow_threads
Summary: Using allow_threads allows python to handle Ctrl+C and update spinner

Reviewed By: DurhamG

Differential Revision: D26670807

fbshipit-source-id: 6506f6aba8a62f0e95d4e04b5ab69539e543f3cd
2021-03-01 20:25:18 -08:00
Andrey Chursin
c8871fd796 checkout: support sparse profile update in python binding
Summary:
This diff integrates CheckoutPlan::with_sparse_profile_change into python code
It also updates test-update-over-sparse-profile-change.t to use native checkout, as this test now passes

Reviewed By: DurhamG

Differential Revision: D26670414

fbshipit-source-id: 73011217b4a0d80ef643b778cdaf75bbada5dcf2
2021-03-01 20:25:17 -08:00
Jun Wu
4f0e42a891 pytracing: normalize foo.bar to foo::bar for tracing target
Summary:
The target form `foo.bar` cannot be used in the env filter syntax:

  EDENSCM_LOG=edenscm.hgext.dirsync=debug lhg log -r .
  ignoring `edenscm.hgext.dirsync=debug`: invalid filter directive

Reviewed By: DurhamG

Differential Revision: D26708621

fbshipit-source-id: 370e93fe6abf2311c8b4ae07d0906973c8a9b74b
2021-03-01 14:10:58 -08:00
Arun Kulshreshtha
f2fc83597d edenapi: add Content-Length header to ResponseMeta
Summary: Add `Content-Length` to `ResponseMeta` struct. Will be used for logging purposes.

Differential Revision: D26709386

fbshipit-source-id: 4346627e3883d00350738cca1e71004f8d407c0d
2021-03-01 13:04:37 -08:00
Jun Wu
30ad76433e dag: add a way to describe bytes in indexedlog IdDag store
Summary:
This will be useful to explain bytes in the indexedlog.

Together with `debugdumpindexedlog` this can be used to troubleshoot issues.
For example, `debugdumpindexedlog` has:

  # Entry 11763:
  0004064b: 00 03 01 00 00 00 00 00 05 f1 00 01 ea 8b 80 80  ................
  0004065b: 80 80 80 80 01                                   .....

The entry can then be easily decoded via debugshell:

  In [1]: def e(s):
   ...:     print(b.dag.describebytes(bin(s.replace(' ',''))))

  In [2]: e('00 03 01 00 00 00 00 00 05 f1 00 01 ea 8b 80 80 80 80 80 80 01')
  # 00: Flags = (empty)
  # 03: Level = 3
  # 01 00 00 00 00 00 05 f1: High = N1521
  # 00: Delta = 0 (Low = N1521)
  # 01: Parent count = 1
  # ea 8b 80 80 80 80 80 80 01: Parents[0] = N1514

Reviewed By: sfilipco

Differential Revision: D26654639

fbshipit-source-id: c8438623b7e22e6abaf5c3011be25587f9d68753
2021-02-25 08:32:48 -08:00
Arun Kulshreshtha
c7d1040701 pyauth: omit unset auth fields
Summary: Make the auth Python bindings match the behavior of `httpconnection.readauthforuri` and omit unset fields in the returned dict.

Reviewed By: quark-zju

Differential Revision: D26439292

fbshipit-source-id: 776d8d9bd59726f5ad8d28973e9c2fdc99a2995c
2021-02-24 17:13:51 -08:00
Jun Wu
11fde14c74 pyio: match Rust IO APIs
Summary:
Rename `pager` to `IO` matching the Rust IO APIs. This allows us to use the
Rust IO APIs from Python.

Reviewed By: sfilipco

Differential Revision: D26612485

fbshipit-source-id: d78f1c8966429e563fe7d190bbcb3bad1b0710fd
2021-02-23 22:33:47 -08:00
Jun Wu
f40e980428 pypager: rename to pyio
Summary:
I'm going to expose more APIs from the Rust IO such as setting progress
content, etc. Rename the module to clarify.

Reviewed By: sfilipco

Differential Revision: D26612490

fbshipit-source-id: 136ea27a733b09557d02077e68ce51184125ade1
2021-02-23 22:33:46 -08:00
Jun Wu
b3a8cd238e progress: rename write_progress to set_progress
Summary:
Unlike stderr or stdout, writing to progress clears the previous progress text.
Update the function name to clarify.

Reviewed By: sfilipco

Differential Revision: D26612481

fbshipit-source-id: 382182fdcc713f92117d01f53b8da47d195b06cb
2021-02-23 22:33:46 -08:00
Jun Wu
fe8dada0e6 progress: change write_progress to take &str
Summary:
There seems no need for the progress bar text to be binary (it is not used to
redirect to binary files). Let's change the type to make future changes easier.

Reviewed By: sfilipco

Differential Revision: D26612479

fbshipit-source-id: 1da7950d5ab2b590963f1591e2f1dd5ae8e0116c
2021-02-23 22:33:45 -08:00
Andrey Chursin
3c1884034f checkout: use allow_threads in native checkout
Summary: This allow python to redraw progress bar

Reviewed By: quark-zju

Differential Revision: D26613054

fbshipit-source-id: 717f2c15fd9f9ccf339b457529c4f070d1f7ab79
2021-02-23 15:45:04 -08:00
Jun Wu
e46d5c4295 clidispatch: drop unused mut from IO APIs
Summary: Now IO has internal locking, `mut` is no longer needed.

Reviewed By: sfilipco

Differential Revision: D26518025

fbshipit-source-id: d71e213f6fed24fdefb4c730d576f6cf2fb09d82
2021-02-23 15:09:14 -08:00
Jun Wu
57adadaf1d pypager: use the global IO state
Summary:
Use the global IO state instead of keeping a separate IO state.

This makes the Python pager logic able to affect the tracing logger's error
output. For example, the following command will write the tracing logs to
the streampager's stderr channel as expected:

    EDENSCM_LOG=trace lhg log -r '.~1000::.' --config pager.pager=internal:streampager

Traditional pager also works:

    EDENSCM_LOG=trace lhg log -r '.~1000::.' --config pager.pager=less

Reviewed By: sfilipco

Differential Revision: D26518024

fbshipit-source-id: c7020b7467f9392af8c2a58d064339d05bce35ce
2021-02-23 15:09:13 -08:00
Andrey Chursin
adb28ae0aa checkout: expose stats to Python
Reviewed By: quark-zju

Differential Revision: D26552742

fbshipit-source-id: fccc812eb1f3ad150580538a1d8fa4e8afd3bd7b
2021-02-20 01:29:10 -08:00
Andrey Chursin
2646ed375b checkout: record updates after checkout
Summary: This is needed to correctly show status after checkout

Reviewed By: quark-zju

Differential Revision: D26551119

fbshipit-source-id: 3ab576df8132b1fb8cccf507717923ecf3084757
2021-02-20 01:29:09 -08:00
Andrey Chursin
c7269df47e checkout: impl Display for CheckoutPlan
Summary: Also add __str__ Python binding. Usefull for debugging

Reviewed By: quark-zju

Differential Revision: D26496791

fbshipit-source-id: 8bcfc89918c5fafc9ac8e42ef91c576b160d943c
2021-02-19 10:30:01 -08:00
Andrey Chursin
ceee768281 pycheckout: register checkout module in populate_module
Reviewed By: DurhamG

Differential Revision: D26470216

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

Differential Revision: D26469704

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

Reviewed By: DurhamG

Differential Revision: D26437080

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

Reviewed By: DurhamG

Differential Revision: D26437079

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

Differential Revision: D26435596

fbshipit-source-id: 013070ff918c7b45105c7abdad0950ee96d46d49
2021-02-17 12:02:43 -08:00
Arun Kulshreshtha
c97db6b042 auth: rename structs
Summary:
Make the struct and method names in this crate more clearly reflective of what they do:

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

Reviewed By: singhsrb

Differential Revision: D26436095

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

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

Reviewed By: quark-zju

Differential Revision: D26355403

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

Reviewed By: quark-zju

Differential Revision: D26419447

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

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

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

Reviewed By: quark-zju

Differential Revision: D26385843

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

Reviewed By: quark-zju

Differential Revision: D26385846

fbshipit-source-id: c0df543032461de650a4d24c26c6b8aaab1abbb9
2021-02-11 19:29:21 -08:00