Commit graph

572 commits

Author SHA1 Message Date
Scott Taylor
d5c526f496 branch: ignore git tracking branches for rename warning
Prevents a warning from being printed when renaming branches in a
colocated repo, since git tracking branches were being considered as
remote tracking branches.
2024-07-18 17:27:19 -05:00
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
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
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
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
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
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
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
Vladimir Petrzhikovskii
802d2f5327 cli: recursively create clone destination path 2024-07-07 23:02:41 +02:00
Benjamin Tan
cd41bc3584 backout: accept multiple revisions to back out
Closes #3339.
2024-07-07 17:58:10 +08:00
Benjamin Tan
d2eb4d9b56 backout: include backed out commit's subject in new commit 2024-07-05 17:11:37 +08:00
Yuya Nishihara
44a39017f0 diff: highlight word-level changes in git diffs
The output looks somewhat similar to color-words diffs. Unified diffs are
verbose, but are easier to follow if adjacent lines are added/removed + modified
for example.

Word-level diffing is forcibly enabled. We can also add a config knob (or
!color condition) to turn it off to save CPU time.

I originally considered disabling highlights in block insertion/deletion, but
that wasn't always great. This can be addressed separately as it also applies
to color-words diffs. #3958
2024-07-05 16:07:12 +09:00
Scott Taylor
54877e1f79 workspace: abandon discardable working copy on forget
Forgetting a workspace removes its working-copy commit, so it makes
sense for it to be abandoned if it is discardable just like editing a
new commit will cause the old commit to be abandoned if it is
discardable.
2024-07-04 19:37:56 -05:00
Benjamin Tan
0c0e001262 git init: add revset alias for trunk() when intializing with existing git repository 2024-07-04 23:04:19 +08:00
Benjamin Tan
d8899e1ae7 git clone: add revset alias for trunk() 2024-07-04 23:04:19 +08:00
Yuya Nishihara
79569f8248 changelog: move "rebase --skip-emptied" entry to unreleased section 2024-07-04 22:38:43 +09:00
Matt Stark
31ac0d7e1f feat(rebase): Rename --skip-empty to --skip-emptied.
This is based on @martinvonz's comment in #3830 about the inconsistency between squash --keep-emptied and rebase --skip-empty.
2024-07-04 12:13:02 +10:00
Matt Kulukundis
3c07d10c5b fix: fix change notes to move something from 0.19 to future 2024-07-03 20:53:40 -04:00
Matt Kulukundis
aaa99e6dc7 diff: add a file-by-file variant for external diff tools 2024-07-03 20:09:17 -04:00
Austin Seipp
74c275ed10 release: version 0.19.0
Signed-off-by: Austin Seipp <aseipp@pobox.com>
2024-07-03 14:37:40 -07:00
Austin Seipp
30bb90e417 changelog: minor touchups
Signed-off-by: Austin Seipp <aseipp@pobox.com>
2024-07-03 14:37:40 -07:00
Matt Stark
a840894a02 fix(changelog): Move --keep-emptied to the correct release.
Thanks @scott2000 for catching this.
2024-07-04 01:15:13 +10:00
Matt Stark
ca4eb60426 feat(squash): Add --keep-emptied flag
Fixes #3815
2024-07-03 12:03:26 +10:00
Scott Taylor
e54ecefbd4 commit: add --reset-author option 2024-07-02 18:21:21 -05:00
Yuya Nishihara
5a85254bde docs: add customization example of color-words diff style
The default style is compatible with various terminal emulators, but I suspect
that many people wouldn't like underlines. Let's add an example to override it.
2024-07-02 18:47:36 +09:00
Ilya Grigoriev
1b658ea80e lib id_prefix: look for divergent changes outside short prefix set
Fixes #2476.

Previously, if there was a change id match within the short prefix
lookup set, `jj` would not look for commits with that same change id
outside the short prefix set. So, it wouldn't find the conflicted
commits for a commit with a divergent (AKA conflicted) change id.
2024-06-29 11:44:26 -07:00
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
Ilya Grigoriev
e6c2108d4d cli: rename jj file print (formerly jj cat) to jj file show
We now have two `cmd_show` in the repo. I think this one should become
`cmd_file_show`, but this should be done uniformly over all the commands
for consistency.

I did *not* keep `print` as an alias (I couldn't find a compelling
reason to do it), but let me know if anyone feels like keeping it.
2024-06-26 17:11:16 -07:00
mlcui
6ae4f45838 cli: Ignore immutable() in jj git push conflict/desc/user checks
Fixes #3029.
2024-06-24 10:45:29 +10:00
James Sully
f8e106a194 cli: git: add jj git remote set-url command 2024-06-23 12:31:43 +10:00
Yuya Nishihara
3c80e3453d cli: branch: make "set" do upsert as before
Since "set <thing>" often adds a <thing> if not exists, it make some sense
that "branch set" does upsert. The current "branch set" use case is now covered
by "branch move", so it's okay to change the "set" behavior.

If new branch is created by "branch set", status message and hint will be
printed to help migration. The user should be able to undo creation if it was
a mistake.

