Commit graph

1717 commits

Author SHA1 Message Date
Waleed Khan
60f1d7e307 working_copy: create and propagate TreeStateError 2023-07-14 13:03:57 -07:00
dependabot[bot]
ddd6c3b27b cargo: bump the cargo-dependencies group with 1 update
Bumps the cargo-dependencies group with 1 update: [serde_json](https://github.com/serde-rs/json).

- [Release notes](https://github.com/serde-rs/json/releases)
- [Commits](https://github.com/serde-rs/json/compare/v1.0.100...v1.0.102)

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

Signed-off-by: dependabot[bot] <support@github.com>
2023-07-12 16:25:25 +00:00
Yuya Nishihara
ab2fa35a71 refs: stick to Option<CommitId> type while merging ref targets
This might look more complicated than the original code, but it clarifies
that we always eliminate a (remove, add) pair. The behavior slightly changed
since an absent ref (i.e. None) in "removes" can now be paired with an "add"
even if "removes" contained other ids. Before, it was possible only when
removes.is_empty().
2023-07-12 21:29:41 +09:00
Yuya Nishihara
424786def1 refs: leverage Conflict::flatten() and simplify() to premerge ref targets
The order of conflicted ids slightly changed since Conflict::simplify()
tries to preserve diff pairs. It shouldn't matter so long as the result is
stable.
2023-07-12 21:29:41 +09:00
Yuya Nishihara
ddaf226108 tests: make RefTarget::Conflict { .. } assertion not rely on id order
Here we don't need to care about the order at all. We have test_refs.rs
to ensure that the order is stable.
2023-07-12 21:29:41 +09:00
Yuya Nishihara
9f06bf8be5 repo: do not discard old working-copy commit if it's pointed by local branch
It would be confusing if a branch moved backwards by checking out unrelated
commit.

#1854
2023-07-12 21:29:11 +09:00
dependabot[bot]
78e9a1b34d cargo: bump the cargo-dependencies group with 1 update
Bumps the cargo-dependencies group with 1 update: [rustix](https://github.com/bytecodealliance/rustix).

- [Release notes](https://github.com/bytecodealliance/rustix/releases)
- [Commits](https://github.com/bytecodealliance/rustix/compare/v0.38.3...v0.38.4)

---
updated-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-07-11 19:24:06 +02:00
Yuya Nishihara
2bed9c9112 rewrite: do not insert "removed" refs to reverse branch lookup table
It should no longer be needed since e3254fa5c4 "rewrite: don't rewrite
the "removed" side of a branch conflict."
2023-07-11 19:42:40 +09:00
Yuya Nishihara
f5f61f6bfe revset: resolve "HEAD@git" just like other pseudo @git branches
I don't think this would be practically useful, but consistent UX is
important.

Fixes #1843
2023-07-11 16:29:27 +09:00
Yuya Nishihara
79955d9cb3 git: do not import/export local branch named "HEAD"
Git CLI rejects it (though the data model would probably work fine with
"HEAD" branch.) This ensures that HEAD@git in JJ world is not an exported
branch named "HEAD".
2023-07-11 16:29:27 +09:00
Yuya Nishihara
c1b87d4721 git: add logic to prevent invalid branch name from being exported
I also made remote HEAD branch banned to keep it sync with parse_git_ref().
2023-07-11 16:29:27 +09:00
dependabot[bot]
e618b2c14f cargo: bump the cargo-dependencies group with 3 updates
Bumps the cargo-dependencies group with 3 updates: [regex](https://github.com/rust-lang/regex), [serde](https://github.com/serde-rs/serde) and [tokio](https://github.com/tokio-rs/tokio).


Updates `regex` from 1.9.0 to 1.9.1
- [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.0...1.9.1)

Updates `serde` from 1.0.167 to 1.0.168
- [Release notes](https://github.com/serde-rs/serde/releases)
- [Commits](https://github.com/serde-rs/serde/compare/v1.0.167...v1.0.168)

Updates `tokio` from 1.28.2 to 1.29.1
- [Release notes](https://github.com/tokio-rs/tokio/releases)
- [Commits](https://github.com/tokio-rs/tokio/compare/tokio-1.28.2...tokio-1.29.1)

---
updated-dependencies:
- dependency-name: regex
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: cargo-dependencies
- dependency-name: serde
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: cargo-dependencies
- dependency-name: tokio
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: cargo-dependencies
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-07-10 17:19:33 +01:00
Waleed Khan
e445d36824 fix(docs): fix protobuf job build 2023-07-10 18:56:34 +03:00
Waleed Khan
54dba51a08 docs: warn about missing docs for jj-lib crate 2023-07-10 18:28:59 +03:00
Waleed Khan
24c7b59a80 docs: add docstring for jj-lib crate 2023-07-10 18:28:59 +03:00
Waleed Khan
80b86e653d docs: add missing copyright header 2023-07-10 18:28:59 +03:00
Ilya Grigoriev
d81c599153 clippy: fix nightly clippy warnings *except* for needless_raw_string_hashes
This is (almost) a result of running

    cargo +nightly clippy --workspace --all-targets --fix \
      --  -A 'clippy::needless_raw_string_hashes'

with yesterday's nightly clippy.

https://github.com/mitsuhiko/insta/issues/389 causes numerous additional
`needless_raw_string_hashes` warnings, but it will hopefully be fixed soon.
For now, I recommend appending the second line to your invocations.
2023-07-09 22:28:22 -07:00
Yuya Nishihara
9aa308fb4a revset: include pseudo @git remote in suggestion
Since collect_branch_symbols() doesn't have to be fast, I made it simply
build a new branches map.
2023-07-10 06:17:44 +09:00
Yuya Nishihara
528f6e23c1 refs: simplify inner loop of find_pair_to_remove() too 2023-07-10 06:14:47 +09:00
Yuya Nishihara
fe3be99f0d refs: directly assign ancestor (index, id) pair in find_pair_to_remove() 2023-07-10 06:14:47 +09:00
Yuya Nishihara
9140e5b686 conflicts: relax from_legacy_form() to accept any iterable
This will help to rewrite refs::merge_ref_targets() to leverage Conflict
type. I'm not pretty sure if we'll want to do that, but this change seems
also good for the existing code.
2023-07-10 06:14:47 +09:00
Yuya Nishihara
afb1e1693e conflicts: simplify inner loop of simplify() a bit 2023-07-10 06:14:47 +09:00
Martin von Zweigbergk
aac5b7aa25 cargo: rename crates from jujutsu/jujutsu-lib to jj-cli/jj-lib
Almost everyone calls the project "jj", and there seeems to be
consensus that we should rename the crates. I originally wanted the
crates to be called `jj` and `jj-lib`, but `jj` was already
taken. `jj-cli` is probably at least as good for it anyway.

Once we've published a 0.8.0 under the new names, we'll release 0.7.1
versions under the old names with pointers to the new crates names.
2023-07-09 06:40:43 +02:00
Yuya Nishihara
3e294ca2d6 revset: do not suggest deleted local branches, suggest @remote branches
It seemed too verbose to always include @remote branches, so synced remotes
are omitted by default. If the given symbol contained '@', all remote symbols
are populated so that the distance of remote fragment is taken into account.
2023-07-09 10:42:14 +09:00
Yuya Nishihara
4a5060a618 revset: don't resolve deleted branch symbol to empty set
A deleted branch disappears immediately if there's no remote counterpart,
so I don't think a local name should be resolvable like zombie.
2023-07-09 10:42:14 +09:00
Yuya Nishihara
5c1352d31c revset: add tests for branch symbol resolution
I'm going to fix resolution of remote-only branches. This also includes some
typo tests because I need to fix suggestion as well.
2023-07-09 10:42:14 +09:00
Yuya Nishihara
2606a1073d git: extract helper that merges pseudo @git targets in branches map 2023-07-09 10:39:43 +09:00
Yuya Nishihara
895ebef55c git: refactor git_ref_filter construction in fetch()
branch_name_filter() can be dynamically dispatched, but I think branching
by Some(regex)|None is simpler here.
2023-07-09 10:08:46 +09:00
Yuya Nishihara
a934547720 git: consistently ignore unrelated refs on fetch()
Since "jj git fetch --branch '*'" doesn't import unrelated remote and local
refs, "jj git fetch" shouldn't do either.
2023-07-09 10:08:46 +09:00
Yuya Nishihara
564506a7c7 tests: fix test_fetch_prune_deleted_ref() to set up refs on remote
This is broken since aa78f97d55 "git: refactor tests by extracting some
common setup."
2023-07-09 10:08:46 +09:00
Yuya Nishihara
a21397bfff git: move remove/rename remote logic to library
These functions are somewhat similar to git::import/export_refs() in that
git_refs and branches are manipulated.
2023-07-09 10:08:07 +09:00
Yuya Nishihara
f3d6616057 view: add default formatting to RefName, use it to print unexported branches 2023-07-09 00:51:15 +09:00
Waleed Khan
cf1e1ddc2e feat(fsmonitor): add watchman debug commands 2023-07-08 18:48:14 +03:00
Waleed Khan
ef83f2beeb feat(fsmonitor): Watchman filesystem monitor implementation 2023-07-08 18:48:14 +03:00
Waleed Khan
d8705644b5 refactor(repo_path): accept AsRef<Path> in RepoPath::parse_fs_path
Used in later commit.
2023-07-08 18:48:14 +03:00
Waleed Khan
de9cbace22 refactor(working_copy): create WorkItem struct 2023-07-08 18:48:14 +03:00
Waleed Khan
092dce0625 refactor(working_copy): create SnapshotOptions struct
Required in a later commit.
2023-07-08 18:48:14 +03:00
dependabot[bot]
22a84c8e97 cargo: bump the cargo-dependencies group with 2 updates
Bumps the cargo-dependencies group with 2 updates: [serde](https://github.com/serde-rs/serde) and [thiserror](https://github.com/dtolnay/thiserror).


Updates `serde` from 1.0.166 to 1.0.167
- [Release notes](https://github.com/serde-rs/serde/releases)
- [Commits](https://github.com/serde-rs/serde/compare/v1.0.166...v1.0.167)

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

---
updated-dependencies:
- dependency-name: serde
  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-07-07 17:52:36 +02:00
Yuya Nishihara
43aca696c8 templater: inline RefTarget::has_add()
Since RefTarget::adds() now returns a slice, we don't need has_add() to bypass
temporary allocation of Vec<CommitId>.
2023-07-08 00:06:07 +09:00
Martin von Zweigbergk
7bcb01ae5e conflicts: move repeated definition of c() in tests to module level
Also remove an obsolete "Irreducible" in a comment.
2023-07-07 16:42:07 +02:00
Martin von Zweigbergk
2bc58ebacf tree: avoid "file" in name of variables that can be non-files 2023-07-07 05:15:39 +02:00
Martin von Zweigbergk
76b1d53b1d tree: avoid redoing a RepoPath::join()
I also renamed the variable from `file` to `path` to clarify.
2023-07-07 05:15:39 +02:00
Martin von Zweigbergk
7e48033a65 tree: remove dir argument from TreeDiffIterator::new()
The argument is always the root directory.
2023-07-07 05:15:39 +02:00
Martin von Zweigbergk
1d8e9ec215 tree: inline two trivial functions 2023-07-07 05:15:39 +02:00
Martin von Zweigbergk
5da131f937 tree: add a Diff::from_options() constructor
I'm not sure `Diff` is worth keeping, but as long as we have, it seems
that it should have this constructor.
2023-07-06 15:19:58 +02:00
Martin von Zweigbergk
b738f884c4 tree: drop Diff::as_options(), use Diff::into_options() instead
We don't have any current callers that only have a reference to a
`Diff`, so we don't need `.as_options()`.
2023-07-06 15:19:58 +02:00
Martin von Zweigbergk
8af22eb83c working_copy: remove matching that's always against _ 2023-07-06 14:24:38 +02:00
Yuya Nishihara
868188c84e repo: handle empty .jj repo gracefully, include file path in error message 2023-07-06 20:48:46 +09:00
Yuya Nishihara
9560ca94c5 local_backend: remove global error conversion impls for BackendError
We don't care much about error handling in the local backend, but these
conversion impls are globally available and can be misused.
2023-07-06 20:48:46 +09:00
Yuya Nishihara
5346bd734f git_backend: translate io::Error of read_conflict() to ReadObject error
This is the last place in Git backend where io::Error is magically converted
to BackendError::Other.
2023-07-06 20:48:46 +09:00