Commit graph

608 commits

Author SHA1 Message Date
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