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

5436 commits

Author SHA1 Message Date
Yuya Nishihara
4c16c05be1 cli: move --git-repo path normalization back from workspace
This reverts dc074363d1 "no-op: Move external git repo canonicalization into
Workspace::init_git_external." As I said in the PR comment, appending ".git"
is normalization of the user input, which is IMHO more appropriate to be done
in the CLI layer.
2024-02-28 09:03:16 +09:00
Yuya Nishihara
8d0414549b cli: unblock "jj git init --colocate" in existing Git repo directory
I'm not sure what's the conclusion in #2747, but I don't think there is a
disagreement on allowing --colocate to import existing Git repo.
2024-02-28 09:03:16 +09:00
Yuya Nishihara
356037379a cli: narrow scope of canonicalized cwd in git_init()
It's only needed to calculate relative path of canonicalized workspace_root,
and I'm going to remove it.
2024-02-28 09:03:16 +09:00
Yuya Nishihara
7bc4521862 templater: expand similarity hint with aliases
-Tbuiltin now shows the list of the builtin templates, which seems useful.
2024-02-28 09:03:04 +09:00
Yuya Nishihara
71a9dc8304 templater: add similarity hint to no such method/keyword errors
The translation from method error to keyword error can go wrong if the context
object had n-ary methods (n > 0), which isn't the case as of now. For
simplicity, arguments error is mapped to "self.<name>(..)" suggestion.

Local variables and "self" could be merged without using extra method, but
we'll need extend_*_candidates() to merge in symbol/function aliases anyway.
2024-02-28 09:03:04 +09:00
Yuya Nishihara
de1e4a39f4 revset: add hint to innermost error
This seems more useful if aliases are nested. The innermost error usually
contains the problem, and the outer errors are contexts where aliases are
expanded.
2024-02-28 09:03:04 +09:00
Yuya Nishihara
a235aa51f6 templater: move build_core_method() to table object
Just for convenience.
2024-02-28 09:03:04 +09:00
Yuya Nishihara
bdbb2dec65 templater: migrate core template methods to symbol table
Except for the generic list and template methods. We'll need a bit more
refactoring to migrate List<T> method builders to be compatible with
non-capturing fn() type.
2024-02-28 09:03:04 +09:00
Yuya Nishihara
e1864d90dd templater: extract substr() method body to function
This function isn't trivial, so it's probably better to not inline in the
templater binding.
2024-02-28 09:03:04 +09:00
Evan Mesterhazy
a28beb5b8f Allow id_type! to capture doc comments
This allows us to define documentation comments for types implemented using the
id_type! macro. Comments defined above the type inside the macro will be
captured and visible in generated docs.

Example:

```
id_type!(
    /// Stable identifier for a [`Commit`]. Unlike the `CommitId`, the `ChangeId`
    /// follows the commit and is not updated when the commit is rewritten.
    pub ChangeId
);
```

