Commit graph

2723 commits

Author SHA1 Message Date
Martin von Zweigbergk
91775fc4f6 demos: update with recent changes
I had to modify the operation log a bit to fit on my scren with #1221
fixed.

Closes #1221.
2023-02-14 22:12:23 -08:00
Martin von Zweigbergk
73ce048256 demos: add blank line at the end
This makes it slightly easier to take a screenshot without getting the
cursor character from the shell input line just below.
2023-02-14 22:12:23 -08:00
Martin von Zweigbergk
d87f49ce5f demos: remove unnecessary sleeps 2023-02-14 22:12:23 -08:00
Martin von Zweigbergk
54156335e4 cli: don't print error about broken pipe
`jj log | head` consistently prints "Error: Broken pipe" for me. I
don't know how the output gets printed after the pipe has been closed,
but neither `git` nor `hg` prints an error, so I think we shouldn't
either.
2023-02-14 21:29:02 -08:00
Yuya Nishihara
0abf9ce8cd cli: move default "show" template to alias
I'm not pretty sure if this is structurally good, but 'jj log -T show'
is useful.
2023-02-15 01:44:33 +09:00
dependabot[bot]
65ff1afb0d cargo: bump once_cell from 1.17.0 to 1.17.1
Bumps [once_cell](https://github.com/matklad/once_cell) from 1.17.0 to 1.17.1.
- [Release notes](https://github.com/matklad/once_cell/releases)
- [Changelog](https://github.com/matklad/once_cell/blob/master/CHANGELOG.md)
- [Commits](https://github.com/matklad/once_cell/compare/v1.17.0...v1.17.1)

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

Signed-off-by: dependabot[bot] <support@github.com>
2023-02-14 16:23:42 +00:00
Yuya Nishihara
605eb72883 config: rename [template] section to [templates], drop .graph suffix
This should be more consistent with the other tables.
2023-02-15 00:23:48 +09:00
Yuya Nishihara
9c6fa67b86 config: apply configured id style to commit_summary template
Thanks to 81af5f820b "repo: calculate shortest unique prefix separately for
commit/change", commit_id.shortest() now works even if the repo is MutableRepo.
2023-02-15 00:23:48 +09:00
Yuya Nishihara
bc7ca03da4 config: extract commit_summary template to config/templates.toml 2023-02-15 00:23:48 +09:00
Yuya Nishihara
e996f6859b cli: add dummy load of summary template to WorkspaceCommandHelper::new()
Alternatively, we can make all callers propagate TemplateParseError, but I
don't think format_commit_summary() should have such signature.
2023-02-15 00:23:48 +09:00
Yuya Nishihara
32f4a81329 config: extract "show" template to config/templates.toml
Aside from [template] vs [templates], we might want a "show" template alias
so "jj log -Tshow" serves the role of "hg log -v".
2023-02-15 00:23:48 +09:00
Yuya Nishihara
a5a49c8c12 config: extract default log template to config/templates.toml 2023-02-15 00:23:48 +09:00
Yuya Nishihara
a2bc826cf4 cli: migrate log formatting options to leverage template aliases
No more format!() template expressions.

We might want a separate namespace for configurable "default" aliases, but
let's start with a simple approach. Even if we had [default-templates]
section, it would be practically the same as [template-aliases] so long as
'default-templates.f()' appears as 'f()' in template.
2023-02-15 00:23:48 +09:00
Yuya Nishihara
7e271347d0 cli: remove stale comment about conditional template labeling
We can add boolean.then() for convenience, but it isn't strictly needed.
label(if()) works fine.
2023-02-15 00:23:48 +09:00
Martin von Zweigbergk
2d8aa2d90e index: delete IndexRef, use Index trait
I don't know why I didn't create a trait to begin with. Maybe I had
trouble with lifetimes or object-safety.
2023-02-14 06:51:49 -08:00
Martin von Zweigbergk
b955e3de03 index: extract a trait for the index
Even though we don't know the details yet, we know that we want to
make the index pluggable like the commit and opstore
backends. Defining a trait for it should be a good step. We can refine
the trait later.
2023-02-14 06:51:49 -08:00
Martin von Zweigbergk
7a985ed122 index: remove lifetime parameter to IndexRef::heads()/topo_order()
I want to replace `IndexRef` by a trait, and I want that trait to be
object-safe.
2023-02-14 06:51:49 -08:00
Martin von Zweigbergk
a474c688a8 index: simplify a test helper by specializing it
We apparently always have an `&Arc<ReadonlyIndex>` where we call the
`generation_number()` function.
2023-02-14 06:51:49 -08:00
Martin von Zweigbergk
78d77661bc tutorial: update with recent changes, plus some other editing
We have made some changes to CLI output that had not made it into the
tutorial. It's time to update it, especially with the new change id
rendering. Since I'm updating it now, and since it's a bit of work to
do so, I decided to use GitHub's Hello-World repo instead of jj's own
repo as our example.
2023-02-14 06:06:58 -08:00
Martin von Zweigbergk
81af5f820b repo: calculate shortest unique prefix separately for commit/change
We now resolve the two kinds of ids in separate spaces, so the
shortest prefixes should also be calculated in separate spaces.
2023-02-13 22:49:21 -08:00
Martin von Zweigbergk
222709196a repo: remove code for conflict between root commit/change id
The two ids no longer share a prefix, so we don't need to worry about
one being a prefix of the other.
2023-02-13 22:49:21 -08:00
Martin von Zweigbergk
d6909002f0 repo: elide lifetime on resolve_change_id_prefix() 2023-02-13 22:49:21 -08:00
Martin von Zweigbergk
04a0c60b16 revset: remove code for conflict between commit/change id
Commit ids and change ids now use non-overlapping symbols for their
digits, so they can't share a prefix.
2023-02-13 22:49:21 -08:00
Martin von Zweigbergk
9261bfe5fc revset: resolve change ids only using the new hex digits
Now that we use the new hex digits when we display change ids, we no
longer need to be able to resolve the old (conventional) digits.
2023-02-13 22:49:21 -08:00
Martin von Zweigbergk
331ebf4cef cli: use reverse-alphabet hex for branch name in jj git push --change 2023-02-13 22:49:21 -08:00
Martin von Zweigbergk
9887d2c3d6 templater: use reverse-alphabet hex for change ids 2023-02-13 22:49:21 -08:00
Martin von Zweigbergk
562042312d templater: inline trivial CommitOrChangeId::as_bytes() 2023-02-13 22:49:21 -08:00
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