ok/jj
1
0
Fork 0
forked from mirrors/jj
Commit graph

2846 commits

Author SHA1 Message Date
Martin von Zweigbergk
39640cc288 revset: allow resolving change id using hex digits from reverse alphabet
By separating the value spaces change ids and commit ids, we can
simplify lookup of a prefix. For example, if we know that a prefix is
for a change id, we don't have to try to find matching commit ids. I
think it might also help new users more quickly understand that change
ids are not commit ids.

This commit is a step towards that separation. It allows resolving
change ids by using hex digits from the back of the alphabet instead
of 0-f, so 'z'='0', 'y'='1', etc, and 'k'='f'. Thanks to @ilyagr for
the idea. The regular hex digits are still allowed.
2023-02-13 22:49:21 -08:00
Yuya Nishihara
b44148871a templater: save alias chain to report type/name error in original context
Since type/name checking is made after alias substitution, we need to preserve
the original context to generate a readable error message.

We could instead attach a stack of (alias_id, span) to ExpressionNode, but
the extra AliasExpanded node helps to capture downstream error by a single
.map_err() call.
2023-02-14 10:06:28 +09:00
Yuya Nishihara
bfdaaa4257 templater: implement symbol/function alias expansion
Test vectors are mainly copied from revset.rs and adapted to the template
syntax.

