Commit Graph

7794 Commits

Author SHA1 Message Date
Jun Wu
b805766dd5 clidispatch: add a config option to set indexedlog checksum length
Summary: In case we want a different value, we can use this config option.

Reviewed By: muirdm

Differential Revision: D42783555

fbshipit-source-id: d3d7e1036db4635be45ecc61b0f521552dca6f75
2023-01-26 14:50:21 -08:00
Jun Wu
1492879b4e indexedlog: add a global config to set checksum chain length
Summary:
While D42626678 provides a way to set the max chain length per index, it's
annoying to update all users of indexedlog. Add a global option so we can
just update once for all.

Reviewed By: muirdm

Differential Revision: D42783554

fbshipit-source-id: 8bffe6de4225560c59da207f321fdaa2b65e25a1
2023-01-26 14:50:21 -08:00
Jun Wu
0a544add74 indexedlog: move config variables to a module
Summary: Move global configuration to a module to make it clear that those are configs.

Reviewed By: muirdm

Differential Revision: D42783055

fbshipit-source-id: d725946f1198199c9a40c612c435a60d62838e0d
2023-01-26 14:50:21 -08:00
Jun Wu
4b465a76df indexedlog: fix "race detected" during RotateLog::sync
Summary:
See the previous diff for context. This diff relaxes the metadata check to only
check the log length without checking indexes. This should resolve the race
condition.

The index uses persistent data structure with explicit pointers (offsets) so
data appended by another process would simply be ignored without causing
issues.

Reviewed By: muirdm

Differential Revision: D42627387

fbshipit-source-id: 5e776a8c6b34eeb6eefbb78f249fd99c7bd05b02
2023-01-26 14:50:21 -08:00
Jun Wu
8fc0ef156e indexedlog: add a test to reproduce "race detected" issue
Summary:
This reproduces the "race detected" error that sometimes happens.

Sample error:

  race detected, callsite responsible for preventing races
  (old meta: LogMetadata { primary_len: 500036164, indexes: {"2-node_and_path": 226025125}, epoch: 4118705755139574402 }
  ,new meta: LogMetadata { primary_len: 500036164, indexes: {"2-node_and_path": 235143143}, epoch: 4118705755139574402 })

Reviewed By: muirdm

Differential Revision: D38261693

fbshipit-source-id: c0b909531616bca9622afcf6d0541706a1056dd0
2023-01-26 14:50:21 -08:00
Jun Wu
ecfa1c154a indexedlog: optimize checksum linked list
Summary:
The checksum entry could form a long linked list that takes time to read from
disk. Add a way to "flatten" the chain so the linked list length could be reset
to 1 from time to time for optimized load time.

Reviewed By: muirdm

Differential Revision: D42626678

fbshipit-source-id: 57f13c235939ac416c6871eae7ec4e72b2c72f8e
2023-01-26 14:50:21 -08:00
Jun Wu
84d62aa7d4 runtests: support --time on Windows
Summary:
On Windows, `os.times()` does not provide a meaningful `elapsed`:

  In [1]: os.times()
  Out[1]: nt.times_result(user=1.921875, system=1.3125, children_user=0.0, children_system=0.0, elapsed=0.0)

Replace it with `time.monotonic()` so the wall clock time works on Windows.

Reviewed By: muirdm

Differential Revision: D42718496

fbshipit-source-id: dd1bfc313201cc6d321ee23397168d3981d03ffb
2023-01-26 13:30:19 -08:00
generatedunixname89002005307016
5f2af9ade3 Add annotations to eden/scm/edenscm/branchmap.py
Reviewed By: quark-zju

Differential Revision: D42773222

fbshipit-source-id: b3eecd913174dc6ea923f93019e6ff6769c49c1a
2023-01-26 10:32:25 -08:00
Muir Manders
99f069546b status: fix native status for git repos
Summary:
Teach Repo::file_store() and tree_store() to use the gitstore for git repos.

I also had to avoid a git store tree query for empty repos since git doesn't like our null ID.

Reviewed By: quark-zju

Differential Revision: D42711084

fbshipit-source-id: 399431d1478e9bcb1ffadb08e6bca0ed54f863a3
2023-01-26 09:17:43 -08:00
Muir Manders
ee53deebbe config: avoid loading external config files in tests
Summary:
The built-in git config file has an %include for /etc/mercurial/git_overrides.rc. Test were sensitive to this file, which is undesirable.

