Commit graph

40 commits

Author SHA1 Message Date
Scott Taylor
1eebbe57c0 commit_builder: reset author timestamp on discardable commits
It's common to create empty working-copy commits while using jj, and
currently the author timestamp for a commit is only set when it is first
created. If you create an empty commit, then don't work on a repo for a
few days, and then start working on a new feature without abandoning the
working-copy commit, the author timestamp will remain as the time the
commit was created rather than being updated to the time that work began
or finished.

This commit changes the behavior so that discardable commits (empty
commits with no description) by the current user have their author
timestamps reset when they are rewritten, meaning that the author
timestamp will become finalized whenever a commit is given a description
or becomes non-empty.
2024-06-29 08:35:53 -05:00
Yuya Nishihara
14421ac126 revset: omit function name from type error messages
This simplifies the interface of helper functions. While revset doesn't have
top-level string pattern or integer literal, these parsing helpers could be
used to parse array subscript or n-th parent operator if any.
2024-06-05 10:39:32 +09:00
Martin von Zweigbergk
fe9daac483 tests: avoid deprecated jj init --git/--git-repo
I left the instances in `test_init_command.rs` alone since they're
about testing `jj init`.
2024-05-17 13:55:20 -07:00
tinger
d0a29a831d cli: add ui.color = "debug"
When using `ui.color = "debug"`, changes in the output style
additionally include delimiters << and >>, as well as all active labels
at this point separated by ::. The output is otherwise unformatted and
the delimiters and labels inherit the style of the content they apply
to.
2024-05-11 10:16:09 +02:00
Yuya Nishihara
8e4f75552d templater: add tracking methods to remote RefName
More tests will be added later as "branch list" templates.

In "log" template, we might want to see the number of "local" commits ahead
of any tracked remotes. It can be implemented later in a similar way (or as a
nested remote_refs list.)
2024-05-10 08:36:38 +09:00
Yuya Nishihara
f1fd1d8071 cli: show hint for inner fileset/revset/template errors
Note that find_source_parse_error_hint() has recursion, but it should terminate
because err.source() shouldn't have a cycle.
2024-05-05 11:16:17 +09:00
Noah Mayr
dc693e7b8f template: add contained_in method to commit object in templates
this allows to conditionally display or label elements depending on 
whether the given commit is contained within the revset
2024-04-29 12:16:42 +02:00
Yuya Nishihara
a63dbcc329 templater: include actual type name in error messages 2024-04-26 00:57:26 +09:00
Noah Mayr
2cf1c34f58 template: add method mine() to commit type 2024-04-04 22:47:34 +02:00
Yuya Nishihara
074e6e12bc revset, templater: include short parse error description in summary line
This makes the summary line more informative. Even though it just duplicates
the message printed later, I think it's easier to follow.

This patch also adjusts some RevsetParseError messages because it seemed
redundant to repeat "revset function", "argument", etc.
2024-03-28 10:53:06 +09:00
Yuya Nishihara
2cd70bdf14 revset, templater: render parse error as usual error chain
Because the CLI error handler now prints error sources in multi-line format,
it doesn't make much sense to render Revset/TemplateParseError differently.

This patch also fixes the source() of the SyntaxError kind. It should be
self.pest_error.source() (= None), not self.pest_error.
2024-03-28 10:53:06 +09:00
Yuya Nishihara
b363e695e4 commit_templater: make git_head return Option<RefName> instead of Vec<_>
Since we've introduced Option type, it no longer makes sense that git_head
returns a Vec<RefName>.
2024-03-26 00:28:43 +09:00
Martin von Zweigbergk
e51878f4fd cli: show timestamp in local timezone and without millis and offset
As discussed in #2900, the milliseconds are rarely useful, and it can
be confusing with different timezones because it makes harder to
compare timestamps.

I added an environment variable to control the timestamp in a
cross-platform way. I didn't document because it exists only for tests
(like `JJ_RANDOMNESS_SEED`).

