Commit graph

2404 commits

Author SHA1 Message Date
Ilya Grigoriev
c34b2328c0 Index: Expose an iterator over all entries
Importantly, this includes the commits that are not visible and
thus not in the `all()` revset.
2023-01-17 22:01:09 -08:00
Ilya Grigoriev
10794461b9 Templater: Pass Repo to CommitOrChageIdShortest template objects
It will be necessary to compute the shorter unique prefix.
2023-01-17 22:01:09 -08:00
Ilya Grigoriev
dae42ea34a Templater: change some names from "shortest" to "short"
This matches the templater function name
2023-01-17 22:01:09 -08:00
Ilya Grigoriev
68ad712e12 Templater: Combine Change and Commit id templates
They will both need the unique prefix functionality.

Change ids previously were just strings.
2023-01-17 22:01:09 -08:00
Ilya Grigoriev
1f6c085c4e Move the definition of Property to before its use 2023-01-17 22:01:09 -08:00
Ilya Grigoriev
3e7791bbc1 Make jj abandon print each abandoned commit once 2023-01-17 21:17:27 -08:00
Ilya Grigoriev
7057ce2183 Test that jj abandon root, specifying same revision twice 2023-01-17 21:17:27 -08:00
Ilya Grigoriev
f2114f63ee jj duplicate: Allow duplicating several commits at once
The `indexmap` crate is used to make `duplicate`'s output have a sane order,
making it easier to test.

It's also used later to remove duplicate revisions in the `abandon` command.
2023-01-17 21:17:27 -08:00
Ilya Grigoriev
12ee2b18cd Git backend: Allow simultaneous rebasing of duplicate commits
Fixes https://github.com/martinvonz/jj/issues/27
Fixes https://github.com/martinvonz/jj/issues/694
2023-01-17 21:17:27 -08:00
Ilya Grigoriev
cb299ac836 Test crash when rebasing duplicate commits at the same time 2023-01-17 21:17:27 -08:00
Ilya Grigoriev
4da6428f1a Make jj duplicate root fail gracefully 2023-01-17 21:17:27 -08:00
Ilya Grigoriev
2af732c828 Tests for jj duplicate 2023-01-17 21:17:27 -08:00
Ilya Grigoriev
a9e7c9bffc Make jj undo work after jj duplicate
Fixes https://github.com/martinvonz/jj/issues/1050

Thanks to Martin for suggesting the exact fix.

The tests go into the new tests/test_duplicate_command.rs, which will be
expanded shortly with other tests depending on this bugfix.
2023-01-17 21:17:27 -08:00
Yuya Nishihara
57c554b75c cli: fix panic on invalid git.fetch/push config value
The default could be overridden by invalid value.
2023-01-18 13:53:45 +09:00
Samuel Tardieu
5d0535276c style: use #[error(transparent)] instead of #[error("{0}")]
This is the canonical way of forwarding an error message with
the "thiserror" crate.
2023-01-17 20:39:39 +01:00
Samuel Tardieu
2832d7c739 config: allow configuration of git remotes for fetch and push operations
The `git.fetch` and `git.push` keys can be used in the configuration file
for the default to use in `jj git fetch` and `jj git push` operations.