Fix in the easiest way possible by truncating the static config in tests starting from the first "%include".

I first tried to fix in a general way by refsuing to load any config files in tests unless they are under $TESTTMP. That didn't pan out due to various places that do exactly that.

Reviewed By: quark-zju

Differential Revision: D42711085

fbshipit-source-id: cd36fa439dd08d20ffb362c23a6296ff662b48dc
2023-01-26 09:17:43 -08:00
Mateusz Kwapich
dcfded090a client changes to fix push of commits with null manifests
Summary:
Sapling when trying to push a commit with null manifest tries to pack it first and fails miserably to obtain it. This diffs makes it skip null manifests as those don't need to be transferred.

NOTE: I've also included comment about more general problem that I've noticed. In `shallowbundle.py` we skip over all manifests that don't exist by catching exception but this exception had changed due to rust migration. **I didn't fix that problem.**

Reviewed By: muirdm

Differential Revision: D42753348

fbshipit-source-id: 9a1ae168d09d89bd0316991af88c6801e4c2f41b
2023-01-26 06:17:55 -08:00
generatedunixname89002005307016
77be4f3259 Add annotations to eden/scm/edenscm/ext/github/submit.py
Reviewed By: muirdm

Differential Revision: D42740694

fbshipit-source-id: 4f04a40927d4ac6f2a0168f0014f262790180b0d
2023-01-25 16:30:03 -08:00
Johnson Han
2ed14465d3 workspace.py should use rust config binding
Summary:
Breaking this task down into a few steps:
1. remove reference of config.py in `workspace.py`, `dirsync.py`, and `templater.py`.
2. remove `config.py`.

Reviewed By: muirdm

Differential Revision: D42731038

fbshipit-source-id: 6feb4db0808f5182696e1366042a9a94a59f743b
2023-01-25 12:05:59 -08:00
Johnson Han
14dc97ea6e dirsync.py should use rust config binding
Summary:
Breaking this task down into a few steps:
1. remove reference of config.py in `workspace.py`, `dirsync.py`, and `templater.py`.
2. remove `config.py`.

Reviewed By: muirdm

Differential Revision: D42731393

fbshipit-source-id: c0de17d4a592fbb9aba511ae5012696f57691e53
2023-01-25 12:05:59 -08:00
Johnson Han
6cc13f194c test-configparser.py should cover cfg.names()
Summary: I don't see any test for `cfg.names()`. Adding test in this diff.

Reviewed By: muirdm

Differential Revision: D42731690

fbshipit-source-id: 6d92759921d0fd1c735250a438b98f3c6db4a355
2023-01-25 12:05:59 -08:00
generatedunixname89002005307016
9d42ccb54a Add annotations to eden/scm/edenscm/verify.py
Reviewed By: quark-zju

Differential Revision: D42707762

fbshipit-source-id: 198310540947fdf4cb67e7c17f2fb21a42296827
2023-01-24 17:29:21 -08:00
generatedunixname89002005307016
c0801fecc9 Add annotations to eden/scm/edenscm/ext/errorredirect.py
Reviewed By: quark-zju

Differential Revision: D42658495

fbshipit-source-id: d4a6b77a9529c16261de62d89b8ce93669a63d4c
2023-01-24 17:26:15 -08:00
generatedunixname89002005307016
787f7e8cd5 Lint failure adding annotations to eden/scm/edenscm/dirstate.py
Reviewed By: quark-zju

Differential Revision: D42573407

fbshipit-source-id: 9cc19f28cb544a233889289c1a749a34f12e7889
2023-01-24 17:25:14 -08:00
generatedunixname89002005307016
9a7ee24565 Add annotations to eden/scm/edenscm/ext/disablesymlinks.py
Reviewed By: quark-zju

Differential Revision: D42675658

fbshipit-source-id: e72161ace4b489562bc78bda389e8f5e563e401c
2023-01-24 17:24:32 -08:00
generatedunixname89002005307016
18781e1d8e Add annotations to eden/scm/edenscm/traceimport.py
Reviewed By: quark-zju

Differential Revision: D42635569

