Commit Graph

8039 Commits

Author SHA1 Message Date
Jun Wu
2ef700deec io: add API to quit then wait pager
Summary:
This will be used by Ctrl+C handling. By quitting the pager and waiting
for it, we can drop the `Terminal` properly and restore the terminal state.

Reviewed By: muirdm

Differential Revision: D42876258

fbshipit-source-id: 7849418c8f6d214530b32c25846618d42029399f
2023-02-02 13:28:27 -08:00
Jun Wu
2d5a559f54 git: include more logs for debugging submodule clone deadlock
Summary:
Include the submodule `path` in traceback, and log when the submodule repos are
actually created.

Reviewed By: muirdm

Differential Revision: D42949670

fbshipit-source-id: b09fd4148893d770e38b3f23e8ed3b63a1408f83
2023-02-02 13:20:41 -08:00
Jun Wu
bc45030bcb commitcloud: stop writing v1 state files
Summary:
We have migrated to v2 (D35232804 (3807e9662b)) for a long time.
Let's just write to the v2 state files since it's unlikely
that we need rollback to an older version without the v2
format support.

Reviewed By: markbt

Differential Revision: D42912666

fbshipit-source-id: 77cf6bee866e9a6f58629b9a5ee49c5c604b7ef5
2023-02-02 13:16:52 -08:00
generatedunixname89002005307016
1f4840f579 suppress errors in eden
Differential Revision: D42971344

fbshipit-source-id: 7490d8e9f51ce2fa046c0095dbb5329c3d8c4533
2023-02-02 12:45:01 -08:00
Jun Wu
bc80499084 git: avoid deadlock with nested submodules of same URL
Summary:
Some submodules (ex. gflags) have submodules (ex. gflags/doc) that share the same
URL with the parent repo. Previously those 2 repos would deadlock on the
backing repo wlock on checkout, and the git reference would conflict.

Fix them by:
- Skip the submodule backing repo wlock, since nobody uses the backing repo's
  working copy.
- Escape `/` to `_` in the git reference name to avoid conflict.

Reviewed By: muirdm

Differential Revision: D42949672

fbshipit-source-id: fc471f9c6aeec05212911e3ffeb8f53f0427fa38
2023-02-02 11:32:30 -08:00
Jun Wu
76f184b45a posix: track lock creation stacktrace in deadlock detection
Summary:
This is used to investigate a deadlock pulling submodules when cloning the
pytorch repo.

Note the deadlock checking only works for Python locks and requires
`--config devel.lockmode=python` to activate.

Reviewed By: muirdm

Differential Revision: D42949671

fbshipit-source-id: bfd01e7564bf10f64875a411e7d74c961e240425
2023-02-02 11:32:30 -08:00
Jun Wu
59fce58b2c test-repo-leak: use modern configs
Summary: Test modern code paths.

Reviewed By: muirdm

Differential Revision: D42940458

fbshipit-source-id: e1a0def90e1eca37cfac9d338452098730b171fa
2023-02-02 11:32:30 -08:00
Jun Wu
8387790c17 test-repo-leak: migrate to debugruntest
Summary: Enabling `#inprocess-hg-incompatible` makes the test compatible.

Reviewed By: muirdm

Differential Revision: D42940329

fbshipit-source-id: 0779b4ed4790d087958aee97b54f8e085dd09b28
2023-02-02 11:32:30 -08:00
generatedunixname89002005307016
98b90b65b3 Add annotations to eden/scm/edenscm/ext/remotefilelog/cacheclient.py
Reviewed By: quark-zju

Differential Revision: D42843733

fbshipit-source-id: 82928c2833d9563b648662de74db7743cb408ac1
2023-02-02 08:56:53 -08:00
generatedunixname89002005307016
e44a6a88ce Add annotations to eden/scm/edenscm/localrepo.py
Reviewed By: quark-zju

Differential Revision: D42961124

fbshipit-source-id: 59c6fd5a91b2c8b9f784e1ed3f4803a639373624
2023-02-02 08:53:04 -08:00
generatedunixname89002005287564
8074589d16 Reviewed By: zertosh
Differential Revision: D42955463

fbshipit-source-id: 803f9319b6873da7220af33d5619920b5d1efef0
2023-02-02 04:42:49 -08:00
generatedunixname89002005307016
7942a4e360 upgrade pyre version in fbcode/eden - batch 1
Reviewed By: genevievehelsel

Differential Revision: D42946315

fbshipit-source-id: 38eff0b796fbbd78ba842787c5887390ff698e36
2023-02-01 20:39:41 -08:00
Jun Wu
065cbf8e8e test-debugrevset: fix debugruntest compat
Summary:
The test requires the Rust implementation of `debugrevset`. However by setting
`workingcopy.use-rust` to False (default) the `clidispatch` would request
falling back to a Python implementation of `debugrevset`, which does not exist.

Fix it by setting `workingcopy.use-rust` to True. We should make sure
`run-tests.py` and `debugruntest` has a same view of default hgrc. But that
is a potentially breaking change and would be done separately.

Reviewed By: zzl0

Differential Revision: D42825820

fbshipit-source-id: db537c0226d205f9fc5d1a464a6ef4b4d8793185
2023-02-01 12:05:24 -08:00
Jun Wu
6f940d0d4c test-config-precedence: fix debugruntest compat
Summary:
The "regen-command" spwans a real subprocess in Rust that does not go through
the Python shinterp so it was not compatible with debugruntest.

Let's check the tracing message instead to ensure the spawn behavior happened.

Reviewed By: zzl0

Differential Revision: D42825821

fbshipit-source-id: d51c13e5b6d5ea776cfddd8f49db4913e826304d
2023-02-01 12:05:24 -08:00
Jun Wu
ef6072246b commitcloud: do not make LocalSerivce as a singleton
Summary:
If LocalSerivce is a singleton, it will capture an `ui` object that might be
stale in in-process hg tests. `LocalSerivce` is cheap to construct so let's
just avoid the singleton pattern for test compatibility.

This fixes `test-commitcloud-rename-workspace` debugruntest compatibility as
the following text is now printed properly using the up-to-date `ui.debugflag`:

  commitcloud local service: get_references for current version 2

Reviewed By: zzl0

Differential Revision: D42825822

fbshipit-source-id: 683dec345c4a36a6d79080e54a09050991c11dad
2023-02-01 12:05:24 -08:00
Jun Wu
dcbbb6be77 test-clone-resume: fix debugruntest compat
Summary:
`&>` is parsed by conch-parser as `&` (run in background) and `>` (redirect) so
it does not work properly in debugruntest.

In this case the test just want to silence the traceback of an uncaught error.
Let's make it explicit that we just disable that traceback without affecting
other logic.

Reviewed By: zzl0

Differential Revision: D42825819

fbshipit-source-id: 963f83ed25d22ace13982632e23cc86195a62a2f
2023-02-01 12:05:24 -08:00
Jun Wu
25aa52bc55 checkmessagehook: inline extension
Summary:
Inline the checkmessagehook extension so it works without using hooks.
Hooks have extra overhead (ex. flushing pending commits, files, metalog, etc so
changes are visible to subprocesses) that is unnecessary for just checking
a commit message.

Reviewed By: zzl0

Differential Revision: D42823936

fbshipit-source-id: 4ca951f4f555ea3b3227656539b4748b83692230
2023-02-01 12:05:24 -08:00
Jun Wu
27af34dea0 lib: vendor streampager
Summary:
This allows faster iteration on streampager features.

I made the file loading feature optional by adding the `loaded_file` feature.
This way the code is compatible with upstream and for internal build we can
avoid unnecessary dependency like `notify`.

Reviewed By: markbt

Differential Revision: D42873673

fbshipit-source-id: 7d3d0f07f4f5a30cfcc87ed6d02ea0886f88276b
2023-02-01 11:58:45 -08:00
Muir Manders
63c02b5aee rebase: disable inmemory rebase w/ --collapse
Summary: Conflicts weren't being handled properly with --collapse combined with rebase.experimental.inmemory=true. Work around by disabling in-memory rebase when collapsing.

Reviewed By: sggutier

Differential Revision: D42924842

fbshipit-source-id: 6d86ea1ad8c7b6852f0bd874d26041e42f0c2b10
2023-02-01 11:51:30 -08:00
Muir Manders
7f39eca2df rebase: add test for incorrect "--collapse" behavior
Summary: Add test showing incorrect collapse behavior when source commits merge.

Reviewed By: sggutier

Differential Revision: D42924841

fbshipit-source-id: f4c42af19d52b50a0023b2b44f50e5d264a915ce
2023-02-01 11:51:30 -08:00
Muir Manders
972ea94d27 revert test-merge-tools.t
Summary: This wasn't passing after my recent change to enable native status in more tests. Not sure why I committed or how it landed.

Reviewed By: sggutier

Differential Revision: D42926501

fbshipit-source-id: 2fb8179ba578e8ce61aca6ab2ea3c077dbfc158e
2023-02-01 10:08:38 -08:00
Muir Manders
dbdcd00856 fix test-ext-logginghelper.t
Summary: Switch from "status" to an arbitrary Python command "addremove" so the extension under test gets loaded.

Reviewed By: sggutier

Differential Revision: D42925551

fbshipit-source-id: 88a8a687a86016872eddca99041138df151bce3e
2023-02-01 09:07:15 -08:00
Muir Manders
1a0c6a9fbe fix test-basic.t
Summary: Fix some failing tests that were linux specific related to using native status.

Reviewed By: sggutier

Differential Revision: D42925560

fbshipit-source-id: 387c7cf141a0b6274f7127bca25d3c8c15be375c
2023-02-01 09:07:15 -08:00
Muir Manders
8f7d00dc6a sparse: ignore directory %includes
Summary:
Ingore %include directives that end in "/". It isn't valid to include a directory, and this was causing an error for the Rust status command when it went looking in the manifest for the path ending in "/".

We seem to sanitize the paths given to "hg sparse enable ...", so I'm not sure how the bad path got into a sparse config beyond hand editting.

Differential Revision: D42870518

fbshipit-source-id: d2162ca1180e06080c9bdf846f1715e389ea0fdd
2023-02-01 08:13:43 -08:00
Baojun Wang
286e032ce6 Upgrade uuid to 1.2
Summary:
Upgrade uuid crate from v0.8 to v1.2.

Fixed build errors due to API breakage:

1) `to_hyphenated()` -> `hyphenated()`.
2) `to_hyphenated_ref()` -> `as_hyphenated()`.
3) `to_simple()` -> `simple()`.
4) Update `Cargo.toml` (For some reason `arc autocargo` didn't work for some `Cargo.toml` files, likely due to autocargo config section in `TARGETS`).
5) `to_simple_ref()` -> `as_simple()`.
6) `use uuid::adapter::HyphenatedRef` -> `&` `uuid::fmt::Hyphenated`.

For 1), 2), 3) and 4) I ran below scripts to update the API call sites, respectively:

```
 5139  2023-01-27 13:20:58 for rs in `fbgs -f '.*\.rs' '.to_hyphenated()' | awk -F: '{print $1;}' | uniq`; do sed -i 's/\.to_hyphenated()/.hyphenated()/g' $rs && echo -e "processing $rs"; done
 5140  2023-01-27 13:22:12 for rs in `fbgs -f '.*\.rs' '.to_hyphenated_ref()' | awk -F: '{print $1;}' | uniq`; do sed -i 's/\.to_hyphenated_ref()/.as_hyphenated()/g' $rs && echo -e "processing $rs"; done
 5154  2023-01-27 13:37:19 for rs in `fbgs -f '.*\.rs' '.to_simple()' | awk -F: '{print $1;}' | uniq`; do sed -i 's/\.to_simple()/.simple()/g' $rs && echo -e "processing $rs"; done
 5216  2023-01-27 14:56:26 for toml in `fbgr -f 'Cargo\.toml' 'uuid = { version = "0[^"]*"' | awk -F: '{print $1;}' | uniq`; do sed -i 's/uuid = { version = "0[^"]*"/uuid = { version = "1.2"/g' $toml && echo -e "processing $toml"; done
```

For 5) and 6), There're only a few places need fixing (hermit-cli and linttool), so I fixed them manually.