By defaut, "origin" is used in both cases.
2023-01-17 19:04:11 +01:00
Benjamin Saunders
e63818998d cargo: specify explicit rev for git dep on dag 2023-01-16 21:37:19 -08:00
Michael Forster
6324d0a644 Disable RUSTSEC-2021-012 advisory for cargo deny 2023-01-16 22:15:55 +01:00
Michael Forster
073505fc8e Add sapling graph formatters as an option. 2023-01-16 22:15:55 +01:00
Michael Forster
cf809aefc4 Change the AsciiGraphDrawer interface form &[u8] to &str 2023-01-16 22:15:55 +01:00
Samuel Tardieu
84fc66fe50 gitignore: any character can be backslash-escaped
You may use "abc\\" in .gitignore to ignore a file named "abc\". In this
case, removing training spaces on "abc\\ " must result in "abc\\" as the
trailing space is not escaped, the preceeding backslash being part of
the previous "\\" escaping sequence.
2023-01-16 21:35:54 +01:00
Vamsi Avula
60d1537731 let branches and remote_branches revset functions take needles as arguments
- branches has the signature branches([needle]), meaning the needle is optional (branches() is equivalent to branches("")) and it matches all branches whose name contains needle as a substring
- remote_branches has the signature remote_branches([branch_needle[, remote_needle]]), meaning it can be called with no arguments, or one argument (in which case, it's similar to branches), or two arguments where the first argument matches branch names and the second argument matches remote names (similar to branches, remote_branches(), remote_branches("") and remote_branches("", "") are all equivalent)
2023-01-16 12:15:30 +05:30
Ilya Grigoriev
24ccd80a5c Fix issues with bright color themes
Fixes https://github.com/martinvonz/jj/issues/528 by changing bright yellow
to yellow.

Also, stop using `white` or `bright white` which are hardly visible on bright
themes.

Before (actually before the parent commit):

https://user-images.githubusercontent.com/4123047/212564102-f6e98635-9bde-4392-8b69-5571fdb1303a.png

After:

https://user-images.githubusercontent.com/4123047/212562387-b89a412e-8689-4bdd-9b25-3f5df1a7d31f.png
2023-01-15 22:00:53 -08:00
Ilya Grigoriev
e9e2853ad5 Change (empty) marker from yellow to green
Follows up on  2ccee5456. Not a major change, looks a little more orthogonal
and clear.
2023-01-15 22:00:53 -08:00
Yuya Nishihara
d4ab33951a cli: replace short_commit_description() with commit summary template
resolve_single_rev() would have to parse the template for each revision,
but it's just 5 times at most. Let's start with a simple API. If the template
doesn't capture RepoRef, maybe we can cache it.
2023-01-16 11:53:35 +09:00
Yuya Nishihara
15e51315ec cli: make short_commit_description() compatible with default summary template 2023-01-16 11:53:35 +09:00
Yuya Nishihara
3e50844afa cli: proxy write_commit_summary() of immutable context through workspace helper
I'm going to add 'format_commit_summary(commit) -> String' to replace
short_commit_description(), and it's fundamentally the same as
'write_commit_summary()' except where the output will go. The problem of
adding such method to WorkspaceCommandHelper is that it's super easy to
use wrong repo ref while transaction is in progress. This problem could
be avoided by passing repo ref explicitly, but other methods like
resolve_revset() have the same problem.

One idea to prevent such API misuse is to exclusively borrow the helper:
'start_transaction(&'a mut self) -> Wrapper<'a>'. That's doable, but I'm
not certain that it is the right way to go. Anyway, this isn't the problem
only applies to write_commit_summary(), so I decided to add a convenient
wrapper to WorkspaceCommandHelper.
2023-01-16 11:53:35 +09:00
Yuya Nishihara
8d27bb0f27 cli: fix "workspace list" to use current workspace to format commit summary
It doesn't matter for the default commit-summary template, but it should be
the workspace the user operates on, not the one currently listing.
2023-01-16 11:53:35 +09:00
Yuya Nishihara
4a17bc0302 cli: fix abandon to not reload WorkspaceCommandHelper to get workspace id 2023-01-16 11:53:35 +09:00
Ilya Grigoriev
aef0801917 Fix random seed in all tests that use testutils::user_settings
This doesn't change any tests, but could prevent change ids
randomly matching commit id prefixes from causing tests
to fail in the future.