This commit also adds documentation for the `CommitId` and `ChangeId` types
defined using the `id_type!` macro.
2024-02-27 10:37:05 -05:00
dependabot[bot]
5df334c705 cargo: bump the cargo-dependencies group with 1 update
Bumps the cargo-dependencies group with 1 update: [tempfile](https://github.com/Stebalien/tempfile).


Updates `tempfile` from 3.10.0 to 3.10.1
- [Changelog](https://github.com/Stebalien/tempfile/blob/master/CHANGELOG.md)
- [Commits](https://github.com/Stebalien/tempfile/compare/v3.10.0...v3.10.1)

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

Signed-off-by: dependabot[bot] <support@github.com>
2024-02-27 15:20:53 +00:00
Martin von Zweigbergk
81e9ba3d51 workspace: make recovery commit empty instead of deleting everything
The recovery commit we create when we run into a stale working copy
with a missing operation currently has an empty tree. Our commit
backend at Google creates an index of which files changed in each
commit. That gets really expensive when a commit deletes all files in
the repo, as these recovery commits do. So for our backend, it is much
better to make the recovery commit empty instead. That's what this
patch does.

It almost doesn't matter functionally what tree we use for it since we
don't care much about the current tree when snapshotting the working
copy. It does matter in a few cases, however. One case is for
conflicts. In that case, it's likely better to use the recovery
commit's parent as base tree (as we do by making the recovery commit
empty) than to use an empty tree, as that would guarantee that all
conflicts would be considered resolved. (Side note: perhaps we should
start looking at the current commit's parent instead of looking at the
current commit when snapshotting, but that's a topic for another day.)
2024-02-27 06:45:25 -08:00
Yuya Nishihara
9ad2fee72b templater: migrate operation template methods to symbol table 2024-02-27 11:00:33 +09:00
Yuya Nishihara
10acfdcb86 templater: extract generic type aliases for method build fn and table
I also added a type alias for HashMap<&'static str, _> because it's tedious to
repeat that in function body.
2024-02-27 11:00:33 +09:00
Yuya Nishihara
523f8b26ec templater: migrate other commit template methods to symbol table 2024-02-27 11:00:33 +09:00
Yuya Nishihara
8226584ae9 templater: inline parse_optional_integer() in method body
If each method body is split to closure, this parse helper will no longer be
able to capture the environment.
2024-02-27 11:00:33 +09:00
Yuya Nishihara
1b4c339203 templater: extract stub function that resolves method name
We'll probably add "Did you mean?" hint there.
2024-02-27 11:00:33 +09:00
Stephen Jennings
6e29abb180 docs: add guidance for handling CRLF on Windows 2024-02-26 10:06:06 -08:00
Yuya Nishihara
ef9d22887c tests: disable gpg unknown_key() test on Windows as well
Follows up 7552f939c6 "tests: disable most gpg integration tests on Windows."
I couldn't find this test failing in a few samples before, but it does now.
2024-02-27 00:55:06 +09:00
dependabot[bot]
1b137dbd8a cargo: bump the cargo-dependencies group with 1 update
Bumps the cargo-dependencies group with 1 update: [syn](https://github.com/dtolnay/syn).


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

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

Signed-off-by: dependabot[bot] <support@github.com>
2024-02-26 09:54:29 -06:00
Martin von Zweigbergk
a976b5d482 cli: document that we create a new working-copy commit for abandoned one
When we abandon a working-copy commit, we create a new working-copy
commit on top. This behave is very useful, but it's not obvious. Let's
document it.

Thankfully, 2bbefcc338 (rewrite: default to not simplifying ancestor
merges) means that there are much fewer commands where we need to
document this behavior.
2024-02-25 18:52:10 -08:00
Yuya Nishihara
fd4acf679c templater: clone WorkspaceId/OperationId into templater to simplify lifetime
There would be no measurable cost to clone a couple of id objects.
2024-02-26 10:27:45 +09:00
Yuya Nishihara
68b1f869b6 templater: extract Commit methods to HashMap
There are two major goals:
 * provide typo hints in a similar way to revset
 * make methods extensible

The created method table is bound to the 'repo lifetime because of the problem
described in the inline comment. It would be nice if we can build cachable
core method table for<'repo> CommitTemplateLanguage<'repo, '_>, but I couldn't
figure out how.
2024-02-26 10:27:45 +09:00
Yuya Nishihara
0d77ce5ba9 templater: inline capture variables in each method body of Commit type
Each method body will be turned into a closure.
2024-02-26 10:27:45 +09:00
Paulo Coelho
e9243a7638 cli branch list: list tracked branches
Add an option to list tracked branches only

This option keeps most of the current `--all` printing logic, but:

- Omits local Git-tracking branches by default (can be extended to
  support filtering by remote).
- Skip over the branch altogether if it doesn't contain tracked remotes
- Don't print the untracked_remote_refs at the end

Usage:

`jj branch list -t`
`jj branch list --tracked`
`jj branch list --tracked <branch name>`
2024-02-26 01:05:07 +00:00
Martin von Zweigbergk
1cbf2b4acf rewrite: allow working-copy to be abandoned
This removes the special handling of the working-copy commit. By
recording when an empty/emptied commit was abanoned, we rebase
descendants correctly and create a new empty working-copy commit on
top.
2024-02-25 16:39:05 -08:00
Martin von Zweigbergk
b695fa1d82 cli: make rebase --skip-empty keep already empty commits
I think the user usually wants to abandon only newly empty commits. I
think they should use `jj abandon` if they want to get rid of already
empty commits. By keeping already empty commits, we don't need to
special-case the working copy and merge commits.
2024-02-25 16:39:05 -08:00
Martin von Zweigbergk
3bc3a63411 rewrite: move decision about abandoned commit into update_references() 2024-02-25 16:39:05 -08:00
Philip Metzger
5b0ef324d1 docs: Add a Testmonials page.
Show our positive reviews to the world. It's also not completly serious, in a similar fashion to
Phabricator.

Co-Authored-By: Austin Seipp <aseipp@pobox.com>
2024-02-25 14:20:33 +01:00
Yuya Nishihara
7552f939c6 tests: disable most gpg integration tests on Windows
These tests often stuck on Windows CI for unknown reasons. Let's mark them
ignored for the moment. The unknown_key test is allowed because it somehow
appears to pass.

https://github.com/martinvonz/jj/actions/runs/8009950119/job/21879789008?pr=3123#step:7:1487

#3140
2024-02-25 17:07:05 +09:00
Yuya Nishihara
7525fac12a templater: add special "self" variable to refer to top-level object
This allows us to call alias function with the top-level object.

For convenience, all self.<method>()s are available as keywords. I don't think
we'll want to deprecate them. It would be tedious if we had to specify
-T'self.commit_id()' instead of -Tcommit_id.
2024-02-25 09:01:04 +09:00
Yuya Nishihara
ff37b07d90 docs: move template keywords list to corresponding types
I'm going to introduce the "self" variable, and it will make more sense to
document keywords as methods of the self object type.
2024-02-25 09:01:04 +09:00
Yuya Nishihara
bbf88643cc templater: inline wrap_fn() helpers
If I remember correctly, wrap_fn() was added to help type inference. It no
longer makes sense because the type is coerced by TemplateFunction::new()
and language.wrap_*().
2024-02-25 09:00:56 +09:00
Yuya Nishihara
f0ce448609 templater: merge build_*_keyword_opt() functions into method builders
template_parser::expect_no_arguments(function) is copied to each method body.
We might want to add some helper macros later.
2024-02-25 09:00:56 +09:00
Yuya Nishihara
e588a9babc backend: allow cheap copy of MillisSinceEpoch(i64)
It's unlikely this type will become uncopyable.
2024-02-25 09:00:56 +09:00
Yuya Nishihara
ebf90384f6 operation: add shorthand for .store_operation().metadata 2024-02-25 09:00:56 +09:00
Austin Seipp
3f7b5a75e7 github(nix): don't build everything twice
When running the `nix build`, the `buildRustPackage` function -- which builds
the `jj` crates -- calls `cargo build --release` with flags like `HOST_CXX`
set. This is called the `buildPhase`. Then, it runs the `checkPhase`, which
calls `cargo nextest`, in our case. However, it does not set `HOST_CXX`, for
some reason.

The intent of `buildRustPackage` is that the `buildPhase` and `checkPhase`
have their compilation options fully aligned so that they reuse the local cargo
`target/` cache directory, avoiding a full recompilation. However, the lack
of `HOST_CXX` above among others causes a cache miss, and a bunch of cascading
recompilations. The net impact is that we compile all of the codebase once in
`buildPhase`, then again in `checkPhase`, making the Nix CI build 2x slower on
average than the other Linux runners; 2-3 minutes versus 7 minutes, on average.

Instead, re-introduce a 'check' into the Flake directly, which overrides the
`jujustsu` package, but stubs out the `buildPhase`. This means it will only run
`checkPhase`, which is what we want. Then, modify the CI to run `nix flake check`
again, like it used to in the past.

Unfortunately, this doesn't fix the cache miss when running `nix build`
yourself, it recompiles from scratch in both phases still. That needs to be
fixed in the future, but it's tolerable for now.

This reverts most of 71a3045032.

Signed-off-by: Austin Seipp <aseipp@pobox.com>
2024-02-24 13:56:03 -06:00
Yuya Nishihara
a67aa08995 gitignore: make objects chain be more Arc friendly
This partially reverts changes in a9f489ccdf "Switch to ignore crate for
gitignore handling." Since child ignore object no longer needs to access the
root to resolve the prefix path, it's simpler to store a matcher per node.
2024-02-24 15:55:10 +09:00
Yuya Nishihara
febae9f9e8 gitignore: fix prefix handling when chaining .gitignore in sub directory
The prefix is relative to the root, not to the parent .gitignore file.

Fixes #3126
2024-02-24 15:55:10 +09:00
Yuya Nishihara
2f25848883 gitignore: update file ordering test to not use relative path in patterns
With the current implementation, the file3 pattern is set to the prefix
"foo/foo/bar". I don't know if (unrooted) "baz" prefixed with "foo/foo/bar"
should match "foo/bar/baz", but apparently it is. Anyway, that wouldn't be
the case in practice because adjacent .gitignore files shouldn't be loaded.
2024-02-24 15:55:10 +09:00
Austin Seipp
c5cc6bf501 github: cap builds to 15 minutes
This should nerf some of the impact of the flaky Windows GPG tests right now,
which are currently non-deterministically running into hangs, causing a lot of
PRs to stall out. 15 minutes was chosen as a good trade-off between "pretty far
from our current build times" while also catching obvious bugs and flakes.

Signed-off-by: Austin Seipp <aseipp@pobox.com>
2024-02-23 15:50:52 -06:00
Martin von Zweigbergk
9767620292 cli: restore documentation of jj diff lost in split of commands module
The description of `jj diff` was lost in commit b5e4e670. We later got
a short description for it in b5e4e670. This patch restores the
original description.
2024-02-23 09:45:19 -08:00
Austin Seipp
2f5ce9db89 github: fix codespell ignore list
This seems like it might have been some debugging leftover or
copy-and-paste error?

Signed-off-by: Austin Seipp <aseipp@pobox.com>
2024-02-22 19:13:32 -06:00
Yuya Nishihara
e80b906188 templater: translate keywords to "self" methods by core template engine
This eliminates the separate keywords table. All keywords are resolved through
the pseudo "self" property. Maybe we'll add "self" keyword/variable later.
2024-02-23 10:13:25 +09:00
Yuya Nishihara
6e5eff5423 templater: update test templater to be compatible with "self" methods
Prepares for the removal of build_keyword().
2024-02-23 10:13:25 +09:00
Yuya Nishihara
e9b420f592 templater: add Operation type and methods
There are no keywords or methods that return Operation yet, but we might add
"self" keyword that returns the context object.
2024-02-23 10:13:25 +09:00
Yuya Nishihara
4e0fa6695f templater: extract operation keywords to method-compatible form
This is copied from the commit templater. I'm going to extract the "self"
property handling to the core template builder, and build_keyword() methods
will be replaced with that.
2024-02-23 10:13:25 +09:00
Yuya Nishihara
073310547c operation: make Operation object cheaply clonable
We do clone Operation object in several places, and I'm going to add one more
.clone() in the templater. Since the underlying metadata has many fields, I
think it's better to wrap it with Arc just like a Commit object.
2024-02-23 10:13:25 +09:00
Yuya Nishihara
62f0cb8c3f cli: change default log revset to not include all tagged heads
The default immutable_heads() includes tags(), which makes sense, but computing
heads(tags()) can be expensive because the tags() set is usually sparse. For
example, "jj bench revset 'heads(tags())'" took 157ms in my linux stable
mirror. We can of course optimize the heads evaluation by using bit set or
segmented index, but the query includes many historical heads if the repository
has per-release branches, which are uninteresting anyway. So, this patch
replaces heads(immutable_heads()) with trunk().

The reason we include heads(immutable_heads()) is to mitigate the following
problem. Suppose trunk() is the branch to be based off, I think using trunk()
here is pretty good.

```
A   B
*---*----* trunk() ⊆ immutable_heads()
     \
      * C
```
https://github.com/martinvonz/jj/pull/2247#discussion_r1335078879
2024-02-23 00:25:58 +09:00
Yuya Nishihara
f21c078249 revset: ad-hoc optimization for range queries containing unwanted wanted heads
In my linux stable mirror, this makes the default log revset evaluation super
fast. immutable_heads(), if configured properly, includes many historical
branch heads which are also the visible heads.

revsets/immutable_heads()..
---------------------------
0     12.27     117.1±0.77m
3      1.00       9.5±0.08m
2024-02-22 23:26:29 +09:00