Commit graph

6577 commits

Author SHA1 Message Date
Yuya Nishihara
895eead4b8 revset: add diff_contains(text[, files]) to search diffs
The text pattern is applied prior to comparison as we do in Mercurial. This
might affect hunk selection, but is much faster than computing diff of full
file contents. For example, the following hunk wouldn't be caught by
diff_contains("a") because the line "b\n" is filtered out:

    - a
      b
    + a

Closes #2933
2024-07-18 01:01:16 +09:00
Yuya Nishihara
eabff4c0b4 revset: propagate BackendError from inner file() predicate function
We should probably add error propagation path to Revset iterator, and predicate
functions will return Result<bool, RevsetEvaluationError>.
2024-07-18 01:01:16 +09:00
Yuya Nishihara
a6a67fa8fd revset: pass Commit object to inner file() predicate function
Commit object extraction is common across predicate functions.
2024-07-18 01:01:16 +09:00
Yuya Nishihara
a9af8d21f8 diff: move materialized_diff_stream() to jj_lib::conflicts module
New diff_contains() revset function will use this helper.
2024-07-18 01:01:16 +09:00
Vladimír Čunát
0c8f881fcd docs/git-comparison.md: update the Signed_commits bullet 2024-07-17 17:12:34 +02:00
Austin Seipp
6c54b66fac cargo: build with crt-static on windows
Avoids a runtime dependency on vcruntime140.dll

Signed-off-by: Austin Seipp <aseipp@pobox.com>
2024-07-17 07:40:30 -05:00
Martin von Zweigbergk
f2bfb90c8c cli: remove unused dependency on gix-filter
This dependency was added in 067d37aa but it seems it ended up being
used only from the jj-lib crate.
2024-07-17 11:53:51 +02:00
Yuya Nishihara
d1912bf016 templater: add commit.diff().<format>() methods
This patch adds TreeDiff template type to host formatting options. The main
reason of this API design is that diff formats have various incompatible
parameters, so a single .diff(files, format[, options..]) method would become
messy pretty quickly. Another reason is that we can probably add custom
summary templating support as diff.files().map(|file| file.path()..).

RepoPathUiConverter is passed to templater explicitly because the one stored
in RevsetParseContext is behind Option<_>.
2024-07-17 18:52:49 +09:00
Yuya Nishihara
4a63a1f660 diff: pass repo.store() to inner show_*_diff() functions, reorder arguments
This will help remove lifetimed &dyn Repo from diff object in templater.

Function arguments are reordered in a way that all show_*() functions have
common parameters in the same order.
2024-07-17 18:52:49 +09:00
Yuya Nishihara
18d60ad0d3 cli: use lossy string conversion to accept non-UTF-8 template outputs
I'm going to add diff() method which provides no guarantee about content
encoding.
2024-07-17 18:52:49 +09:00
Vincent Ging Ho Yim
79b326d56b cli_util: add missing word in conflict resolution instructions 2024-07-17 08:10:25 +02:00
Matt Kulukundis
3043b83a8f copy-tracking: add get_copy_records to Store 2024-07-16 13:18:49 -04:00
Anton Älgmyr
c7eac90200 Enable the new graph nodes by default.
It's been tested in various places now, so this is probably mature
enough to be the default.
2024-07-16 12:54:24 +02:00
Yuya Nishihara
a757fddcf1 revset: parse file() argument as fileset expression
Since fileset and revset languages are syntactically close, we can reparse
revset expression as a fileset. This might sound a bit scary, but helps
eliminate nested quoting like file("~glob:'*.rs'"). One oddity exists in alias
substitution, though. Another possible problem is that we'll need to add fake
operator parsing rules if we introduce incompatibility in fileset, or want to
embed revset expressions in a fileset.

