Commit Graph

636 Commits

Author SHA1 Message Date
Ilya Grigoriev
8c11a8ea3e cli new: Allow --before/--after without a value to default to @
Without this, I find it a bit jarring that `jj new` works but `jj new
--before` does not. By contrast, since `jj rebase` does not currently
work, I don't think `jj rebase --before` should either.

Note that `jj new --before @ another_revision` is invalid, so `jj new
--before another_revision` can only be parsed correctly in one way. I am
slightly concerned that `clap` might forbids this in the future even in
the cases where a human can tell there is no ambiguity, but I'm hoping
for the best.
2024-09-29 17:55:16 -07:00
Tyler Goffinet
9f8d936189 cli: color author and commiter names yellow
When `format_short_signature(signature)` is set to `signature.name()` the author names are not yellow like other signature types (eg email and username). When the commit signatures have no colors, they blend in making it hard to distinguish between signatures and commit messages.

If just `name` were set to `yellow`, just like email and username, it affects the colorization of branch names making them also yellow despite them being designated as magenta. Setting `author` and `committer` to `yellow` is specific enough to allow branches to keep their colors while still coloring signature names. This is known to affect signatures in both 'log' and 'show'.
2024-09-28 23:34:26 -07:00
Samuel Tardieu
f38c59f734 split: do not prevent all changes from going into the first commit
Let the user select all changes interactively and put them into
the first commit, and create a second commit with the possibility
of preserving the current commit message. This was previously only
possible in non-interactive mode by specifying matching paths, e.g.
".".  In both cases, a warning will be issued indicating that the second
commit is empty.
2024-09-27 13:33:05 +02:00
Samuel Tardieu
0058c4f451 changelog: make indentation consistent 2024-09-26 20:22:17 +02:00
Samuel Tardieu
07c7d89f85 changelog: warning on jj git fetch is a new feature, not a bugfix 2024-09-26 19:01:47 +02:00
Samuel Tardieu
baf25ba482 unsquash: deprecate in favor of squash and diffedit
Everything that could be done with `jj unsquash` can be done with
`jj squash` or `jj diffedit --preserve-descendants`.
2024-09-26 16:34:48 +02:00
Essien Ita Essien
e99cca8a93 changelog: conflict() and file() deprecations are yet unreleased.
Move this update under `Unreleased`. I started the change before the last
release and after rebasing, forgot to move it. Fixing it now thanks to @yuja
catching this on time.

Issue: #4122
2024-09-25 09:57:53 +01:00
Essien Ita Essien
2196eb1249 Update CHANGELOG to mention deprecation of file() for files().
I missed this update in #4334.

Issue: #4122
2024-09-24 20:29:28 +01:00
Essien Ita Essien
895d53f395 Rename conflict and file revsets to conflicts and files.
See discussion thread in linked issue.

With this PR, all revset functions in [BUILTIN_FUNCTION_MAP](8d166c7642/lib/src/revset.rs (L570))
that return multiple values are either named in plural or the naming is hard to misunderstand (e.g. `reachable`)

Fixes: #4122
2024-09-24 20:02:49 +01:00
Samuel Tardieu
cf7847d784 restore: add --restore-descendants flag 2024-09-24 14:26:54 +02:00
Samuel Tardieu
e8deb08f78 abandon: add --restore-descendants flag 2024-09-24 10:52:06 +02:00
Samuel Tardieu
f76ee1872f diffedit: add --restore-descendants flag 2024-09-24 09:30:28 +02:00
Essien Ita Essien
76f40e5990 cli: reorder updating and reporting for consistency.
* See #4239 for details.
* For now, update working copy before reporting repo changes, so that
  potential errors in reporting changes don't leave the repo in a stale
  state.

Fixes: #4239
2024-09-22 15:02:21 +01:00
Mateusz Mikuła
2e9049b188 cli: add --author argument for commit and describe 2024-09-22 12:40:46 +02:00
Essien Ita Essien
0f5c5530df cli: Warn if specified remote branch not found for jj git fetch
* First fetch from remote.
* Then check tx.{base_repo(),repo}.view().remote_bookmarks_matching(<branch>, <remote>).
  This has to happen after the fetch has been done so the tx.repo() is updated.
* Warn if a branch is not found in any of the remotes used in the fetch. Note that the remotes
  used in the fetch can be a subset of the remotes configured for the repo, so the language
  of the warning tries to point that out.

