Commit graph

2539 commits

Author SHA1 Message Date
Yuya Nishihara
195672f75e tests: extract helper that renders single commit template with no graph 2023-02-01 10:25:28 +09:00
dependabot[bot]
c6dc4ec811 cargo: bump zstd from 0.12.2+zstd.1.5.2 to 0.12.3+zstd.1.5.2
Bumps [zstd](https://github.com/gyscos/zstd-rs) from 0.12.2+zstd.1.5.2 to 0.12.3+zstd.1.5.2.
- [Release notes](https://github.com/gyscos/zstd-rs/releases)
- [Commits](https://github.com/gyscos/zstd-rs/commits)

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

Signed-off-by: dependabot[bot] <support@github.com>
2023-01-31 22:32:47 +01:00
Martin von Zweigbergk
18d4300895 formatter: rename underlined color config to underline
I keep calling it `underline` by mistake, so that probably means that
it's a more natural name for it. We haven't made a release of it yet,
so I didn't mention it in the changelog.

I didn't update all variables to also use `underline`, because I felt
that `underlined` was usually more natural there, plus crossterm calls
it `Attribute::Underlined`.
2023-01-31 08:14:27 -08:00
Yuya Nishihara
f1e6146d6d templater: add newtype to implement property over closure
Many template keywords and methods are one liners, and I think that's actually
good because writing tests for templater would be more involved than for pure
functions.

This patch introduces a wrapper for such one-line functions, and migrates
method parser to that. Some of the commit keyword structs can also be ported
to this wrapper.
2023-01-31 16:27:52 +09:00
Yuya Nishihara
67eac2a455 templater: host shortest_styled_prefix() by CommitOrChangeId
HighlightPrefix::extract() will be inlined by the next commit.
2023-01-31 16:27:52 +09:00
David Barnett
94b53575d8 Add ui.graph.style into config schema 2023-01-31 01:10:31 -06:00
Ilya Grigoriev
6e05c5a829 jj log: Change the default of ui.unique-prefixes to "styled" 2023-01-30 22:48:38 -08:00
Ilya Grigoriev
adeba7f2a5 test_commit_template: break up long lines 2023-01-30 22:48:38 -08:00
Ilya Grigoriev
adfae11e11 jj log: ui.unique-prefixes="styled" option to show prefixes in color
The tail of the id is shown in grey. For divergent commits, it looks better
to show the tail in red, so the prefix is underlined.

https://user-images.githubusercontent.com/4123047/213904951-caccef87-3636-45b1-b503-86a4271f0cc8.png
2023-01-30 22:48:38 -08:00
Ilya Grigoriev
26cc290157 Templater: Create shortest_styled_prefix function for ids 2023-01-30 22:48:38 -08:00
Ilya Grigoriev
bd37989b63 Templater: Inline highlight_shortest_prefix_brackets 2023-01-30 22:48:38 -08:00
Ilya Grigoriev
3ee87aa5a7 Rename short => shortest 2023-01-30 22:48:38 -08:00
Ilya Grigoriev
85452397c4 Templater: Show entire prefix even if it's long + refactor
This refactors the unique prefix functionality and extracts a function
that will be reused by the styled prefix highlighting.

This also includes a minor change in functionality: if the unique prefix
of an id does not fit into the space provided, it is still printed.

Currently, this would happen if the prefix is more than 12 characters
long, which takes a huge repository. However, I'm hoping that in the
future we'll make this number customizeable.
2023-01-30 22:48:38 -08:00
Martin von Zweigbergk
910c73a9ae tests: demonstrate bug on undo after squash in colocated working copy
I think this is the same bug as reported in #922, just simplified a
bit further. The branches in the repo actually look good after the
`undo` operation, but the reverted `master` branch doesn't get
exported to the git repo even though our recorded `refs/heads/master`
in the repo was moved back. Then the next automatic import on `log`
notices that the `master` branch in the git repo still points to the
new commit, and that commit becomes visible again.
2023-01-30 22:43:46 -08:00
Martin von Zweigbergk
e3e7c17f52 git: demonstrate bug when fetching into colocated working copy (#864) 2023-01-30 09:05:03 -08:00
Martin von Zweigbergk
fafa9b70fc view: also merge git_heads when merging views
I don't know if I had just forgotten to merge `git_heads` when I added
it to the view object, but it seems like it should be merged just like
refs.
2023-01-30 09:05:03 -08:00
Martin von Zweigbergk
4e8fbaa210 git: allow conflicts in "HEAD@git"
Git's HEAD ref is similar to other refs and can logically have
conflicts just like the other refs in `git_refs`. As with the other
refs, it can happen if you run concurrent commands importing two
different updates from Git. So let's treat `git_head` the same as
`git_refs` by making it an `Option<RefTarget>`.
2023-01-30 09:05:03 -08:00
Martin von Zweigbergk
6cf7d98465 templater: replace is_git_head keyword by git_head keyword
I'm about to make it possible for `HEAD@git` to be conflicted. For
that, we need to be able to include the trailing `?`. This patch
prepares for that.
2023-01-30 09:05:03 -08:00
Martin von Zweigbergk
23fc849574 log: add test of HEAD@git template 2023-01-30 09:05:03 -08:00
dependabot[bot]
b88478d8d2 cargo: bump crossterm from 0.25.0 to 0.26.0
Bumps [crossterm](https://github.com/crossterm-rs/crossterm) from 0.25.0 to 0.26.0.
- [Release notes](https://github.com/crossterm-rs/crossterm/releases)
- [Changelog](https://github.com/crossterm-rs/crossterm/blob/master/CHANGELOG.md)
- [Commits](https://github.com/crossterm-rs/crossterm/compare/0.25...0.26)

---
updated-dependencies:
- dependency-name: crossterm
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-01-30 08:30:56 -08:00
Glen Choo
b338c916c0 cli: report no updates to current branch
Fix a bug where `jj git push` would print "No current branch." when
there is a current branch but it is unchanged. We were conflating the
two because we print the message when no updates were performed, instead
of only when no branches were found.
2023-01-29 22:07:28 -08:00
Glen Choo
3418c8ff73 git: add git.auto-local-branch
Add a new git.auto-local-branch config option. When set to false, a
remote-tracking branch imported from Git will not automatically create a
local branch target. This is implemented by a new GitSettings struct
that passes Git-related settings from UserSettings.

This behavior is particularly useful in a co-located jj and Git repo,
because a Git remote might have branches that are not of everyday
interest to the user, so it does not make sense to export them as local
branches in Git. E.g. https://github.com/gitster/git, the maintainer's
fork of Git, has 379 branches, most of which are topic branches kept
around for historical reasons, and Git developers wouldn't be expected
to have local branches for each remote-tracking branch.
2023-01-29 20:17:49 -08:00
Glen Choo
4716c1e9e2 git: test import of remote-only branch
This test coverage will become more important when we make changes to
remote branch importing.
2023-01-29 20:17:49 -08:00
Glen Choo
469d315003 git: rename test to cover import/export
We'll add an import test in the next commit.
2023-01-29 20:17:49 -08:00
Martin von Zweigbergk
5fecb396aa working_copy: write tree_state file on init
I don't think there's a good reason not to write the
`.jj/working_copy/tree_state` file on init. Being able to assume that
the file exists means that we won't need the store object to to lazily
load the `TreeState` object. Well, except that `TreeState` keeps an
`Arc<Store>`, but I'm trying to change that.
2023-01-29 20:01:22 -08:00
Yuya Nishihara
3d965f22ab templater: disallow empty template in function arguments and parens
Before, "f()" was parsed as a function call with one empty argument. In
practice, this change means "if(divergent,,false_template)" is no longer
valid.
2023-01-30 12:50:40 +09:00
Yuya Nishihara
a5bb48d47e templater: introduce top-level rule that wraps template terms
An epsilon rule will be moved here to disambiguate f() with f("").
2023-01-30 12:50:40 +09:00
Yuya Nishihara
c44dda55e3 templater: extract function arguments to inner node
This should help to represent an empty argument properly.
2023-01-30 12:50:40 +09:00
Yuya Nishihara
62def97f58 templater: remove redundant boxing of single template term
It was a copy-paste error.
2023-01-30 12:50:40 +09:00
Martin von Zweigbergk
2971c45e04 index_store: don't look up whole commit when only id is needed
When building an initial index from an existing Git repo, for example,
we walk parents and predecessors to find all commits to index. Part of
that code was looking up the whole parent and predecessor commits even
though it only needed the ids. I don't know if this has a measurable
impact on performance, but it's not really any more complex to just
get the ids anyway.
2023-01-29 10:45:03 -08:00
Martin von Zweigbergk
be638d0205 dag_walk: delete unused common_ancestor() 2023-01-29 10:42:11 -08:00
Samuel Tardieu
890327ea68 style: return early from exceptional situation 2023-01-29 19:23:56 +01:00
Samuel Tardieu
fc59db5d52 split: allow creation of empty parent or child
jj split .           => create an empty child
jj split nonexistent => create an empty parent
2023-01-29 19:23:56 +01:00
Samuel Tardieu
200f40b836 tests: use change id instead of commit id in split tests 2023-01-29 19:23:56 +01:00
Yuya Nishihara
a3d3947499 templater: move epsilon rule out of term rule
Suppose "template" is a sequence of "term"s, it makes more sense to handle
an empty sequence there. It might be even better to disallow empty template
other than the top-level one.
2023-01-29 08:54:14 +09:00
Yuya Nishihara
d1281ef48e templater: ensure "template" node is passed to parse_commit_template_rule()
Assertion will be added by the next commit.
2023-01-29 08:54:14 +09:00
Yuya Nishihara
bf66beab36 templater: fix parsing of parenthesized expression
A "list" is a sequence of more than one "term" nodes, so it shouldn't contain
a single parenthesized node.

Also, a parenthesized "term" rule wasn't handled.
2023-01-29 08:54:14 +09:00
Yuya Nishihara
f7993f0fe9 templater: eliminate whitespace nodes from parse tree 2023-01-29 08:54:14 +09:00
Yuya Nishihara
a85488b11d cli: pretty-print "debug template" output
Since a parsed tree is deeply nested, it's difficult to read as a one-line
string.
2023-01-29 08:54:14 +09:00
Martin von Zweigbergk
aaf75b4793 repo: inline single-caller, and surprising, Commit::is_empty()
I would expect `Commit::is_empty()` to check if the commit is empty in
our usual sense, i.e. that there are no changes compared to the
auto-merged parents. However, it would return `false` for any merge
commit (and for the root commit). Since we only use it in one place,
let's inline it there. The use there does seem reasonable, because
it's about abandoning an "uninteresting" working-copy commit.
2023-01-28 15:54:03 -08:00
Samuel Tardieu
615862dde8 ci: add codespell to the workflow 2023-01-28 07:23:45 -08:00
Samuel Tardieu
a7aed0171d style: fix typos found by codespell 2023-01-28 07:23:45 -08:00
Michael Forster
567a05d7ec nix: use default list of systems
Most notably this removes the `i686-linux` target, which wasn't added
deliberately and is also not tested.
2023-01-28 07:10:12 +01:00
Michael Forster
3a139e81dc nix: re-enable the .envrc file
With #1095 fixed, let's try enabling `.envrc` again.
2023-01-28 07:10:12 +01:00
Michael Forster
3ca26974e6 nix: filter source files
This speeds up the nix build by reducing the number of files that are copied to
the nix store.

Hopefully fixes #1095.
2023-01-28 07:10:12 +01:00
Michael Forster
29db607e10 nix: replace manual system iteration by flake-utils
Let's not reinvent the wheel. This makes the flake more readable, and also would
detect typos in the system list.
2023-01-28 07:10:12 +01:00
Michael Forster
3c0eb21ed1 nix: refactor flake to avoid building jj for the dev shell
We don't actually need `jj` itself in the development shell. But having it in
the overlay significantly increases the time it takes to build the shell.
2023-01-28 07:10:12 +01:00
Martin von Zweigbergk
388fb0ffc1 readme: add --locked to cargo install step
Our installation instructions don't currently work with Rust < 1.64
because `clap` updated their MSRV to 1.64, and `cargo install` without
`--locked` bypasses `Cargo.lock` and selects the version of `clap`
that needs Rust 1.64.
2023-01-27 18:42:09 -08:00
Yuya Nishihara
29eb7a16b8 templater: process method chaining from left to right
A method call is typically left associative, and LTR processing is simpler.
2023-01-28 10:53:03 +09:00
Yuya Nishihara
2ae892efab templater: reuse function rule to represent a method chain
A method call is typically parsed as (obj.meth)(), not as obj.(meth()),
but the latter is good enough for our needs. It's unlikely we'll add a
first-class function support.

.into_inner().next().unwrap() mess will be cleaned up by the next commit.
2023-01-28 10:53:03 +09:00