== Exceptions
gpt crate v0.3 still uses uuid-0.8 as a dependency, hence [metalos/**/expand_paritiion.rs](https://www.internalfb.com/code/fbsource/[72f22c0ad63b64adbe88fa9213d60ce8f0320421]/fbcode/metalos/lib/expand_partition/src/expand_partition.rs?lines=138) should not apply above 'codemod' (or must be reverted).

NOTE: Because uuid crate v1 has breaking API changes, there's no easy way to split the diffs to multiple smaller *atomic* (where each diff wouldn't cause CI failures) diffs, unfortunately.

Reviewed By: edward-shen

Differential Revision: D42811369

fbshipit-source-id: 377fd1036c8a75bcb1982b03c720a3cea02421e5
2023-01-31 14:55:53 -08:00
Muir Manders
1caeb25d0a status: enable rust status in more tests
Summary:
These tests just needed to switch to a modern, non-revlog repo format.

Remaining tests using the old status have the same problem, but are trickier to migrate due more complicated client/server interactions.

Reviewed By: quark-zju

Differential Revision: D42748903

fbshipit-source-id: 979720cff4e72de586c90d922694d4d88c130b2f
2023-01-31 12:25:37 -08:00
Muir Manders
2ac1872674 tests: kill test-fb-ext-treemanifest-convertflat.t
Summary: We don't care about flat manifest anymore, and it would be work to update this test to use modern repo format.

Reviewed By: quark-zju

Differential Revision: D42748901

fbshipit-source-id: fd67adf9992b45264a100b5838866ea35d6ad7ff
2023-01-31 12:25:37 -08:00
Muir Manders
8daadd0716 status: enable rust status in test-fb-ext-tweakdefaults.t
Summary:
This test had a real failure where the new status wasn't respecting HGPLAIN to force root-relative paths in the output. It is safer to keep that behavior since we presume some automation would break if we changed to show cwd-relative paths unconditionally.

To use the native status I had to change this test to use modern repo format. That broke some use of revision numbers, so I tweaked tweakdefaults to respect the devel.default-date option to get stable commit hashes (so I could use those instead of revision numbers).

Reviewed By: quark-zju

Differential Revision: D42748900

fbshipit-source-id: 3358c659d5c67e781723720fcb2f760518d7d46f
2023-01-31 12:25:37 -08:00
Muir Manders
11f804ac3d hgcommands: enable "backtrace" feature for anyhow
Summary: This allows RUST_BACKTRACE=1 to work for "make local" builds. I believe buck uses nightly which should get backtrace enabled by default.

Reviewed By: quark-zju

Differential Revision: D42748902

fbshipit-source-id: fdd9473f1c0250a117c83b9637a6e23e0df26da4
2023-01-31 12:25:37 -08:00
Muir Manders
f360ac6b8c color: use "backslashreplace" instead of "replace" for invalid utf8
Summary: This way the user can see the original byte values.

Differential Revision: D42889478

fbshipit-source-id: 7876787180136cdd86839913eba77cad44115ce3
2023-01-31 11:31:48 -08:00
Muir Manders
eab63a2b60 color: don't crash styling non-utf8 strings
Summary: Make sure we only pass valid utf-8 strings to Rust's text styling.

Reviewed By: quark-zju

Differential Revision: D42886530

fbshipit-source-id: 2dc7f1ade57d3324997aa9c9a111016cfef51e07
2023-01-31 09:15:10 -08:00
Muir Manders
32018072c6 tests: fix test-import-git.t
Summary: Switch to modern repo config to resolve "hg status" errors. Somehow missed this one (I probably assumed it was a test using git instead of an hg test importing git diff format).

Reviewed By: sggutier

Differential Revision: D42863480

fbshipit-source-id: 9d595954fb7f7c9693b6d91ef9485acdc37ddc2d
2023-01-30 17:26:30 -08:00
Andres Suarez
00b1f93276 Update tokio-1.21.2 to tokio-1.25.0
Reviewed By: diliop

Differential Revision: D42837228

fbshipit-source-id: 5e891cf1ff8ab1beff6e3c845b913144655778ea
2023-01-30 14:49:36 -08:00
Jun Wu
d7d50df449 checkserverbookmark: remove extension and test
Summary:
`checkserverbookmark` was added by D15450801 (865b8b3a46) for early Mononoke migration.
It is no longer relevant.

Reviewed By: zzl0

Differential Revision: D42823312

fbshipit-source-id: f120255c4c33b919718e46052967d28e7ab772a4
2023-01-30 14:01:19 -08:00
Jun Wu
445af61f11 conch_parser: move Python bindings to bindings module
Summary:
Previously, `conch_parser` was built as a separate Python module (`.so`)
so it is not distributed with the main executable, for portability and
binary size considerations.

However, it's annoying to maintain a separate Python module, for example,
buck macOS build would have issues importing it. The binary size concern also
seems minor: stripped Linux binary increases from 43174872 to 43537624 bytes,
+363KB, less than 1%.

Therefore, let's just embed `conch_parser` directly for better macOS support.

`conch_parser` is kept in case someone wants to build a standalone Python extension.

Reviewed By: zzl0

Differential Revision: D42822105

fbshipit-source-id: 287f25aa1860836a3c7df913233b9cb92d6fd0e3
2023-01-30 10:56:17 -08:00
Jun Wu
e6f09028ba changelog: support migrating from lazy to lazytext
Summary:
Teach `debugchangelog --migrate lazytext` to fetch commit hashes and migrate
the repo to not using lazy commit hashes, which supports
`devel.segmented-changelog-rev-compat` for compatibility with legacy tests.

Reviewed By: muirdm

Differential Revision: D42788588

fbshipit-source-id: b95045bba48f4fbc5c10d94780656163f1335587
2023-01-30 10:55:11 -08:00
John Billings
7bbe6fbaf2 Upgrade indexmap
Summary: Upgrade indexmap from 1.9.1 to 1.9.2, enable new `arbitrary` feature.

Reviewed By: morphmeme

Differential Revision: D42780598

fbshipit-source-id: f8b5df50352824aa8fcf864090e53669faae7b8c
2023-01-29 11:17:39 -08:00
Zhaolong Zhu
29bf7a4cef copytrace: use gitcopytrace in Python code
Summary: integrate `gitcopytrace` with Python code to detect renames in for Git repo

Reviewed By: quark-zju

Differential Revision: D42790306

fbshipit-source-id: 396574641e4c09caf3db3f80c0a3622cc5bcfd12
2023-01-27 19:02:01 -08:00
Jun Wu
f865734583 test-dirstate-nonnormalset: remove the test
Summary:
The test was intended to check that the nonnormalset is a subset of files
tracked by dirstate. Previously the nonnormalset is tracked separately so
it can be buggy and include files not in the main dirstate map. But the
TreeState format enforces the nonnormalset to be a subset of files tracked
by TreeState (dirstate). Therefore the test is no longer relevant.

Reviewed By: sggutier

Differential Revision: D42818816

fbshipit-source-id: 24277f4cd16efc82ac803e1ff2b5b53941289abd
2023-01-27 15:10:14 -08:00
Mark Shroyer
88ddf0c403 Make hgmain depend on identity crate based on with_chg feature
Summary: This way we stop hardcoding platform-specific deps for individual unix-like operating systems. A step toward unblocking building on FreeBSD.

Reviewed By: muirdm, quark-zju

Differential Revision: D42685396

fbshipit-source-id: e8c2e08042ae3ca2ba7121947ff7604ee77212c0
2023-01-27 14:40:56 -08:00
Zhaolong Zhu
bdbcfa045b copytrace: bindings for GitCopyTrace
Summary:
Thin Wrapper around GitCopyTrace, it can be used in pathcopies
function for detecting Git file moves.

Reviewed By: quark-zju

Differential Revision: D42787243

fbshipit-source-id: ebbb5e092c0f162d42e66420e644b9488c6b6bec
2023-01-27 13:01:54 -08:00
Zhaolong Zhu
4ba25be7e1 copytrace: add GitCopyTrace Rust lib
Summary: This is a temporary solution to unblock hg-over-git use case, specifically detect renames

Reviewed By: quark-zju

Differential Revision: D42787244

fbshipit-source-id: 37edfc8efbb8a6229a3c2a5bdc3309cf2a89ae3c
2023-01-27 13:01:54 -08:00
Zhaolong Zhu
bb149840db copytrace: add test-git-rename.t
Summary:
add test for git rename, confirm it does not detect renames. After we
complete the feature, this test should fail and need to update.

Reviewed By: quark-zju

Differential Revision: D42787246