Fixes: #4293
2024-09-21 14:09:24 +01:00
Vamsi Avula
a2e67bdd9b templates: add .normal_hex() for {Commit,Change}Id
This doesn't do much for CommitId but outputs the "forward" hex for
ChangeId, which can be useful to use as Gerrit Change-Id.
2024-09-17 21:11:00 -05:00
Kevin Liao
412ef36259 cli: Support renaming workspaces
fixes #4342
2024-09-16 19:35:36 -07:00
Samuel Tardieu
a7f32d3652 squash: accept -k as a shorthand for --keep-emptied
This eases the workflow in which a commit in the middle of the tree is
repeatedly squashed into its parent.
2024-09-15 18:31:47 +02:00
Lukas Wirth
8e727de2ab undo: Report what operation has been undone in jj op undo 2024-09-15 14:11:33 +02:00
Samuel Tardieu
6e72b1cfb0 git: add --remote option to clone command
This makes it easier to work with multiple remotes at once while
tracking the default branch of the remote used to create the local
repository:

```shell
$ jj git clone --remote upstream https://github.com/upstream-org/repo
$ cd repo
$ jj git remote add origin git@github.com:your-org/repo
$ jj config set --repo git.fetch upstream
```

In the example above, `upstream` is the repository containing the
reference source code that you might want to patch, while `origin` is
your fork where pull-request will be pushed. The branch `main@upstream`
will be tracked.
2024-09-13 18:14:57 +02:00
Lukas Wirth
1410f2bee7 docs: Remove trailing whitespace in markdown files 2024-09-13 13:06:28 +02:00
Martin von Zweigbergk
63e616c801 git: restore support for git.push-branch-prefix config but deprecate it 2024-09-12 23:28:30 -07:00
Martin von Zweigbergk
136dcac1e1 changelog: remove an unclear "in lieu of"
I wasn't sure how to read the sentence. I think "as part of" is
clearer.
2024-09-12 23:00:57 -07:00
Yuya Nishihara
78edc6aba5 op log: add --op-diff option to embed operation diffs
This is basically "log -p" for "op log". The flag name has "op" because --diff
and --patch mean a similar thing in this context. Since -p implies --op-diff,
user can just do "op log -p" if he's okay with verbose op + content diffs.
Note that --no-graph affects both "op log" and "op diff" parts.

We might want to do some style changes later, such as inserting/deleting blank
lines, highlighting headers, etc.
2024-09-12 06:51:45 +09:00
Philip Metzger
d9c68e08b1 everything: Rename branches to bookmarks
Jujutsu's branches do not behave like Git branches, which is a major
hurdle for people adopting it from Git. They rather behave like
Mercurial's (hg) bookmarks. 

We've had multiple discussions about it in the last ~1.5 years about this rename in the Discord, 
where multiple people agreed that this _false_ familiarity does not help anyone. Initially we were 
reluctant to do it but overtime, more and more users agreed that `bookmark` was a better for name 
the current mechanism. This may be hard break for current `jj branch` users, but it will immensly 
help Jujutsu's future, by defining it as our first own term. The `[experimental-moving-branches]` 
config option is currently left alone, to force not another large config update for
users, since the last time this happened was when `jj log -T show` was removed, which immediately 
resulted in breaking users and introduced soft deprecations.

