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

863 commits

Author SHA1 Message Date
Martin von Zweigbergk
2b64e52b4d repo: inline single-user init_repo_dir()
The function has only one caller since 25b922cd0b and it's pretty
small. Inlining also means we can reuse the joined paths created in
it, so I did that by extracting variables for them.
2022-10-27 17:46:13 -07:00
Yuya Nishihara
59717aa187 revset: remove redundant candidates argument from merges()
Since 'merges()' just filters the candidates set per item, it doesn't need
a candidates argument. Perhaps, 'merges(x)' could be a predicate to select
merge commits within a subgraph 'x', but I don't know if that would be
useful.
2022-10-27 21:33:35 +09:00
Yuya Nishihara
373c63b414 revset: remove redundant candidates argument from filter predicates 2022-10-27 21:33:35 +09:00
Yuya Nishihara
f48675ad90 revset: evaluate optimized expression 2022-10-27 21:33:35 +09:00
Yuya Nishihara
4d5936983a revset: optimize filter expression to minimize candidates set
Since 'filter(expr)' is identical to 'expr & filter()', it can be rewritten
in order to minimize the candidates set to be scanned.

The implementation is somewhat similar to revsetlang.optimize() of Mercurial,
but I've split the tree rewriting logic to several steps. I think that's good
for maintainability and should help us conclude that a recursion will
eventually terminate.
2022-10-27 21:33:35 +09:00
Yuya Nishihara
cfae28575b revset: add explicit RevsetExpression::All variant
This isn't strictly necessary, but is useful while getting rid of
redundant 'all() &' expression.
2022-10-27 21:33:35 +09:00
Yuya Nishihara
4337a997cf revset: unify FilterRevset variants at RevsetExpression level
This helps to match '(filter, _) | (_, filter)' to rewrite the expression
tree. Only one predicate is allowed for now, but I think it can be extended
to internalize 'f(c) & g(c)' as '(g*f)(c)' to eliminate redundant lookup
of commit object.
2022-10-27 21:33:35 +09:00
Yuya Nishihara
030e0069f6 revset: reorder match arms in evaluate_expression() to group filter stuff 2022-10-27 21:33:35 +09:00
Benjamin Saunders
c03c746f8d cli: report fetch progress continuously 2022-10-23 12:13:25 -07:00
Martin von Zweigbergk
b2e309c9e4 tests: stop libgit2 from reading configs in lib tests too
I had `init.defaultBranch = main` in my global config (just being
rolled out internally at Google, it seems), which made
`test_import_refs_reimport_head_removed()` and
`test_fetch_initial_commit()` fail. This fixes it.
2022-10-23 11:08:22 -07:00
Martin von Zweigbergk
efce1e54e6 tests: extract setup of libgit2 config to lib crate
We have some problems with non-hermetic tests in the lib crate, so
we'll want to reuse the setup code there.
2022-10-23 11:08:22 -07:00
Martin von Zweigbergk
c366795d80 tests: remove obsolete workaround for WorkingCopy reading from $HOME
Since d56ae79d3f, `WorkingCopy` no longer reads `.gitignores`
directly from `$HOME/.gitignore`, so we don't need the workaround to
prevent it in the tests.
2022-10-23 11:08:22 -07:00
Yuya Nishihara
cb2fcde560 revset: implement file(pattern[, candidates]) predicate
The name "file()" is just copied from hg. I'm not sure if it's good in
jj's context, but I couldn't find a better name.
2022-10-24 01:48:00 +09:00
Yuya Nishihara
d5cf2582dc revset: instantiate Workspace in tests where workspace_id is needed
This makes resolve_commit_ids_in_workspace() reusable for file() revset
tests.
2022-10-24 01:48:00 +09:00
Yuya Nishihara
5c52b4e819 revset: introduce wrapper struct to pass around workspace information
More workspace-derived parameters will be added, and I don't think wrapping
with Option for each makes sense because all parameters should be available
if workspace exists.
2022-10-24 01:48:00 +09:00
Yuya Nishihara
efb8c5e58a revset: make filter_by_diff() accept either borrowed or owned matcher
So filter_by_diff() can also be used to evaluate file() revset.

I've never seen Borrow<T> for this sort of abstraction, but it seems a valid
use case of Borrow<T>.

https://stackoverflow.com/a/69318514
https://github.com/rust-lang/rust/blob/1.64.0/compiler/rustc_mir_dataflow/src/framework/cursor.rs#L45
2022-10-24 01:48:00 +09:00
Yuya Nishihara
977cfd3d4a repo_path: make FsPathParseError displayable by itself
So it can be easily embedded in other error types such as RevsetError.
2022-10-24 01:48:00 +09:00
Yuya Nishihara
3fe6da1b51 repo_path: migrate parse_file_path() from ui
It seems a bit invasive that RepoPath constructor processes an environment
like cwd, but we need an unmodified input string to build a readable error.
The error could be rewrapped at cli boundary, but I don't think it would
worth inserting indirection just for that.