Since "file(x, y)" is equivalent to "file(x|y)", the former will be deprecated.
I'll probably add a mechanism to collect warnings during parsing.
2024-07-16 10:18:57 +09:00
Yuya Nishihara
c74cf2d80d revset: use .ok_or_else() to handle missing workspace context
FWIW, this might be changed to non-error so that "file()" revset can be used
at server side.
2024-07-16 10:18:57 +09:00
Scott Taylor
91504cae02 obslog: reverse order of predecessors in topo traversal
Currently, when there is a commit with two predecessors, the graph
splits into two branches, and all of the predecessors on the first
branch are printed before all of the predecessors on the second branch.
This causes the graph to grow wider with each squashed commit, since the
second branch must always get indented one level farther each time a
commit is squashed. I have some commits where the graph is indented more
than 10 levels due to squashing more than 10 times, making it very
difficult to read.

Reversing the order and printing the second branch before the first
branch prevents this unnecessary indentation and makes the graph easier
to read. This does not change the order of the edges in the graph (i.e.
the first predecessor is still the first edge and the second predecessor
is still the second edge in the graph).
2024-07-15 20:10:31 -05:00
Scott Taylor
fcf1ca95f2 obslog: update test to show multiple squashes 2024-07-15 20:10:31 -05:00
Matt Kulukundis
df021083c9 diff: add unit tests for copy tracking in the git backend 2024-07-15 16:49:10 -04:00
dependabot[bot]
58a772d205 cargo: bump itertools in the cargo-dependencies group
Bumps the cargo-dependencies group with 1 update: [itertools](https://github.com/rust-itertools/itertools).


Updates `itertools` from 0.12.1 to 0.13.0
- [Changelog](https://github.com/rust-itertools/itertools/blob/master/CHANGELOG.md)
- [Commits](https://github.com/rust-itertools/itertools/compare/v0.12.1...v0.13.0)

---
updated-dependencies:
- dependency-name: itertools
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: cargo-dependencies
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-07-15 17:26:51 +02:00
Yuya Nishihara
ea3a574e36 cli: include untracked remote branches in default immutable_heads()
I used to use "remote_branches() & ~mine()" to exclude "their" branches from
the default log, and I don't think that's uncommon requirement. Suppose
untracked branches are usually read-only, it's probably okay to make them
immutable by default.
2024-07-15 23:41:07 +09:00
Yuya Nishihara
692c9960c0 diff: do not emit unified diff for binary files 2024-07-15 14:45:59 +09:00
Yuya Nishihara
e3055e5aaf diff: do not emit unified diff header on absent/empty transitions
---/+++ lines are part of unified diff hunks, not Git diff header.
2024-07-15 14:45:59 +09:00
Yuya Nishihara
53f7acbc42 diff: refactor show_git_diff() to construct GitDiffPart for absent side
This will simplify binary content handling.
2024-07-15 14:45:59 +09:00
Yuya Nishihara
7bdc4a9681 diff: clarify that mode flag of GitDiffPart is hard-coded
We can also change it to enum, but let's keep it str for now.
2024-07-15 14:45:59 +09:00
Yuya Nishihara
07a6a8016c diff: fix typo in Git diff "index old..new" header
Spotted while consolidating "index" line generation. Git appears to use ".." to
separate hashes.
2024-07-15 14:45:59 +09:00
Yuya Nishihara
0912c74ecf diff: add tests for mode changes and absent/empty transitions
This captures a bug of "diff --git" which emits unified diff header without
hunks.
2024-07-15 14:45:59 +09:00
Yuya Nishihara
6f6381d06e diff: leverage BStr for better debug printing 2024-07-14 23:26:29 +09:00
Yuya Nishihara
502547d6a5 diff: add generic DiffHunk constructors
For the same reason as the previous patch. I'm going to make DiffHunk leverage
BStr wrapper instead of custom Debug impl.

b"" literals in tests are changed to &str to get around type incompatibility
between &[u8; N].
2024-07-14 23:26:29 +09:00
Yuya Nishihara
59daef2351 diff: accept diff inputs by generic iterator
This helps migrate internal [u8] variables to BStr.

b"" literals in tests are changed to &str to get around potential type
incompatibility between &[u8; N].
2024-07-14 23:26:29 +09:00
Yuya Nishihara
2ca3bad0ee diff: split non-generic part from Diff::for_tokenizer() 2024-07-14 23:26:29 +09:00
Yuya Nishihara
5601fb40f8 cargo: add "bstr" dependency
I'm going to replace some Debug impls with BStr, and we already depend on
"bstr" through "gix".
2024-07-14 23:26:29 +09:00
Yuya Nishihara
ac2bddbc3d cargo: remove unused "bytes" dependency 2024-07-14 23:26:29 +09:00
Scott Taylor
2dd75b5c53 revset: add tracked/untracked_remote_branches()
Adds support for revset functions `tracked_remote_branches()` and
`untracked_remote_branches()`. I think this would be especially useful
for configuring `immutable_heads()` because rewriting untracked remote
branches usually wouldn't be desirable (since it wouldn't update the
remote branch). It also makes it easy to hide branches that you don't
care about from the log, since you could hide untracked branches and
then only track branches that you care about.
2024-07-13 10:43:21 -05:00
Austin Seipp
35b2136c68 cargo: run cargo update
Just to keep transitive deps fresh.

Signed-off-by: Austin Seipp <aseipp@pobox.com>
2024-07-13 06:26:16 -07:00
Austin Seipp
867851b108 cargo: update bytes 1.6.0 -> 1.6.1
v1.6.0 was yanked several hours ago, so this will block updates
if it isn't merged.

Signed-off-by: Austin Seipp <aseipp@pobox.com>
2024-07-13 06:26:16 -07:00
Yuya Nishihara
8ee5b783b3 formatter: minor cleanup in --color=debug handling 2024-07-13 11:08:01 +09:00
dependabot[bot]
5aa08042c5 cargo: bump the cargo-dependencies group with 2 updates
Bumps the cargo-dependencies group with 2 updates: [syn](https://github.com/dtolnay/syn) and [thiserror](https://github.com/dtolnay/thiserror).


Updates `syn` from 2.0.70 to 2.0.71
- [Release notes](https://github.com/dtolnay/syn/releases)
- [Commits](https://github.com/dtolnay/syn/compare/2.0.70...2.0.71)

Updates `thiserror` from 1.0.61 to 1.0.62
- [Release notes](https://github.com/dtolnay/thiserror/releases)
- [Commits](https://github.com/dtolnay/thiserror/compare/1.0.61...1.0.62)

---
updated-dependencies:
- dependency-name: syn
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: cargo-dependencies
- dependency-name: thiserror
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: cargo-dependencies
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-07-12 12:25:34 -05:00
dependabot[bot]
94dea0d26b github: bump github/codeql-action in the github-dependencies group
Bumps the github-dependencies group with 1 update: [github/codeql-action](https://github.com/github/codeql-action).


Updates `github/codeql-action` from 3.25.11 to 3.25.12
- [Release notes](https://github.com/github/codeql-action/releases)
- [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md)
- [Commits](b611370bb5...4fa2a79536)

---
updated-dependencies:
- dependency-name: github/codeql-action
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: github-dependencies
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-07-12 12:25:21 -05:00
Tim Janik
11f56800fa test_gpg: fix warnings ending up on stdout
Signed-off-by: Tim Janik <timj@gnu.org>
2024-07-12 10:32:13 +09:00
Tim Janik
219a63540f local_working_copy: fix warnings ending up on stdout
As suggested by @crackcomm on discord, use eprintln!() to print warnings
to avoid messing up template output, e.g.:

jj --no-pager --ignore-working-copy show --tool true -T change_id -r rv...
rv...ignoring git submodule at "some/submodule"

Signed-off-by: Tim Janik <timj@gnu.org>
2024-07-12 10:32:13 +09:00
Yuya Nishihara
ffd7b41d2b revset: rename expect_literal_with() to expect_expression_with()
The return type T doesn't have to be a literal, and I'm going to use this
function to reparse fileset expression. We might also want to add another
expect_literal_with() helper that parses enum-like string value.
2024-07-12 10:31:45 +09:00
Philip Metzger
0690922ca1 FAQ: Add some more variants on how to deal with temporary files
The people in #323 think that we should document all patterns there are to deal with ignored files.
2024-07-11 20:01:57 +02:00
Jonathan Tan
de2940f9b7 --color=debug: combine segments with same labels
This not only makes the output easier to read, but also protects against
implementation detail changes in `write!` when used with a format
string (especially, how many times and with what strings it calls the
underlying writer).
2024-07-11 10:39:05 -07:00
Jonathan Tan
579ba8031b --color=debug: print unlabeled text without markup
This makes the debug output cleaner and makes the subsequent commit
easier to write.
2024-07-11 10:39:05 -07:00
dependabot[bot]
10a272aea6 cargo: bump clap_complete in the cargo-dependencies group
Bumps the cargo-dependencies group with 1 update: [clap_complete](https://github.com/clap-rs/clap).


Updates `clap_complete` from 4.5.7 to 4.5.8
- [Release notes](https://github.com/clap-rs/clap/releases)
- [Changelog](https://github.com/clap-rs/clap/blob/master/CHANGELOG.md)
- [Commits](https://github.com/clap-rs/clap/compare/clap_complete-v4.5.7...clap_complete-v4.5.8)

---
updated-dependencies:
- dependency-name: clap_complete
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: cargo-dependencies
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-07-11 17:40:09 +02:00
Yuya Nishihara
415c831e30 revset: flatten union nodes in AST to save recursion stack
Maybe it'll also be good to keep RevsetExpression::Union(_) flattened, but
that's not needed to get around stack overflow. The constructed expression
tree is balanced.

test_expand_symbol_alias() is slightly adjusted since there are more than
one representation for "a|b|c" now.

Fixes #4031
2024-07-11 11:20:25 +09:00
Yuya Nishihara
f90b061808 fileset: flatten union nodes in AST to save recursion stack
This is somewhat similar to templater where "x ++ y" operator is special cased.
2024-07-11 11:20:25 +09:00
dependabot[bot]
503771c33e github: bump actions/setup-python in the github-dependencies group
Bumps the github-dependencies group with 1 update: [actions/setup-python](https://github.com/actions/setup-python).


Updates `actions/setup-python` from 5.1.0 to 5.1.1
- [Release notes](https://github.com/actions/setup-python/releases)
- [Commits](82c7e631bb...39cd14951b)

---
updated-dependencies:
- dependency-name: actions/setup-python
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: github-dependencies
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-07-10 18:17:58 +02:00
Benjamin Tan
f76d682bab readme: include link to wiki "Media" page and fix broken changelog link 2024-07-10 18:09:38 +08:00
Emily
93d76e5d8f str_util: support case‐insensitive string patterns
Partially resolve a 1.5‐year‐old TODO comment.

Add opt‐in syntax for case‐insensitive matching, suffixing the
pattern kind with `-i`. Not every context supports case‐insensitive
patterns (e.g. Git branch fetch settings). It may make sense to make
this the default in at least some contexts (e.g. the commit signature
and description revsets), but it would require some thought to avoid
more confusing context‐sensitivity.

Make `mine()` match case‐insensitively unconditionally, since email
addresses are conventionally case‐insensitive and it doesn’t take
a pattern anyway.

This currently only handles ASCII case folding, due to the complexities
of case‐insensitive Unicode comparison and the `glob` crate’s lack
of support for it. This is unlikely to matter for email addresses,
which very rarely contain non‐ASCII characters, but is unfortunate
for names and descriptions. However, the current matching behaviour is
already seriously deficient for non‐ASCII text due to the lack of any
normalization, so this hopefully shouldn’t be a blocker to adding the
interface. An expository comment has been left in the code for anyone
who wants to try and address this (perhaps a future version of myself).
2024-07-10 05:58:34 +01:00