Commit Graph

708 Commits

Author SHA1 Message Date
Martin von Zweigbergk
04f11c0dc3 rebase: update bookkeeping for branches as we rebase descendants
The `DescendantRebaser` keeps a map of branches from the source
commit, so it gets efficient lookup of branches to update when a
commit has been rebased. This map was not kept up to date as we
rebased. That could lead to branches getting left on hidden
intermediate commits. Specifically, if a commit with a branch was
rewritten by some command, and an ancestor of it was also rewritten,
then we'd only update the branch only the first step and not update it
again when rebasing onto the rewritten ancestor.
2022-04-25 14:05:27 -07:00
Martin von Zweigbergk
99d2ef8883 cleanup: simplify some uses of Option, mostly by using ? 2022-04-25 13:09:24 -07:00
Martin von Zweigbergk
3305e045ef cleanup: prefer Option<&T> over &Option<T>
It seems to me like `Option<&T>` is pretty much always better to
return than `&Option<T>`.
2022-04-25 13:09:24 -07:00
Martin von Zweigbergk
601638c422 op_heads_store: don't pass whole RepoLoader into get_heads()
We only need to be able to read operations, so it's better to pass in
just an `OpStore`.
2022-04-21 21:55:19 -07:00
Martin von Zweigbergk
21d8c501e3 cleanup: replace .tree().id() by tree_id() to avoid looking up trees 2022-04-21 21:54:52 -07:00
Martin von Zweigbergk
f5e9444456 cargo: upgrade uuid to 1.0.0 2022-04-20 14:18:59 -07:00
Martin von Zweigbergk
762c8984c6 trees: when merging trees and one is missing, treat it as empty
When a directory is missing in one merge input (base or one side), we
would consider that a merge conflict. This patch changes that so we
instead merge trees by treating the missing tree as empty.
2022-04-20 13:47:03 -07:00
Martin von Zweigbergk
53911b076b working_copy: fix crash when updating and only executable bit changed 2022-04-14 23:46:28 -07:00
dependabot[bot]
0a68670c30 cargo: bump config from 0.13.0 to 0.13.1
Bumps [config](https://github.com/mehcode/config-rs) from 0.13.0 to 0.13.1.
- [Release notes](https://github.com/mehcode/config-rs/releases)
- [Changelog](https://github.com/mehcode/config-rs/blob/master/CHANGELOG.md)
- [Commits](https://github.com/mehcode/config-rs/compare/0.13.0...0.13.1)

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

Signed-off-by: dependabot[bot] <support@github.com>
2022-04-14 08:57:35 -07:00
Martin von Zweigbergk
7e79f25508 revset: add a roots() function 2022-04-13 23:24:51 -07:00
Martin von Zweigbergk
9ff21d8924 revset: add a connected() function
This introduces a `connected(x)` function, which is simply the same as
`x:x`. It's occasionally useful if `x` is a long expression. It's also
useful as a building block for `root(x)` (coming soon).
2022-04-13 23:24:51 -07:00
Martin von Zweigbergk
fa6b14f166 revset: rename internal head() to visible_heads() 2022-04-13 23:24:51 -07:00
Martin von Zweigbergk
97a1a3e20b merge: fix modify/delete conflict to not resolve 2022-04-10 18:32:36 -07:00
Martin von Zweigbergk
5a77e88b94 cargo: specify MSRV (1.57 on lib and 1.58 on CLI) 2022-04-10 12:19:07 -07:00
dependabot[bot]
028e6106f5 cargo: bump config from 0.12.0 to 0.13.0
Bumps [config](https://github.com/mehcode/config-rs) from 0.12.0 to 0.13.0.
- [Release notes](https://github.com/mehcode/config-rs/releases)
- [Changelog](https://github.com/mehcode/config-rs/blob/master/CHANGELOG.md)
- [Commits](https://github.com/mehcode/config-rs/compare/0.12.0...0.13.0)

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

Signed-off-by: dependabot[bot] <support@github.com>
2022-04-04 09:06:47 -07:00
Martin von Zweigbergk
6efa47814a release: release version 0.4.0
This release is mostly about the fix for #177, which looks pretty bad
even though I think it is actually harmless. It also has `jj log -p`
contributed by @yuja!
2022-04-02 23:35:15 -07:00
Martin von Zweigbergk
16994308fa git: remove code for upgrading from Git notes 2022-03-31 13:32:43 -07:00
Martin von Zweigbergk
600aad62f4 tests: extract some variables for repeated expressions 2022-03-31 10:23:33 -07:00
Martin von Zweigbergk
f16d2a237b backend: pass in path when reading/writing conflicts as well
We do it for all the other kinds of objects already. It's useful to
have the path for backends that store objects by path (we don't have
any such backends yet). I think the reason I didn't do it from the
beginning was because we had separate `RepoPath` types for files and
directories back then.
2022-03-31 10:23:33 -07:00
Martin von Zweigbergk
fd5bc7966c tests: pass around &RepoPath instead of &str in working copy test
This is a leftover from when there were separate `RepoPath` types for
directories and files.
2022-03-31 10:23:33 -07:00
Martin von Zweigbergk
a9d1b16937 workspace: canonicalize workspace and repo paths internally
We depend on comparing the workspace root with the Git repo's path to
know if we're sharing the working copy with it. For that to work
reliably, we need the paths to be canonicalized, so that's what this
patch tries to do.
2022-03-30 22:09:55 -07:00
Martin von Zweigbergk
6cd4e03c25 cleanup: use canonicalize() method instead of free function
I had somehow not noticed that `Path` and `PathBuf` have
`canonicalize()` methods. Using them saves a few characters of code.
2022-03-30 22:09:55 -07:00
dependabot[bot]
d8b7d2269d cargo: bump test-case from 2.0.1 to 2.0.2
Bumps [test-case](https://github.com/frondeus/test-case) from 2.0.1 to 2.0.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.0.1...v2.0.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-03-28 08:53:04 -07:00
Martin von Zweigbergk
662297acc3 tests: add test for delete/modify branch-conflict case (#32)
There was a TODO about adding a test case for a delete/modify conflict
in a branch target that got resolved by abandoning a commit. The
resolution is to delete the branch. That case couldn't happend with
our old evolution-based mechanism for tracking rewrites (because we
couldn't un-prune a commit then).
2022-03-27 21:11:55 -07:00
Martin von Zweigbergk
12bce70bed cli: display how many commits were rebased when merging operations (#111)
This involved copying `UnresolvedHeadRepo::resolve()` into the CLI
crate (and modifying it a bit to print number of rebased commit),
which is unfortunate.
2022-03-26 22:31:49 -07:00
Martin von Zweigbergk
f7abeed2a6 transaction: move rebasing of descendants out of merge_operation() (#111)
I want to do the rebasing a bit later, so the CLI can do it and print
how many commits got rebased.
2022-03-26 22:31:49 -07:00
Martin von Zweigbergk
a0f05a60e4 repo: inline merge_op_heads() (#111)
The function is now pretty simple, and there's only one caller, so
let's inline it. It probably makes sense to move the code out of
`repo.rs` at some point.
2022-03-26 22:31:49 -07:00
Martin von Zweigbergk
d45a25b1ee op_heads_store: return operations sorted by timestamp (#111)
It's cheap to sort them, so let's have them always sorted, so all
callers can rely on that order.
2022-03-26 22:31:49 -07:00
Martin von Zweigbergk
d62cc15ff0 repo: move merge with operation to transaction (#111)
It's the transaction's job to create a new operation, and that's where
the knowledge of parent operations is. By moving the logic for merging
in another operation there, we can make it contiuously update its set
of parent operations. That removes the risk of forgetting to add the
merged-in operation as a parent. It also makes it easier to reuse the
function from the CLI so we can inform the user about the process
(which is what I was investigating when I noticed that this cleanup
was possible).
2022-03-26 22:31:49 -07:00
Martin von Zweigbergk
4d64687bc3 transaction: keep whole operation objects, not just IDs, of parents (#111)
We already have the operation objects, and keeping them will allow
some cleanup (see next change).
2022-03-26 22:31:49 -07:00
Martin von Zweigbergk
04ad9a3628 repo: when merging in removed head, rebase descendants (#111) 2022-03-26 22:31:49 -07:00
Martin von Zweigbergk
ec84de7779 repo: clarify that some repo functions load the repo at head (#111) 2022-03-26 22:31:49 -07:00
Martin von Zweigbergk
a38dd9d693 repo: make resolution of concurrent operations a separate step (#111)
This is yet another refactoring step to allow the UI layer to inspect
and control how concurrent operations are resolved.
2022-03-26 22:31:49 -07:00
Martin von Zweigbergk
e384f97b20 transaction: check that we haven't forgotten to rebase descendants (#111)
If we have recorded in `MutableRepo` that commits have been abandoned
or rewritten, we should always rebase descendants before committing
the transaction (otherwise there's no reason to record the
rewrites). That's not much of a risk in the CLI because we already
have that logic in a central place there (`finish_transaction()`), but
other users of the library crate could easily miss it. Perhaps we
should automatically do any necessary rebasing we commit the
transaction in the library crate instead, but for now let's just have
a check for that to catch such bugs.
2022-03-26 22:31:49 -07:00
Martin von Zweigbergk
eb333dc07d cli: move optimization for no-op rebases into MutableRepo (#111)
Certain commands should never rewrite commits, or they take care of
rebasing descendants themselves. We have an optimization in
`commands.rs` for those commands, so they skip the usual automatic
rebasing before committing the transaction. That's risky to have to
remember and `MutableRepo` already knows if any commits have been
rewritten (that wasn't the case before, in the Evolution-based
code). So let's just have `MutableRepo` do the check instead.
2022-03-26 22:31:49 -07:00
Martin von Zweigbergk
11525bfba0 repo: move resolving of concurrent operations to repo level (#111)
It's useful for the UI layer to know that there's been concurrent
operations, so it can inform the user that that happened. It'll be
even more useful when we soon start making the resolution involve
rebasing commits, since that's even more important for the UI layer to
present to the user. This patch gets us a bit closer to that by moving
the resolution to the repo level.
2022-03-26 22:31:49 -07:00
Martin von Zweigbergk
364f8010e7 op_heads_store: remove Result that never fails (#111) 2022-03-26 22:31:49 -07:00
Martin von Zweigbergk
40aa9741ec op_heads_store: move lock and updating of heads on disk to new type (#111)
We had a few lines of similar code where we added a new of the
operation log and then removed the old heads. By moving that code into
a new type, we prepare for further refactorings.
2022-03-26 22:31:49 -07:00
Martin von Zweigbergk
39838a76bf view: move merging of views up to repo level (#111)
I want to make it so when we apply a repo-level change that removes a
head, we rebase descendants of that head onto the closes visible
ancestor, or onto its successor if the head has been rewritten (see
#111 for details). The view itself doesn't have enough information for
that; we need repo-level information (to figure out relationships
between commits).

The view doesn't have enough information to do the.
2022-03-26 22:31:49 -07:00
Martin von Zweigbergk
a663a5d89c repo: don't abandon empty commit if it has descendants
It's unusual for the current commit to have descendants, but it can
happen. In particular, it can easily happen when you run `jj new`. You
probably don't want to abandon it in those cases.
2022-03-26 21:11:42 -07:00
Martin von Zweigbergk
1d3f909a3b config: move reading of config from lib crate to CLI crate
The library crate should be usable by e.g. server processes, so it
should not read from the current user's home directory.
2022-03-23 09:57:42 -07:00
dependabot[bot]
302b4025d5 cargo: bump test-case from 2.0.0 to 2.0.1
Bumps [test-case](https://github.com/frondeus/test-case) from 2.0.0 to 2.0.1.
- [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.0.0...v2.0.1)

---
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-03-22 09:33:22 -07:00
Martin von Zweigbergk
3f24411bbf cargo: upgrade the config crate from 0.11.0 to 0.12.0
This required a bit of work.
2022-03-18 22:33:04 -07:00
dependabot[bot]
30e3685f5e cargo: bump regex from 1.5.4 to 1.5.5
Bumps [regex](https://github.com/rust-lang/regex) from 1.5.4 to 1.5.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.5.4...1.5.5)

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

Signed-off-by: dependabot[bot] <support@github.com>
2022-03-16 22:57:09 -07:00
dependabot[bot]
f14b1260e5 cargo: bump rand from 0.8.4 to 0.8.5
Bumps [rand](https://github.com/rust-random/rand) from 0.8.4 to 0.8.5.
- [Release notes](https://github.com/rust-random/rand/releases)
- [Changelog](https://github.com/rust-random/rand/blob/master/CHANGELOG.md)
- [Commits](https://github.com/rust-random/rand/compare/0.8.4...0.8.5)

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

Signed-off-by: dependabot[bot] <support@github.com>
2022-03-16 22:27:45 -07:00
dependabot[bot]
a8f881b84c cargo: bump test-case from 1.2.3 to 2.0.0
Bumps [test-case](https://github.com/frondeus/test-case) from 1.2.3 to 2.0.0.
- [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/v1.2.3...v2.0.0)

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

Signed-off-by: dependabot[bot] <support@github.com>
2022-03-16 22:07:44 -07:00
dependabot[bot]
c8b32238f9 cargo: bump zstd from 0.10.0+zstd.1.5.2 to 0.11.1+zstd.1.5.2
Bumps [zstd](https://github.com/gyscos/zstd-rs) from 0.10.0+zstd.1.5.2 to 0.11.1+zstd.1.5.2.
- [Release notes](https://github.com/gyscos/zstd-rs/releases)
- [Commits](https://github.com/gyscos/zstd-rs/commits)

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

Signed-off-by: dependabot[bot] <support@github.com>
2022-03-16 21:52:29 -07:00
dependabot[bot]
65bc87f57d cargo: bump serde_json from 1.0.78 to 1.0.79
Bumps [serde_json](https://github.com/serde-rs/json) from 1.0.78 to 1.0.79.
- [Release notes](https://github.com/serde-rs/json/releases)
- [Commits](https://github.com/serde-rs/json/compare/v1.0.78...v1.0.79)

---
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-03-16 21:52:06 -07:00
dependabot[bot]
fae61bad79 cargo: bump blake2 from 0.10.2 to 0.10.4
Bumps [blake2](https://github.com/RustCrypto/hashes) from 0.10.2 to 0.10.4.
- [Release notes](https://github.com/RustCrypto/hashes/releases)
- [Commits](https://github.com/RustCrypto/hashes/commits)

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

Signed-off-by: dependabot[bot] <support@github.com>
2022-03-16 21:51:29 -07:00
Martin von Zweigbergk
168d986827 release: bump version to 0.3.3 (skipping 0.3.2)
I forgot to bump the version to 0.3.2 before tagging and releasing it,
so the released 0.3.2 has version number 0.3.1 in the source code and
(therefore) reported from `jj --version`. I'm therefore bumping it
from 0.3.1 to 0.3.3 now, so there can be a matching 0.3.3 release.
2022-03-16 12:20:52 -07:00
Martin von Zweigbergk
794e956a84 release: bump version to 0.3.1
This release is just to get #131 out and to see if the automated
release builds work now that we use a vendored OpenSSL from libgit2.
2022-03-13 21:49:09 -07:00
Martin von Zweigbergk
cac93e2793 cargo: use libgit2 with vendored OpenSSL (#73)
I was able to build a working musl binary with this change, by running
this command:

```
cargo build --release --target x86_64-unknown-linux-musl
```

Thanks to @arxanas for the tip.
2022-03-13 21:34:07 -07:00
Martin von Zweigbergk
8f4949d2e4 release: bump version to 0.3.0
There's been *a lot* of changes since 0.2.0 almost a year ago. With
the attention the project has gotten recently, I feel like I should
cut a new release and start keeping a changelog. So let's start by
bumping the version to 0.3.0.
2022-03-12 23:03:01 -08:00
Martin von Zweigbergk
d56ae79d3f working_copy: let caller pass in base Git ignores (#65, #87)
The library crate shouldn't look up the user's `$HOME` directory
(maybe the library is used by a server process), so let's have the
caller pass it into the library crate instead.
2022-03-12 10:48:06 -08:00
Martin von Zweigbergk
51da2a2dc1 gitignore: move function for chaining .gitignore to central place (#65, #87)
I want to be able to reuse the code for chaining two `.gitignore`
files outside of `working_copy.rs`.
2022-03-12 10:48:06 -08:00
Martin von Zweigbergk
e7a7cb8ea5 gitignores: remove error type that's never instantiated 2022-03-12 10:48:06 -08:00
Martin von Zweigbergk
6fabf89529 diff: add helpers for finding index for non-base side
We have some repeated code doing `wrapping_add()`, so let's add
helpers to reduce repetition.
2022-03-10 22:00:45 -08:00
Martin von Zweigbergk
a9eebe779e tests: set user and email in e2e tests
We don't display the user and email yet, so the only visible effect
this has on the tests is that some hashes change.
2022-03-10 12:38:07 -08:00
Martin von Zweigbergk
9702684a4d settings: read and parse timestamp from config only once 2022-03-10 12:38:07 -08:00
Martin von Zweigbergk
18861c67c3 settings: allow setting author/commit timestamp via config
I'm not sure it'll be useful, but it seems nice to be able to set the
same values via config or environment variables. Perhap we should
simply use `config::Environment` to make everything configurable via
environment variables, but I'll leave that for later.
2022-03-10 12:38:07 -08:00
Martin von Zweigbergk
e0115d2af7 commit_builder: move signature() to UserSettings
It's useful to have `signature()` live on `UserSettings` because that
will let us cache information (such as the timestamp) in the
instance. It will also make it easier to have the timestamp settable
via regular config files. I don't know that that will be useful, but
it seems like a clean way of implementing it if we can have
environment variables simply as an overlay of configs.
2022-03-10 12:38:07 -08:00
Martin von Zweigbergk
fc1731a180 diff: switch from BTreeMap to sorted Vec for unchanged ranges
We don't really need a BTreeMap for keeping the unchanged ranges. The
only place it helps a bit is when refining a diff because we may then
insert some more unchanged ranges in the list. I think there has to be
very many unchanged ranges for that to matter, however. This patch
therefore replace the BTreeMap by a sorted Vec. `cargo bench` says
that a few tests got ~20% faster.

I'm looking into this code now because I'm thinking of copying some of
it for the "partial conflict resolution" tool I'm working on for
Mercurial.
2022-03-10 00:33:17 -08:00
Martin von Zweigbergk
934564bf8d diff: also sort base ranges by end point
I wanted to replace the BTreeMap by a Vec and noticed that we actually
sometimes end up having a `0..n` range followed by a `0..0` after
refinement. We currently compare those two as equal because I had not
thought that we could end up attempting to add two ranges with the
same start point. When trying to insert the second range (`0..0`), the
BTreeMap will keep the existing key (`0..n`) and replace the
value. That's probably works, but it's clearly not what I
intended. Let's fix by sorting by the end point if the start point is
equal. This actually improves some benchmarks by a few percent (maybe
because the subsequent compaction can then remove the `0..0` range).
2022-03-10 00:33:17 -08:00
Martin von Zweigbergk
42252a2f00 cli: on jj init --git-repo=., use relative path to .git/
When the backing Git repo is inside the workspace (typically directly
in `.git/`), let's point to it by a relative path so the whole
workspace can be moved without breaking the link.

Closes #72.
2022-03-05 09:37:48 -08:00
Martin von Zweigbergk
0c6d89581e tests: pass timestamps via env vars for reproducible hashes
This patch introduces a `JJ_TIMESTAMP` environment variable that lets
us specify the timestamp to use in tests. It also updates the tests to
use it, which means we get to simplify the tests a lot now that that
the hashes are predictable.
2022-03-05 08:48:42 -08:00
Martin von Zweigbergk
648cfd698c cleanup: run rustfmt 2022-02-27 10:59:28 -08:00
Cole Mickens
fbe8eb47db lib/settings: try to load from platform config_dir 2022-02-26 00:09:34 -08:00
Waleed Khan
76974a9050 build: suppress unstable_name_collisions warnings on stable
Originally, I had thought that these warnings would only potentially show up in nightly because there was a feature which exposed these functions, and we would be able to enable that feature and conditionally not define the conflicting methods. But it looks like these warnings also show up in stable. I've just suppressed each of them individually. Other options would be to rename them and just make them wrapper methods, or to disable `unstable_name_collisions` warnings at a higher scope (possibly including at the crate level).
2022-02-23 23:41:55 -08:00
Waleed Khan
9202aae8b1 build: conditionally use map_first_last feature if available 2022-02-20 22:21:14 -08:00
Waleed Khan
dd3272fe90 build: use assert_matches crate
The `assert_matches` feature is nightly-only, so use this crate as a shim.
2022-02-20 22:21:14 -08:00
Waleed Khan
75480c2bdc build: migrate diff_bench to criterion
Benchmarking is currently nightly-only, so to get `jujutsu` to build on stable, we need to use a stable benchmarking library.
2022-02-20 22:21:14 -08:00
Waleed Khan
261cd1a1c4 build: add shims for nightly feature map_first_last 2022-02-20 22:16:07 -08:00
Martin von Zweigbergk
108b785a36 cli: don't panic on invalid config
If `~/.jjconfig` is invalid, we currently simply panic. That results
in a poor error message. We should handle the error instead.

Closes #55.
2022-02-19 23:38:23 -08:00
Martin von Zweigbergk
7c247116b9 repo: remove code for upgrading old repos to have .jj/store/git/
1b6efdc3f8 moved `.jj/git/` into `.jj/store/` for consistency with
the layout of native stores. It provided automatic format upgrades for
repos with the old format. It's been about four months now, so let's
remove the migration code.
2022-02-17 22:44:05 -08:00
Martin von Zweigbergk
03e6b8c0e6 working_copy: take Tree, not CommitId, as argument to check_out()
We no longer need the commit ID, so we shouldn't make the callers pass
it. This lets us simplify several tests, because they no longer to
create commits just to check out a tree in the working copy.
2022-02-13 12:14:34 -08:00
Martin von Zweigbergk
315e5e87a3 working_copy: take a tree object instead of ID in TreeState::check_out()
The callers mostly have the tree object available anyway.
2022-02-13 12:12:08 -08:00
Martin von Zweigbergk
00c9a1ae11 working_copy: stop taking commit ID in LockedWorkingCopy::finish()
We used to use the value to detect races, but we use the tree ID and
the operation ID these days, so we don't need the commit ID.

By changing this, we can avoid creating some commit IDs in tests,
which is why I tackled this issue now.
2022-02-12 23:48:06 -08:00
Martin von Zweigbergk
cde3609163 working_copy: stop taking initial checkout in constructor
We don't use the value anymore.
2022-02-12 23:45:05 -08:00
Martin von Zweigbergk
993de96fc7 working_copy: stop keeping track of commit ID 2022-02-12 17:22:37 -08:00
Martin von Zweigbergk
e098c01935 working_copy: replace commit ID by tree ID for checking for changes
What matters for the working copy is the tree ID. We should be able to
remove the commit ID. This patch gets us close.
2022-02-12 17:16:19 -08:00
Martin von Zweigbergk
537b1de7d9 working_copy: move check of old commit ID on checkout to higher level
There are only two callers of `LockedWorkingCopy::check_out()`. One is
in `commands.rs`. That caller already checks after taking the lock
that the old commit ID is as expected. The other caller is
`WorkingCopy::check_out()`. We can simply move the check to that level
since it's the only caller that cares now.
2022-02-12 14:27:40 -08:00
Martin von Zweigbergk
be7b0e6839 cargo: upgrade dependencies 2022-02-09 22:21:39 -08:00
Martin von Zweigbergk
117bf13708 cargo: upgrade backoff 2022-02-09 22:21:39 -08:00
Martin von Zweigbergk
33cc6b1253 cargo: upgrade blake2 2022-02-09 22:19:04 -08:00
Martin von Zweigbergk
dabfd04da6 tests: attempt to de-flake operation-merging test
We resolve checkouts in favor of the first-committed operation (which
is more likely to have managed to update the working copy). The test
case has been flaky on GitHub lately. I've run it 1000 times on my
machine without failure. I don't know if GitHub's machines are just
faster in some way (SSD, maybe) that makes them finish the two
operations in the test in the same millisecond. Let's add a
1-millisecond sleep to see if that helps. If it doesn't, then maybe
the issue is that the clock has lower precision (or their clocks can
go backwards?).
2022-02-09 11:15:10 -08:00
Martin von Zweigbergk
b74851e005 working_copy: make sure discarded update is not visible
`LockedWorkingCopy::discard()` shouldn't result in changes to the
on-disk state, but `LockedWorkingCopy::check_out()` may have already
written a state file, which is surprising. The changes also remain in
memory, which is also surprising. Let's fix both of those issues.
2022-02-09 10:40:51 -08:00
Martin von Zweigbergk
d24cf15f2d tests: in .gitignore test, explicitly save working copy state
One of the .gitignore tests writes a tree from the working copy
twice. However, it discards the `LockedWorkingCopy` instance after the
first write, so the second write shouldn't really see the changes from
the first write. It does see them because we don't clear them in
memory (and we also surprisingly write them to disk). I'm about to fix
that, so the test needs to be fixed first.
2022-02-09 10:34:52 -08:00
Martin von Zweigbergk
cce12261d8 matchers: add a matcher for path prefixes (#52)
It's useful to be able to match path prefixes for many commands,
e.g. to allow `jj restore src` to restore all files in under `src/`
(or a file called `src`). I also plan to use it for sparse checkouts.

We'll need to be able to match path prefixes
2022-02-06 14:49:22 -08:00
Martin von Zweigbergk
d49892431b matchers: make visit() return cloned sets instead of references
This is just to avoid the lifetime parameter. It was a premature
optimization to return a reference (we don't even use the matchers
yet, so it cloning these sets clearly doesn't show up in profiling).
2022-02-05 20:24:53 -08:00
Martin von Zweigbergk
3c787459dc tests: remove a leftover removal of a checkout in a revset test
The test setup no longer attaches a workspace to the repo, so there's
also no need remove it.
2022-02-05 20:11:50 -08:00
Martin von Zweigbergk
f294df6e8e view: inline checkout() into remaining few callers 2022-02-05 15:43:37 -08:00
Martin von Zweigbergk
9b275a406c tests: don't create workspaces in CommitBuilder tests 2022-02-05 15:39:03 -08:00
Martin von Zweigbergk
980e80618c tests: don't create workspaces in conflict tests 2022-02-05 15:39:03 -08:00
Martin von Zweigbergk
2af6b4c58d tests: don't create workspaces in operation tests 2022-02-05 15:35:59 -08:00
Martin von Zweigbergk
2eb46fda8a tests: don't create workspaces in diff-summary tests 2022-02-05 15:31:09 -08:00
Martin von Zweigbergk
978cafe387 tests: don't create workspaces in RevsetGraphIterator tests 2022-02-05 15:30:27 -08:00
Martin von Zweigbergk
214c0793b0 tests: don't create workspaces in MutableRepo tests 2022-02-05 15:27:02 -08:00
Martin von Zweigbergk
10fbe2cb55 tests: don't create workspaces in revset tests 2022-02-05 15:13:07 -08:00
Martin von Zweigbergk
8d5587355b tests: don't create workspaces in rewrite tests 2022-02-05 15:02:10 -08:00
Martin von Zweigbergk
fbc13440a1 tests: don't create workspaces in tree-merge tests 2022-02-05 13:47:48 -08:00