I made s/file_path/fs_path/ change because there's already to_fs_path()
function, and "file path" in RepoPath context may be ambiguous.
2022-10-22 12:40:43 +09:00
Yuya Nishihara
689332aedd file_util: move path handling functions from ui module
We'll need this kind of functions in the library crate to parse user file
patterns.
2022-10-22 12:40:43 +09:00
Benjamin Saunders
037eaaf36c repo: forbid checking out the root commit
Prevents `jj edit root` from succeeding, which would otherwise place
the repo in a state where every operation panics.
2022-10-21 10:10:07 -07:00
Benjamin Saunders
b009019d8d cli: add git remote rename subcommand 2022-10-20 11:04:16 -07:00
dependabot[bot]
f3a9b06cc8 cargo: bump serde_json from 1.0.86 to 1.0.87
Bumps [serde_json](https://github.com/serde-rs/json) from 1.0.86 to 1.0.87.
- [Release notes](https://github.com/serde-rs/json/releases)
- [Commits](https://github.com/serde-rs/json/compare/v1.0.86...v1.0.87)

---
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-10-20 09:35:30 -07:00
Benjamin Saunders
646fc338ab Include @ in the default revset
Yields a less confusing behavior of `jj log` after pushing a commit.
2022-10-19 13:30:16 -07:00
Martin von Zweigbergk
7bca6854a0 release: release version 0.5.1
This point of this release is just to trigger the release automation
on GitHub.
2022-10-17 22:00:29 -07:00
Martin von Zweigbergk
eda79bf7d3 release: release version 0.5.0
It's been several months since the last release and a lot has
changed. Probably the biggest change is that open commits are now
disabled by default.
2022-10-17 20:25:08 -07:00
dependabot[bot]
45e2f38bba cargo: bump serde_json from 1.0.85 to 1.0.86
Bumps [serde_json](https://github.com/serde-rs/json) from 1.0.85 to 1.0.86.
- [Release notes](https://github.com/serde-rs/json/releases)
- [Commits](https://github.com/serde-rs/json/compare/v1.0.85...v1.0.86)

---
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-10-10 10:56:04 -07:00
dependabot[bot]
7784be4200 cargo: bump uuid from 1.1.2 to 1.2.1
Bumps [uuid](https://github.com/uuid-rs/uuid) from 1.1.2 to 1.2.1.
- [Release notes](https://github.com/uuid-rs/uuid/releases)
- [Commits](https://github.com/uuid-rs/uuid/compare/1.1.2...1.2.1)

---
updated-dependencies:
- dependency-name: uuid
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-10-10 10:55:45 -07:00
Martin von Zweigbergk
6526b76ef0 cleanup: move default() functions to impl Default
As suggested by a newer version of Clippy.
2022-10-09 12:20:15 -07:00
Martin von Zweigbergk
d8c8283782 revset: wrap pest error in a Box, to keep type small
A newer version of Clippy starts complianing that the type is too
large (>=184 bytes) otherwise.
2022-10-09 12:20:15 -07:00
Martin von Zweigbergk
af4d183c7e cleanup: automated fixes by new Clippy version 2022-10-09 12:20:15 -07:00
Martin von Zweigbergk
043d118f1f cli: disallow initializing repo with native backend by default
The native backend is just a proof of concept and there's no real
reason to use it other than for testing, so let's reduce the risk of
accidentally creating repos using it.
2022-10-09 01:00:03 -07:00
Yuya Nishihara
45c4734b52 revset: fix parsing of concatenated-identifier in expression
Previously an expression 'foo-bar-' failed to parse because

 1. try first rule: 'foo-bar-' matches (identifier_part+ ~ '-')+, but the
    trailing '' doesn't match identifier_part+
 2. fall back to second rule: 'foo' matches identifier_part+
    => (identifier 'foo')

Instead, we need to consume as much (identifier_part ~ '-' ~ ...) as possible
before falling back to the identifier_part rule.

I think the trailing + of identifier_part+ is redundant, so removed it as
well.
2022-10-06 21:56:41 +09:00
Martin von Zweigbergk
43f0cddb1c cargo: enable only config crate's toml feature
I had intended for the `features = ["toml"]` to enable *only* the
`toml` feature, but I forgot to disable the default features so it had
no effect. This shrinks the binary from 17.4 MiB to 16.8 MiB.
2022-10-05 22:12:12 -07:00
dependabot[bot]
1e35a5eeee cargo: bump pest_derive from 2.3.1 to 2.4.0
Bumps [pest_derive](https://github.com/pest-parser/pest) from 2.3.1 to 2.4.0.
- [Release notes](https://github.com/pest-parser/pest/releases)
- [Commits](https://github.com/pest-parser/pest/compare/v2.3.1...v2.4.0)

---
updated-dependencies:
- dependency-name: pest_derive
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-10-04 22:49:29 -07:00
Yuya Nishihara
f5d0419384 working_copy: return {operation_id, workspace_id} by reference
Let WorkspaceCommandHelper clone it. WorkspaceCommandHelper could return
workspace_id by reference, but doing that would introduce noisy .clone()
calls and lifetime mess.
2022-10-03 21:41:20 -07:00
Yuya Nishihara
c0c1eade91 working_copy: use OnceCell to manage {operation_id, workspace_id}
For consistency with the tree_state handling. This isn't that simple and
concise compared to the tree_state one, so I'm fine to drop the series.

I've extracted {operation_id, workspace_id} pair so these values can be
safely initialized by OnceCell. The extracted struct is named after the
"checkout" file.
2022-10-03 21:41:20 -07:00
Yuya Nishihara
a2f750171a working_copy: remove redundant reload of checkout state on discard()
There's no way to mutate operation_id other than finish().
2022-10-03 21:41:20 -07:00
dependabot[bot]
b5e628ab07 cargo: bump pest from 2.3.1 to 2.4.0
Bumps [pest](https://github.com/pest-parser/pest) from 2.3.1 to 2.4.0.
- [Release notes](https://github.com/pest-parser/pest/releases)
- [Commits](https://github.com/pest-parser/pest/compare/v2.3.1...v2.4.0)

---
updated-dependencies:
- dependency-name: pest
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-10-03 08:56:24 -07:00
dependabot[bot]
53fc4a179c cargo: bump test-case from 2.2.1 to 2.2.2
Bumps [test-case](https://github.com/frondeus/test-case) from 2.2.1 to 2.2.2.
- [Release notes](https://github.com/frondeus/test-case/releases)
- [Changelog](https://github.com/frondeus/test-case/blob/master/CHANGELOG.md)
- [Commits](https://github.com/frondeus/test-case/compare/v2.2.1...v2.2.2)

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

Signed-off-by: dependabot[bot] <support@github.com>
2022-10-03 08:50:48 -07:00
Yuya Nishihara
1800354465 working_copy: remove .clone() from TreeState proxy methods
Let the caller .clone() as needed.
2022-10-02 22:46:09 +09:00
Yuya Nishihara
786e6211d8 working_copy: use OnceCell for lazy instantiation of TreeState
Here OnceCell<T> serves as RefCell<Option<T>>, but it doesn't require runtime
Ref/RefMut wrapper. This allows us to get rid of some .clone() calls needed to
hide Ref<_> from public interface.
2022-10-02 22:46:09 +09:00
Yuya Nishihara
4f72ec142d cargo: bump once_cell, add explicit dependency 2022-10-02 22:46:09 +09:00
Tal Pressman
621caa4dcb add default log revset configuration setting 2022-10-02 16:56:18 +09:00
Yuya Nishihara
dc9a9ed4c1 working_copy: on finish(), don't serialize checkout if operation_id is unchanged
Maybe it's okay to always save the checkout state, but let's apply the same
rule as the previous commit.
2022-10-02 15:15:18 +09:00
Yuya Nishihara
a8a3a236b0 working_copy: on finish(), don't serialize tree_state if known to be clean
This allows us to call locked_wc.finish() no matter if the tree is changed
or not.
2022-10-02 15:15:18 +09:00
Yuya Nishihara
e716fe7abf working_copy: remove return value from TreeState::snapshot()
I'll make TreeState::snapshot() return a boolean denoting whether tree_state
is updated or not. New tree_id can be obtained from TreeState, so let's
remove it from the return value.
2022-10-02 15:15:18 +09:00
Yuya Nishihara
9c33062d11 working_copy: clarify tree_state shouldn't be modified without mutable ref
While making tree_state() return RefMut<TreeState> instead of RefMut<Option<_>>,
I felt uncomfortable that tree_state(&self) returned a mutable reference. So
this patch splits it into tree_state() and tree_state_mut().
2022-10-02 15:15:18 +09:00
Martin von Zweigbergk
3b3f6129e6 backend: allow negative timestamps in commits and operations
I was reading a draft of "Git Rev News: Edition 91" [1] where Peff
mentions some unfinished patches to allow negative timestamps in
Git. So I figured I should add support for that before I forget. I
haven't checked if libgit2 supports it, so it might be that our Git
backend still doesn't support it after this patch.

 [1] https://github.com/git/git.github.io/blob/master/rev_news/drafts/edition-91.md
2022-09-30 00:50:17 -07:00
Martin von Zweigbergk
3fc7b549ec cleanup: rename some more variables from checkout_* to ~wc_ 2022-09-29 23:51:34 -07:00
dependabot[bot]
c06fbfa603 cargo: bump insta from 1.20.0 to 1.21.0
Bumps [insta](https://github.com/mitsuhiko/insta) from 1.20.0 to 1.21.0.
- [Release notes](https://github.com/mitsuhiko/insta/releases)
- [Changelog](https://github.com/mitsuhiko/insta/blob/master/CHANGELOG.md)
- [Commits](https://github.com/mitsuhiko/insta/commits)

---
updated-dependencies:
- dependency-name: insta
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-09-28 09:09:45 -07:00