fbshipit-source-id: f8d4fdecae0d268e7634d96f51c387c0e1db3060
2023-01-24 17:24:07 -08:00
generatedunixname89002005307016
07fa648294 Add annotations to eden/scm/edenscm/ext/checkserverbookmark.py
Reviewed By: quark-zju

Differential Revision: D42603976

fbshipit-source-id: 2e668d634ab152f4058f18d8a6c45fcb00ac9ae5
2023-01-24 17:23:51 -08:00
Michael Bolin
732d512647 chore: apply Black formatter to ghstack fork
Summary:
Historically, we avoided running the Black autoformatter on our
fork of ghstack so that the code would be easier to diff with
upstream. Now that Black is run on upstream ghstack:

e5eca89cb3

we have no reason to exclude it from our linter.

Going forward, we should update the GitHub CI to run `black --check`
and report back so that contributors get this signal as well.

Reviewed By: zsol

Differential Revision: D42494629

fbshipit-source-id: 7f09ec46f687e56662f4f6ac477fd2fd077709d6
2023-01-24 12:48:13 -08:00
Michael Bolin
36f952970d remove ghstack/github_schema.graphql
Summary:
Upstream ghstack uses this for `github_fake.py`:

004d330948/ghstack/github_fake.py (L261)

Because our fork of ghstack talks to GitHub in a different
way and has its own test harness such that we deleted
`github_fake.py`, we can remove `github_schema.graphql`, as well.

This simplifies things because our internal linter wants to run
Prettier over it.

Reviewed By: evangrayk

Differential Revision: D42698061