Closes #2900
2024-03-20 07:54:08 -07:00
Yuya Nishihara
218b1c6c16 commit_templater: add self.immutable() method
I don't know how immutable revisions should be labeled by default, but users
can customize templates whatever they like.
2024-03-14 22:59:43 +09:00
Yuya Nishihara
9b42c81d6f templates: add missing "\n" to builtin "root" output 2024-03-13 23:29:27 +09:00
Yuya Nishihara
82b3017fda templater: add string.len() and list.len() methods 2024-03-01 08:51:20 +09:00
Martin von Zweigbergk
7c5cfa7cc7 templater: add a local() method on Timestamps (#2900) 2024-02-12 10:22:24 -08:00
jyn
d66fcf2ca0 compile integration tests as a single binary
this greatly speeds up the time to run all tests, at the cost of slightly larger recompile times for individual tests.

this unfortunately adds the requirement that all tests are listed in `runner.rs` for the crate.
to avoid forgetting, i've added a new test that ensures the directory is in sync with the file.

 ## benchmarks

before this change, recompiling all tests took 32-50 seconds and running a single test took 3.5 seconds:

```
; hyperfine 'touch lib/src/lib.rs && cargo t --test test_working_copy'
  Time (mean ± σ):      3.543 s ±  0.168 s    [User: 2.597 s, System: 1.262 s]
  Range (min … max):    3.400 s …  3.847 s    10 runs
```

after this change, recompiling all tests take 4 seconds:
```
;  hyperfine 'touch lib/src/lib.rs ; cargo t --test runner --no-run'
  Time (mean ± σ):      4.055 s ±  0.123 s    [User: 3.591 s, System: 1.593 s]
  Range (min … max):    3.804 s …  4.159 s    10 runs
```
and running a single test takes about the same:
```
; hyperfine 'touch lib/src/lib.rs && cargo t --test runner -- test_working_copy'
  Time (mean ± σ):      4.129 s ±  0.120 s    [User: 3.636 s, System: 1.593 s]
  Range (min … max):    3.933 s …  4.346 s    10 runs
```

about 1.4 seconds of that is the time for the runner, of which .4 is the time for the linker. so
there may be room for further improving the times.
2024-02-06 18:19:41 -08:00
Yuya Nishihara
4fed19361a cli: include branches and tags in default "show" template
The formatting is closer to hg than git just because it's easier to
conditionalize the whole line per keyword. Our template language doesn't
have infix logical operators.

Unlike the other default templates, all remote branches are displayed because
it's "detailed" output.

Closes #2509
2024-01-11 15:47:09 +09:00
Yuya Nishihara
6971ec239a tests: set git_settings.auto_local_branch where it matters 2023-12-17 08:30:24 +09:00
Yuya Nishihara
0e14a1f04d templater: add local/remote_branches keywords 2023-10-28 11:03:23 +09:00
Yuya Nishihara
01d474563e templater: make branches, tags, git_refs, and git_head return list type
I'm not going to change the default output, but this allows us to highlight
or dim only the @remote component.
2023-10-28 05:29:50 +09:00
Ilya Grigoriev
eeb93cc8be cli change id templates: make "hidden" override "divergent"
See the test changes in `test_undo.rs` for motivation. This matters rarely, but
seems to be better.
2023-10-26 17:58:13 -07:00
Yuya Nishihara
b455335983 tests: move test_templater_branches() to test_commit_template.rs
It's not testing the core templater functionality.
2023-10-27 05:30:53 +09:00
Yuya Nishihara
7a3e72415c cli: send status messages to stderr, specify stdout/stderr explicitly
Many of &mut UI can be changed to immutable borrows, but I'm not gonna
update them in this patch.
2023-10-11 19:24:01 +09:00
Yuya Nishihara
58acc1d111 tests: replace jj_cmd_success() involving mutation to allow stderr output 2023-10-11 19:24:01 +09:00
Yuya Nishihara
0fe25575ba cli: ensure first new HEAD is detached
The problem is that the first non-working-copy commit moves the unborn current
branch to that commit, but jj doesn't "export" the moved branch. Therefore,
the next jj invocation notices the "external" ref change, which was actually
made by jj.

I'm not sure why we play nice by setting the "current" HEAD, but I *think* it's
okay to set the "new" HEAD and reset to the same commit to clear Git index.
2023-10-03 00:58:22 +09:00
Yuya Nishihara
480efc1503 cli: add context to checkout/abandon messages triggered by automated git import
Otherwise, it's unclear why "jj status" abandoned commits for example.
2023-10-02 17:31:05 +09:00
Yuya Nishihara
e3c85d6ecc revset: convert root symbol to function
The idea is that we can fully eliminate special symbols that would otherwise
shadow user branches, tags, or change ID prefixes.

Closes #2095
2023-09-04 10:36:30 +09:00
Vamsi Avula
32377a13f4 templates: default placeholders to red
With the idea that less severe placeholders (like description) could
(and should) explicitly "opt out".

(Both email and name placeholders will be red with this change.)
2023-08-30 12:54:15 +08:00
Vamsi Avula
dbf13a5250 tests: add test for log builtin templates with colors 2023-08-30 12:54:15 +08:00
Yuya Nishihara
a0ae09f461 templates: reword signature placeholders to match description 2023-08-27 09:38:36 +09:00
Yuya Nishihara
f422f1300c templater: move empty signature placeholder to user template
This patch also extracts format_detailed_signature() function to deduplicate
the "show" template bits.

The added placeholder templates aren't labeled as "empty". If needed, I think
the whole template can be labeled as "empty" (or "empty_commit") just like
"working_copy".

Closes #2112
2023-08-27 09:38:36 +09:00
Yuya Nishihara
b45da80c12 tests: add more tests for empty signature
As I'm going to change the Signature type to not fill out a placeholder
message, we need to test the builtin templates as well.
2023-08-27 09:38:36 +09:00
Vamsi Avula
89b7b0bfe8 templates: colorize description_placeholder
Also, see https://github.com/martinvonz/jj/pull/2100.
2023-08-25 10:03:30 +05:30
Preston Van Loon
ac5d8eb784 Add UTC format for timestamp formats. Thanks to @rauljordan for these changes.
Add tests for new UTC timestamp format

Add documentation for timestamp utc

Update CHANGELOG.md
2023-08-20 17:24:09 -05:00
Emily Fox
2062abdc9d templates: replace empty name and email strings with placeholders
New placeholders say "(no name availalbe)" and "(no email available)",
because empty strings aren't _necessarily_ a configuration issue.
2023-08-18 17:22:59 -05:00
Ilya Grigoriev
863f1760f9 log template: make root commit green instead of bright green
Bright green really pops on my screen, and I don't think there is a reason
for the root commit to be attention-grabbing.

This follows up on https://github.com/martinvonz/jj/pull/2084.
2023-08-16 17:26:36 -07:00
Anton Bulakh
dc6e1d7dee cli: hide irrelevant information about root commit in default log templates
I've extracted the `builtin_log_root` template for users to customize the
default templates without fully overriding them, for example I would remove
the change_id/commit_id for myself - and we discussed in Discord that leaving
those makes sense for the user to be reminded/teached that the root commit has
a change id made from z's.
2023-08-15 18:54:59 +03:00
Martin von Zweigbergk
0075174308 tests: move tests/ under cli/ so they're run again
Thanks to @ilyagr for noticing that they should be moved.
2023-08-05 06:18:59 +00:00
Renamed from tests/test_commit_template.rs (Browse further)