Commit Graph

1283 Commits

Author SHA1 Message Date
Martin von Zweigbergk
6c83eb6ae3 cli: teach log flag to show commits in reverse order
This adds a `--reversed` flag to `jj log` to show commits with later
commits further down. It works both with and without the graph.

Since the graph-drawing code is already independent of the
relationship between commits, it doesn't need any updating.
2022-05-15 05:17:54 -07:00
Martin von Zweigbergk
0747da0491 revset_graph_iterator: add a mode for generating reverse graph
The request to show the log output with more recent commits at the
bottom comes up once in a while (among Mercurial users, and now also
for jj from @arxanas). It's pretty easy to implement by adding an
adapter to the current `RevsetGraphIterator`. It works by first
collecting all nodes and edges into a vector and then yielding them in
reverse order and with reversed edges. That means it's no longer lazy,
but that seems fine since the feature is optional. Also, it's only the
subset of nodes that are in the selected revset that will be
collected.

Making the CLI use the new iterator adapter will come in a later
patch.
2022-05-15 05:17:54 -07:00
Martin von Zweigbergk
71c789f50b cli: make log show only local commits by default
The default log output of showing all commits is not very useful when
contributing to an existing repo. Let's have it default to showing
commits not on any remote branch instead. I think that's the best we
can do since we don't have a configurable main branch yet, and we
don't even have per-repo configuration..