This name change will also make it easier to introduce Topics (#3402) as _topological branches_ 
with a easier model. 

This was mostly done via LSP, ripgrep and sed and a whole bunch of manual changes either from
me being lazy or thankfully pointed out by reviewers.
2024-09-11 18:54:45 +02:00
Kevin Liao
69edc7f2df Update jj edit <commit> to add commit into view heads if not already
`jj new <commit>` automatically adds the checked out commits into the view head ids. However,
`jj edit` does not.

To reproduce:
```
jj git init test
cd test
jj commit -m "my commit"
jj log -r @- -T commit_id # Save the id
jj abandon -r @-
jj edit <saved_id>

jj log -r :: # Does not show the currently editing commit 
```
2024-09-10 11:01:49 -07:00
Martin von Zweigbergk
f36f4ad257 cli: make paths to auto-track configurable, add jj track
It's a pretty frequent request to have support for turning off
auto-tracking of new files and to have a command to manually track
them instead. This patch adds a `snapshot.auto-track` config to decide
which paths to auto-track (defaults to `all()`). It also adds a `jj
track` command to manually track the untracked paths.

This patch does not include displaying the untracked paths in `jj
status`, so for now this is probably only useful in colocated repos
where you can run `git status` to find the untracked files.

#323
2024-09-09 07:49:55 -07:00
Austin Seipp
a31fe7f6d6 cli: implement workspace add --sparse-patterns
This flag implements three modes:

- `copy`: copy sparse patterns from parent
- `full`: do not copy sparse patterns from parent
- `empty`: clear all paths, equal to `set --clear`

This is useful for various tooling like tools that want to run a parallel
process that queries the build system (without running into locks/blocking.)

I think continuing to copy sparse patterns makes sense as the default behavior.

Signed-off-by: Austin Seipp <aseipp@pobox.com>
2024-09-06 16:22:47 -05:00
Danny Hooper
bf543402cc cli: fix: add --include-unchanged-files flag to allow fixing as yet unchanged files
This enables workflows like "insert a commit that reformats the code in one of
my project directories".

`jj fix --include-unchanged-files` is an easy way to fix everything in the repo.

`jj fix --include-unchanged-files <file...>` fixes all of the `<files>` even if they are
unchanged.

This is mostly orthogonal to other features, so not many tests are added.

This is a significant and simple enough improvement that I think it's
appropriate to make it here instead of waiting for a `jj run`-based solution.
2024-09-06 13:50:28 -05:00
Martin von Zweigbergk
3133534b32 conflicts: don't panic when a conflict marker is missing removes
Closes #2611
2024-09-05 22:09:55 -07:00
Yuya Nishihara
36ab165b57 cli: parse graph node settings strictly 2024-09-06 09:51:10 +09:00
Martin von Zweigbergk
a0fae76622 cli: rename obslog to evolution-log/evolog
It seems everyone agrees that `obslog` is not an intuitive name. There
was some discussion about alternatives in #3592 and on #4146. The
alternatives included `evolution`, `evolutionlog`, `evolog`,
`rewritelog`, `revlog`, and `changelog`. It seemed like
`evolution-log`/`evolog` was the most popular option. That also
matches the command's current help text ("Show how a change has
evolved over time").
2024-09-05 13:45:17 -07:00
Martin von Zweigbergk
d002a5ad35 release version 0.21.0 2024-09-04 10:11:13 -07:00
Yuya Nishihara
5af906d924 cli: change default inline threshold of color-words diffs
I played with max-inline-alternation = 3 for a couple of weeks, and it's pretty
good. I think somewhere between 2 and 4 is good default because one or two
remove + add sequences are easy to parse.
2024-08-28 10:33:33 +09:00
Yuya Nishihara
6b65f8abec cli: move "untrack" to "file" subcommand
I don't think "jj untrack" is frequently used, and I think it is a "file"
command rather than "workspace".
2024-08-26 01:19:15 +09:00
Martin von Zweigbergk
b78c83e9fe status: report copies and renames 2024-08-23 18:51:02 -07:00
Martin von Zweigbergk
fc09be1a62 changelog: simply bullet about diff formats supporting copies/renames
Since only `--name-only` doesn't support copies/renames, it's simpler
to say that than to list the formats that do.
2024-08-23 18:51:02 -07:00
Yuya Nishihara
a83dadd5a9 diff: add option to display complex color-words diffs without inlining
In this patch, I use the number of adds<->removes alternation as a threshold,
which approximates the visual complexity of diff hunks. I don't think user can
choose the threshold intuitively, but we need a config knob to try out some.
I set `max-inline-alternation = 3` locally. 0 and 1 mean "disable inlining"
and "inline adds-only/removes-only lines" respectively.

I've added "diff.<format>" config namespace assuming "ui.diff" will be
reorganized as "ui.diff-formatter" or something. #3327

Some other metrics I've tried:
```
// Per-line alternation. This also works well, but can't measure complexity of
// changes across lines.
fn count_max_diff_alternation_per_line(diff_lines: &[DiffLine]) -> usize {
    diff_lines
        .iter()
        .map(|line| {
            let sides = line.hunks.iter().map(|&(side, _)| side);
            sides
                .filter(|&side| side != DiffLineHunkSide::Both)
                .dedup() // omit e.g. left->both->left
                .count()
        })
        .max()
        .unwrap_or(0)
}

// Per-line occupancy of changes. Large diffs don't always look complex.
fn max_diff_token_ratio_per_line(diff_lines: &[DiffLine]) -> f32 {
    diff_lines
        .iter()
        .filter_map(|line| {
            let [both_len, left_len, right_len] =
                line.hunks.iter().fold([0, 0, 0], |mut acc, (side, data)| {
                    let index = match side {
                        DiffLineHunkSide::Both => 0,
                        DiffLineHunkSide::Left => 1,
                        DiffLineHunkSide::Right => 2,
                    };
                    acc[index] += data.len();
                    acc
                });
            // left/right-only change is readable
            (left_len != 0 && right_len != 0).then(|| {
                let diff_len = left_len + right_len;
                let total_len = both_len + left_len + right_len;
                (diff_len as f32) / (total_len as f32)
            })
        })
        .reduce(f32::max)
        .unwrap_or(0.0)
}

// Total occupancy of changes. Large diffs don't always look complex.
fn total_change_ratio(diff_lines: &[DiffLine]) -> f32 {
    let (diff_len, total_len) = diff_lines
        .iter()
        .flat_map(|line| &line.hunks)
        .fold((0, 0), |(diff_len, total_len), (side, data)| {
            let l = data.len();
            match side {
                DiffLineHunkSide::Both => (diff_len, total_len + l),
                DiffLineHunkSide::Left => (diff_len + l, total_len + l),
                DiffLineHunkSide::Right => (diff_len + l, total_len + l),
            }
        });
    (diff_len as f32) / (total_len as f32)
}
```
2024-08-21 17:48:52 +09:00
Essien Ita Essien
bb018a54c3 next/prev: Add config flag to control prev/next edit behaviour.
* We started with a tristate flag where:
    - Auto - Maintain current behaviour. This edits if
      the wc parent is not a head commit. Else, it will
      create a new commit on the parent of the wc in
      the direction of movement.
    - Always - Always edit
    - Never - Never edit, prefer the new+squash workflow.
  However, consensus the review thread is that `auto` mode where we try to infer when to
  switch to `edit mode`, should be removed. So `ui.movement.edit` is a boolean flag now.
    - true: edit mode
    - false: new+squash mode
* Also add a `--no-edit` flag as the explicit inverse of `--edit` and
  ensure both flags take precedence over the config.
* Update tests that assumed edit mode inference, to specify `--edit` explicitly.

NOTE: #4302 was squashed into this commit, so see that closed PR for review history.

Part of #3947
2024-08-20 15:46:00 +01:00
Marijan Smetko
0852724c76 Warn user about the working copy when configuring the author 2024-08-19 17:09:30 +02:00
Austin Seipp
5eab5c8d75 github: build on macos-13 for x86_64
We all noticed that x86 macOS binaries are no longer being provided on release,
due to `macos-11` runners going the way of the Dodo a while back. Nobody
alterted us to this, funny enough.

After some quick discussion, we concluded some things:

- x86 macOS runners are likely oversubscribed, and hurt CI latency badly
- `macos-12` is also deprecated; `macos-13` is the best x86 runner available
- GitHub probably isn't going to expand macOS runner capacity; `macos-13` will
one day go away
- Some people are still using `jj` on Intel Macs. We didn't get alerted because
they do their own builds for now, but may not always do that.
- We can just try to build on `macos-13` and make it optional for merges.

So that's what this does. It might be mergeable outright, but we can also use it
to measure build latency impacts.

Signed-off-by: Austin Seipp <aseipp@pobox.com>
2024-08-16 14:23:09 -05:00
Matt Kulukundis
2f2e5fb72a copy-tracking: implement copy tracking for external tools 2024-08-16 07:48:43 -04:00
Matt Kulukundis
95e8dd51eb copy-tracking: add support for diff --git 2024-08-15 11:03:39 -04:00
Matt Kulukundis
0b179dcbde copy-tracking: implement copy-tracking for --types 2024-08-14 20:48:43 -04:00
Essien Ita Essien
a6d8009097 Define builtin_immutable_heads() as a default revset alias.
* Add `builtin_immutable_heads()` in the `revsets.toml`.
* Redefine `immutable_heads()` in terms of `builtin_immutable_heads()`
* Warn if user redefines `builtin_immutable_heads()`, `mutable()` or
  `immutable()`.
* Update module constant in revset_util.rs from BUILTIN_IMMUTABLE_HEADS
  to USER_IMMUTABLE_HEADS to avoid confusion since it points at
  `immutable_heads()` **and** we now have a revset-alias
  literally named `builtin_immutable_heads()`.
* Add unittest
* Update CHANGELOG
* Update documentation.

Fixes: #4162
2024-08-14 11:32:16 +01:00
Matt Kulukundis
ec99a17ae8 copy-tracking: improve --summary and add --stat
- add support for copy tracking to `diff --stat`
- switch `--summary` to match git's output more closely
- rework `show_diff_summary` signature to be more consistent
2024-08-13 21:37:45 -04:00
Aaron Bull Schaefer
e803bed845 config: expand tilde in ssh key filepaths
Add home directory expansion for SSH key filepaths. This allows the
`signing.key` configuration value to work more universally across both
Linux and macOS without requiring an absolute path.

This moved and renamed the previous `expand_git_path` function to a more
generic location, and the prior use was updated accordingly.
2024-08-13 08:06:43 -07:00
Matt Kulukundis
5911e5c9b2 copy-tracking: Add copy tracking as a post iteration step
- force each diff command to explicitly enable copy tracking
- enable copy tracking in diff_summary
- post-process for diff iterator
- post-process for diff stream
- update changelog
2024-08-11 17:01:45 -04:00
Martin von Zweigbergk
27d8198fa1 release: release version 0.20.0
Thanks to everyone who's contributed!
2024-08-07 10:20:21 -07:00
Yuya Nishihara
f7836aa687 cli: obslog: show diffs from all predecessors, not first predecessor
Suppose a squash node in obslog is analogous to a merge in revisions log, it
makes sense to show diffs from auto-merge (or auto-squash) parents. This
basically means a non-partial squash node no longer shows diffs.

This also fixes missing diffs at the root predecessors if there were.
2024-08-07 10:51:23 +09:00