ok/jj
1
0
Fork 0
forked from mirrors/jj
Commit graph

4184 commits

Author SHA1 Message Date
Martin von Zweigbergk
7c8f66ab0c cli: make jj abandon print commit info as it was before the command
As we discussed in #1928, it seems better to print information about
abandoned commits in the context of the pre-abandon state. For
example, that means that we'll include any branches that pointed to
the now-abandoned commits.
2023-09-05 21:51:32 -07:00
Yuya Nishihara
a868b2d9a5 revset: do not lookup unimported tags or remote branches by unqualified name
Since e7e49527ef "git: ensure that remote branches never diverge", the last
known "refs/remotes" ref should be synced with the corresponding remote branch.
So we can always trust the branch@remote expression. We don't need "refs/tags"
lookup either since tags should have been imported by git::import_refs().

FWIW, I'm thinking of reorganizing view.git_refs() map as per-remote views.
It would be nice if we can get rid of revsets and template keywords exposing
low-level Git ref primitives.
2023-09-06 13:42:22 +09:00
Yuya Nishihara
4e6323c0a4 revset: add basic test for tag name resolution 2023-09-06 13:42:22 +09:00
Yuya Nishihara
8f4512b109 git: rename local variables in diff_refs_to_export()
old/new_branch sounds like a branch name, but it's a RefTarget. And
jj_known_refs_passing_filter may contain "new" ref names.
2023-09-06 08:17:49 +09:00
Yuya Nishihara
119cc88832 git: extract calculation step from export_some_refs()
export_some_refs() is big, let's split it to functions of reasonable size.
2023-09-06 08:17:49 +09:00
Yuya Nishihara
89f1d83a22 git: do not export new ref if racy process created one with the same name
Since we've checked the ref doesn't exist in this code path, I think it's
better to not overwrite the existing ref.
2023-09-06 08:17:49 +09:00
Yuya Nishihara
a4dd598e3e git: extract helper that exports single updated ref 2023-09-06 08:17:49 +09:00
Yuya Nishihara
d1a08782c9 git: extract helper that exports single deleted ref 2023-09-06 08:17:49 +09:00
Yuya Nishihara
7282b517e8 git: remove stale TODO comment about FailedRefExportReason 2023-09-06 08:17:49 +09:00
Philip Metzger
f131dc9814 commands: Implement next and prev
This is a naive implementation, which cannot deal with multiple children
or parents stemming from merges.

Note: I gave each command separate a separate argument struct
for extensibility. 

