Summary: move GraphQL queries into consts module, so they can be reused by tests.
Reviewed By: bolinfest
Differential Revision: D42035497
fbshipit-source-id: 0f43e6b43a43c15b61f696858abdd5ae230a2c45
Summary: Move the update_distance log up so it fires for the Edenfs case as well.
Reviewed By: quark-zju
Differential Revision: D41750022
fbshipit-source-id: 48df0a58c009bc5bb87d76495d942a53f3089d1a
Summary:
This was requested for `sl pr` in
https://github.com/facebook/sapling/issues/218,
though this diff adds support for signing commits in general, in Sapling.
Here's how it works:
- `sl config --local gpg.key <KEY>` to specify your key
- Now `gitcommittext()` takes an optional `str` for the `gpgsigningkey` if `gpg.key` is set and `gpg.enabled` is `true` (which is the default).
- The text of the unsigned commit object is constructed and then signed using `gpg --status-fd=2 -bsau <KEY>` with the text passed via stdin.
- The resulting signature is embedded into the original text to sign it. Note that the original PGP key goes through some minor formatting (`\r` is removed; lines must start with a space to avoid a `\n\n` sequence) before it is embedded.
I documented things to the best of my knowledge in `eden/website/docs/git/signing.md`.
Follow-up items:
- Show signed status in smartlog?
- Update `sl ghstack` to honor signing configuration when running `git commit-tree`.
- Update `sl pr` to honor signing configuration when running `git commit-tree`.
Reviewed By: quark-zju
Differential Revision: D41778874
fbshipit-source-id: 5018a0d8bea1b5e9293c05954db65f35dd3c7aff
Summary:
fix "repo changed while backing up" errors for non best effort runs
metalog reloads on transaction, so let's add a transaction
before that, we had lots of **false positives** "repo changed while backing up" errors because we read cached values
also, enable best effort mode for scm daemon, it locks the whole working copy after https://www.internalfb.com/diff/D34797187 (2e1b3436b3), which is not expected
Reviewed By: markbt
Differential Revision: D41871718
fbshipit-source-id: 14e222d0ccbcd6aa4a6dd773f2889aa0721c9842
Summary: use GitHubEndpoint instead of low level async make_request, then we will be able to use a fake GitHubEndpoint in testing environment.
Reviewed By: bolinfest
Differential Revision: D41818264
fbshipit-source-id: 4ec511821a2e0fddf17bf384b73f0fc72dccb5b4
Summary:
I will add an async method `graphql` for `GitHubCLIEndpoint` later, so users can use it instead of low level async `make_request`. In order to do that, we need to rename current `graphql` to `graphql_sync`
This change is to keep the API same with [graphql-core library](https://fburl.com/nszrxh2m)
Reviewed By: bolinfest
Differential Revision: D41818265
fbshipit-source-id: 8aa0be9a4ac3a7b977069dabcd075187d3735226
Summary:
add . alias for the current workspace to `hg cloud move` and `hg cloud
copy` commands
Reviewed By: mitrandir77
Differential Revision: D41582556
fbshipit-source-id: 36fb71b6dc0217c21916f98cf35f2ea3c5a8c83a
Summary:
add dates support for `hg cloud log`
this feature will allow our users to select revisions within some date range and even generate a list of revs using template language and a date spec that can be later passed to the `hg hide`, `hg move` or `hg copy` command
```
liubovd ⛅️ ~/fbsource/fbcode/eden/scm
[21] → CHGDISABLE=1 ./hg cloud log -d "may 2022 to nov 2022" -T "-r {node} "
-r 9eff116c3ded29fdbb9677a6f224d5c0fb176b51 -r cd77c4713f7cc05979513156aa3cee9b1b71c0a5 -r 7d518da4cd576781236ef242f50afd4b26304101 -r be6bcf2e06cc4b86fb1f4d5916ff499aab87ec0b -r bd25bf01ea0f0c409e511d788f0d4e0977f2a23f -r b628734bfcdabbf171e3e7f68b6bb083091d3bf4 -r a0b62ddbcb92d9016a91fc029f9c39a4139d2a00 -r 744a751b2559d1a22595f3e883a02741c1676a6d -r 64c3c2729d90548d51213d10ece158be6e0995e3 -r 514f222243cc1e803f6164ee94a5e9a230e1fb6b -r 4eff725b392f8f5841e9674c87bdc1cba675f6e8
```
Reviewed By: mitrandir77
Differential Revision: D41580891
fbshipit-source-id: 7cb2db121795135d74098898b2a81e70c7eafce8
Summary:
`git commit-tree` reads identity information from `.gitconfig` by default,
but a Sapling user is not required to have a `.gitconfig` file.
Previously to this change, this call to `git commit-tree` would crash
if `git` could not read the identity information from `.gitconfig`.
Reviewed By: zzl0
Differential Revision: D41855800
fbshipit-source-id: b11e0e96bca7720aaf0d06fd44bfdb49666fc072
Summary:
Previously, users would get a confusing error about
`git commit-tree` failing if no `.gitconfig` existed for Git
to read `user.name` and `user.email` values from.
Reviewed By: zzl0
Differential Revision: D41852251
fbshipit-source-id: 788d6ffa5e78db913ada08b777f28897656fd161
Summary:
There are cases where Git needs `user.name` and `user.email`
specified independently, so introduce a utility to facilitate that.
Also move the existing `gituser()` function into this new file
so utilities are consolidated in one place.
Reviewed By: zzl0
Differential Revision: D41852252
fbshipit-source-id: 8b998074017372cd2a55f1209240949c8f18036f
Summary:
Mononoke repo names are permitted to contain slashes, however currently Sapling's URL parsing doesn't understand this, and instead has a bunch of hacks designed to work around misunderstandings of URIs. As a result, Sapling can't currently clone them.
You can look at resources like [Wikipedia's artical on URIs](https://en.wikipedia.org/wiki/Uniform_Resource_Identifier) if you are not familiar with how uniform resource identifier syntax should work.
We fix this by handling the `mononoke` and `fb` URI schemes specifically.
* For the `mononoke` scheme, the authority is the Mononoke server and the path is the name of the repository, with any leading or trailing slashes removed.
* For the `fb` scheme, the path is the name of the repository, and there should be no authority as the server is implicit. This means a valid `fb` scheme URI is of the form `fb:reponame`. Unfortunately, since people misunderstand `://` to be a single token, existing `fb` URIs exist of the form `fb://reponame`. This is a problem, as if the repo name has a slash in it, it becomes `fb://firstpart/secondpart`, where `firstpart` is the authority and `secondpart` is the path. We handle this specially by taking the scheme-specific part as a whole and removing all leading and trailing slashes.
In order to fix the second in the long-term, we must also fix up how the `schemes` extension handles URIs like the `fb` scheme. In a similar vein, we substitute the full scheme-specific part in the target URL. This will allow us to migrate from `fb://reponame` to `fb:reponame`, at which point we can use correct URI parsing in the `fb` scheme, as we do for the `mononoke` scheme.
Reviewed By: yancouto
Differential Revision: D41771964
fbshipit-source-id: e93060afe316f4b965a6d1770b1b88a8d60e5f5c
Summary:
Adds a VERY simple implementation of the `tar` command to debugruntest. This command was added since old version of Windows still don't have the `tar` command. Additionally, running tests using the `tar` command on Windows would cause trouble for certain paths when running tests using Cygwin.
At the moment this implementation only supports decompressing files, but support for other options can be added in the future.
Reviewed By: quark-zju
Differential Revision: D41793100
fbshipit-source-id: 8761ebd1e02a010e4634e6003ed7bcdd3a5166d4
Summary: Adds a simple equivalent to the `-a` option in the `ls` command to the `ls` debugruntest "command".
Reviewed By: quark-zju
Differential Revision: D41793380
fbshipit-source-id: 6e001e768eae4206efc037f2f366028060aba5c8
Summary:
As mentioned in D41793101, debugruntest on Windows had trouble invocating external binaries. This was in part due to an issue with `.bat` files, which this diff fixes.
`debugruntest` creates shims for calling the original binaries and somewhat alters the path, including only the path to the shims and the path to hg (`.bat` files on Windows). The non-Windows shims worked fine, but the Windows ones had an issue since before this diff the paths on the shim were not quoted, making the desired binary not invokable (e.g. `C:\Program Files\Git\cmd\git.exe` unquoted failed because of the space on it).
Reviewed By: quark-zju
Differential Revision: D41825107
fbshipit-source-id: 5f73a52f62e468d44c35870d28319892fb69258d
Summary:
When running `.t` integration tests using `debugruntest`, and those tests depend on some external binary, they have to be declared with teh `requires` keyword at the beginning of the test. Those external binaries can be invoked either by the "shell" in the `.t` tests or by hg/sl.
Before this diff a mechanism existed for calling external commands under `debugruntest`, but this only worked for those invoked via the `ui.system` method. This was possible since one of the methods ultimately called by `ui.system` was monkey-patched by `hg.py`. This diff does something similar for the `subprocess.run` method.
Reviewed By: quark-zju
Differential Revision: D41793101
fbshipit-source-id: dffb042791e3c4b9be9ae05a8b8586a4fe3f382d
Summary:
Using f-strings avoids the need to mentally match up `%s`
placeholders with variables.
Reviewed By: quark-zju
Differential Revision: D41784141
fbshipit-source-id: d55a5ffda4696e3ccfe2370434f3712e249067f6
Summary:
Before making changes to `gitcommittext()`, this puts some
stronger guarantees in place in the form of doctests and types.
Reviewed By: zzl0
Differential Revision: D41784016
fbshipit-source-id: 3ca8e957b0dabc1eededfe25d137371dcbdeaab5
Summary: add metrics for copytracing rename prompt to understand how many users are impact by renaming issue.
Reviewed By: quark-zju
Differential Revision: D41804438
fbshipit-source-id: cf73f433512b63f5c06056d2bf32733bc2e86df3
Summary:
as mentioned in https://github.com/facebook/sapling/issues/228 ``sl init --git DIR`` results in an error if ``DIR`` already exists, this fix creates a temporary directory if the directory exists and then moves the ``.sl`` directory into the target directory, if the target directory exists and already contains a ``.sl`` directory an error is thrown saying ``destination DIR is already a repository``
Pull Request resolved: https://github.com/facebook/sapling/pull/277
Reviewed By: zzl0
Differential Revision: D41771411
Pulled By: bolinfest
fbshipit-source-id: e3dc108c37a7dfce61f854212a1e4fc178e1cf89
Summary:
add template support to `hg cloud sl` command
it is a bit unusual from user's point of view that it is not supported, now
let's support it
it also provides an easy way to see the full hashes
Reviewed By: markbt
Differential Revision: D41579865
fbshipit-source-id: 92f15394628799ee8f54796387f0055ed8bfac7e
Summary:
add `hg cloud log` command to print metadata for commit cloud commits from a
workspace in linear view (without lines to connect nodes)
it used to be possible to get a linear (non graph) view from `hg cloud sl` command with some tricks around templates but it is not possible anymore nowadays, so adding a separate command to make it possible again
the command will be helpful for bulk commit cloud operations without a need of full sync or workspaces switch, see more details here: https://www.internalfb.com/intern/wiki/Commit_Cloud_Sync/#copy-move-all-commits-fr
Reviewed By: mitrandir77
Differential Revision: D41579597
fbshipit-source-id: a08e6c885515318977fc59cd77bdc49fa87ab561
Summary:
Previously there is no way to set user or complex (including spaces) commit
messages using drawdag. This diff introduces a way to do that for maximum
flexibility.
This is intended to be used to create repo state for documentation rendering.
Note the `{sl}` template configs do not exist in test environment yet so we
emulate a minimal version of the template in test.
Reviewed By: zzl0
Differential Revision: D41674152
fbshipit-source-id: 2bb1212da06ddd2fd93f780d6f7b291f873fa922
Summary:
Print an appropriate error message if no default branch exists when running `sl pr`.
Previously the user would see:
```
commit has no parent: currently unsupported
```
Due to:
32e50cf5e0/eden/scm/edenscm/ext/github/submit.py (L57)
Now we provide a link to help the user create an initial commit.
Pull Request resolved: https://github.com/facebook/sapling/pull/263
Test Plan:
Ran on a dev build of `sl` using https://github.com/bolinfest/uninitialized
and saw the expected error:
```
$ sl pr
abort: failed to fetch repo id: This repository has no default branch. This is likely because it is empty.
Consider using https://github.com/bolinfest/uninitialized/new/main to initialize your
repository.
```
Imported from OSS
Reviewed By: quark-zju
Differential Revision: D41704188
Pulled By: bolinfest
fbshipit-source-id: aafe10da5af6dd3e5ca98d6ac1a6ba3fc0c6208f
Summary:
fixed the outdated doc about graft, we have changed the default behavior in [this commit](d5c12360a4)
https://github.com/facebook/sapling/issues/299
Reviewed By: quark-zju
Differential Revision: D41700926
fbshipit-source-id: e80fc279d03a31aee8a0b138c85c38b3e606a6b2
Summary: This makes "now" overrides effective for the `simpledate` template function.
Reviewed By: zzl0
Differential Revision: D41674153
fbshipit-source-id: 9d19409e93f1953effe9313fc087ff322df3d906
Summary:
* remove the redundant 'node' parameter from 'get_pull_request_for_node' function since 'ctx' already has that information
* rename 'get_pull_request_for_node' to 'get_pull_request_for_context'
Reviewed By: quark-zju
Differential Revision: D41560639
fbshipit-source-id: e776470d7815b8d2fd5c4a24825c6004520cb5cb
Summary:
This diff introduces emacs style bindings for navigating the crecord interface for people who are used to using magit.
C-n: Move down
C-p: Move up
C-v: Move to the next item of the current item type you have selected
M-v: Move to the previous item of the current item type you have selected
tab: Fold / Unfold item
curses.raw() is used so that C-v does not need to be pressed twice for it to work.
Reviewed By: quark-zju
Differential Revision: D41539621
fbshipit-source-id: 873c605c793d8ceba4d3f630aaca617506a19e43
Summary:
Instead of reversing the partitions inside `create_pull_requests()`,
iterate them in reverse order when building up
`pull_requests_to_create` (so branch names are assigned from the
bottom of the stack to the top), and then
`create_pull_requests()` will receive them in the same order.
Fixes https://github.com/facebook/sapling/issues/231
Reviewed By: quark-zju
Differential Revision: D41643866
fbshipit-source-id: f597955e7d6d9eb621bc4e201fbfc020d0a4d0df
Summary:
Stack created with [Sapling](https://sapling-scm.com). Best reviewed with [ReviewStack](https://reviewstack.dev/facebook/sapling/pull/280).
* __->__ https://github.com/facebook/sapling/issues/280
[github] have `pr link` link the current rev by default
The docs seem to imply that `--rev` is optional, but right now if you don't specify a rev, you get a crash with unexpected `None`
Pull Request resolved: https://github.com/facebook/sapling/pull/280
Test Plan:
Before:
```
$ sl pr link 148
...
File "/Users/shish2k/sapling/eden/scm/edenscm/util.py", line 1285, in check
return func(*args, **kwargs)
File "/Users/shish2k/sapling/eden/scm/edenscm/ext/github/__init__.py", line 78, in link_cmd
return link.link(ui, repo, *args, **opts)
File "/Users/shish2k/sapling/eden/scm/edenscm/ext/github/link.py", line 31, in link
pr_store.map_commit_to_pull_request(ctx.node(), pull_request)
File "/Users/shish2k/sapling/eden/scm/edenscm/ext/github/pullrequeststore.py", line 41, in map_commit_to_pull_request
self._write_mappings(mappings)
File "/Users/shish2k/sapling/eden/scm/edenscm/ext/github/pullrequeststore.py", line 64, in _write_mappings
commits[hex(node)] = entry
TypeError: descriptor 'hex' for 'bytes' objects doesn't apply to a 'NoneType' object
```
After:
```
$ sl pr link 148
$ sl
@ 5a1bc01b8 Yesterday at 17:30 shish #148
╭─╯ Chomecast support
...
```
Reviewed By: zzl0
Differential Revision: D41548035
Pulled By: shish
fbshipit-source-id: fde4f715d4de8701e545f6145df11b604afb2dd9
Summary: Currently, the GitHub PR status prefetch logic causes exception on non-github repos, this diff skips the logic for non-github repos.
Reviewed By: bolinfest
Differential Revision: D41573751
fbshipit-source-id: 2aa34557219dd027aedffd124aa4b6c6d8f54863
Summary:
This diff was to fix the smartlog fails with below error on non-github repos, and the original bug was fixed by Jun in D41446273 (b242a1cafd). So I changed the title to refactor `check_github_repo`, and added a function to return a Rust `Result` like type instead of aborting, since it easy to misuse the original function and cause unexpected abort.
```
$ sl sl # this was caused by `github_repo` template keyword
abort: Either gitlab.com is not a GitHub Enterprise hostname or you are not logged in.
Authenticate using the GitHub CLI: `gh auth login --git-protocol https --hostname gitlab.com`
```
Related issue: https://github.com/facebook/sapling/issues/229
Reviewed By: bolinfest
Differential Revision: D41446532
fbshipit-source-id: 80f35670aee5ea29f21b5762ad7223b968f768f9
Summary: Added Rust like Result type to Python.
Reviewed By: bolinfest
Differential Revision: D41627421
fbshipit-source-id: a3f6ab34a2ecde9d7527417e2020d0fa6568e764
Summary: Cloning repos that contained backslashes (e.g. `..\test.txt`) in the names of the files would files to be created outside of the repo. This diff adds some sanitation to prevent this.
Reviewed By: quark-zju
Differential Revision: D41508860
fbshipit-source-id: 57dbbdba9be273c077be96e823c6856c42ab592a
Summary:
The `getcanonicalpath` is a "stronger" version of `os.path.realpath` that it
normalizes cases. See D13886207 (5eced4c533) and D4315444 (in watchman).
Since `bindings.fs.canonicalize` does case normalization it seems we can
switch.
The direct motivation is that `getcanonicalpath`'s macOS code path has issues
running with cpython ARM. It segfaults or produces errno 14 (Bad address)
causing fsmonitor to fallback to not using watchman silently.
I added a config option in case we do want the old code path back. If the
new code path runs fine we should delete the old code paths.
Resolves#279 and #184.
Reviewed By: DurhamG
Differential Revision: D41571813
fbshipit-source-id: 0fddd605b7a1998626c377c4d42b3ff8989f8d5b