fbshipit-source-id: 602346e4e5ee48331513c5e28eafbb39f1fac71a
2023-01-24 12:48:13 -08:00
Saul Gutierrez
352feeef11 ci: bump python3.11.0 to python3.11.1 (#496)
Summary:
[sl] ci: bump python3.11.0 to python3.11.1

 ---
Stack created with [Sapling](https://sapling-scm.com). Best reviewed with [ReviewStack](https://reviewstack.dev/facebook/sapling/pull/496).
* __->__ https://github.com/facebook/sapling/issues/496

Pull Request resolved: https://github.com/facebook/sapling/pull/496

Reviewed By: zzl0

Differential Revision: D42719323

Pulled By: sggutier

fbshipit-source-id: e71d0ec4b9ccdc206bd7d844176a7896d5a3d97f
2023-01-24 12:45:16 -08:00
Jun Wu
db214dd551 indexedlog: document more details about checksum entry
Summary:
The implementation details are not obvious (for example, the xxhash chunk start
does not match start). Add more docs about them.

Reviewed By: muirdm

Differential Revision: D42626680

fbshipit-source-id: 2294d1cb6af859fb75a68b3618796d26b2dadd1c
2023-01-24 10:17:44 -08:00
Jun Wu
a4f78536dc indexedlog: clean up usage of cfg!(debug_assertions)
Summary:
`if cfg!(debug_assertions) { ... } else { ... }` is a better form since it
always checks that the code compiles and is sometimes shorter.

Reviewed By: muirdm

Differential Revision: D42626679

fbshipit-source-id: 1165b92b7b81d33704a5b4ee6ed36c61f4250c87
2023-01-24 10:17:44 -08:00
Saul Gutierrez
a8fb90880f revsets: add a test for ghrevset
Summary: Adds an integration test for the features added in D42221073

Reviewed By: bolinfest

Differential Revision: D42625035

fbshipit-source-id: 40a00f36ce25bd2250637bca3b42f16076be1304
2023-01-23 13:11:01 -08:00
Saul Gutierrez
6fde922876 tests: add mock for default push path
Summary:
D42614252 (79886f53d4) introduced a way of setting `default.default-push` through the `SL_TEST_GH_URL` environment variable in tests. This diff makes use of the same environment variable for `github.submit.get_origin`.

This can be useful when testing commands that need to connect to the mock GitHub server but still need to get data from the git repo being tested.

Reviewed By: bolinfest

Differential Revision: D42625037

fbshipit-source-id: bf19d772fef32bf4ce8326391a9df360a3412040
2023-01-23 13:11:01 -08:00
Saul Gutierrez
4720a2eff8 revsets: add support revset for Github pull requests
Summary:
This allows revsets of the form `PR[0-9]+` to be translated to commit hashes as well as autopulling them in case a local copy doesn't exist.  This revset can be used in commands that support revsets, such as:
- `goto`
- `log`
- `show`
- `rebase`
- `pull`

Marking the translated revsets as remote bookmarks is still pending

Reviewed By: bolinfest

Differential Revision: D42221073

fbshipit-source-id: 695fe82d0f0c23ea32e18c86be537ed3ea0807f7
2023-01-23 13:11:01 -08:00
Zhaolong Zhu
dc367d14d9 indexedlog_store: fix for_loops_over_fallibles warning
Summary:
https://doc.rust-lang.org/nightly/nightly-rustc/rustc_lint/for_loops_over_fallibles/static.FOR_LOOPS_OVER_FALLIBLES.html

Both Option and Result implement IntoIterator trait, which allows using them in a for loop. for loop over Option or Result will iterate either 0 (if the value is None/Err(_)) or 1 time (if the value is Some(_)/Ok(_)). This is not very useful and is more clearly expressed via `if let`.

Reviewed By: muirdm

Differential Revision: D42656184

fbshipit-source-id: b14b53b49ef90eea26a2329dbe37168e5d454dea
2023-01-23 11:54:07 -08:00
Zhaolong Zhu
77d3e8cafe shelve: simplify test and fix typos
Summary: removed unnecessary 'hg' command in the test and fixed some typos.

Reviewed By: muirdm

Differential Revision: D42656185

fbshipit-source-id: 4300b32703230193df425193715bfd0974872695
2023-01-23 11:54:07 -08:00
Jun Wu
dcc49d2fee tests: run cargo tests with different features
Summary:
Detect cargo features and run with features turned off. This can help capture
issues turning default features off.

Reviewed By: muirdm

Differential Revision: D42642444

fbshipit-source-id: 4a65d71a1e4e9766f385456c6738e2a01f644aca
2023-01-23 11:38:41 -08:00
Jun Wu
a087166913 cpython-ext: select python3 feature unconditionally
Summary:
This avoids invalid feature selections such as `--no-default-features` when
testing `cpython-ext`.

Reviewed By: muirdm

Differential Revision: D42643921

fbshipit-source-id: 517a47c81aed49ca8ebf0c7b8f4bdcb9eba8bba0
2023-01-23 11:38:41 -08:00
Jun Wu
e27c1ce127 renderdag: make serde an optional dependency
Summary: It is only used by the website SVG renderer. Let's make it optional.

Reviewed By: muirdm

Differential Revision: D42590209

fbshipit-source-id: 17231e8468792dfb87cc2010d4b74257fb5257b6
2023-01-23 11:38:41 -08:00
Muir Manders
ebbe7d8d7d ghstack: fix "land" rebase
Summary:
First, don't use "--keep" since that results in a duplicate set of commits visible in smartlog. It also makes it hard to map between the rebased commits since it doesn't record mutation markers. Further, note that "--keep" does not output the "nodechanges" data, so we were always assuming the rebase did no work, and would proceed to push the un-rebased commits. This would lead to a "non-fast forward" error whenever the default branch was newer than the stack's base.

Second, use "rebase -r" instead of "rebase -s". "-s" was rebasing the entire stack in the first loop iteration which causes two problems: 1) It rebases too much (i.e. it can rebase later commits in your stack you aren't trying to land right now). This is bad because you could see conflicts in commits you aren't trying to land, which doesn't make sense. And 2) it messes up the loop's mapping of commits since the loop assumes it is rebasing one commit a time. This issue was probably moot due to the "--keep" issue.

I also added some logic to "goto" back to the un-rebased commit after the rebase. In general, landing commits should not change the working copy. We also "hide" the commits created by rebase so the user won't see duplicate commits in their smartlog if there is a failure.

Finally, I tweaked the rebase logic to be more conservative wrt commits being "rebased out". If one of the commits being landed is already on the target branch, we abort and ask the user to rebase manually.

Fixes #333.

Reviewed By: bolinfest

Differential Revision: D42203379

fbshipit-source-id: 39a8dcd4d65e0535fc2379e4ad16fea902bb88d0
2023-01-23 10:40:34 -08:00
Muir Manders
79886f53d4 ghstack: add test for "land" logic
Summary:
Add a test that demonstrates an issue w/ "ghstack land" logic. The main issue is the pull/rebase never affects what we end up pushing, so non-fast-forward errors will occur whenever the remote main branch has commits newer than the stack's branching point.

I added/tweaked the mock utils based on what queries ghstack submit/land uses. I added a more generic "expect_request" which callers can use to mock out a response without needing to create a specific type.

Reviewed By: bolinfest

Differential Revision: D42614252

fbshipit-source-id: b9928361128f22c2f456836075aa7cf7ead5be11
2023-01-23 10:40:34 -08:00
Muir Manders
492c45bf53 github: add unexported _make_request mock point
Summary: Some users of make_request import the function, so subsequent wrapping of make_request has no effect. Now the wrapping applies to the unexported _make_request and always take effect.

Reviewed By: bolinfest

Differential Revision: D42614253

fbshipit-source-id: bc7c7b74333984c54adfc3d49a6207c46ee2f9b6
2023-01-23 10:40:34 -08:00
Muir Manders
fb562999f3 gituser: use ui.username() instead of direct config query
Summary:
I mainly want this so the HGUSER env var is respected in tests.

I prefer ui.username()'s abort message to what get_identity_or_raise() had since it cuts to the chase instead of "forcing" the user to open the link to discover the recommended command for setting username.

Reviewed By: bolinfest

Differential Revision: D42614255

fbshipit-source-id: de4a6719bfdefb2298e316bd18bad2c564aded84
2023-01-23 10:40:34 -08:00
kurtz.brandon@gmail.com
c8b66c6899 query HEAD name, instead of assuming main/master (#386)
Summary: query HEAD name, instead of assuming main/master

Test Plan:
 ---
Stack created with [Sapling](https://sapling-scm.com). Best reviewed with [ReviewStack](https://reviewstack.dev/facebook/sapling/pull/386).
* __->__ https://github.com/facebook/sapling/issues/386

Pull Request resolved: https://github.com/facebook/sapling/pull/386

Fixes https://github.com/facebook/sapling/issues/375

Ran a number of affected integration tests:

```
./run-tests.py test-git.t test-git-submodule.t test-git-submodule-rebase.t test-rust-clone.t test-doctest.py
```

Using the example from https://github.com/facebook/sapling/issues/375,
cloned the repo and verified that it cloned the `trunk` branch:

```
$ lhg clone --git https://github.com/cli/cli
$ cd cli
$ lhg
@  179e9c256  Yesterday at 14:13  2159081+qoega  remote/trunk
│  Add projectsV2 support to issue create, issue edit, pr create, and pr edit (#6735)
│
o    06ae07f97  Yesterday at 07:25  mislav
├─╮  Merge pull request #6880 from cli/setdefault-bare-repo
│ │
o │    351226d34  Yesterday at 07:17  mislav
├───╮  Merge pull request #6881 from cli/reviewers-json-fix
│ │ │
o │ │    241f9197e  Wednesday at 21:15  rmw
├─────╮  Merge pull request #6815 from cli/intake-doc
...
```

Reviewed By: quark-zju

Differential Revision: D42597162

Pulled By: bolinfest

fbshipit-source-id: 2f4b3869f452b57290f2a7a69721ecdd4e444b2e
2023-01-20 18:44:13 -08:00
Zhaolong Zhu
cea7748e20 shelve: ignore ._ hidden files created by MacOS
Summary: Currently, 'hg sl' template is calling 'shelved()' revset function to add '(shelved)' label, and it crashes if there are '._*' binary files created by MacOS. This diff ignores the '._*' files.

Reviewed By: quark-zju

Differential Revision: D42647182

fbshipit-source-id: 9ff8b67e85c55bf2ea24af774f1b638798e71f4c
2023-01-20 15:15:36 -08:00
Zhaolong Zhu
3d04ffdd94 shelve: add test for ._* hidden files
Summary:
Currently, `hg sl` template is calling `shelved()` revset function to add '(shelved)' label, and it crashes if there are `._*` binary files created by MacOS.

This diff is to add a test to repro the bug

Reviewed By: muirdm

Differential Revision: D42647185

fbshipit-source-id: 72b1677cc2cdc9c084b9e2a5a778d27d4a6c0abc
2023-01-20 15:15:36 -08:00
Jun Wu
f3aa6e64f6 dag: fix cargo test with non-default features
Summary:
By tweaking `cfg`s and visibility, it's now possible to run:

  cargo test --no-default-features
  cargo test --no-default-features --features render
  cargo test --no-default-features --features indexedlog-backend
  cargo test

  cargo build --no-default-features
  cargo build --no-default-features --features render
  cargo build --no-default-features --features indexedlog-backend
  cargo build

Reviewed By: muirdm

Differential Revision: D42619735

fbshipit-source-id: 404d2c1e81a79bc6bdead7072e5b4517df997967
2023-01-20 12:42:43 -08:00
Jun Wu
009c883081 dag: drop for-tests cargo feature
Summary:
The feature delegates to dag-types/for-tests. Crates using this feature can
enable it on dag-types instead.

Reviewed By: muirdm

Differential Revision: D42591209

fbshipit-source-id: aa0d5c788377cc7500fd0fc10dedf90d2d8d0583
2023-01-20 12:42:43 -08:00
Jun Wu
c4390a93cc dag-types: drop quickcheck_arbitrary_derive
Summary:
Partially reverts D34191759 (0cc5984cde).  `quickcheck_arbitrary_derive` is not published on
`crates.io` and is blocking `dag-types` from being able to be published.

Reviewed By: muirdm

Differential Revision: D42591210

fbshipit-source-id: f8d92af0d142bde15900757c9bb58fd19813ad1d
2023-01-20 12:42:43 -08:00
Jun Wu
d34a7119a0 dag: move dag/render to a separate crate
Summary:
This partially reverts D22970570 (c448e0f575). There is no circular dependency because a crate and its
test are treated differently as 2 crates. So `dag`, `dag (test)`, `renderdag`,
`renderdag (test)` are 4 crates. A dependency graph like:

  dag(test)
   +--renderdag
       +--dag
  renderdag(test)
   +--dag
       +--renderdag

is not circular and can be handled by cargo just fine.

Reviewed By: muirdm

Differential Revision: D42590207

fbshipit-source-id: 25e917f78f088be13711d652adbec3e5d6e47e4b
2023-01-20 12:42:43 -08:00
Jun Wu
ac062898ed dag: make abomonation optional
Summary:
It's only used by Mononoke caching and not used by other users.

See https://github.com/martinvonz/jj/issues/1056 for context.

Reviewed By: muirdm

Differential Revision: D42590206

fbshipit-source-id: 6fa25844775a91b9e4aabb23c2c499d4e4570e70
2023-01-20 12:42:43 -08:00
Jun Wu
9f33493110 treestate: use real threads for check_concurrent_writes
Summary: This makes the test a bit stronger.

Reviewed By: zzl0

Differential Revision: D42493269

fbshipit-source-id: d51ef1f6c0e9c5d7d72dd2e27c1800f0e62c16e9
2023-01-19 21:38:51 -08:00
Jun Wu
29a5c93a00 dirstate: remove treedirstate support
Summary: We only use treestate now.

Reviewed By: zzl0

Differential Revision: D42493091

fbshipit-source-id: 42a7d8d45f7e21810112a454596c730ed3b6c32f
2023-01-19 21:38:51 -08:00
Jun Wu
67e2145dd2 treestate: use internal locking to support concurrent writes
Summary:
Use locking internally to avoid racy concurrent writes that could cause
unrecoverable data corruption.

Previously:

  Timeline:  -------------------------->
  Process 1: open(), append, append, ...
  Process 2: open(), append, append, ...

Now:

  Process 1: open(), lock { append, append }, ...
  Process 2: open(),                          lock { append, append } ...

`append()` to the same file is exclusive to one instance.

Note we need to update `position` after obtaining the lock to pick changes from
other instances.

Reviewed By: zzl0

Differential Revision: D42492667

fbshipit-source-id: 6a6184c945d23e16eb1619458abdb18afc64868c
2023-01-19 21:38:51 -08:00
Jun Wu
5b5354b6e6 treestate: add Store.locked API
Summary: It'll be used by the next change.

Reviewed By: zzl0

Differential Revision: D42492670

fbshipit-source-id: 676320fc4fd14411a6feca450b53a0b67e82f6ec
2023-01-19 21:38:51 -08:00