Closes #1190
2023-02-14 10:06:28 +09:00
Yuya Nishihara
6ebf05790f templater: add origin field to TemplateParseError to chain alias errors
Copied from 5df25cd834 "revset: add origin field to RevsetParseError to
chain alias errors."
2023-02-14 10:06:28 +09:00
Yuya Nishihara
d0715a0935 cli: load [template-aliases] section and pass around aliases table 2023-02-14 10:06:28 +09:00
Yuya Nishihara
9d356b8094 templater: add table of alias (decl, defn) rules
This is basically a copy of revset::RevsetAliasesMap. We could extract a
common table struct, but that wouldn't be worth the effort since the core
alias substitution logic can't be easily abstracted.
2023-02-14 10:06:28 +09:00
Yuya Nishihara
6c5ff5a2a7 cli: split up write_commit_summary() to avoid passing too many arguments
update_working_copy() borrows self.workspace mutably, which is the reason
why this function needs to borrow things explicitly.
2023-02-14 10:06:28 +09:00
Yuya Nishihara
493cb83fd5 cli: proxy parse_commit_template() through WorkspaceCommandHelper
I'll add an alias table there. Since this function borrows self, it can't
always be used in between mutable operations. For log-like commands, this
should just work fine.
2023-02-14 10:06:28 +09:00
dependabot[bot]
bc7a086192 cargo: bump test-case from 2.2.2 to 3.0.0
Bumps [test-case](https://github.com/frondeus/test-case) from 2.2.2 to 3.0.0.
- [Release notes](https://github.com/frondeus/test-case/releases)
- [Changelog](https://github.com/frondeus/test-case/blob/master/CHANGELOG.md)
- [Commits](https://github.com/frondeus/test-case/compare/v2.2.2...v3.0.0)

---
updated-dependencies:
- dependency-name: test-case
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-02-13 23:11:04 +00:00
dependabot[bot]
ebd9a94d4b github: bump github/codeql-action from 2.2.3 to 2.2.4
Bumps [github/codeql-action](https://github.com/github/codeql-action) from 2.2.3 to 2.2.4.
- [Release notes](https://github.com/github/codeql-action/releases)
- [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md)
- [Commits](8775e86802...17573ee1cc)

---
updated-dependencies:
- dependency-name: github/codeql-action
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-02-13 22:52:07 +00:00
dependabot[bot]
e21ae8b9d0 github: bump dtolnay/rust-toolchain
Bumps [dtolnay/rust-toolchain](https://github.com/dtolnay/rust-toolchain) from c758e63728211bd4acda6501cfa2a16c5c751fc4 to 25dc93b901a87e864900a8aec6c12e9aa794c0c3.
- [Release notes](https://github.com/dtolnay/rust-toolchain/releases)
- [Commits](c758e63728...25dc93b901)

---
updated-dependencies:
- dependency-name: dtolnay/rust-toolchain
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-02-13 23:39:24 +01:00
Martin von Zweigbergk
4fbf09ed8c revset: remove obsolete silencing of Clippy check 2023-02-12 23:07:09 -08:00
Yuya Nishihara
81c8543621 cli: switch "debug template" command to new AST
This should be more readable than raw pest tree.
2023-02-13 02:11:19 +09:00
Yuya Nishihara
677ac54855 templater: build evaluatable expression from AST nodes 2023-02-13 02:11:19 +09:00
Yuya Nishihara
9dc68af4f9 templater: introduce AST structs
This prepares for template aliases support #1190. Unlike revset, template
expressions can be of various types, whereas alias substitution will process
untyped nodes. That's one reason that ExpressionNode is closer to parsed tree
than evaluatable Property structs. Another reason is that it's uneasy to split
name/type checking into "parsing" and "building property function" stages.

We could do alias expansion at once while building Property functions, but
that would make testing harder because Property isn't Debug + PartialEq.
2023-02-13 02:11:19 +09:00
Yuya Nishihara
7c6ddf9773 templater: duplicate parsing functions for reference
I'm going to split 'parse() -> Expression' functions into 'parse() -> AST'
and 'build(AST) -> Expression'. The duplicated functions will be baseline of
new 'parse() -> AST' functions.
2023-02-13 02:11:19 +09:00
Yuya Nishihara
8749a325e9 templater: move whitespace rule out of template node
For the same reason as b2825c22d7 "revset: move whitespace rule out of
expression."
2023-02-13 02:11:19 +09:00
Martin von Zweigbergk
a67fbb6714 cli: switch default graph style to be Sapling's curved style
We seem to quite unanimously prefer this style, so let's make the
default.
2023-02-12 07:23:29 -08:00
Martin von Zweigbergk
990d87fad5 tests: make timestamp().ago() test independent of graph style 2023-02-12 07:23:29 -08:00
Martin von Zweigbergk
aefd0fe69e cli: set LESSCHARSET=utf-8 for our default less -FRX pager
Without a pager configured (in `ui.pager` or `$PAGER`), running
`LC_CTYPE=foo jj log` would replace the Unicode characters in our
(Sapling's) "curved" graph style by escapes, like this:

```
@  1d4ae2372dd2 martinvonz@google.com 2023-02-11 14:56:00.000 -08:00 a8eac1f9efe8
<E2><94><82>  (no description set)
```

This fixes that by including the `LESSCHARSET=utf-8` environment
variable in our default `ui.pager` value.
2023-02-12 07:23:29 -08:00
Martin von Zweigbergk
170de4749f allow passing environment variables to external tools
We would like our default pager of `less -FRX` to also get passed
`LESSCHARSET=utf-8`. I don't like having defaults that the user can't
specify themselves, so this commits provides users with a way to pass
environment variables to their configured pager (or editor, or merge
tool, ...).

I didn't document this feature and I didn't add it to the config
schema because it seems it's going to be so rarely useful to users.
2023-02-12 07:23:29 -08:00
Samuel Tardieu
c0c3f87574 git fetch: prune old branch names before adding new ones 2023-02-12 02:10:17 +01:00
Samuel Tardieu
b7b3314afe git fetch: exhibit bug due to fetching references before pruning 2023-02-12 02:10:17 +01:00
Vamsi Avula
98261e81e2 Fix typos and slightly simplify code from #1235 2023-02-12 03:17:40 +05:30
Vamsi Avula
daf7b656e3 config: add and parse ui.log_author_format for use in the default template
Supported values are,

- `none` for no author information,
- `full` for both the name and email,
- `name` for just the name,
- `username` for username part of the email,
- (default) `email` (or any other gibberish for that matter) for the full email.
2023-02-11 20:54:23 +05:30
Yuya Nishihara
c2b92f43c6 cli: do not report "broken pipe" if pager exits successfully
This partially reverts the change in d7f64c07e0 "cli: handle last-minute
ui.write() error." In this commit, I tried to handle the case when the pager
process goes through env/sh, and exits immediately with "command not found".
However, I missed EPIPE could also occur when the pager was closed by user.

Apparently, hg is killed by SIGPIPE in that case (exits with 141), and chg
exits with 255. With this change, jj will silently exits with 3.
2023-02-12 00:06:01 +09:00
Vamsi Avula
aacdcf629b author/committer templates: add a username method
I haven't used a proper email address parser as I'm not really sure if it's
worth the extra dependency and effort -- thoughts?
2023-02-11 15:38:27 +05:30
Martin von Zweigbergk
3744ae4508 index: remove unused iter() function 2023-02-10 10:31:42 -08:00
Martin von Zweigbergk
ee336a2e45 cli: delete builtin update/up aliases
These don't seem used much, and maybe we (or a customized build) will
want to use the name in the future.
2023-02-10 08:33:05 -08:00
Yuya Nishihara
d7f64c07e0 cli: handle last-minute ui.write() error
This works if the pager exits instantly and jj is slow enough to notice
EPIPE. If the pager exits late, no error would be reported.

Since the pager process is asynchronous, EPIPE could occur in
handle_command_result(). That's why I made it not panic.
2023-02-10 23:30:35 +09:00
dependabot[bot]
8eda80fc53 cargo: bump serde_json from 1.0.92 to 1.0.93
Bumps [serde_json](https://github.com/serde-rs/json) from 1.0.92 to 1.0.93.
- [Release notes](https://github.com/serde-rs/json/releases)
- [Commits](https://github.com/serde-rs/json/compare/v1.0.92...v1.0.93)

---
updated-dependencies:
- dependency-name: serde_json
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-02-09 16:33:11 +01:00
dependabot[bot]
67c7c27043 cargo: bump pest_derive from 2.5.4 to 2.5.5
Bumps [pest_derive](https://github.com/pest-parser/pest) from 2.5.4 to 2.5.5.
- [Release notes](https://github.com/pest-parser/pest/releases)
- [Commits](https://github.com/pest-parser/pest/compare/v2.5.4...v2.5.5)

---
updated-dependencies:
- dependency-name: pest_derive
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-02-09 16:32:54 +01:00
dependabot[bot]
123d677aed github: bump github/codeql-action from 2.2.2 to 2.2.3
Bumps [github/codeql-action](https://github.com/github/codeql-action) from 2.2.2 to 2.2.3.
- [Release notes](https://github.com/github/codeql-action/releases)
- [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md)
- [Commits](39d8d7e78f...8775e86802)

---
updated-dependencies:
- dependency-name: github/codeql-action
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-02-09 16:32:36 +01:00
Yuya Nishihara
038497638f revset: parse keyword arguments, accept remote_branches(remote=needle)
The syntax is identical to Mercurial's revset, which is derived from Python.
2023-02-09 12:11:58 +09:00
Yuya Nishihara
b2825c22d7 revset: move whitespace rule out of expression
There's a subtle difference between
 - 'expression = { whitespace* ... whitespace* }', and
 - '_{ whitespace* ~ expression ~ whitespace* }'.

The former includes surrounding whitespace in an "expression", the latter
doesn't. This affects the span of error indication.
2023-02-09 12:11:58 +09:00
Yuya Nishihara
78227dc7bc revset: consolidate argument parsing functions
The added expect_arguments() is basically a copy from the template_parser.
I'll reimplement it to support keyword arguments, so I don't care much about
the current implementation.

I leave expect_no/one_argument() as wrappers because parsing 0/1 arguments
is pretty common.

Error messages are slightly changed. I personally prefer not to add extra
code for singular/plural handling, but if we do, I'll add 'if N == 1' case.
2023-02-09 12:11:58 +09:00
dependabot[bot]
9791152cb9 cargo: bump pest from 2.5.4 to 2.5.5
Bumps [pest](https://github.com/pest-parser/pest) from 2.5.4 to 2.5.5.
- [Release notes](https://github.com/pest-parser/pest/releases)
- [Commits](https://github.com/pest-parser/pest/compare/v2.5.4...v2.5.5)

---
updated-dependencies:
- dependency-name: pest
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-02-08 08:24:00 -08:00
Martin von Zweigbergk
d1dc22d957 backend: let backend decide length of change id
As mentioned in the previous commit, our internal backend at Google
uses a 32-byte long change id. This commit will make us able to use
that.
2023-02-07 22:31:34 -08:00
Martin von Zweigbergk
e6693d0f68 backend: let backend choose root change id
Our internal backend at Google uses a 32-byte change id, so I'd like
to make the backend able to decide the length. To start with, let's
make the backend able to decide what the root change id should
be. That's consistent with how we already let the backend decide what
the root commit id should be.
2023-02-07 22:31:34 -08:00
Martin von Zweigbergk
98259346df backend: make hash_length() specifically about commit IDs
The function is currently only about the length of commit IDs, so
let's clarify that. I'm going to add another function for the length
of change IDs next. I don't know if we're going to care about lengths
of other hashes in the future. We might even be able to remove the
current restriction that all commit IDs and all change IDs have the
same length.
2023-02-07 22:31:34 -08:00
Martin von Zweigbergk
29a48ebde7 cargo: upgrade openssl-src to make cargo deny happy 2023-02-07 22:18:34 -08:00
dependabot[bot]
e7c9493506 github: bump github/codeql-action from 2.2.1 to 2.2.2
Bumps [github/codeql-action](https://github.com/github/codeql-action) from 2.2.1 to 2.2.2.
- [Release notes](https://github.com/github/codeql-action/releases)
- [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md)
- [Commits](3ebbd71c74...39d8d7e78f)

---
updated-dependencies:
- dependency-name: github/codeql-action
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-02-07 08:24:19 -08:00
Yuya Nishihara
fa045d632c revset: allow trailing comma
It's unlikely we would write multi-line function call in revset, but let's
allow trailing comma for consistency.
2023-02-07 23:19:36 +09:00
Yuya Nishihara
686c1fb522 templater: allow trailing comma
While rewriting the default log template, I find it's annoying that I have
to remove "," from the last line.
2023-02-07 23:19:36 +09:00
Yuya Nishihara
ba1c4f5fe5 cli: replace all $variable matches found in edit/merge-args 2023-02-07 18:32:57 +09:00
Yuya Nishihara
a1bfe33a08 cli: expand $left/$right parameters in merge-tools.<name>.edit-args
And set edit_args = ["$left", "$right"] by default.
2023-02-07 18:32:57 +09:00
Yuya Nishihara
449e84d7ea cli: rename interpolate_mergetool_filename_patterns(), inline caller
I'll add string interpolation support to edit-args.
2023-02-07 18:32:57 +09:00
Yuya Nishihara
baa67fe1db cli: make interpolate_mergetool_filename_patterns() simply work with strings
The assumption here is temp_dir wouldn't contain invalid utf-8 bytes. If it
can contain invalid bytes, maybe we can remove temp_dir from arguments, and
chdir(temp_dir) instead.

This unblocks the use of Regex. We could use regex::bytes, but it's way
more complex as we would have to go back and forth between str/OsStr and
bytes.
2023-02-07 18:32:57 +09:00
Yuya Nishihara
d5f05b7897 cli: implement Default for MergeTool, do not override it with empty args
The default edit_args will be changed to ["$left", "$right"] to support
variable substitution without breaking the existing configuration too much.

The default merge_args could also be set if we could come up with something
meaningful.
2023-02-07 18:32:57 +09:00
Yuya Nishihara
2d17385d2e config: add merge-tools.<name>.edit-args to schema 2023-02-07 18:32:57 +09:00