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

2735 commits

Author SHA1 Message Date
Martin von Zweigbergk
b7dad291df repo: make all base_repo() functions return &Arc<ReadonlyRepo>
This is to prepare for a `Repo` trait implemented for
`Arc<ReadonlyRepo>` (not for `ReadonlyRepo` itself).
2023-02-15 19:15:17 -08:00
Martin von Zweigbergk
8a067282c8 repo: make ReadonlyRepo::index() return a &dyn Index
This is just a little preparation for extracting a `Repo` trait that's
implemented by both `ReadonlyRepo` and `MutableRepo`. The `index()`
function in that trait will of course have to return the same type in
both implementations, and that type will be `&dyn Index`.
2023-02-15 19:15:17 -08:00
Yuya Nishihara
3c61e9239c config: remove ui.log-author-format in favor of template alias 2023-02-16 11:43:17 +09:00
Yuya Nishihara
6316ec7442 config: migrate log/show timestamp format away from config knob
Since oplog still relies on ui.relative-timestamps, this config key
isn't removed.
2023-02-16 11:43:17 +09:00
Yuya Nishihara
a00767bc0f config: remove ui.unique-prefixes/log-id-preferred-length in favor of alias 2023-02-16 11:43:17 +09:00
Yuya Nishihara
7913f90869 templater: remove "brackets" short id style in favor of template alias
Though .prefix() + .rest() has to call .shortest() twice, I don't think
the added cost would be significant.
2023-02-16 11:43:17 +09:00
Yuya Nishihara
ffa690abec docs: document default template aliases instead of config knobs
I'm going to remove the corresponding config knobs.

As an example of "brackets" short id, I put a simplified version. It's
unlikely that the "rest()" gets empty for hashes of 12-char long.
2023-02-16 11:43:17 +09:00
Yuya Nishihara
ed4a696dea templater: add shortest().prefix()/rest() accessors
This ensures that the "brackets" style can be emulated by a template
expression.
2023-02-16 11:43:17 +09:00
Martin von Zweigbergk
29792dab9b cli: avoid a closure in op log code for printing timestamp
I find it easier to read the code without the closure and the extra
indentation. Instead, leverage `formatter.labeled()`.
2023-02-15 09:46:38 -08:00
dependabot[bot]
2217a78df3 github: bump dtolnay/rust-toolchain
Bumps [dtolnay/rust-toolchain](https://github.com/dtolnay/rust-toolchain) from 25dc93b901a87e864900a8aec6c12e9aa794c0c3 to 0a1713a447f74360b294fd86bc56dc23af3a9d3e.
- [Release notes](https://github.com/dtolnay/rust-toolchain/releases)
- [Commits](25dc93b901...0a1713a447)

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

Signed-off-by: dependabot[bot] <support@github.com>
2023-02-15 08:49:33 -08:00
Martin von Zweigbergk
e76492b5e9 demos: minor changes to operation log demo 2023-02-15 00:25:56 -08:00
Yuya Nishihara
1bdee80a0d cli: remove attempt to detect EPIPE caused by bad pager configuration
It turned out bad idea because EPIPE (or SIGPIPE) is kind of a successful
termination. We could show some warning based on pager exit code, but let's
avoid messing up again.

io::Error occurred in handle_command_result() is still mapped to a BrokenPipe.
panic()-ing there should be wrong.
2023-02-15 15:36:23 +09:00
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