fbshipit-source-id: b65c454b3abf1cf7b25e5a501e3b4c652940a834
2023-01-27 13:01:54 -08:00
Matthew strager Glazar
731ba0459c oss: make 'make tests' run Python tests (#458)
Summary:
oss: make 'make tests' run Python tests
'make check' tries to run 'make tests', but despite being documented, the
'tests' target does not exist in the Makefile.

Create a 'tests' target which runs the Python test suite.

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

Test Plan:
$ make oss
    $ make check
    [bunch of failures]
    $ (cd tests && python run-tests.py test-debugcheckcasecollisions.t)
    ----------------------------------------------------------------------
    # Ran 1 tests, 0 skipped, 0 failed.

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

Reviewed By: muirdm

Differential Revision: D42742607

Pulled By: zzl0

fbshipit-source-id: 790624f28da629fe25846d1dde1fad2aa3382911
2023-01-27 10:44:33 -08:00
Thomas Orozco
cf3efd7672 third-party/rust: update cc
Summary:
If you ran autocargo right now on master it would fail because of this. I need
to run it later in this stack, so let's fix it.

Reviewed By: lmvasquezg

Differential Revision: D42776200

fbshipit-source-id: c95a8f0e5d34a99b11a069752fbfbde568fbecac
2023-01-27 05:07:50 -08:00
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
Jun Wu
73c8fa0fef treestate: wrap FileStore.file with Arc<Mutex>
Summary:
It'll be used by the next change. Note `Rc<RefCell>` or `Arc<RefCell>` won't
compile for the rest of the project.

Reviewed By: zzl0

Differential Revision: D42492672

fbshipit-source-id: 28b167b1d1e61a715f86911ea1d314fc2420eafd
2023-01-19 21:38:51 -08:00
Jun Wu
8633a5ed41 treestate: add locking methods to trait FileReadWrite
Summary:
trait FileReadWrite is used for both on-disk and in-memory files. Add locking
so the next change can use it to avoid races on the physical filesystem.

Reviewed By: zzl0

Differential Revision: D42492668

fbshipit-source-id: 06c02ea4fb52213c3a64fc17a336a5edba385dc4
2023-01-19 21:38:51 -08:00
Zhaolong Zhu
bcafa0fb5c shelve: ignore the extended attribute files created by MacOS
Summary:
Fix below error when doing `hg shelve --clean`

```
Traceback (most recent call last):
  File "/xxx/hg/bin/edenscm/ext/shelve.py", line 1222, in shelvecmd
    return cleanupcmd(ui, repo)
  File "/xxx/hg/bin/edenscm/ext/shelve.py", line 568, in cleanupcmd
    shelvedfile(repo, name).movetobackup()
    # name = '._default.oshelve'
  File "/xxx/hg/bin/edenscm/ext/shelve.py", line 117, in movetobackup
    util.rename(self.filename(), self.backupfilename())
FileNotFoundError: [Errno 2] No such file or directory: '/Users/xxx/fbsource/.hg/shelved/._default.oshelve' -> '/Users/xxx/fbsource/.hg/shelve-backup/._default-3.oshelve'
```

Reviewed By: quark-zju

Differential Revision: D42594463

fbshipit-source-id: 97d418066397cc0fb2babfadd0f99c6c745828bc
2023-01-19 14:44:24 -08:00
Zhaolong Zhu
ed1a55cf28 rebase: fix a bug of rebasing hidden commits
Summary: Currently, 'hg rebase' is rebasing hidden commits and making them visible to users, this is a regression caused by D42087621 (96b767efde).

Reviewed By: quark-zju

Differential Revision: D42608733

fbshipit-source-id: de4b7b231d42a45844174e4a417d3c07a6869b97
2023-01-19 14:25:02 -08:00
Evan Krause
5c161c93d6 isl: Add --slversion argument
Summary: Add arguments to isl.py so that each ISL server is spawned with --slversion as expected

Reviewed By: bolinfest

Differential Revision: D42563631

fbshipit-source-id: 9a493c4ddf3f7529f032bc130cbd164fb9d4a668
2023-01-19 13:16:50 -08:00
Mark Juggurnauth-Thomas
5c361938ca add abomonation as a patch dependency
Summary: The patched abomonation is required to build because of the transitive dependency on the new smallvec feature.  We are separately working on removing this dependency, but for now we need to include the patch.

Reviewed By: bolinfest

Differential Revision: D42612033

fbshipit-source-id: 7991db74946cce8640795104623841f23abf82c6
2023-01-19 12:59:37 -08:00
Zhaolong Zhu
4a8e6b8fa6 util: delete unused puredirs
Summary: When reading copytrace related code, I found we deprecated puredirs in favor of Rust 'dirs' in D19634699 (8e673a1de0).

Reviewed By: markbt

Differential Revision: D42539556

fbshipit-source-id: 59ae23e5d92626cac11cc9ea4c41d196940796b0
2023-01-19 11:12:24 -08:00
Zhaolong Zhu
2ab1a0931d doctor: skip None remotenames
Summary:
We met an issue that `oldml["remotenames"]` can be None.

```
    with progress.bar(ui, _("reading repo history"), "", len(roots)) as prog:
        for rootid in reversed(roots):
            prog.value += 1
            oldml = ml.checkout(rootid)
            node = bookmod.decoderemotenames(oldml["remotenames"]).get(mainfullname)
            if node and node in repo:
                found = node
                break
```
And it will cause below TypeError.

```
│ `hg doctor` stderr:
│ segments/v1: repaired
│ remote/master points to an unknown commit - trying to move it to a known commit
│ exception TypeError('Expected type that converts to PyBytes but received NoneType') ignored during checkmissingmaster
```

Reviewed By: quark-zju

Differential Revision: D42588709

fbshipit-source-id: 79013cc311cfdb4ab033c20cdd7c508d3341c88d
2023-01-19 11:05:58 -08:00
Liubov Dmitrieva
0fbb99d133 use phases information returned from the server to speed up
Summary:
use phases information returned from the server to speed up
retrieval of mutations

if we keep phases calculation client side, it often makes few single "commit_hash_to_location" requests and then a huge batched request with few hundred of hashes

Reviewed By: quark-zju

Differential Revision: D42453084

fbshipit-source-id: bec211c41da61332ba324b6b934540d5a48bc65d
2023-01-19 11:00:32 -08:00
Matthew strager Glazar
d837936837 config: delete unused convert.* settings (#462)
Summary:
config: delete unused convert.* settings
A bunch of configuration settings are defined, but don't seem to be referenced
anywhere. Delete them.

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

Test Plan:
I did not test this change.

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

Reviewed By: genevievehelsel

Differential Revision: D42608651

Pulled By: bolinfest

fbshipit-source-id: c0c17ed11d470d02287c8f0a7c3591e9d31db48a
2023-01-19 10:59:18 -08:00
Matthew strager Glazar
32691f46b7 phases: Delete dead code (#461)
Summary:
Stack created with [Sapling](https://sapling-scm.com). Best reviewed with [ReviewStack](https://reviewstack.dev/facebook/sapling/pull/461).
* __->__ https://github.com/facebook/sapling/issues/461

phases: Delete dead code
We check self._headbased twice, and the second time, we know that
self._headbased is true. Don't check twice; delete the dead code.

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

Test Plan: Untested.

Reviewed By: genevievehelsel

Differential Revision: D42608659

Pulled By: bolinfest

fbshipit-source-id: 2a15be95eac31c4f7e7993cf0fd433c43f64cbb7
2023-01-19 10:52:53 -08:00
kurtz.brandon@gmail.com
117e4dca50 add status err if linked PR was closed when submitting (#356)
Summary:
add status err if linked PR was closed when submitting

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

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

Reviewed By: akushner

Differential Revision: D42299786

Pulled By: bolinfest

fbshipit-source-id: dfc2e0b95bca998f3fdb2e87cf6649f622d0621b
2023-01-18 18:51:11 -08:00
Michael Bolin
98245071ef add integration for new sl pr submit default behavior
Summary:
Change `test-ext-github-pr-submit.t` so it tests the
new `sl pr submit` behavior introduced in D42550052
while introducing `test-ext-github-pr-submit-placeholder-issue.t`
to verify the old behavior.

Reviewed By: sggutier

Differential Revision: D42554648

fbshipit-source-id: 79f4a876993ad3d85bb2a11be1460de55d5530c0
2023-01-18 16:43:53 -08:00
Michael Bolin
18c5c2569a use PR# in body param in expect_update_pr_request()
Summary:
The entry in the bulleted list in the pull request body
should match the pull request number argument
rather than hardcoding it to `1`.

Reviewed By: sggutier

Differential Revision: D42554647

fbshipit-source-id: d5ec178ad8981d92214300f8663e5bc13981357d
2023-01-18 16:43:53 -08:00
Michael Bolin
7ce516dfac revert behavior that uses placeholder GitHub issues for PRs
Summary:
D42050143 (e77e67bba7) / e77e67bba7
changed the default behavior for `sl pr submit` in hopes of
being more performant [by rearchitecting things so that more
work could be done in parallel], but ended up causing the following
issues:

- could not be used with repos that disabled GitHub issues: https://github.com/facebook/sapling/issues/371
- unexpected failures when trying to convert a placeholder issue
  to a pull request (such as https://github.com/facebook/sapling/issues/384)
  meant that users often found themselves with stale placeholder issues
- third-party tools, such as Slack apps, that have triggers based on the creation
  of new GitHub issues, find this noisy: https://github.com/facebook/sapling/issues/383

This diff changes `sl pr submit` such that it defaults to the previous
behavior (in which pull requests are created in series, rather than in
parallel, and is subject to a race condition where pull request numbers
may not match branch numbers), though for now, it still makes the
old behavior available behind a boolean config, `github.placeholder-strategy`.

Because quite a few changes were made to
`eden/scm/edenscm/ext/github/submit.py` since D42050143 (e77e67bba7)
was committed, this diff is not a straight revert of the
original diff.

Reviewed By: muirdm

Differential Revision: D42550052

fbshipit-source-id: 68d6d1e00b5af2d166b7e3aab2dda959fae5de82
2023-01-18 16:43:53 -08:00
Mark Juggurnauth-Thomas
ca851e8c17 vendor abomonation with smallvec support
Reviewed By: liubov-dmitrieva

Differential Revision: D42511631

fbshipit-source-id: a551ed64bfbd02e354baf647f66260507b606798
2023-01-18 09:43:07 -08:00
generatedunixname89002005287564
3fb8b70ea2 Reviewed By: zertosh
Differential Revision: D42570031

fbshipit-source-id: d885c6e6d2da2634936b4072bc8a22f1612f28a8
2023-01-18 06:24:35 -08:00
John Lyons
3b33dbadfb Update sl_cloud template to remove repeated remote bookmarks
Summary:
Running 'hg cloud sl' shows remote bookmarks printed twice in the commit tree.

The issue is caused by remote bookmarks added at to the general bookmarks field at: `eden/scm/edenscm/ext/commitcloud/baseservice.py (lines=395)`

and again in the template used to render the hg cloud sl command (sl_cloud).

I have updated the sl_cloud template to no longer add the remote bookmarks a second time, by creating a new config option 'sl_cloud_books' to be used by the template. I have included this change in all files containing configuration for sl_cloud.

Reviewed By: liubov-dmitrieva

Differential Revision: D42531237

fbshipit-source-id: 1ed70c3072531c138757e760e60f0d6ae8d810b6
2023-01-18 02:42:51 -08:00
Igor Makaruks
5cfd42f9cb Replaced event/client with reqwest-eventsource
Summary: Replaced internally developed event/client with reqwest-eventsource

Reviewed By: liubov-dmitrieva

Differential Revision: D42476335

fbshipit-source-id: 4392d18b9fba6e2ebc6b2ffc5b79036c08dddf44
2023-01-18 00:07:09 -08:00
Jun Wu
c4887311ff treestate: add fs2 dependency
Summary: Will use fs2's locking feature in the next diff.

Reviewed By: zzl0

Differential Revision: D42492666

fbshipit-source-id: 05f66ce7a833865bd3ced08ff574f3c23f3a1e82
2023-01-17 10:54:03 -08:00
Jun Wu
611dcf2ad7 treestate: add tests about concurrent writes
Summary:
Treestate can be corrupted by concurrent writes.
This is used to verify the fix in a later diff.

Reviewed By: zzl0

Differential Revision: D42492671

fbshipit-source-id: b5ede9f66e85cef4b5bfd7ae1732ab04f258b13b
2023-01-17 10:54:03 -08:00
Jun Wu
20253392b0 treestate: tempdir -> tempfile
Summary: `tempfile` is recommended for tempdir test use-cases.

Reviewed By: zzl0

Differential Revision: D42492669

fbshipit-source-id: 0c21393ba3331471a97e1ee363e198606eb54bdf
2023-01-17 10:54:03 -08:00
Saul Gutierrez
2a9c08743d github: refactor gh_run
Summary:
Moves the `gh_run` function to `github_repo_util`, since it can be used by some other functions that need to call the `gh` binary.

This also changes `os.execv` for `subprocess.run`, since `subprocess.run` can have more flexibility in regards to obtaining the exit code and the output of `gh`. Also, using `subprocess.run` makes using `gh` on `.t` tests easier when using the `requires` keyword in this kind of tests.

Reviewed By: bolinfest

Differential Revision: D42221074

fbshipit-source-id: 5e7e002fdec01e1bad7b32e4ef1f8478c57d4d23
2023-01-17 09:37:29 -08:00
Muir Manders
258f8d69bc debugnetwork: improve remote url determination
Summary:
Use the scheme extension directly to expand the scheme. This allows paths like "fb:fbsource" to turn into the right Mononoke URL.

Perhaps the schemes translation should be integrated directly into the path machinery.

Reviewed By: markbt

Differential Revision: D42396672

fbshipit-source-id: 1f0ca64ee175c7041e6483539c74c60d663fe1d7
2023-01-17 08:40:55 -08:00
Liubov Dmitrieva
acc4dd557f add new interation test for commit graph v2
Summary: add new interation test

Reviewed By: yancouto

Differential Revision: D42453795

fbshipit-source-id: 32ada3fc33157ed3ba39fdea59ffb8243a2594a4
2023-01-17 06:27:51 -08:00
Liubov Dmitrieva
0e0c959c7f return phases from server if they are known
Summary:
return phases from server if they are known

As we discussed, with edenapi strait after the "commitgraph" request we need to
ask the sever for the mutations for draft commits. Computing drafts on client
side is ok but extra overhead since the phases have been calculated already
server side for derivation purposes (derive filenodes for public roots to
support linknodes). It would be nice to return them, so the client can use if
they want.

Reviewed By: RajivTS

Differential Revision: D42451892

fbshipit-source-id: db94a6b14b9a8e1966d2355806b569d6abee546d
2023-01-17 04:26:10 -08:00
Liubov Dmitrieva
6ad79a2840 disable min speed check for commit graph requests
Summary:
disable min speed check for commit graph requests.

for commit graph request, server returns result once it is fully ready, due to phases calculation and derivation filenodes for public roots, so the check must be disabled.

we still have a general timeout for an edenapi request, that is configured as 30 min, so enough for hg pull commands to complete for all edge cases, including aosp repo pulls of other main lines.

Reviewed By: muirdm

Differential Revision: D42478560

fbshipit-source-id: ff73cafee78175e07bc6379658f081c393aa91d3
2023-01-13 03:54:26 -08:00
Zhaolong Zhu
7e50b5b6eb split: fix crash issue when doing split and resize terminal window
Summary:
currently, hg crashes with below error when 'hg split' and resize terminal window (both VS Code terminal and normal terminal)

```
      File "/opt/fb/mercurial/edenscm/crecord.py", line 1788, in main
        return self._main(stdscr)
      File "/opt/fb/mercurial/edenscm/crecord.py", line 1839, in _main
        keypressed = curses.keyname(self.statuswin.getch()).decode("utf-8")
    ValueError: invalid key number
```

Reviewed By: muirdm

Differential Revision: D42399034

fbshipit-source-id: 40d05c11ed1e901375c7356789e2b209fc67e788
2023-01-12 15:48:37 -08:00
Eddie Shen
59e4a893b3 Bump lz4, lz4-sys
Summary: [`RUSTSEC-2022-0051` - Memory corruption in liblz4](https://rustsec.org/advisories/RUSTSEC-2022-0051.html) is aliased as [`CVE-2021-3520`](https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2021-3520) with a CVSS 3.x score of 9.8.

Reviewed By: sneakywombat

Differential Revision: D42483074

fbshipit-source-id: 6f3d87874ed145ec946bf63069709457309cb485
2023-01-12 14:45:41 -08:00
Zhaolong Zhu
703c6e26d4 doc: fix '@prog' -> '@prog@'
Summary:
```
$ rg 'prog ' edenscm -l | xargs sed -i'' 's/prog /prog@ /g'
```

Reviewed By: muirdm

Differential Revision: D42444773

fbshipit-source-id: 6d3f9fa1222207b22497e15d020136f955d4908c
2023-01-12 13:40:08 -08:00
generatedunixname89002005307016
9dad90c246 Add annotations to eden/scm/edenscm/ext/remotefilelog/historypack.py
Reviewed By: yancouto

Differential Revision: D42450978

fbshipit-source-id: 6cdebf872e52ac548021a34d509a6a20de7eab66
2023-01-12 08:44:55 -08:00
generatedunixname89002005307016
5b34561502 Add annotations to eden/scm/edenscm/ext/debugshell.py
Reviewed By: yancouto

Differential Revision: D42476222

fbshipit-source-id: 0a35f2de2ae6a096a19e662f87af216cf4be062d
2023-01-12 08:41:21 -08:00
Muir Manders
50881d7567 changelog: require edenapi to migrate to lazytext
Summary: lazytext backend requires edenapi so avoid the migration if the repo has no edenapi client (similar to "lazy" migration).

Reviewed By: quark-zju

Differential Revision: D42316095

fbshipit-source-id: 291e54612ef49ab458612f659a71e3fb2f8cf437
2023-01-11 13:37:07 -08:00
Jun Wu
739af3c085 copytrace: remove undefined symbol dbm._Databse
Summary:
Pyre automation added `dbm._Databse` in D42385084 (c95dcdc664). But `dbm._Databse` does not
exist and cause

  $ hg bookmark book1
  Traceback (most recent call last):
    File "eden/scm/edenscm/__init__.py", line 86, in run
      dispatch.runchgserver(args[2:])
    File "eden/scm/edenscm/dispatch.py", line 368, in runchgserver
      _preimportmodules()
    File "eden/scm/edenscm/dispatch.py", line 348, in _preimportmodules
      extensions.preimport(extname)
    File "eden/scm/edenscm/extensions.py", line 208, in preimport
      mod = getattr(__import__("edenscm.ext.%s" % name).ext, name)
    File "eden/scm/edenscm/ext/copytrace.py", line 169, in <module>
      ) -> Tuple[Optional[dbm._Database], Optional[Tuple[Type[dbm._error], Type[OSError]]]]:
  AttributeError: module 'dbm' has no attribute '_Database'

Reviewed By: zzl0

Differential Revision: D42456269

fbshipit-source-id: f6494f66b0676b5f2525110bc04060db9d85c027
2023-01-11 12:46:31 -08:00
Zhaolong Zhu
b318ba7085 doc: fix typo in the help message of commit
Summary: fix typo in the help message of commit

Reviewed By: muirdm

Differential Revision: D42415448

fbshipit-source-id: 2cd64303af845f9f47d4fae9b45e18920484ce13
2023-01-11 08:51:20 -08:00
Liubov Dmitrieva
d68ceaa171 add a way to try commitgraph and commitgraph2 edenapi endpoints
Summary:
add a way to try commitgraph and commitgraph2 edenapi endpoints

so, we would have some end to end integration with hg client to try pulls with new commit graph

Reviewed By: mitrandir77

Differential Revision: D42416426

fbshipit-source-id: 98ad2aba5beedec4c6973be8d281b2f2f270e916
2023-01-11 05:56:20 -08:00
generatedunixname89002005307016
00ee87c105 Add annotations to eden/scm/edenscm/cffi/osutil.py
Reviewed By: yancouto

Differential Revision: D42413974

fbshipit-source-id: a7eb3b5105f337319e875d0ddd8a7e8e9aa3e3a7
2023-01-10 05:24:26 -08:00
generatedunixname89002005307016
7820675477 Add annotations to eden/scm/edenscm/ext/extlib/pywatchman/capabilities.py
Reviewed By: yancouto

Differential Revision: D42400963

fbshipit-source-id: b91a361ed618e6e4b08124355c236b159aa7af82
2023-01-10 05:20:20 -08:00
generatedunixname89002005307016
c95dcdc664 Add annotations to eden/scm/edenscm/ext/copytrace.py
Reviewed By: yancouto

Differential Revision: D42385084

fbshipit-source-id: 435b88d79df95dee8bd72597eb2bc7fdcc1622c7
2023-01-10 05:19:09 -08:00
generatedunixname89002005307016
14f2df1374 Add annotations to eden/scm/edenscm/ext/win32mbcs.py
Reviewed By: yancouto

Differential Revision: D42311888

fbshipit-source-id: 99bc72b448e3feef603e50a0beb1893cd1ffeacc
2023-01-10 05:18:57 -08:00
generatedunixname89002005307016
01f7bfe1e1 Add annotations to eden/scm/edenscm/lsprof.py
Reviewed By: yancouto

Differential Revision: D42405358

fbshipit-source-id: e18c9a75e33dacac80574620382fd87f00a2129b
2023-01-10 05:18:50 -08:00
generatedunixname89002005307016
0f27e09f61 Add annotations to eden/scm/edenscm/ext/debugnetwork.py
Reviewed By: yancouto

Differential Revision: D42306137

fbshipit-source-id: c4d3ef7ea1b130a8d187ce4147512163cb2b4619
2023-01-10 05:18:39 -08:00
generatedunixname89002005307016
02e3643681 Add annotations to eden/scm/edenscm/ext/phabdiff.py
Reviewed By: yancouto

Differential Revision: D42342460

fbshipit-source-id: 1a58bc8c47cd30d97863dfa16b84f3e10ce2adfd
2023-01-10 05:18:10 -08:00
generatedunixname89002005307016
ad2fa77916 Add annotations to eden/scm/edenscm/ext/remotefilelog/repack.py
Reviewed By: yancouto

Differential Revision: D42266284

fbshipit-source-id: 5b0b8a6e6f16f4b3030edb27f87d396bd3a3c570
2023-01-10 04:25:45 -08:00
generatedunixname89002005307016
27b36cb10e Add annotations to eden/scm/edenscm/repair.py
Reviewed By: yancouto

Differential Revision: D42249787

fbshipit-source-id: 026ac51d1cd84fd6849f3a084ee484cd80cae4bf
2023-01-10 04:24:05 -08:00
generatedunixname89002005307016
274e0fa12d Add annotations to eden/scm/edenscm/ext/snapshot/commands.py
Reviewed By: yancouto

Differential Revision: D42245017

fbshipit-source-id: b222098fafc1488471b7cb05dd1d7f53a153c69d
2023-01-10 04:22:35 -08:00
Mateusz Kwapich
0ddaa622a7 Revert D42203299 to fix scmlib
Reviewed By: RajivTS, mzr

Differential Revision: D42224851

fbshipit-source-id: 72d310c4d2f017d3f9128eaa1c8459489af571fa
2023-01-10 03:31:11 -08:00
Scott Ramsby
af8cae9213 Fix typo in warning message (#442)
Summary:
Pull Request resolved: https://github.com/facebook/sapling/pull/442

Log message should say "Your" rather than "You".

Reviewed By: zzl0

Differential Revision: D42419203

fbshipit-source-id: 49817641f68da048025f7f811f8f6f9ebe4c50dc
2023-01-09 13:29:06 -08:00
Muir Manders
e81fcae23a config: respect config filters for static config
Summary:
The config "Options" object includes filter functions that can arbitrarily mutate or filter out any config value as the config is being loaded. One important place filters are used is to drop command alias configuration when running under HGPLAIN mode. (Note that I feel it would be better to not mutate the config and instead skip the aliases during command dispatch, but I didn't attempt to make that change.)

The recent static config improvements accidentally skirt the config filters. This meant aliases were respected with HGPLAIN=1. For example, this caused "jf submit -s" to pop open an editor because jf runs "HGPLAIN=1 hg metaedit ..." and there is a built in alias for metaedit => "metaedit --batch", and "--batch" forces an editor to pop up when there is more than one revision to edit.

Fix by computing static config "overrides" based on anything that is filtered out. Any overrides are layered in on top of the static configs.

Reviewed By: zzl0

Differential Revision: D42395024

fbshipit-source-id: 2f5b4420f3583bab9cc642aae8e3c1f1d0ff952e
2023-01-09 11:51:41 -08:00
Muir Manders
b58d4e43e4 config: show builtin config values with --verbose
Summary: Some times you just want to see all the config values, including builtins.

Reviewed By: zzl0

Differential Revision: D42395025

fbshipit-source-id: d15a38583f7e87c56f45989c5be25782f33b768d
2023-01-09 11:51:41 -08:00
Muir Manders
427d713be1 config: move filter logic onto Options struct
Summary: Move this code in preparation to use it in a second spot.

Reviewed By: zzl0

Differential Revision: D42395026

fbshipit-source-id: 835359c63e20576ef8f28efaca70ed2855b75455
2023-01-09 11:51:41 -08:00
kurtz.brandon@gmail.com
4c028cba77 abort if no args provided to sl pr pull (#357)
Summary:
abort if no args provided to sl pr pull

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

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

Reviewed By: akushner

Differential Revision: D42299779

Pulled By: bolinfest

fbshipit-source-id: d5705a99f1b03eed81aebd076d8ba7200d40618e
2023-01-01 21:34:23 -08:00
Michael Bolin
a1187e8766 use ui.system() instead of os.execv() to run gh list (#377)
Summary:
Use `ui.system()` instead of `os.execv()` to run `gh list`.

As described in https://github.com/facebook/sapling/issues/363,
the existing logic did not work correctly in the presence of `chg`.

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

Test Plan:
Build Sapling from source and verify that `sl pr list` works with
various arguments.

Verified it works on Windows, where `chg` does not exist, but it
was important to verify that `util.shellquote()` did the right thing
[where `shlex.quote()` did not].

On macOS, I had an instance of `chg` running that exhibited the bug
described in https://github.com/facebook/sapling/issues/363.
After running `sl --kill-chg-daemon` once, I then ran `sl pr list`
with my dev build of `sl` that contained this change and verified
that it fixed https://github.com/facebook/sapling/issues/363.
That is, running `sl pr list` now returns control to the terminal
*after* running `gh pr list` and showing its output.

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

Reviewed By: akushner

Differential Revision: D42299741

Pulled By: bolinfest

fbshipit-source-id: 0970f1b7c729e5694cacfc2a07889cbb2e0e1e8a
2023-01-01 20:34:20 -08:00
Muir Manders
48cc260bd5 tests: deflake test-clone-resume.t
Summary:
Previously it triggered a checkout error by setting bad permissions on a directory checkout needed to write to. However, nothing guaranteed that other files were successfully written to before the permission error, so sometimes zero files were skipped when continuing the checkout (which failed the test). Now we use a pre-existing failpoint to fail the checkout. Hopefully this works now on Windos as well.

I also reduced the size of test data from 5002 files to 2.

Reviewed By: zzl0

Differential Revision: D42256394

fbshipit-source-id: d3016779b5bbd734a0f00afd2885b63218dedaae
2022-12-28 09:05:53 -08:00
Muir Manders
affbfc224c fix usage of f-string
Summary: Don't use f-string since that precludes use of the i18n framework. Instead, use _() to (potentially) translate the format string, then substitute the format verbs.

Reviewed By: bolinfest

Differential Revision: D42251176

fbshipit-source-id: af7e20d2fc8c81fd04e8c366373c46e333e09635
2022-12-27 10:09:50 -08:00
Zhaolong Zhu
b2269eaf31 remotenames: fix test-remotenames-pushto-pathandname.t
Summary: as title

Reviewed By: akushner

Differential Revision: D42224640

fbshipit-source-id: 2263d0ec5c714eb318829c128c928ec6cda726c4
2022-12-23 03:36:10 -08:00
Zhaolong Zhu
a6a66d09ad casecollisionauditor: ignore eden_dirstate_map
Summary:
The default casecollisionauditor reads all of dirstate._map by iterating through it. This is expensive for a large repo and eden now raises RuntimeError for the iterator method. Please check D3964461 (73f0e3dd41) for more info.

As Jun pointed out:

* For non-edenfs we would always use treestate, therefore the original `if not dirstate._istreestate and not dirstate._istreedirstate:` check always evaluate to `False`.
* For EdenFS, due to above reason, we should not go into the `then`-part of the if statement.

So we can just delete the `then`-part of the if statement:

```
if not dirstate._istreestate and not dirstate._istreedirstate:
    allfiles = "\0".join(dirstate._map)
    self._loweredfiles = set(encoding.lower(allfiles).split("\0"))
```

Reviewed By: quark-zju

Differential Revision: D42210487

fbshipit-source-id: 6c5d5daca9dd85deae6505344a4abad2cafb2831
2022-12-22 15:24:08 -08:00
Jun Wu
01167e3baa snapshot: do not write to metalog directly
Summary:
Metalog committing should go through the transaction layer. The transaction
layer ensures all metadata are consistently updated atomically, and ensures the
description of metalog is in a certain format.

Let's migrate snapshot to use transaction for metalog write instead.

Reviewed By: yancouto

Differential Revision: D42203509

fbshipit-source-id: b5ecd90c52389add7bdc40ebd383b05bb586470f
2022-12-22 13:13:55 -08:00
Jun Wu
9d5a484820 remotenames: translate 'push --to remote/foo' to 'push default --to foo'
Summary:
The command flags of `push` is not obvious.  A common mistake is
`push --to remote/main` (which will create a `remote/remote/main` remote
bookmark).

This diff changes the logic to accept `push remote/main`,
`push --to remote/main` or `push default/main` to do the obvious thing for a
better UX.

Reviewed By: muirdm

Differential Revision: D42203177

fbshipit-source-id: d73647823c147dbdbce58c71a04dd4965e8ac2fb
2022-12-22 13:13:55 -08:00
Jun Wu
4dcde3c343 remotenames: drop forcecompat support
Summary: The forcecompat config is not used. Therefore remove it.

Reviewed By: muirdm

Differential Revision: D42203299

fbshipit-source-id: 36f7b86661e8ecc716f223daf7cefadd7ced76b0
2022-12-22 13:13:55 -08:00
Jun Wu
7f88efd743 git: update committer information when creating new commits
Summary:
This matches the Git behavior. Update committer and date by default.

`test-git.t` is changed since some commits have committer written by Git with
`test <test@example.org>` and this diff rewrites the committer to `test <>`.

Reviewed By: sggutier

Differential Revision: D42200687

fbshipit-source-id: 0d40ad0868e89cbe0cf932782bfe4f74d42c9e65
2022-12-22 08:54:54 -08:00
Muir Manders
67fa8488e1 paths: normalized scp-like git urls
Summary:
Scp-like git urls like "user@host:path" are common, but Sapling wants proper ssh urls like "ssh://user@host/path". clone already converts to the desired format. Now, "paths" also converts scp-like urls to ssh urls when adding a new remote.

Fixes #196.

Reviewed By: quark-zju

Differential Revision: D42196319

fbshipit-source-id: 3a27027a17fa770ab1291ace654ecff95a63afef
2022-12-21 19:08:24 -08:00
Muir Manders
f2078085a1 paths: use rcutil to edit "[paths]" config
Summary: The existing config editting code didn't look correct in all cases, so let's standardize on rcutil.

Reviewed By: quark-zju

Differential Revision: D42196320

fbshipit-source-id: 2dd325fc527a9b0ecf10827651a3655591e232e5
2022-12-21 19:08:24 -08:00
Muir Manders
77fa228f5b rcutil: support deleting config items
Summary: Going to use this in next diff.

Reviewed By: quark-zju

Differential Revision: D42196323

fbshipit-source-id: 38e79307213cf850c45dc96c8e87712e0f295518
2022-12-21 19:08:24 -08:00
Muir Manders
58331d4925 rcutil: support adding config items to existing sections
Summary: When adding a secion.name=value config item, we now check if "[section]" already exists, and if so append the config item. Previously, we always created a new "[section]" entry at the bottom.

Reviewed By: quark-zju

Differential Revision: D42196321

fbshipit-source-id: 94630cee893683f54b5cb4ea954bd19e5ce324c3
2022-12-21 19:08:24 -08:00
Muir Manders
1b74d35598 scmposix: kill some dead code
Reviewed By: quark-zju

Differential Revision: D42196322

fbshipit-source-id: 04915727e086f3f1f214441605a9df5d0610ecba
2022-12-21 19:08:24 -08:00
kurtz.brandon@gmail.com
2a7fa80c65 surface output in addition to exit code if ghstack shell command fails (#340)
Summary:
Stack created with [Sapling](https://sapling-scm.com). Best reviewed with [ReviewStack](https://reviewstack.dev/facebook/sapling/pull/340).
* __->__ https://github.com/facebook/sapling/issues/340

surface output in addition to exit code if ghstack shell command fails

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

Reviewed By: mitrandir77

Differential Revision: D42198530

Pulled By: bolinfest

fbshipit-source-id: 2fc0422e3eb95e715f162320d8c88e9696ef883b
2022-12-21 14:57:46 -08:00
Muir Manders
d934cb3715 fix test-merge-halt.t on Windows
Summary: A recently added tripwire check was misfiring for this test. Fix by stripping quotes off the path before testing for absoluteness.

Reviewed By: zzl0

Differential Revision: D42196915

fbshipit-source-id: 7db29dad02f89f7bd27b25cd239c300226e63375
2022-12-21 14:06:50 -08:00
Muir Manders
e8f57d7902 bookmark: support querying remote Git refs
Summary:
Revive the "bookmark --remote" flag to allow querying Git refs. There are some pattern aliases "branches", "tags", and "prs" which can be used for convenience to trim off the leading "refs/*". Or, you can specify "git ls-remote" patterns directly, such as "refs/heads/*", in which case no trimming is done.

Examples:

```
list remote branches:

    sl bookmark --remote

list remote tags:

    sl bookmark --remote tags

list all refs:

    sl bookmark --remote 'refs/*'

list branches from specified path:

    sl bookmark --remote --remote-path my-fork
```

I moved the "--remote-path" flag from the infinitepush extension to the remotenames extension so it can be used for choosing the Git remote. remotenames is a required extension, so this should be safe.

Reviewed By: quark-zju

Differential Revision: D42183496

fbshipit-source-id: 58892fe9203ae7471663faef078e37f90199454c
2022-12-21 13:50:31 -08:00
Muir Manders
9804c66bb8 clone: improve "-u" for git repos
Summary: Now if you give --updaterev/-u a branch name, we will include it in "names" when doing the initial pull. If you specify a 40 byte commit hash, we include it in "nodes". This makes it possible to (easily) clone and goto an arbitrary branch or commit.

Reviewed By: quark-zju

Differential Revision: D42183498

fbshipit-source-id: 4fd821de809501f7a4bc8936b35a886511bd8106
2022-12-21 13:50:31 -08:00
Muir Manders
159fe07e6d node: remove Python 2 support
Reviewed By: quark-zju

Differential Revision: D42183497

fbshipit-source-id: 069fe3dd1a319dd428ed0ebc1e5a6ee8c0e228cc
2022-12-21 13:50:31 -08:00
Jun Wu
a0a1aac26b test-git-submodule-rebase: check in-memory rebases
Summary:
In-memory rebase and on-disk rebase are quite different in terms of code paths
used for submodule handling. Let's run the test cases through both
configurations.

Reviewed By: sggutier

Differential Revision: D42193838

fbshipit-source-id: 9cddb84fad667bb8f2b6334da185e931e3127990
2022-12-21 10:58:58 -08:00
Jun Wu
0d8667f03b testing: add 'py' builtin to get python values from shell
Summary: This will be used by the next change.

Reviewed By: sggutier

Differential Revision: D42193839

fbshipit-source-id: 9c287cd76574cb899031d3fee1e5e832f2c1fd76
2022-12-21 10:58:58 -08:00
Jun Wu
59426d7e91 test-git-submodule-rebase: remove duplicated logic
Summary:
Move the "showing commit description with submodule commit description" logic
to a function so it can be used in all test cases.

Reviewed By: bolinfest

Differential Revision: D42186691

fbshipit-source-id: a142eb8443b3ace1936556817af68a1287c7b336
2022-12-21 10:58:58 -08:00
Jun Wu
2b94b6f941 git: fix rebasing conflicted submodule changes
Summary:
Rebasing a stack that contains submodule change to the destination with
conflicted submodules should not crash.

The current implementation might be not the final UX. But at least it no longer
crashes.

Reviewed By: bolinfest

Differential Revision: D42184286

fbshipit-source-id: da5bc4a8b4caf60673e159955a0f1153510a9ca3
2022-12-21 10:58:58 -08:00
Jun Wu
1f5424d83c git: fix rebasing submodule changes
Summary:
Rebasing a stack that contains submodule change should preserve the change in
the destination, if the destination does not change the submodules.

Reviewed By: bolinfest

Differential Revision: D42184288

fbshipit-source-id: 678a931ece444a008b7d8cb34741e271579469f3
2022-12-21 10:58:58 -08:00
Jun Wu
2f0f0fdc54 git: fix rebasing past submodule changes
Summary: Implement a naive submodule merge logic that can be used by rebase.

Reviewed By: bolinfest

Differential Revision: D42184287

fbshipit-source-id: fdb8e83733aa8a295405085ac1e5ace526c3421b
2022-12-21 10:23:22 -08:00
Jun Wu
91246a1d33 git: move submodule (ctx, path) -> node logic to a function
Summary: This function will be used in other places.

Reviewed By: bolinfest

Differential Revision: D42185597

fbshipit-source-id: e464ab83893bfe3f3476003295c4cf4bb50ed9bc
2022-12-21 10:23:22 -08:00
Jun Wu
49bf2d8d97 git: move submodule fctx -> node logic to a function
Summary: This function will be used in other places.

Reviewed By: bolinfest

Differential Revision: D42185598

fbshipit-source-id: 7805f1fe1b86862c49af9c81805b01285a9df782
2022-12-21 10:23:22 -08:00
Zhaolong Zhu
20d26bcab9 github: eliminate github_gh_cli.Result in favor of edenscm.Result
Summary: as mentioned in D42078459 (ef9830b244), we in favor of `edenscm.Result` since it's more generic and feature complete.

Reviewed By: bolinfest

Differential Revision: D42122290

fbshipit-source-id: 6750818aa8bbd3c81fd9a8e40c43f999848db949
2022-12-21 08:54:56 -08:00
Zhaolong Zhu
ac28c0edb4 pr: enable prmarker for all git repos
Summary:
Currently we enabled `prmarker` extension in sapling.rs config, and also added a post pull hook for calling the command of `prmarker` extension, but in some corner cases, the hook triggers other `sl` binary, and will cause "no debugprmarker" warning message.

```
post-pull.prmarker=sl debugprmarker

```

This diff is to enable `prmarker` for all git repos. BTW: it's safe to enable this extension for non-GitHub repo, it will just exit if the repo is not a GitHub repo.

Reviewed By: quark-zju

Differential Revision: D42181509

fbshipit-source-id: 976009a570bb476194f69b99feabf7256467f320
2022-12-21 08:24:22 -08:00
Michael Bolin
e933705cc2 MockRequestNotFound should show available requests
Summary:
When there is no response for a request, the test should
print out the other requests that were known to `MockGitHubServer`.
The test debugging experience still needs to be improved,
but at least this is a start.

Reviewed By: muirdm

Differential Revision: D42143989

fbshipit-source-id: 919ce741c6ebddc0025b67aad6e25f569cddbf18
2022-12-21 00:30:52 -08:00
Michael Bolin
21579f01c6 run ghstack from the current commit instead of the branch tip
Summary:
Previously, in our Sapling port of ghstack, we were interpreting `HEAD`
from Git as the result of:

```
sl log -r 'max(descendants(.))' -T '{node}'
```

which was forcing ghstack to always operate from the tip of your feature
branch rather than where you are. This updates the code so that `HEAD`
is interpreted as `sl whereami` so you can submit only your current commit
and the commits *below* it in the stack as pull requests.

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

Reviewed By: muirdm

Differential Revision: D42121060

fbshipit-source-id: 9ea54c200b9d7938225a858ef2421bc5cf4b78e5
2022-12-21 00:30:52 -08:00
Michael Bolin
8f0a657a00 implement sl pr list
Summary:
GitHub's `gh` CLI has a number of useful subcommands under `gh pr`.
When run in a Git repo, `gh` can automatically figure out the appropriate
value to use with the `--repo` flag, though that is not the case in Sapling.

In this case, we do a small amount of plumbing to implement
`sl pr list [flags]` so that it execs the analogous `gh pr list [flags]` call.
This pattern should work well for supporting more `gh pr` commands.

Reviewed By: muirdm

Differential Revision: D42120917

fbshipit-source-id: 51bd51f46cd15fc9e4bbde631adfe24646b0efb7
2022-12-21 00:30:52 -08:00
Michael Bolin
d09d5985c2 introduce sl pr pull PULL_REQUEST function
Summary:
This adds a key subcommand, `sl pr pull`, that facilitates
importing a stack created by `sl pr submit` in another working copy.
This is the `sl pr` analogue to `sl ghstack checkout`.

Reviewed By: muirdm

Differential Revision: D42116136

fbshipit-source-id: 94423f6bd15ab07771bdb671994912a1c0354137
2022-12-21 00:30:52 -08:00
Jun Wu
3ace51224c git: fix amend submodule change
Summary: This makes it possible to amend submodule changes to fix mistakes.

Reviewed By: bolinfest

Differential Revision: D42182504

fbshipit-source-id: 2fc416a1741d427c7b8fbed2c0514c10102e4e11
2022-12-20 18:43:33 -08:00
Jun Wu
69db5eaef5 git: add a test case showing amend crash with submodule change
Summary: As the title. This verifies the next diff actually fixes the bug.

Reviewed By: bolinfest

Differential Revision: D42182508

fbshipit-source-id: 412c7d1559a8e8c9b50479171d84ec8511e58c91
2022-12-20 18:43:33 -08:00
Jun Wu
af2985752a git: move revert submodule test to a separate file
Summary: Revert related tests will be expanded.

Reviewed By: bolinfest

Differential Revision: D42182506

fbshipit-source-id: 519be2b7f5c9c99b347520a794a2656e992b6ad7
2022-12-20 18:43:33 -08:00
Jun Wu
773a2b2a46 git: add a test showing wrong rebase past submodule change
Summary: Added a test.

Reviewed By: bolinfest

Differential Revision: D42182505

fbshipit-source-id: 62086b3aee58d096a5f420c2c36d2cd11491b253
2022-12-20 18:43:33 -08:00
Jun Wu
935d9dfa14 drawdag: support submodule
Summary:
Make drawdag flexible so it can be used to create commits with submodule
changes.

Reviewed By: bolinfest

Differential Revision: D42182507

fbshipit-source-id: 1f68daaf4c5f17ae11b231a0b6afe9748bc4a82d
2022-12-20 18:43:33 -08:00
Muir Manders
00e0310f1a windows: don't look for executables in CWD
Summary:
In hgmain, set the environment variable NoDefaultCurrentDirectoryInExePath to disable the default Windows behavior of including the current working directory in PATH.

This avoids security issues where sl could execute a binary from the CWD (i.e. untrusted repo's working copy) instead of the proper system binary. For example, if the repo contains a binary named "watchman", code such as `util.popen4("watchman debug-status")` would prefer the repo's "watchman" to the system watchman.

Setting NoDefaultCurrentDirectoryInExePath assumes there is no legitimate use of this behavior when running other programs from within sl. I wouldn't be surprised if _something_ is depending on this behavior, but it doesn't seem like anything _should_ depend on it.

I like this approach since it should prevent all occurrences of this issue (i.e. including Python, Rust, ISL, etc). Another approach that isn't totally mutually exclusive with this approach is to add runtime checks to make sure we aren't accidentally running programs from the working copy (but still allow the CurrentDirectoryInExePath behavior). That seems harder to implement and verify/maintain.

Reviewed By: quark-zju

Differential Revision: D42154134

fbshipit-source-id: f625bb51e470c320ac96f803b55cb2c4ab4e44ec
2022-12-20 13:58:53 -08:00
Muir Manders
ac00bb4544 util: kill quotecommand
Summary: Since Python 3, this was a no-op on all platforms.

Reviewed By: quark-zju

Differential Revision: D42158008

fbshipit-source-id: a25065037079cb136a6e54579a5373a9791cb3f0
2022-12-20 13:58:53 -08:00
Muir Manders
0e2c502d6b stablerev: run script as absolute path
Summary:
In D42154134 we want to disable the default Windows CWD-is-in-$PATH behavior. However, that also disables all relative path invocation (e.g. `system("foo/bar", cwd=repo.root)` would still work on Posix systems, but fail on Windows because Windows would no longer search ".").

I looked through our subprocess usage and this was the only example I could find.

I tried to also add a tripwire warning message to help discover more/future uses that might not work with D42154134.

Reviewed By: quark-zju

Differential Revision: D42158007

fbshipit-source-id: df94502244937c01ea2f1e025833d9699574523d
2022-12-20 13:58:53 -08:00
Muir Manders
3d57f7816c kill "extdata()" revset/template func
Summary: I don't think we use this, and it includes a "shell:" gateway to invoke arbitrary commands.

Reviewed By: quark-zju

Differential Revision: D42158009

fbshipit-source-id: 514da6fdf9b1644db98d48fe4a9aaca4c6096515
2022-12-20 13:58:53 -08:00
Saul Gutierrez
96b767efde rebase: do not rebase public commits with -b flag
Summary:
Before this change, the rebase command would error out on public commits when using the `-b` option and rebase backwards. For instance, if one had the following graph:

```
    Y
    |
X   B
 \ /
  A
```

and both `A` and `B` were public commits, while `X` and `Y` weren't, `rebase -b Y -d X` would try to move `B` on top of `X` and complain about `B` being a public commit.

This diff makes rebasing with `-b` slightly smarter, by trying to find the appropriate bottom-most non-public commits to be rebased.

Reviewed By: quark-zju

Differential Revision: D42087621

fbshipit-source-id: bd5b5e7b6b1716f72929b405beb53906d92614f1
2022-12-20 13:51:43 -08:00
David Tolnay
81298dd90f Utc.timestamp(…) -> Utc.timestamp_opt(…).unwrap()
Summary:
Implicitly panicking methods like `TimeZone::timestamp` are deprecated as of chrono 0.4.23.

```
warning: use of deprecated associated function `chrono::TimeZone::timestamp`: use `timestamp_opt()` instead
   --> buck2_common/src/cas_digest.rs:330:13
    |
330 |         Utc.timestamp(self.inner.expires.load(Ordering::Relaxed), 0)
    |             ^^^^^^^^^

warning: use of deprecated associated function `chrono::TimeZone::timestamp`: use `timestamp_opt()` instead
   --> buck2_build_api/src/actions/impls/cas_artifact.rs:234:60
    |
234 |                 let dir = re_tree_to_directory(&tree, &Utc.timestamp(0, 0))
    |                                                            ^^^^^^^^^

warning: use of deprecated associated function `chrono::TimeZone::timestamp`: use `timestamp_opt()` instead
   --> buck2_build_api/src/interpreter/rule_defs/context.rs:925:43
    |
925 |         let expires_after_timestamp = Utc.timestamp(expires_after_timestamp, 0);
    |                                           ^^^^^^^^^
```

Reviewed By: zertosh

Differential Revision: D42177451

fbshipit-source-id: fd0ba0a37b02316e3fcd67737049a53dffb94ed2
2022-12-20 13:50:25 -08:00
Muir Manders
1d0a4747ed status: don't always enable pager
Summary:
For native "status" (and "config") commands, we now respect various flags and configs to determine if we should enable pager. Previously the only thing we checked was stdout.is_tty().

We don't support _everything_ Python does (e.g. don't support pager.ignore list of commands), but this is probably good enough for now.

Reviewed By: quark-zju

Differential Revision: D42088976

fbshipit-source-id: 171588f11f1b5c5f7f86ce55298ee9a1377610f7
2022-12-20 13:25:36 -08:00
Muir Manders
59af6659ee status: add "querying watchman" progress bar to Rust
Summary:
This at least indicates to the user what they are waiting for.

We should port the recrawl progress bar to Rust as well, but that is a bit more work.

Reviewed By: quark-zju

Differential Revision: D42088974

fbshipit-source-id: 2fc5e1ac2b69d8416ca6382e7131db131e7bdead
2022-12-20 13:25:36 -08:00
Muir Manders
4b13f97a33 watchman: add metrics for Rust watchman
Summary:
Log the number of files returned and whether it was a fresh instance. Also, instrument the watchman query so it shows up in perftrace, and populates the watchmanquery_time field.

Note that I didn't go through the hgmetrics stuff and instead logged straight to tracing. hgmetrics currently only makes it to scuba for Python commands.

Reviewed By: quark-zju

Differential Revision: D42088975

fbshipit-source-id: 38a2a647f9e3ce9b612d8f203fc3777c259698b9
2022-12-20 13:25:36 -08:00
Muir Manders
cb6da16399 status: send configured sync_timeout to watchman
Summary:
Send sync_timeout in Rust to match what we do in Python. Not sure if this matters, but I'm trying investigate/fix p90+ Rust status being slower than Python in some situations.

I observed that Rust is faster most of the time except for some (big) spikes where it isn't, so I looked at timeouts. Note that the Rust watchman client doesn't seem to have a configurable client side timeout (which Python does have).

Reviewed By: quark-zju

Differential Revision: D42088977

fbshipit-source-id: da12dc4d2bb5df96ce9855b835aa5fa8a8509012
2022-12-20 13:25:36 -08:00
Mat Hostetter
9e915ad00e Add raw-api feature to dashmap
Summary: raw-api allows access to the underlying DashMap shards, which I need.

Reviewed By: davidbarsky

Differential Revision: D42132672

fbshipit-source-id: 22b753f3ec95c85526f96a9e26d28379b2b4179b
2022-12-20 10:31:47 -08:00
Muir Manders
8377ef85e6 help: get rid of "hgrc" references in help text
Reviewed By: quark-zju

Differential Revision: D42156408

fbshipit-source-id: ee774e43f979e7ebe61c24cad43a757b8796dc42
2022-12-20 09:23:14 -08:00
Muir Manders
ea97558251 help: simplify "sl help config" contents
Summary:
Point the user to "sl configfile" instead of trying to list the config file locations statically.

Also, get rid of blurbs about per-installation config file and built in config files because they don't really apply anymore.

Reviewed By: quark-zju

Differential Revision: D42156409

fbshipit-source-id: 9fed8723d87c95f818a4fcfd323a310c4dd65060
2022-12-20 09:23:14 -08:00
Muir Manders
41cf10197c help: fix "HG:" references in "sl help config.committemplate"
Reviewed By: quark-zju

Differential Revision: D42156410

fbshipit-source-id: 9e5978560093dd001bc21ddd3c2fca4509484dbb
2022-12-20 09:23:14 -08:00
Chad Austin
604825a558 rename edenfs rage to eden rage in hg rage
Summary:
We call it "eden rage" everywhere else, so searching hg rages for
"edenfs rage" is always unintuitive to me. Let's rename the header to
"eden rage".

Reviewed By: quark-zju

Differential Revision: D42152264

fbshipit-source-id: 32ecb8f935aaf386c5148586fb9cb8f9e4a4089f
2022-12-19 14:36:37 -08:00
Saul Gutierrez
cfbb6a256b add an additional exception for gdbm
Summary: There are some OSS users that have the `gdbm` module installed, but for some reason it doesn't contain the `open` function. This diff adds an additional check for it.

Reviewed By: quark-zju

Differential Revision: D42116597

fbshipit-source-id: 0700650120f5442a0dd738221e7d4dee57552012
2022-12-19 14:28:44 -08:00
Zhaolong Zhu
8ba7dc7272 push: fix TypeError when deleting remote bookmark
Summary:
Currently, we append both `tuple` and `list` types to `outbookmarks`, which causes TypeError like below:

```
  - Traceback (most recent call last):
      File "/opt/fb/mercurial/edenscm/commands/__init__.py", line 4984, in push
        pushop = exchange.push(
      File "/opt/fb/mercurial/edenscm/exchange.py", line 506, in push
        _pushdiscovery(pushop)
      File "/opt/fb/mercurial/edenscm/exchange.py", line 620, in _pushdiscovery
        step(pushop)
      File "/opt/fb/mercurial/edenscm/ext/remotenames.py", line 624, in expushdiscoverybookmarks
        return exchange._pushdiscoverybookmarks(pushop)
      File "/opt/fb/mercurial/edenscm/exchange.py", line 757, in _pushdiscoverybookmarks
        pushop.outbookmarks.sort()
    TypeError: '<' not supported between instances of 'tuple' and 'list'
```

Reviewed By: quark-zju

Differential Revision: D42151253

fbshipit-source-id: e9eacc6530d8302ce102f0bed069066ec6932e88
2022-12-19 13:57:19 -08:00
Michael Bolin
650673762e add parse_stack_information() helper
Summary:
Introduces a helper function to parse the stack information
originally written to a pull request body by
`create_pull_request_title_and_body()`.

Reviewed By: zzl0

Differential Revision: D42117514

fbshipit-source-id: 43c6580a3774ae2e44108298a88b3b597a3b2c01
2022-12-19 10:39:24 -08:00
Michael Bolin
fad11abbfb move create_pull_request_title_and_body() into its own file
Summary:
In a subsequent diff, we need to add logic for parsing
the pull request body, so we should encapsulate this in
its own file.

This also makes `submit.py` 50 lines shorter!

Reviewed By: zzl0

Differential Revision: D42117031

fbshipit-source-id: da5837f619c9cc02ba01dd04f227f63c73cd39fb
2022-12-19 10:39:24 -08:00
Michael Bolin
8910d18fe8 change how Sapling stack information is written into a pull request body
Summary:
As suggested on https://github.com/facebook/sapling/issues/191,
this moves the Sapling stack information below a horizontal rule
so the author's commit message appears first.

As noted in the PR, this will require a complementary change to
ReviewStack to recognize this new pattern.

Reviewed By: zzl0

Differential Revision: D42116914

fbshipit-source-id: c2e3afbf2233849046c5986133f43fcb0e527ed7
2022-12-19 10:39:24 -08:00
Michael Bolin
8ca54814b8 include body in PullRequestDetails
Summary:
We need this for two things:

- In `sl pr submit`, we can often avoid updating every pull request
  when the user runs `sl pr submit --stack`, but we need to make
  sure the message does not have to change.
- In `sl pr get` (upcoming change), we need to be able to parse the
  stack information for the pull request we are importing.

Reviewed By: zzl0

Differential Revision: D42114153

fbshipit-source-id: 31a3407c509ec4809c5dfcfeb85b6b147be7c70a
2022-12-19 10:39:24 -08:00
Michael Bolin
eef4d49ab9 do some renaming around add_pr_head_to_archives()
Summary:
Renames `add_pr_head_to_archives()` to `add_commit_to_archives()`
to more accurately describe what the function does.
Includes additional documentation cleanup to reflect this change.

Reviewed By: zzl0

Differential Revision: D42112392

fbshipit-source-id: 42f3e0b816117da0ab002aa1490e9cab3b4db453
2022-12-19 10:39:24 -08:00
Michael Bolin
69b0176db5 split add_pr_head_to_archives() into its own file
Summary:
This moves `add_pr_head_to_archives()` out of `submit.py`
and into its own file, `archive_commit.py`. Of note:

- This makes `submit.py` 300 lines shorter.
- This makes it possible to reuse `add_pr_head_to_archives()` in `sl ghstack`

Note that the `run_git_command()` and `none_throws()` functions
are shared across `submit.py` and `archive_commit.py`, so they
were moved into their own files.

Reviewed By: zzl0

Differential Revision: D42108697

fbshipit-source-id: 27827658ea56a6644b4a024a0e839c5d74e71b47
2022-12-19 10:39:24 -08:00
Michael Bolin
48e349f725 add missing assertion to doctest
Summary:
This appears to have been an oversight when this function
was written as the example for the doctest was written
but never evaluated.

Reviewed By: zzl0

Differential Revision: D42110434

fbshipit-source-id: f1af32514324ef7bf2683612deb4f1dbd60a4bb7
2022-12-19 10:39:24 -08:00
Michael Bolin
166e2640d3 experiment with the "single" commit pull request workflow
Summary:
This introduces an experimental new pull request workflow
named "single" because it creates a single PR per commit.
To enable it, run:

```
sl config --local github.pr_workflow single
```

It is similar to ghstack with the following notable differences:

- Instead of creating three branches for each commit
  (`orig`, `base`, `head`), it creates only one. This makes it
  straightforward to work with the branches directly, if desired.
- It updates a stack via force-pushing. This can be problematic
  in GitHub where comments on earlier versions may get lost
  in the course of force-pushing. Our hope is that we can
  use ReviewStack to workaround this issue.

See https://github.com/facebook/sapling/issues/302

Reviewed By: zzl0

Differential Revision: D42062506

fbshipit-source-id: 2d29784cfbf40ab09421cc364d10230a4463fba6
2022-12-19 10:39:24 -08:00
Zhaolong Zhu
35a456ca23 github: add test for sl pr submit
Summary: added tests for `sl pr submit`, the test uses `extensions.wrapfunction` to wrap the original `make_request` and `run_git_command` functions (registered in `mock_create_one_pr.py`), so we can replace the network requests with mock data.

Reviewed By: bolinfest

Differential Revision: D42037042

fbshipit-source-id: 011bfcb2400200baecf547ec0b18b0154ff580a9
2022-12-19 06:13:27 -08:00
Zhaolong Zhu
a7bee24f4d github: add merge into branch request for MockGitHubServer
Summary: as title

Reviewed By: bolinfest

Differential Revision: D42116786

fbshipit-source-id: 61c0cc1b8d64fb73e0a10ebd627faf3ae6795cec
2022-12-19 06:13:27 -08:00
Zhaolong Zhu
e02a3873ee github: add get username request to MockGitHubServer
Summary: as title

Reviewed By: bolinfest

Differential Revision: D42116125

fbshipit-source-id: 4f453dc2c909a39835dfaa2798386a4b1a0d498c
2022-12-19 06:13:27 -08:00
Zhaolong Zhu
ea4b37208f github: add update pr request to MockGitHubServer
Summary: as title

Reviewed By: bolinfest

Differential Revision: D42115796

fbshipit-source-id: 5db80224ddc251b9ffcb9431595022944ed2a334
2022-12-19 06:13:27 -08:00
Zhaolong Zhu
647e05a5dd github: add get pr details request to MockGitHubServer
Summary: added get pr details request to MockGitHubServer

Reviewed By: bolinfest

Differential Revision: D42112944

fbshipit-source-id: 521cd29855695113b133e697574f0f1928e3a791
2022-12-19 06:13:27 -08:00
Zhaolong Zhu
ef9830b244 github: add mock utils for testing GitHub
Summary: add mock utils (e.g. MockGitHubServer) for testing GitHub

Reviewed By: bolinfest

Differential Revision: D42078459

fbshipit-source-id: 91cbbdd74747c2a10c5a5a65a1f98460810bc0a6
2022-12-19 06:13:27 -08:00
generatedunixname89002005307016
3ef2cb3cad Add annotations to eden/scm/edenscm/ext/conflictinfo.py
Reviewed By: yancouto

Differential Revision: D42139518

fbshipit-source-id: 5c7ae479f3d70ac3064e5150c05d5203dbd85bd3
2022-12-19 05:40:13 -08:00
Jun Wu
115a33bf0e drawdag: support --no-files
Summary: By default drawdag creates files. Make it possible to disable it using flags.

Reviewed By: muirdm

Differential Revision: D42102946

fbshipit-source-id: 0fa91ffb34d569238a477378bb87be37ef3b75c4
2022-12-16 14:04:17 -08:00
Jun Wu
4aaae1619f debugexportrevlog: use .hg instead of .sl
Summary:
The command creates a revlog repo for compatibility with Mononoke blobimport
and open-source Mercurial. Threrefore it should always use `.hg`.

Reviewed By: muirdm

Differential Revision: D42102948

fbshipit-source-id: 341ccbc35cbdae86311bcf7c8c8b076168332f5a
2022-12-16 14:04:17 -08:00
Jun Wu
91ec693716 config: color bold => brightcolor bold
Summary:
Most modern terminals "auto-bright" when text is also bold. However, the
website ANSI -> HTML converter does not do that. In practice we pretty
much rely on the "auto-bright" behavior. So let's update the smartlog
colors with bright versions to make it more explicit.

Reviewed By: muirdm

Differential Revision: D42102947

fbshipit-source-id: 867d6947a5db0fe59a627ff2bd9a82621d28bfe5
2022-12-16 14:04:17 -08:00
Jun Wu
0a17a76a1d config: load sapling "prod" config if TEST_PROD_CONFIGS is set
Summary:
It turns out `unsetting TESTTMP` is not a great idea for loading production
configs, since there might be other references to it, for example:

  [remotefilelog]
  cachepath=$TESTTMP/foo/bar

in test hgrc relies on runtime expansion of `$TESTTMP`.

For documentation purpose, we do want to load the "prod" config including the
templates and colors. Make it possible using `TEST_PROD_CONFIGS`.

Reviewed By: muirdm

Differential Revision: D42102951

fbshipit-source-id: baa82b85873f0793b3b873b9a63bb7865e28787b
2022-12-16 14:04:17 -08:00
Jun Wu
2eb818db71 workingcopy: add tracing about why it might fail
Summary:
When I tried to create a real repo with TESTTMP unset for documentation, I got
mysterious errors like:

  File "/opt/fb/mercurial/edenscm/dirstate.py", line 186, in make_treestate
    ui, opener, root, self._repo._rsrepo.workingcopy().treestate()
    # root = '$TESTTMP/repo1'
  error.WorkingCopyError: working copy is missing information or corrupt: No such file or directory (os error 2) at path "$TESTTMP/repo1/$TESTTMP/.tmp2f2UD9 (ef5a29b32a)"

This diff adds tracing logs in various layers to help narrow it down.

The error message is changed since the underlying errors can be unrelated to
the working copy directly.

For now I just trace the mysterious error down. Note the logs are for component
initialization, which usually just run once. They are not in hot paths to
affect performance.

A more systematic solution might be using the `fn_error_context` crate and
enforce functions returning errors to attach context.

Reviewed By: muirdm

Differential Revision: D42102949

fbshipit-source-id: 6060bebe280a72ab6cd32e4d0eb55e5332612287
2022-12-16 14:04:17 -08:00
Muir Manders
54b1ac0a69 main: support dropping root to specified user/group
Summary: On *nix, optionally read <user>:<group> from SL_DEBUG_DROP_ROOT and try to switch user/group. This is useful when tying to run sl under DTrace since DTrace requires root, but sl in general does not work when running "unexpectedly" as root.

Reviewed By: quark-zju

Differential Revision: D42088978

fbshipit-source-id: b625af9859994b368b127837610bf36b0f250bc5
2022-12-16 12:04:26 -08:00
Muir Manders
4e3080d05d status: remove edenfs v1 getScmStatus fallback
Summary: getScmStatusv2 has been around for years, so lets kill the fallback.

Reviewed By: quark-zju

Differential Revision: D42074065

fbshipit-source-id: 1a655d571253326ad0c4ff1ddf06525bae0f164f
2022-12-16 12:04:26 -08:00
Muir Manders
b1a4c67bac status: fix native status to ignore modified symlinks on Windows
Summary:
Python status has some logic to ignore changes to symlinks on platforms that don't support symlinks. This diff ports that logic to Rust as well.

The issue appeared on Windows with symlinks inside node_modules/.bin directories. On Windows when you run "yarn", the symlinks are overwritten with wrapper scripts (since symlinks are not supported). The Rust status was showing those as modified files, buy Python had special logic to ignore "suspect" changes to symlinks.

Reviewed By: quark-zju

Differential Revision: D42016078

fbshipit-source-id: 18d0f41253611fab28e36aa4f720534144008d3f
2022-12-16 12:04:26 -08:00
Muir Manders
fcd29fa7b0 status: fix expansion of env vars in ignore file paths
Summary: In Rust, we now properly expand environment variables in ui.ignore.* paths. In particular, the default config "ui.ignore.system=%PROGRAMDATA%\Facebook\Mercurial\gitignore" on Windows now applies properly since we expand "%PROGRAMDATA%" when loading the ignore files.

Reviewed By: quark-zju

Differential Revision: D42016077

fbshipit-source-id: d7ad2d7c0e60334dab3e03eb26922e8127274c9b
2022-12-16 12:04:26 -08:00
David Barsky
df0dde069b rust-analyzer: update to 2022-12-14
Summary:
Replaces D41855449.

This diff updates:
- rust-analyzer to 2022-12-12's release.
- bumps `dashmap` to 5.4.0 from 5.2.0
- bumps `windows-sys` to 0.42, which unfortunately necessary because `dashmap` bumped their minimum version of `parking_lot` internally.
- bumps `notify` from the pre-release builds to 5.0

 allow-large-files

Reviewed By: zertosh

Differential Revision: D41971461

fbshipit-source-id: 51c1d969d0cdcabcc37f2381e8c942fd0d0af765
2022-12-16 11:20:56 -08:00
Zhaolong Zhu
f30ea51ba1 gh_submit: refactor make_request usage
Summary:
refactor 'make_request' usage to 'module.function' style, so we
replace it with a wrapper function by using 'extensions.wrapfunction'

Reviewed By: bolinfest

Differential Revision: D42100407

fbshipit-source-id: 822b5f292ca633e07d25b9f8dee638513df83869
2022-12-16 10:46:40 -08:00
Jun Wu
709398a495 config: rename pest-hgrc to hgrc-parser
Summary: The crate no longer uses pest. Let's rename to clarify.

Reviewed By: zzl0

Differential Revision: D42054965

fbshipit-source-id: f3be977c6def6e6e12a886b0d91b4a40641a9c55
2022-12-15 20:04:29 -08:00
Jun Wu
a2694e29d0 config: drop pest for parsing hgrc
Summary:
The hgrc format is quite simple. Writing a parser directly actually has similar
complexity to the pest parser, but with improved performance. Therefore let's
migrate off pest.

Before:
  % buck2 run @//mode/opt :bench --
  parse 645KB file                                   89.872 ms
  load system and user                                1.877 ms
  load repo                                           4.107 ms

After:
  % buck2 run @//mode/opt :bench --
  parse 645KB file                                   31.501 ms
  load system and user                                0.757 ms
  load repo                                           2.360 ms

Reviewed By: zzl0

Differential Revision: D42054371

fbshipit-source-id: 7dc84154cabec52ed7910e12fbac894845770076
2022-12-15 20:04:29 -08:00
Jun Wu
6088810cc0 config: clean up based on debugduplicatedconfig output
Summary: Manual clean up based on `debugduplicatedconfig` output.

Reviewed By: muirdm

Differential Revision: D42036005

fbshipit-source-id: 4a32dd284ade2e10e826afad6e97981322b4f040
2022-12-15 18:24:16 -08:00
Jun Wu
93cf6a2938 commands: add debugduplicatedconfig
Summary: Add a way to find duplicated or overridden configs for cleanup purpose.

Reviewed By: muirdm

Differential Revision: D42035995

fbshipit-source-id: 138964ffcfb9896ea69a850d1a9369405cedfa99
2022-12-15 18:24:16 -08:00
Jun Wu
f2847d7eb9 config: drop configs.remote_allowlist
Summary:
It's a super long (>4K) config. Code search shows it's not used anywehere.
Therefore let's drop it.

I checked that `configs.legacylist` is also unused.

Reviewed By: muirdm

Differential Revision: D42036006

fbshipit-source-id: 82b886b9eb6abb50cacef7ee0f868280d45ab0a8
2022-12-15 18:24:16 -08:00
Jun Wu
f0e24b5c97 config: move part of dynamicconfig to static config
Summary:
Part of the internal dynamicconfig logic is actually just static. Move the most
obvious function common() to static config to avoid parsing overhead.

I dropped "DO NOT ADD NEW ENTRIES IN THIS FUNCTION !!!" since it no longer
applies - there is no function, and the static config macro is the right place
to update static configs.

Reviewed By: muirdm

Differential Revision: D42036002

fbshipit-source-id: a815715c83b751340e0181e4630371fe3b6f7932
2022-12-15 18:24:16 -08:00
Jun Wu
58a215681d config: move opensource as static sapling config
Summary:
Move the opensource dynamicconfig to statically compiled config used by the
Sapling identity. This should reduce parsing time and make the internal `sl`
behave more closely with the external `sl`.

Reviewed By: muirdm

Differential Revision: D42036011

fbshipit-source-id: d45d6de0bac49d2d9397ff0556a4130cf7c93a84
2022-12-15 18:24:16 -08:00
Jun Wu
9ac87d66b7 config: drop HG_NO_DEFAULT_CONFIG
Summary:
The TESTTMP check is sufficient. All places setting HG_NO_DEFAULT_CONFIG
already have TESTTMP set.

Reviewed By: muirdm

Differential Revision: D42036001

fbshipit-source-id: a1cf4f7a02917fcfee51d581b1bb6d5a81572c70
2022-12-15 18:24:16 -08:00
Jun Wu
72a9940312 config: move merge-tools and core to static_config!
Summary:
Use the `ConfigSet::secondary` added by D42023337 to include statically
compiled builtin merge-tools and core python configs. This avoids parsing cost.

Reviewed By: muirdm

Differential Revision: D42036010

fbshipit-source-id: 20bd724c31c4b5924c7124a35c859c9c66784c5d
2022-12-15 18:24:16 -08:00
Jun Wu
8e6ba3b0a8 config: make ensure_location_supersets print full path in tracing messages
Summary:
The "dropping" tracing messages would be useful to figure out exactly what
parts of config files are ignored.

Reviewed By: muirdm

Differential Revision: D42035997

fbshipit-source-id: 7f9f92510d445b23d357ff3fd6f891f14dbc4f80
2022-12-15 18:24:16 -08:00
Jun Wu
7fe0ef4d21 pyconfigloader: drop validate
Summary:
The underlying Rust method `ensure_location_supersets` only needs to be called once.
It's already called for `load` and `reload` paths. Therefore it's unnecessary
to call `ensure_location_supersets` again.

Reviewed By: muirdm

Differential Revision: D42036012

fbshipit-source-id: e181775a88880ea95da6399996367d1e30a8b31e
2022-12-15 18:24:16 -08:00
Jun Wu
56b43fea0b config: remove SupersetVerification
Summary: See the previous diff for context. Remove it since it's no longer used.

Reviewed By: muirdm

Differential Revision: D42025934

fbshipit-source-id: 31598893c78b103fa09d262f107c660aeb3a566a
2022-12-15 18:24:16 -08:00
Jun Wu
8036cae2fc config: remove unused logic in ensure_location_supersets
Summary:
`ensure_location_supersets` has 2 features:
1. Verify hgrc.dynamic matches /etc configs. Report mismatches. This was the
   initial purpose as you can see from the function docstring. At that time
   the idea was that dynamicconfig matches /etc configs exactly (we no longer
   do that).
2. Enforce `configs.allowedlocations` and `configs.allowedconfigs`. This was
   added later - wasn't mentioned in docstring.

Feature 1 does not actually work, since the filenames of the /etc configs are
supposed set by `configs.validationsubset`, but is empty in production setup.

Worse, the existing logic would treat all config items as "mismatch" and
`uiconfig.reportissues` will report near 1000 config items.

Since feature 1 is already not working as intended, this diff drops it.
Logging via Rust tracing is added for changes by feature 2. Note we cannot
rely on Python `uiconfig.reportissues` logging because
`ensure_location_supersets` is called multiple times and it can only report
mismatches the first time, while the Python code does not call it the first
time.

Reviewed By: muirdm

Differential Revision: D42024668

fbshipit-source-id: fbe5cf42e45fb1e68e2d32ec27fbdfe00cb62170
2022-12-15 18:24:16 -08:00
Jun Wu
ce7a311b1a config: add benchmarks loading real configs
Summary:
Add a way to get some ideas about the overhead of config loading.

An example benchmark run shows:

  $ cargo bench --bench bench -- system
  load system and user                                1.873 ms
  load repo                                           2.052 ms

Reviewed By: muirdm

Differential Revision: D42036000

fbshipit-source-id: 3f566fb0c3f8369d3e257f845b4d803a6742dd26
2022-12-15 18:24:16 -08:00
Jun Wu
7637c9cae0 config: fix configloader benchmark
Summary: Fix compile of the benchmark logic.

Reviewed By: muirdm

Differential Revision: D42035999

fbshipit-source-id: 00d59f033bd3caf128d72b127908e952e6fb1aac
2022-12-15 18:24:16 -08:00
Jun Wu
6d961bd3f8 config: support abstracted secondary config as fallback
Summary:
This makes ConfigSet more flexible. It can include other kind of configs
(ex.  staticconfig, unionconfig, etc) to form layers of configs.

Reviewed By: muirdm

Differential Revision: D42023337

fbshipit-source-id: 436b688bb4aa661a5dbaf5086e11f6edf7affb7b
2022-12-15 18:24:16 -08:00
Michael Bolin
e77e67bba7 reserve GitHub issue number for new pull request
Summary:
Historically, I was under the impression that it was impossible
to create a pull request with a specific number. As you can see
in this diff, we had a `guess_next_pull_request_number()` helper
function that had a "pretty good" heuristic for guessing the next
pull request number, which made it likely that we could make
the number encoded in the branch name match that of the PR.
Unfortunately:

- This heuristic was not guaranteed to work 100% of the time,
  due to either races or deleted issues that could throw off the count.
- Using this heuristic required that we create the pull requests
  serially [from bottom to top of the stack] rather than in parallel.

However, today while reading the REST API docs for creating a
pull request (https://docs.github.com/en/rest/pulls/pulls?apiVersion=2022-11-28#create-a-pull-request),
I noticed it was possible to specify an `issue`:

> An issue in the repository to convert to a pull request. The issue title, body, and comments will become the title, body, and comments on the new pull request. Required unless `title` is specified.

Ah ha! This meant we could first create a number of GitHub
issues (in parallel!) with placeholder data and then use the numbers
from these issues when creating pull requests (also in parallel)!
This also means we know the PR number when choosing the branch
name (recall the branch cannot be changed after creating the PR).

This diff updates the existing `sl pr` command to take advantage
of this information.

Reviewed By: muirdm

Differential Revision: D42050143

fbshipit-source-id: a52694f6599c4ba99f568c538d557e6d10db72a6
2022-12-15 11:54:11 -08:00
Michael Bolin
6e9c3d7a66 add --draft option to sl pr submit
Summary:
With this change, running `sl pr submit --draft` will create any *new*
pull requests in draft mode. Commits already associated with a pull
request will not have their draft status changed.

Reviewed By: muirdm

Differential Revision: D42048510

fbshipit-source-id: fd1d1f1f1268b4deb9135f0f75115bbcc48d9ebe
2022-12-15 11:54:11 -08:00
generatedunixname89002005325677
6e51f16156 Daily arc lint --take RUSTFMT
Reviewed By: muirdm

Differential Revision: D42063430

fbshipit-source-id: b8d8c3c376385e1539ab4640121f71ae3f5755f7
2022-12-15 07:22:15 -08:00
generatedunixname89002005307016
6f4ce82bee Add annotations to eden/scm/edenscm/ext/lz4revlog.py
Reviewed By: yancouto

Differential Revision: D41996356

fbshipit-source-id: bcecf60bc784e81159483e42e7237e65df8366f1
2022-12-15 07:13:32 -08:00
generatedunixname89002005307016
6bd0b690ad Add annotations to eden/scm/edenscm/eden_dirstate_map.py
Reviewed By: yancouto

Differential Revision: D42068065

fbshipit-source-id: 197270808a20a0043fdef5f3b206265443048fe3
2022-12-15 07:12:38 -08:00
generatedunixname89002005307016
fba6e0daf7 Add annotations to eden/scm/edenscm/ext/gitrevset.py
Reviewed By: yancouto

Differential Revision: D42032097

fbshipit-source-id: a3c5d8227acb3080325ddcccc02aab9dc5bdb1f1
2022-12-15 07:10:45 -08:00