Follows up on bbd49cdf29, https://github.com/martinvonz/jj/issues/1024
and https://github.com/martinvonz/jj/pull/1033.
2023-01-15 10:15:44 -08:00
Ilya Grigoriev
d5bbf65da1 Update Cargo.lock to make cargo-deny happy
See https://github.com/martinvonz/jj/actions/runs/3920774270/jobs/6702590941
2023-01-14 18:57:48 -08:00
Ilya Grigoriev
50321f851f revsets.md: Add a sentence to clarify connected 2023-01-14 15:52:51 -08:00
Samuel Tardieu
bdaebf33c4 style: do not dereference self to perform pattern-matching
Dereferencing `self` as `*self` in order to perform patten-matching
using `ref` is unnecessary and will be done automatically by the
compiler (match ergonomics, introduced in Rust 1.26).
2023-01-14 19:28:24 +01:00
Samuel Tardieu
c6d9024ef3 revset: ignore valid commit ids unknown to jj 2023-01-14 18:29:35 +01:00
Samuel Tardieu
efceccb17d refactor: separate timestamp related utilities in time_util module 2023-01-14 16:07:09 +01:00
Samuel Tardieu
3d870068c2 log: add (empty) in front of an empty commit description 2023-01-14 16:00:42 +01:00
Samuel Tardieu
f563e550c4 template: add "empty" template item 2023-01-14 16:00:42 +01:00
Samuel Tardieu
665f7c5917 style: description template extractor
This also prevents the creating of an extra empty String when
the description is empty.
2023-01-14 15:52:31 +01:00
Yuya Nishihara
bbd49cdf29 tests: stabilize change id in test_resolve_symbol_commit_id()
Hopefully fixes #1024.
2023-01-14 23:49:16 +09:00
Yuya Nishihara
a3a495a140 cargo: drop dependency on "uuid" 2023-01-14 23:48:02 +09:00
Yuya Nishihara
ca2e9fe6d1 git: simply use rand::random() to generate ref preventing gc
We don't care the ref content as long as it is unique, so using threaded
RNG should be fine.

This change means refs/jj/keep will now contain refs of the following
forms:

 - new create_no_gc_ref(): 0f8d6cd9721823906cfb55dac99d7bf5
 - old create_no_gc_ref(): 0f6d93fe-0507-4db8-ad0a-6317f02e27b9
 - prevent_gc(commit_id):  0f9c15100b6f1373f38186357e274a829fb6c4e2
2023-01-14 23:48:02 +09:00
Martin von Zweigbergk
31ad0cd2ed formatter: reset color around newlines
There are several reasons for this:

 * We can more easily skip styling a trailing blank line, which other
   internal code then can correctly detect as having a trailing
   newline. This fixes the TODO in tests/test_commit_template.rs.

 * Some tools (like `less -R`) add an extra newline if the final
   character is not a newline (e.g. if there's a color reset after
   it), which led to an annoying blank line after the diff summary in
   e.g. `jj status`.

 * Since each line is styled independently, you get all the necessary
   escapes even when grepping through the output.

 * Some terminals extend background color to the end of the terminal
   (i.e. past the newline character), which is probably not what the
   user wanted.

 * Some tools (like `less -R`) get confused and lose coloring of lines
   after a newline.
2023-01-13 21:47:50 -08:00
Martin von Zweigbergk
6ae671960c formatter: don't write escape codes until we write text
We often end up writing escape codes for one style and then
immediately after, we write escape codes for another style. That seems
harmless, but it's a little ugly. More importantly, it prepares for
not emitting any escapes for turning off attributes at the end of
formatted contents across multiple lines (see next commit).
2023-01-13 21:47:50 -08:00
Martin von Zweigbergk
041b42ced6 formatter: rename current_style() to requested_style()
This hopefully clarifies the difference between the function and the
attribute called `current_style`.
2023-01-13 21:47:50 -08:00
Martin von Zweigbergk
d33721d6fb formatter: rename {add,remove}_label to {push,pop}_label
The labels behave like a stack, and these names hopefully help clarify
that.
2023-01-13 21:47:50 -08:00
Martin von Zweigbergk
25422b2abd formatter: replace HashMap by Vec for rules
We only ever iterate over the map, we never look up by key.
2023-01-13 21:47:50 -08:00
Martin von Zweigbergk
fcbc791c3d formatter: add support for underlined text 2023-01-13 21:47:50 -08:00
Martin von Zweigbergk
2a9c37a693 formatter: remove hack for making bright colors bold
We can now configure the working-copy commit and the head operation to
use bold font, so we no longer need the hack to make bright colors
bold.
2023-01-13 21:47:50 -08:00
Martin von Zweigbergk
e93a347f9e formatter: add support for bold text 2023-01-13 21:47:50 -08:00
Martin von Zweigbergk
3b4ed096d0 formatter: add support for setting background color 2023-01-13 21:47:50 -08:00