Closes #3584
2024-06-23 09:44:38 +09:00
Yuya Nishihara
ddeb10b3f3 cli: branch: drop support for deprecated --glob option
It's been 8 months since the option got deprecated by 8dbe12da2a.
2024-06-21 09:43:23 +09:00
Philip Metzger
de022aeaa7 next/prev: Implement next/prev --conflict
This allows users to jump to the next conflict in the ancestors or children of 
the start commit.

Continues work on #2126

Co-Authored-By: Noah Mayr <dev@noahmayr.com>
2024-06-20 23:29:41 +02:00
Austin Seipp
397e96f9ae cli: let jj git push --change handle large revsets
In a repo of mine I wanted to do something like the following to push all of my
leaves to the remote as backup:

    jj git push -c 'all:heads(base::) & mine() ~ empty()'

But couldn't, because `jj git push` doesn't handle large revsets, even though
it does handle multiple `-c` arguments, so I had to work out some pipe-to-xargs
command instead.

Signed-off-by: Austin Seipp <aseipp@pobox.com>
2024-06-20 11:40:55 -05:00
Matt Kulukundis
33ab8d4371 cli: Add an option to diff to output only paths. 2024-06-19 20:27:51 -04:00
Yuya Nishihara
b8e921eeae cli: branch: add "move" command that can update branches by revset or name
This basically supersedes the current "branch set" command. The plan is to turn
"branch set" into an "upsert" command, and deprecate "branch create". (#3584)
Maybe we can also add "branch set --new" flag to only allow creation of new
branches. One reason behind this proposed change is that "set" usually allows
both "creation" and "update". However, we also need a typo-safe version of
"set" to not create new branches by accident.

"jj branch move" is useful when advancing ancestor branches. Let's say you've
added a couple of commits on top of an existing PR branch, you can advance the
branch by "jj branch move --from 'heads(::@- & branches())' --to @-". If this
pattern is super common, maybe we can add --advance flag for short.

One drawback of this change is that "git branch --move" is equivalent to
"jj branch rename". I personally don't find this is confusing, but it's true
that "move" sometimes means "rename".
2024-06-18 12:48:32 +09:00
Martin von Zweigbergk
a861baecbf changelog: remove mention of jj file cat/ls aliases
These two aliases didn't survive code review.
2024-06-18 10:24:54 +09:00
tp-woven
1cf53a25f4 Update CHANGELOG.md
Fix config flag name in changelog.
2024-06-18 09:51:49 +09:00
Matt Kulukundis
5d307e628b cli: create jj file list and deprecate jj files 2024-06-17 14:13:36 -04:00
Matt Kulukundis
47bd6f4aa4 feat: Create a file command containing print and chmod
- rearrange the files involved to be more clear about structure
- deprecate existing `jj cat` and `jj chmod`
2024-06-17 12:17:49 -04:00
Matt Kulukundis
8aa71f58f3 feat: add an option to monitor the filesystem asynchronously
- make an internal set of watchman extensions until the client api gets
  updates with triggers
- add a config option to enable using triggers in watchman

Co-authored-by: Waleed Khan <me@waleedkhan.name>
2024-06-16 23:24:22 -04:00
Martin von Zweigbergk
a9953b3fb0 cli: deprecate jj split --siblings in favor of jj split --parallel
This better matches `jj parallelize`.
2024-06-15 22:45:34 +09:00
Manuel Caldeira
72438fc9d2 cli: deprecate -l short alias for --limit in favour of -n
This better matches `git log` and affects `jj log`, `jj op log` and `jj obslog`
2024-06-15 14:14:29 +02:00
Benjamin Tan
9be33724dc conflicts: materialize simplified file conflicts 2024-06-15 06:05:06 +08:00
Yuya Nishihara
a7bff04af8 revset, templater: implement arity-based alias overloading
Still alias function shadows builtin function (of any arity) by name. This
allows to detect argument error as such, but might be a bit inconvenient if
user wants to overload heads() for example. If needed, maybe we can add some
config/revset syntax to import builtin function to alias namespace.

The functions table is keyed by name, not by (name, arity) pair. That's mainly
because std collections require keys to be Borrow, and a pair of borrowed
values is incompatible with owned pair. Another reason is it makes easy to look
up overloads by name.

Alias overloading could also be achieved by adding default parameters, but that
will complicate the implementation a bit more, and can't prevent shadowing of
0-ary immutable_heads().

Closes #2966
2024-06-14 23:11:29 +09:00
Kyle J Strand
03a0921e12 give descendants a range arg 2024-06-13 18:54:57 -06:00
Danny Hooper
986630b270 cli fix: change default from -s @ to -s 'reachable(@, mutable())'
Most of the value of `jj fix` over a shell script is in formatting commits
other than `@`. `@::` often doesn't contain those other commits, so `-s @` is a
bad default.

We could get the same effect from `-s 'mutable() & ::@'`, but `reachable()` is
a bit more explicit and simple to read.

We could also base this on excluding `trunk()`, but that just seems like an
indirection for `mutable()` that might ignore the user's intent if they have
configured part of trunk to be mutable.
2024-06-13 17:08:24 -05:00
Danny Hooper
faf9a9d757 cli fix: add revsets.fix config for default revset to be fixed 2024-06-13 17:08:24 -05:00