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

489 commits

Author SHA1 Message Date
Yuya Nishihara
6d9b836d10 revset: extract unresolved commit references to separate enum
This makes it clear what should be resolved at resolve_symbols(). Symbol
is a bit special while parsing function arguments, but it's no different
than the other unresolved references at expression level.
2023-04-10 00:39:58 +09:00
Yuya Nishihara
0d991bfa4a cli: make "debug revset" print expression for each stage
It helps while debugging tree substitution.
2023-04-10 00:39:58 +09:00
Martin von Zweigbergk
4b5b497283 tests: use absolute timestamps in the operation log
The current use of `timestamp.ago()` in the default template makes the
tests depend on the current time, which they shouldn't.
2023-04-08 14:02:39 -07:00
Martin von Zweigbergk
ed0b23d009 cli: include commit id from build in version
This changes the version number reported by `jj version` from "0.7.0"
to something like
"0.7.0-24a512683bc921699575b6a953624b05c068d544a". The hash is added
if running in a jj repo or a git repo.
2023-04-07 17:33:44 -07:00
Ilya Grigoriev
233dda1057 cmd: prohibit creating branches at the root commit
Such branches lead to confusing errors on git expoert or push.
2023-04-03 23:51:47 -07:00
Ilya Grigoriev
31f7c806e2 squash/amend: Add -m argument to set description
This prevents an editor opening, and is useful in scripts/tests.
2023-04-03 23:51:15 -07:00
Martin von Zweigbergk
e1c57338a1 revset: split out no-args head() to visible_heads()
The `heads()` revset function with one argument is the counterpart to
`roots()`. Without arguments, it returns the visible heads in the
repo, i.e. `heads(all())`. The two use cases are quite different, and
I think it would be good to clarify that the no-arg form returns the
visible heads, so let's split that out to a new `visible_heads()`
function.
2023-04-03 23:46:34 -07:00
Ilya Grigoriev
0e2579ee6a Switch graph node to use for commit instead of
This follows up on 5c703aeb03.

The only reason for this change is that, subjectively, the result looks better to me. I'm not sure why, but I couldn't get used to the old symbol in spite of its seeming reasonableness. It felt really bold and heavy.

If people agree, we can wait until we need to update the screenshots for some other reason before merging this. Sorry I didn't figure this out while the discussion about the referenced commit was going on.

I'm not 100% certain how many fonts support each symbol. Please try it out and let me know if it doesn't work for you.

Compare after:

![image](https://user-images.githubusercontent.com/4123047/229251383-563b889d-7233-42e2-a3c5-bf9368a4d1fd.png)

and before:

![image](https://user-images.githubusercontent.com/4123047/229251695-7fd0ff2c-2832-4262-ade5-5120288cccdf.png)
2023-04-02 23:15:37 -07:00
Yuya Nishihara
6c5947181d cli: reimplement "debug resolverev" as command to debug print revset
Also removed -r/--revision and the default "@" as it is a debug command.
2023-04-02 22:54:46 +09:00
Martin von Zweigbergk
5fe5991ca8 cli: on config error, point to documentation 2023-03-30 21:16:28 -07:00
Waleed Khan
4c629f3aa6 cli: add warrant to identity-not-configured message
The impact of not having configured one's name and email is not apparent from the warning message. Under the Toulmin model:

- Claim (implicit): You should configure your name and email.
- Grounds: Your name and email are not currently configured.
- Warrant (currently missing): Configuring your name and email will let you do...
2023-03-30 11:43:30 -07:00
Yuya Nishihara
0532301e03 revset: add latest(candidates, count) predicate
This serves the role of limit() in Mercurial. Since revsets in JJ is
(conceptually) an unordered set, a "limit" predicate should define its
ordering criteria. That's why the added predicate is named as "latest".

Closes #1110
2023-03-25 23:48:50 +09:00
Yuya Nishihara
75d68fe24c templater: add "parents" keyword in place of "parent_commit_ids"
All commit keywords are mapped to nullary methods. No matter if we'll
introduce .field syntax and/or self. keyword, this implementation can be
reused.
2023-03-24 12:17:38 +09:00
Yuya Nishihara
9d661d6f69 cli: render other kind of revset error suggestion as hint 2023-03-23 23:08:17 +09:00
Yuya Nishihara
ddeb645d7f cli: provide hint for typo of revset function name
This is similar to what Mercurial does. The similarity threshold is copied
from clap, but we might want to adjust it later.
2023-03-23 23:08:17 +09:00
Martin von Zweigbergk
fc84c02c8e cli: add jj describe --no-edit to not open editor 2023-03-19 00:48:05 -07:00
Martin von Zweigbergk
3bacc367cd cli: add jj describe --reset-author
I think requests to reset the author came up twice in the last week,
so let's just add support for it. I copied git's behavior of resetting
the name, email, and timestamp. The flag name is also from git.
2023-03-19 00:48:05 -07:00
Martin von Zweigbergk
8f1dc49039 cargo: upgrade to clap 4.1
This includes some changes to error messages. Also, the Zsh shell
completion script is now simpler to source.

Fixes #1393.
2023-03-17 22:44:29 -07:00
Yuya Nishihara
998727266c templater: add join method to mapped template 2023-03-18 12:04:00 +09:00
Yuya Nishihara
3124444d24 templater: add list.map(|x| ...) operation
This involves a little hack to insert a lambda parameter 'x' to be used at
keyword position. If the template language were dynamically typed (and were
interpreted), .map() implementation would be simpler. I considered that, but
interpreter version has its own warts (late error reporting, uneasy to cache
static object, etc.), and I don't think the current template engine is
complex enough to rewrite from scratch.

.map() returns template, which can't be join()-ed. This will be fixed later.
2023-03-18 12:04:00 +09:00
Yuya Nishihara
1c0bde1a2b templater: add parsing rule for lambda expression
A lambda expression will be allowed only in .map() operation. The syntax is
borrowed from Rust closure.

In Mercurial, a map operation is implemented by context substitution. For
example, 'parents % "{node}"' prints parents[i].node for each. There are two
major problems: 1. the top-level context cannot be referred from the inner map
expression. 2. context of different types inserts arbitrarily-named keywords
(e.g. a dict type inserts "{key}" and "{value}", but how we could know.)

These issues should be avoided by using explicitly named parameters.

    parents.map(|parent| parent.commit_id ++ " " ++ commit_id)
                                                    ^^^^^^^^^ global keyword

A downside is that we can't reuse template fragment in map expression. Suppose
we have -T commit_summary, -T 'parents.map(commit_summary)' doesn't work.

    # only usable as a top-level template
    'commit_summary' = 'commit_id.short() ++ " " ++ description.first_line()'

Another problem is that a lambda expression might be confused with an alias
function.

    # .map(f) doesn't work, but .map(g) does
    'f(x)' = 'x'
    'g' = '|x| x'
2023-03-18 12:04:00 +09:00
Martin von Zweigbergk
e2b4d7058d cli: move some debug commands to new (non-hidden) support group
The `jj debug` commands are hidden from help and are described as
"Low-level commands not intended for users", but e.g. `jj debug
completion` is intended for users, and should be visible in the help
output.
2023-03-17 06:50:55 -07:00
Martin von Zweigbergk
e64ca31bfd cli: show diff summary as two states instead of transition
By using one letter for the path type before and one letter for path
type after, we can encode much more information than just the current
'M'/'A'/'R'. In particular, we can indicate new and resolved
conflicts. The color still encodes the same information as before. The
output looks a bit weird after many years of using `hg status`. It's a
bit more similar to the `git status -s` format with one letter for the
index and one with the working copy. Will we get used to it and find
it useful?
2023-03-16 08:01:13 -07:00
Martin von Zweigbergk
ed1c2ea1aa cli: disallow jj diff --color-words --git 2023-03-16 08:01:13 -07:00
Yuya Nishihara
0bbf146469 templater: unify variants of type error as general expression error
I'm going to add a lambda expression, and the current type-error message
wouldn't work for the lambda type. I also renamed "argument" to "expression"
as the expect_<type>() helper may be called against any expression node.
2023-03-16 03:46:54 +09:00
Yuya Nishihara
f6b0b7788e templater: unify variants of argument count error, embed function name
This is similar to the structure of RevsetParseError. It's unlikely we would
need to discriminate parsing errors, so let's avoid wasting time on naming
things.
2023-03-16 03:46:54 +09:00
Yuya Nishihara
86318bf530 templater: add timestamp.format() method
A format string is parsed statically due to error handling restriction.
I think it covers almost all use cases.
2023-03-15 12:14:42 +09:00
Martin von Zweigbergk
5c703aeb03 cli: replace o as graph node by when using unicode graph
@joyously found `o` confusing because it's a valid change id prefix. I
don't have much preference, but `●` seems fine. The "ascii",
"ascii-large", and "legacy" graph styles still use "o".

I didn't change `@` since it seems useful to have that match the
symbol used on the CLI. I don't think we want to have users do
something like `jj co ◎-`.
2023-03-12 23:21:05 -07:00
Martin von Zweigbergk
504a2b3fd0 cli: add test of jj debug reindex, do full reindexing
I broke the commands in a27da7d8d5 and thought I just fixed it in
c7cf914694a8. However, as I added a test, I realized that I made it
only reindex the commits since the previous operation. I meant for the
command to do a full reindexing of th repo. This fixes that.
2023-03-12 22:08:31 -07:00
Yuya Nishihara
904e9c5520 cli: add ui.log-word-wrap option
Unlike Mercurial, this isn't a template keyword/function, but a config knob.
Exposing graph_width to templater wouldn't be easy, and I don't think it's
better to handle terminal wrapping in template.

I'm not sure if patch content should be wrapped, so this option only applies
to the template output for now.

Closes #1043
2023-03-11 12:01:17 +09:00
Yuya Nishihara
c52efd9df3 templater: add fill(width, content) function
The parameter order follows indent()/label() functions, but this might be
a bad idea because fill() is more likely to have optional parameters. We can
instead add template.fill(width) method as well as .indent(prefix). If we take
this approach, we'll probably need to add string.fill()/indent() methods,
and/or implicit cast at method resolution. The good thing about the method
syntax is that we can add string.refill(), etc. for free, without inventing
generic labeled template functions.

For #1043, I think it's better to add a config like ui.log-word-wrap = true.
We could add term_width/graph_width keywords to the templater, but the
implementation would be more complicated, and is difficult to use for the
basic use case. Unlike Mercurial, our templater doesn't have a context map
to override the graph_width stub.
2023-03-10 16:07:55 +09:00
Yuya Nishihara
e8fd12aff6 templater: add list.join(separator) method
The implementation is a bit tricky since we have to combine a property
(of C -> Vec<Template<()>> type) and a separator of Template<C> type.
2023-03-10 12:58:32 +09:00
Yuya Nishihara
6c146de2e8 templater: add string.lines() method
This wouldn't be used much in practice, but is useful for writing tests of
list methods.
2023-03-10 12:58:32 +09:00
Yuya Nishihara
4984e611f4 templater: add "parent_commit_ids" keyword
A list type isn't so useful without a map operation, but List<CommitId>
is at least printable. Maybe we can experiment with it to craft a map
operation.

If a map operation is introduced, this keyword might be replaced with
"parents.map(|commit| commit.commit_id)", where parents is of List<Commit>
type, and the .map() method will probably return List<Template>.
2023-03-07 11:33:15 +09:00
Samuel Tardieu
decca920c7 git push: do not consider @- if @ has non-empty content or description 2023-03-05 23:50:20 +01:00
Yuya Nishihara
5d184e6694 cli: in "show" template, indent description like Git does 2023-03-04 12:10:53 +09:00
Yuya Nishihara
8f8a9c91bc templater: add indent(prefix, content) function
The argument order is different from Mercurial's indent() function. I think
indent(prefix, content) is more readable for lengthy content. However,
indent(content, prefix, ...) might be better if we want to add an optional
firstline_prefix argument.
2023-03-04 12:10:53 +09:00
Samuel Tardieu
5ecdeed606 git: only consider references matching globs when fetching 2023-03-02 10:09:08 +01:00
Yuya Nishihara
66458a097e templater: require infix ++ operator to concatenate expressions
This eliminates ambiguous parsing between "func()" and "expr ()".

I chose "++" as template concatenation operator in case we want to add
bit-wise negate operator. It's also easier to find/replace than "~".
2023-03-01 16:39:23 +09:00
Yuya Nishihara
fd27d228ed templater: add concat(contents..) function, migrate default templates
Multi-line templates looked a bit ugly if I replaced all implicit concats
with ++ operations.
2023-03-01 16:39:23 +09:00
Yuya Nishihara
6bbf4c6fcf tests: extract log template function/variable for code readability
Also rewrites some lengthy templates. That's why the test output slightly
changed.
2023-03-01 16:39:23 +09:00
David Barnett
99cb0ba7c5 Implement "config set" subcommand
Uses toml_edit to support simple config edits like:
  jj config set --repo user.email "somebody@example.com"
2023-02-28 18:18:02 -08:00
Yuya Nishihara
bab13e1982 cli: snapshot stale working copy before updating
Since there's no easy API to snapshot the stale working copy without releasing
the lock, we have to compare the tree ids after reacquiring the lock. We could
instead manually snapshot and rebase the working-copy commit, but that would
require more copy-paste codes.

Closes #1310
2023-02-28 12:59:30 +09:00
Yuya Nishihara
34a2b4a46d tests: add test for update-stale without dirty working copy
test_workspaces_updated_by_other() is a simplified version of
test_workspaces_conflicting_edits().
2023-02-28 12:59:30 +09:00
Yuya Nishihara
9dc069eeec tests: include divergence label in update-stale snapshots 2023-02-28 12:59:30 +09:00
Yuya Nishihara
b7eb8ee438 cli: include command args in "snapshot working copy" op log
Since "import git refs" includes the args, there would be no point to exclude
snapshot_working_copy().
2023-02-28 12:59:30 +09:00
Yuya Nishihara
a81c78cf5a tests: use template to filter out uninteresting parts from op log 2023-02-28 12:59:30 +09:00
Martin von Zweigbergk
346e3c849b repo: propagate error when failing to look up backend type 2023-02-27 09:44:28 -08:00
Martin von Zweigbergk
37e1ed403a tests: add test of jj config edit --repo outside of repo
I'm about to change the implementation a bit, so let's have a test for
it.
2023-02-27 09:44:28 -08:00
Samuel Tardieu
c5e41a99c3 git remote rename: rename git refs as well 2023-02-26 15:22:18 +01:00