Fixes #878
2023-09-05 23:13:39 +02:00
Philip Metzger
8dda7e21e0 revsets: Add descendants_at and ancestors_at
They are needed for `next` and `prev`.
They behave symmetrically for parents and children.
2023-09-05 23:13:39 +02:00
dependabot[bot]
57f46a4bb7 cargo: bump the cargo-dependencies group with 1 update
Bumps the cargo-dependencies group with 1 update: [chrono](https://github.com/chronotope/chrono).

- [Release notes](https://github.com/chronotope/chrono/releases)
- [Changelog](https://github.com/chronotope/chrono/blob/main/CHANGELOG.md)
- [Commits](https://github.com/chronotope/chrono/compare/v0.4.28...v0.4.29)

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

Signed-off-by: dependabot[bot] <support@github.com>
2023-09-05 16:13:02 +00:00
Martin von Zweigbergk
2b9c9d22cf cli: make it allowed to have a branch on the root commit again
Closes #1529.
2023-09-04 20:08:11 -07:00
Martin von Zweigbergk
f198a1e5f9 git: skip branches on root commit on export
Git doesn't have a root commit, so we should skip branches pointing to
it on export, just like we do with conflicted branches (which Git also
doesn't support).
2023-09-04 20:08:11 -07:00
Martin von Zweigbergk
4ea6b4a75b cli: make hint about foo and foo/bar branches more targeted
Many failure to export refs to Git are not about conflicts between a
branch named `foo` and a branch named `foo/bar`, so don't give that
hint in most cases.
2023-09-04 20:08:11 -07:00
Martin von Zweigbergk
ef550a9d6d git: include reason for each failed ref export 2023-09-04 20:08:11 -07:00
Martin von Zweigbergk
f6c24fbcef git: return refs that failed to export in sorted order
Before this patch, the order would depend on the reason we failed to
export a ref, because we would add to the `failed_branches` list in
several different places. What's worse, when the export failed because
the branch was conflicted or had an invalid name (from Git's
perspective), it was non-deterministic because we iterated over a
HashSet. This patch fixes that by sorting at the end.

Note that we still want the `branches_to_update` map to be a
`BTreeMap` so we update branches in deterministic order. Otherwise the
error when trying to export both branches `main` and `main/sub` will
become non-deterministic.
2023-09-04 20:08:11 -07:00
Yuya Nishihara
b0c8e9ef62 revset: add 0-ary "::" and ".." operators as short for "all()" and "~root()"
Suppose "x::y" is the operator that defaults to "root()::visible_heads()"
respectively, "::" is identical to "all()". Since we've just changed the
behavior of "..y", ".." is now "root()..visible_heads()" meaning "~root()".
2023-09-05 10:40:04 +09:00
Yuya Nishihara
6b2ad23f8f revset: evaluate "..y" expression to "root()..y"
This seems useful since the root commit is often uninteresting. It's also
consistent with "x::y" in a way that the left operand defaults to "root()".
2023-09-05 10:40:04 +09:00
Yuya Nishihara
f2c1697362 revset: fix comment about "@" expression 2023-09-05 10:40:04 +09:00
dependabot[bot]
0fa6d132ab cargo: bump the cargo-dependencies group with 2 updates
Bumps the cargo-dependencies group with 2 updates: [regex](https://github.com/rust-lang/regex) and [thiserror](https://github.com/dtolnay/thiserror).


Updates `regex` from 1.9.4 to 1.9.5
- [Release notes](https://github.com/rust-lang/regex/releases)
- [Changelog](https://github.com/rust-lang/regex/blob/master/CHANGELOG.md)
- [Commits](https://github.com/rust-lang/regex/compare/1.9.4...1.9.5)

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

---
updated-dependencies:
- dependency-name: regex
  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>
2023-09-04 13:39:27 -07:00
dependabot[bot]
d420ca06d0 github: bump the github-dependencies group with 1 update
Bumps the github-dependencies group with 1 update: [actions/checkout](https://github.com/actions/checkout).

- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](https://github.com/actions/checkout/compare/v3...3df4ab11eba7bda6032a0b82a6bb43b11571feac)

---
updated-dependencies:
- dependency-name: actions/checkout
  dependency-type: direct:production
  update-type: version-update:semver-major
  dependency-group: github-dependencies
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-09-04 13:39:04 -07:00
Yuya Nishihara
e3c85d6ecc revset: convert root symbol to function
The idea is that we can fully eliminate special symbols that would otherwise
shadow user branches, tags, or change ID prefixes.

Closes #2095
2023-09-04 10:36:30 +09:00
Yuya Nishihara
c08fab60da docs: update description of @ revset expression, mention name@remote syntax
Since I'm going to remove the root symbol, it doesn't make sense to leave
@ in the priority list.
2023-09-04 10:36:30 +09:00
Yuya Nishihara
4394bf8de8 templater: add boolean literals
They are implemented as literal expressions so that user cannot override
them by false and true aliases.
2023-09-03 07:01:40 +09:00
Yuya Nishihara
08e66fb7d4 templater: fix span of method call expression
Spotted while experimenting with field expression. This span is unused,
so no test output changes.
2023-09-03 07:01:40 +09:00
Martin von Zweigbergk
e3825495e3 store: don't include cached objects in Debug format
I was looking into some overly verbose logs and happened to notice
that `Store` uses the default derived, which presumably means it's
going to include all objects in its cached. Just including the
backend's debug string seems enough.
2023-09-01 16:49:23 -07:00
Martin von Zweigbergk
16c897d8b4 conflicts: leverage Merge::map() in materialize_merge_result() 2023-09-01 16:23:39 -07:00
Yuya Nishihara
e36237426a cli: elide path in snapshot progress in the same way 2023-09-02 08:21:33 +09:00
Yuya Nishihara
1c7d2b9a96 cli: make diff stat calculate path length based on unicode width 2023-09-02 08:21:33 +09:00
Yuya Nishihara
643b2d4974 cli: include both ascii and non-ascii file names in diff stat test
ASCII file names can be used as reference widths.
2023-09-02 08:21:33 +09:00
Yuya Nishihara
3d54df9806 cli: add helper to elide text from left
I don't think this implements unicode layout stuff thoroughly, but it can at
least handle Latin and unambiguous East-Asian characters.
2023-09-02 08:21:33 +09:00
Martin von Zweigbergk
b8f71a4b30 working_copy: in LockedWorkingCopy::drop(), discard unsaved changes
In `LockedWorkingCopy::drop()`, we panic if the caller had not called
`finish()`. IIRC, the idea was both to find bugs where we forgot to
call `finish()` and to prevent continuing with a modified
`WorkingCopy` instance. I don't think the former has been a problem in
practice. It has been a problem in practice to call `discard()` to
avoid the panic, though. To address that, we can make the `Drop`
implementation discard the changes (forcing a reload of the state if
the working copy is accessed again).
2023-09-01 12:25:47 -07:00
Martin von Zweigbergk
f3a16eb964 cli: add hint when snapshot fails due to large file
I also converted the error from `InternalError` to `UserError`. So far
I've intented to use `InternalError` only to indicate bugs or corrupt
repos. I'm not sure that's a good idea, and we can revisit it later.
2023-09-01 12:25:47 -07:00
dependabot[bot]
c329cc0dc1 cargo: bump the cargo-dependencies group with 2 updates
Bumps the cargo-dependencies group with 2 updates: [clap](https://github.com/clap-rs/clap) and [rustix](https://github.com/bytecodealliance/rustix).


Updates `clap` from 4.4.1 to 4.4.2
- [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/v4.4.1...v4.4.2)

Updates `rustix` from 0.38.10 to 0.38.11
- [Release notes](https://github.com/bytecodealliance/rustix/releases)
- [Commits](https://github.com/bytecodealliance/rustix/compare/v0.38.10...v0.38.11)

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

Signed-off-by: dependabot[bot] <support@github.com>
2023-09-01 16:08:12 +00:00
Martin von Zweigbergk
5ef0be73c1 merged_tree: allow building trees with variable-arity overrides
When restoring (`jj restore`) a 3-sided conflict from one tree into a
2-sided tree (or a resolved tree), we'll need to extend the size arity
of the target tree to that of the source tree. I had not considered
this case before. This patch relaxes the constraint in
`MergedTreeBuilder` to allow such cases. The additional trees are
based on empty trees with only the larger overrides in them.
2023-09-01 06:09:37 -07:00
Martin von Zweigbergk
d29c831ef9 merge: add a function for padding a Merge to a given size
This will be useful for padding merge objects in `MergedTreeBuilder`
to the size of the widest override.
2023-09-01 06:09:37 -07:00
Ilya Grigoriev
772e2b8be6 GitHub release action: publish HTML docs in an archive 2023-08-31 20:44:08 -07:00
Ilya Grigoriev
bfe4240b67 GitHub release action: minor cleanup for consistency with next commit 2023-08-31 20:44:08 -07:00
Martin von Zweigbergk
b18c97aa12 cli: trim path in diff stat if it's long, to give room for stat
If the path is too long to fit on the screen, this patch makes it so
we elide the first part of it. It goes a bit further and trims it down
to ~70% of the screen, giving some room for the stat. This seems
somewhat similar to what Git does.
2023-08-31 16:26:43 -07:00
Martin von Zweigbergk
497f4a952c cli: fix indentation of two insta snapshots
`insta` ignores leading indentation (as long as it's consistent within
the snapshot), but when a test case fails and you let `cargo insta`
update it, it's going to use a specific indentation. There were a few
tests that didn't match that indentation, which could lead to
surprising diffs if the tests fail at some point.
2023-08-31 16:26:43 -07:00
Martin von Zweigbergk
5ecc95a245 cli: make diff stat determine path length in chars, not bytes 2023-08-31 16:26:43 -07:00
Martin von Zweigbergk
0493e2b50e cli: use non-ascii chars in diff stat test
This shows that there's too much padding because we pad based on
number of bytes.

I had to reduce the path names for the file names not to get too long
for my file system.
2023-08-31 16:26:43 -07:00
Martin von Zweigbergk
4377c08f83 cli: don't crash diffstat on very narrow terminals
We can still crash on terminals that are less than 4 characters wide
(maybe it doesn't matter if we do because the user can't tell the
crash report from a diffstat in such a terminal?). This patch fixes
the crash.
2023-08-31 16:26:43 -07:00
Martin von Zweigbergk
5a054fcd20 cli: reuse number_padding instead of calculating twice in diff stat 2023-08-31 16:26:43 -07:00
Martin von Zweigbergk
5ce4ed45de cli: allow diff stat bar to be one character longer
I think the `+ 1` here came from an old iteration of this feature
where there was a single space before each line.
2023-08-31 16:26:43 -07:00
Martin von Zweigbergk
939528122d cli: fix crash on diff stat with long path name
We would run into a panic due to "attempt to subtract with overflow"
if the path was long. This patch fixes that and adds tests showing the
current behavior when there are long paths and/or large diffs.
2023-08-31 16:26:43 -07:00
Martin von Zweigbergk
be08707a3a op_heads_store: propagate errors from OpStore 2023-08-31 12:36:47 -07:00
dependabot[bot]
134881c670 cargo: bump the cargo-dependencies group with 1 update
Bumps the cargo-dependencies group with 1 update: [chrono](https://github.com/chronotope/chrono).

- [Release notes](https://github.com/chronotope/chrono/releases)
- [Changelog](https://github.com/chronotope/chrono/blob/main/CHANGELOG.md)
- [Commits](https://github.com/chronotope/chrono/compare/v0.4.27...v0.4.28)

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

Signed-off-by: dependabot[bot] <support@github.com>
2023-08-31 16:13:12 +00:00
Martin von Zweigbergk
9d9b2cd057 tests: leverage create_tree() in a few more tests 2023-08-30 19:58:42 -07:00