Closes #250.
2022-05-14 11:50:05 -07:00
Martin von Zweigbergk
45830a0203 docs: mention jj rebase -b in git-comparison doc
I forgot to update the document in 30f5471fc3.
2022-05-14 11:10:52 -07:00
dependabot[bot]
bb99ab72d9 cargo: bump clap from 3.1.17 to 3.1.18
Bumps [clap](https://github.com/clap-rs/clap) from 3.1.17 to 3.1.18.
- [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/v3.1.17...v3.1.18)

---
updated-dependencies:
- dependency-name: clap
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-05-13 08:42:49 -07:00
dependabot[bot]
f0b1a18a8e cargo: bump zstd from 0.11.1+zstd.1.5.2 to 0.11.2+zstd.1.5.2
Bumps [zstd](https://github.com/gyscos/zstd-rs) from 0.11.1+zstd.1.5.2 to 0.11.2+zstd.1.5.2.
- [Release notes](https://github.com/gyscos/zstd-rs/releases)
- [Commits](https://github.com/gyscos/zstd-rs/commits/v0.11.2)

---
updated-dependencies:
- dependency-name: zstd
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-05-13 08:42:11 -07:00
dependabot[bot]
1e55b790eb github: bump github/codeql-action from 2.1.9 to 2.1.10
Bumps [github/codeql-action](https://github.com/github/codeql-action) from 2.1.9 to 2.1.10.
- [Release notes](https://github.com/github/codeql-action/releases)
- [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md)
- [Commits](7502d6e991...2f58583a1b)

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

Signed-off-by: dependabot[bot] <support@github.com>
2022-05-13 08:41:27 -07:00
Martin von Zweigbergk
87ba11592b cli: make log -s/--git imply -p
`log -s/--summary` and `log --git` without `-p` don't do anything. I
also don't think it's very useful to pass these flags in an alias,
where you would then sometimes also pass `-p` to see the diff summary
in the output. We already have the `diff.format` config for that use
case. So let's make both of these flags imply `-p`.

I implemented it by making the `diff_format` variable an
`Option<DiffFormat>`, which is set iff we should show a patch. That
way we have the condition in one place, and the places we use it
cannot forget to check it.
2022-05-13 03:19:10 -07:00
Martin von Zweigbergk
788831fed3 cli: allow alias after global args, and recursive aliases
Our support for aliases is very naively implemented; it assumes the
alias is the first argument in argv. It therefore fails to resolve
aliases after global arguments such as `--at-op`.

This patch fixes that by modifying the command defintion to have an
"external subcommand" in the list of available commands. That makes
`clap` give us the remainder of the arguments when it runs into an
unknown command. The first in the list will then be an alias or simply
an unknown command. Thanks to @epage for the suggestion on in
clap-rs/clap#3672.

With the new structure, it was easy to handle recursive alias
definitions, so I added support for that too.

Closes #292.
2022-05-12 06:30:27 -07:00
Martin von Zweigbergk
d0ecbaf1a4 graphlog: don't de-indent multi-line text at end of chain 2022-05-11 04:42:44 -07:00
Martin von Zweigbergk
9f6f4b4a55 graphlog: show bug in indentation after chain ends
If a chain ends, we don't count the chain itself when calculating the
padding to use before text. This patch updates a few tests to use
multi-line descriptions so this is seen.

We actually already have a case of this bug `test_operations.rs`. I
noticed that when I added that test, but it didn't bother me enough to
fix it until now.
2022-05-11 04:42:44 -07:00
Martin von Zweigbergk
866539f977 graphlog: use insta for tests
It's much easier to update the tests with `insta`.

It also presents you with the bad output including real newlines (a
diff, actually), so we can remove the `println!()` calls we had in
order to get readable output without escaped newlines.
2022-05-11 04:42:44 -07:00
Martin von Zweigbergk
6483aeefea cli: respect $VISUAL, overriding $EDITOR
With this patch, the order is this:

`$JJ_EDITOR` environement variable
`ui.editor` config
`$VISUAL` environement variable
`$EDITOR` environement variable
`pico`

That matches git, except that git falls back to an editor determined
at compile time (usually `vi`) instead of using `pico`.
2022-05-10 10:39:59 -07:00
Martin von Zweigbergk
96849da332 docs: prefer ~/.jjconfig.toml on all platforms
It's much easier to tell users on all platforms to put their config in
`~/.jjconfig.toml` than in a path that varies across the platforms, so
let's do that. It also seems like a less controversial location for
the file.

Closes ##233.
2022-05-10 10:21:22 -07:00
Martin von Zweigbergk
0f5e360d96 cli: allow config in ~/.jjconfig.toml
As I said in 095fb9fef4, removing support for `~/.jjconfig` was an
experiment. I've heard from a few people (including in #233) that they
would prefer to have configs in the home directory. This patch
therefore restores that functionality, except I added a `.toml`
extension to the file to clarify the expected format to users and
editors.

After this patch, we still allow configs in `$XDG_CONFIG_HOME` (and
the other paths used by `dirs::config_dir()`), but we error out there
are config files in both that location and `~/.jjconfig.toml`.
2022-05-10 10:21:22 -07:00
Martin von Zweigbergk
8b54ac58bd config: wrap config errors in our own type 2022-05-10 10:21:22 -07:00
Martin von Zweigbergk
8289e87423 cli: move config-reading to new config module 2022-05-10 10:21:22 -07:00
Martin von Zweigbergk
0bbf360432 cli: move definition of global arguments to separate struct
By having the global arguments on a separate struct, I think it will
be easier to improve how we resolve aliases (#292).
2022-05-10 09:20:45 -07:00
Martin von Zweigbergk
f5f363f079 cli: make invalid alias definition an error 2022-05-10 04:02:24 -07:00
Martin von Zweigbergk
9df1512b7d cli: use exit code 2 for invalid utf-8 2022-05-10 04:02:24 -07:00
Martin von Zweigbergk
15070bce5f cli: use exit code 3 for broken pipe
Since `clap` uses exit code 2 for bad CLI arguments, we should use a
different code for broken pipes.
2022-05-10 04:02:24 -07:00
Martin von Zweigbergk
c10247d5df cli: move all process::exit() calls to main.rs
It's cleaner to have all the calls in one place, and this structure
will also make it easier to return other errors from the `dispatch()`
function.

Note that there's still a call to `process::exit()` inside `clap` when
it fails to parse arguments.
2022-05-10 04:02:24 -07:00
Martin von Zweigbergk
1faffbb5aa tests: check exit code on failure, and fix a bug in argument parsing
We didn't have any testing of exit codes on failure, other than
checking that they were not 0. This patch changes that so we always
check. Since we have the special exit code 2 (set by `clap`) for
incorrect command line, I've replaced some testing of error messages
by testing of just the exit code.

As part of this, I also fixed `jj branch --allow-backwards` to
actually require `-r` (it didn't before because having a default value
means the argument is considered always provided).
2022-05-10 04:02:24 -07:00
Martin von Zweigbergk
a4f58ae918 cli: pass Ui as mutable reference to dispatch()
The function only needs a mutable reference (it doesn't store an owned
value anywhere), and this will enable the caller (i.e. `main()`) to
use the `Ui` instance after control returns from `dispatch()`.
2022-05-10 04:02:24 -07:00
dependabot[bot]
54fefdf45e cargo: bump clap from 3.1.16 to 3.1.17
Bumps [clap](https://github.com/clap-rs/clap) from 3.1.16 to 3.1.17.
- [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/v3.1.16...v3.1.17)

---
updated-dependencies:
- dependency-name: clap
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-05-09 22:11:08 -07:00
dependabot[bot]
deeb324a0a cargo: bump indoc from 1.0.5 to 1.0.6
Bumps [indoc](https://github.com/dtolnay/indoc) from 1.0.5 to 1.0.6.
- [Release notes](https://github.com/dtolnay/indoc/releases)
- [Commits](https://github.com/dtolnay/indoc/compare/1.0.5...1.0.6)

---
updated-dependencies:
- dependency-name: indoc
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-05-09 09:20:04 -07:00
Martin von Zweigbergk
31041ef46c github: trigger all builds on main branch, and PR for any branch
The conditions for triggering Nix builds and other builds were
slightly different.

Nix builds triggered by PRs happened on PRs for any branch, not just
the `main` branch. That makes very little difference in practice
because PRs for other branches are very rare. Still, let's be
consistent. I decided to trigger the builds on PRs for any branch.

More importantly, Nix builds triggered by push were only done for
pushes to `master`, which is not what our main branch is called, so
those never happened.
2022-05-06 11:56:50 -07:00
dependabot[bot]
0d40a120f5 cargo: bump clap_complete from 3.1.3 to 3.1.4
Bumps [clap_complete](https://github.com/clap-rs/clap) from 3.1.3 to 3.1.4.
- [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-v3.1.3...clap_complete-v3.1.4)

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

Signed-off-by: dependabot[bot] <support@github.com>
2022-05-06 09:07:24 -07:00
dependabot[bot]
828c995d46 cargo: bump indoc from 1.0.4 to 1.0.5
Bumps [indoc](https://github.com/dtolnay/indoc) from 1.0.4 to 1.0.5.
- [Release notes](https://github.com/dtolnay/indoc/releases)
- [Commits](https://github.com/dtolnay/indoc/compare/1.0.4...1.0.5)

---
updated-dependencies:
- dependency-name: indoc
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-05-06 08:52:46 -07:00
dependabot[bot]
c49386043b cargo: bump clap from 3.1.15 to 3.1.16
Bumps [clap](https://github.com/clap-rs/clap) from 3.1.15 to 3.1.16.
- [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/v3.1.15...v3.1.16)

---
updated-dependencies:
- dependency-name: clap
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-05-06 08:51:48 -07:00
Martin von Zweigbergk
b94c78545b protos: use run_from_script() in build.rs
`run_from_script()` is effectively the same as we did with `.expect()`
(print the error to stderr and exit with an error).
2022-05-05 11:46:40 -07:00
Martin von Zweigbergk
c1d0c08c03 protos: move protos.rs into src/protos/
It's easier to find the file this way and not forget that it's part of
the setup for building with protos.
2022-05-05 11:46:40 -07:00
Martin von Zweigbergk
a59724b082 protos: move .proto files to more conventional src/protos/ 2022-05-05 11:46:40 -07:00
Martin von Zweigbergk
36ae9421ad github: don't override nixpkgs version (use the lock file's version)
I don't know what it was overridden here, but it meant that CI didn't
notice that the package was broken (#299).
2022-05-05 11:14:08 -07:00
Martin von Zweigbergk
3cf1d629c8 nix: update lock file to nixpkgs with rust toolchain 1.60
Closes #299
2022-05-05 10:55:53 -07:00
Martin von Zweigbergk
ffc57310f6 cargo: upgrade protobuf crates to 3.0.1
The biggest difference in the API is that fields are now public. The
exception from that is `oneof` fields, which still require setters and
getters.

I couldn't measure any difference in performance. I didn't expect any
difference either, but it's good that it didn't seem to regress. I
timed `jj debug operation <some hash prefix>`, which will read the
whole operation log (to check that the prefix is unambiguous).
2022-05-04 17:02:11 -07:00
Martin von Zweigbergk
cba89886e5 cleanup: replace some for x in xs.iter() by for x in &xs 2022-05-04 17:02:11 -07:00
dependabot[bot]
8a6cf4bb3b cargo: bump serde_json from 1.0.80 to 1.0.81
Bumps [serde_json](https://github.com/serde-rs/json) from 1.0.80 to 1.0.81.
- [Release notes](https://github.com/serde-rs/json/releases)
- [Commits](https://github.com/serde-rs/json/compare/v1.0.80...v1.0.81)

---
updated-dependencies:
- dependency-name: serde_json
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-05-04 08:58:48 -07:00
dependabot[bot]
1f9a47c750 cargo: bump clap from 3.1.14 to 3.1.15
Bumps [clap](https://github.com/clap-rs/clap) from 3.1.14 to 3.1.15.
- [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/v3.1.14...v3.1.15)

---
updated-dependencies:
- dependency-name: clap
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-05-04 08:58:33 -07:00
dependabot[bot]
ad5cc029be cargo: bump serde from 1.0.136 to 1.0.137
Bumps [serde](https://github.com/serde-rs/serde) from 1.0.136 to 1.0.137.
- [Release notes](https://github.com/serde-rs/serde/releases)
- [Commits](https://github.com/serde-rs/serde/compare/v1.0.136...v1.0.137)

---
updated-dependencies:
- dependency-name: serde
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-05-04 08:58:00 -07:00
Martin von Zweigbergk
efa77fd024 github: run clippy on all targets (including tests and benches) 2022-05-03 15:41:03 -07:00
Martin von Zweigbergk
cce2ca06e2 github: stop running nightly clippy
It seems fine to wait for the clippy lints to graduate before we run
them if we can save a bit of GitHub resources.
2022-05-03 15:41:03 -07:00
Martin von Zweigbergk
e4f83e353e errors: use custom error for failed tree merge
Tree merges can currently fail because of a failure to look up an
object, or because of a failure to read its contents. Both results in
`BackendError` because of a `impl From<std::io::Error> for
BackendError`. That's kind of correct in this case, but it wasn't
intentional (that impl was from `local_backend`), and we need to
making errors more specific for better error handling.
2022-05-03 06:52:00 -07:00
Waleed Khan
67be21d9cb cleanup: fix some cargo clippy warnings 2022-05-02 21:49:01 -07:00
Waleed Khan
7a551e584f cli: jj branch can accept any number of branches 2022-05-02 21:33:58 -07:00
Yuya Nishihara
f6acee41df diff_edit: load command arguments from merge-tools.<name> config
Apparently, I need to pass `--merge` option to use kdiff3 as a diff editor.

We could add `diff-editor-args` or extend `diff-editor` to a list of command
arguments, but we'll eventually add stock merge tools and the configuration
would look like:

    [merge-tools.<name>]
    program = ...
    diff-args = [...]
    edit-args = [...]
    merge-args = [...]
2022-05-03 12:24:05 +09:00
Martin von Zweigbergk
1f2753fd3f cli: fix incompatibility between #271 and #273
The two PRs were incompatible, but it seems they were allowed to
"merge" (rebase) because the merge was conflict free?
2022-05-02 17:46:06 -07:00
Martin von Zweigbergk
305adf05cc cli: when auto-importing from git, rebase descendants 2022-05-02 17:01:38 -07:00
Martin von Zweigbergk
726b29978d tests: show failure in git-shared working copy after deleting commit in git
Since 57ba9a9409, if the automatic import from git results in some
abandoned commit, that information gets recorded in the `MutableRepo`,
but I forgot to add a call to rebase the descendants. That causes a
failed assertion at
81a8cfefcb/lib/src/transaction.rs (L86). This
patch add a test showing that failure.
2022-05-02 17:01:38 -07:00
Waleed Khan
ed2b8643f8 docs: update README.md
The intention is to make it easier to jump to the Installation section.
2022-05-02 13:57:10 -07:00