Commit Graph

708 Commits

Author SHA1 Message Date
Martin von Zweigbergk
23f9e6479f working_copy: stop suppressing a warning that doesn't happen
We mutate the `new_file_state` variable on line 513 regardless of
platform these days, so we don't need to suppress the warning on Unix.
2022-05-25 11:51:18 -07:00
Martin von Zweigbergk
ecb86118e5 working_copy: get file metadata using open file descriptor
When we have just written a file or conflict, we can get metadata for
it via the open file descriptor instead of using the path. That
removes the risk of a race where the file got removed or replaced by
another file type (at least on Unix).
2022-05-25 11:51:18 -07:00
Martin von Zweigbergk
e7aaf2f95f working_copy: pass Metadata into file_state()
This is a refactoring to prepare for getting the metadata from an
already open file when possible.
2022-05-25 11:51:18 -07:00
Martin von Zweigbergk
d451242746 working_copy: propagate backend errors on checkout 2022-05-25 11:51:18 -07:00
Martin von Zweigbergk
899325e94e working_copy: use #[from] to slightly simplify error handling 2022-05-25 11:51:18 -07:00
Martin von Zweigbergk
9dbf32db3a settings: fix a clippy warning 2022-05-25 10:02:11 -07:00
Tal Pressman
9831b82a98 Add configuration option to override branch name prefix. 2022-05-26 00:41:52 +09:00
dependabot[bot]
044bc93aeb cargo: bump git2 from 0.14.2 to 0.14.4
Bumps [git2](https://github.com/rust-lang/git2-rs) from 0.14.2 to 0.14.4.
- [Release notes](https://github.com/rust-lang/git2-rs/releases)
- [Commits](https://github.com/rust-lang/git2-rs/compare/0.14.2...0.14.4)

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

Signed-off-by: dependabot[bot] <support@github.com>
2022-05-24 08:56:29 -07:00
Martin von Zweigbergk
45c9d297c2 drop: downgrade two assertions to error messages
These assertions were there to catch bugs, but when the bugs happen,
the assertions can obsure the underlying error (as @tp-woven found out
on #258). Let's just print errors instead.
2022-05-23 15:36:18 -07:00
dependabot[bot]
ca5a2391ab cargo: bump regex from 1.5.5 to 1.5.6
Bumps [regex](https://github.com/rust-lang/regex) from 1.5.5 to 1.5.6.
- [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.5...1.5.6)

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

Signed-off-by: dependabot[bot] <support@github.com>
2022-05-23 09:10:52 -07:00
Martin von Zweigbergk
5c6f82ec7b tests: remove &UserSettings argument from TestRepo::init()
We don't even have any settings that affect the repo, so there's no
point in passing the settings. I think this was a leftover from before
we separated out the "workspace" concept; now we no longer create a
working-copy commit when we initialize a repo (we do that when we
attach the workspace).
2022-05-21 22:33:16 -07:00
Martin von Zweigbergk
4cf04f373e tests: move init_{repo,workspace} functions onto types
I tried to create a `TestRepo` and was surprised that I couldn't do
that by calling a function on it.
2022-05-21 22:33:16 -07:00
Martin von Zweigbergk
6c6e6cb423 checkout: don't abandon old commit if it has non-empty description
If the user entered a description, we shouldn't abandon it even if it
has no changes to the content.
2022-05-21 22:12:15 -07:00
Martin von Zweigbergk
8f0c6a2fe9 cargo: use only "toml" feature from config crate
We don't need the `config` crate's support for JSON etc., so let's
just enable the TOML feature. (Trying to import all the JSON, RON,
dependencies etc. into Google's source control was a pain.)
2022-05-20 11:21:33 -07:00
dependabot[bot]
3750d1097b cargo: bump test-case from 2.0.2 to 2.1.0
Bumps [test-case](https://github.com/frondeus/test-case) from 2.0.2 to 2.1.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/v2.0.2...v2.1.0)

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

Signed-off-by: dependabot[bot] <support@github.com>
2022-05-18 08:49:45 -07:00
Martin von Zweigbergk
6c83eb6ae3 cli: teach log flag to show commits in reverse order
This adds a `--reversed` flag to `jj log` to show commits with later
commits further down. It works both with and without the graph.

Since the graph-drawing code is already independent of the
relationship between commits, it doesn't need any updating.
2022-05-15 05:17:54 -07:00
Martin von Zweigbergk
0747da0491 revset_graph_iterator: add a mode for generating reverse graph
The request to show the log output with more recent commits at the
bottom comes up once in a while (among Mercurial users, and now also
for jj from @arxanas). It's pretty easy to implement by adding an
adapter to the current `RevsetGraphIterator`. It works by first
collecting all nodes and edges into a vector and then yielding them in
reverse order and with reversed edges. That means it's no longer lazy,
but that seems fine since the feature is optional. Also, it's only the
subset of nodes that are in the selected revset that will be
collected.

Making the CLI use the new iterator adapter will come in a later
patch.
2022-05-15 05:17:54 -07:00
dependabot[bot]
f0b1a18a8e cargo: bump zstd from 0.11.1+zstd.1.5.2 to 0.11.2+zstd.1.5.2
Bumps [zstd](https://github.com/gyscos/zstd-rs) from 0.11.1+zstd.1.5.2 to 0.11.2+zstd.1.5.2.
- [Release notes](https://github.com/gyscos/zstd-rs/releases)
- [Commits](https://github.com/gyscos/zstd-rs/commits/v0.11.2)

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

Signed-off-by: dependabot[bot] <support@github.com>
2022-05-13 08:42:11 -07:00
Martin von Zweigbergk
866539f977 graphlog: use insta for tests
It's much easier to update the tests with `insta`.

It also presents you with the bad output including real newlines (a
diff, actually), so we can remove the `println!()` calls we had in
order to get readable output without escaped newlines.
2022-05-11 04:42:44 -07:00
Martin von Zweigbergk
b94c78545b protos: use run_from_script() in build.rs
`run_from_script()` is effectively the same as we did with `.expect()`
(print the error to stderr and exit with an error).
2022-05-05 11:46:40 -07:00
Martin von Zweigbergk
c1d0c08c03 protos: move protos.rs into src/protos/
It's easier to find the file this way and not forget that it's part of
the setup for building with protos.
2022-05-05 11:46:40 -07:00
Martin von Zweigbergk
a59724b082 protos: move .proto files to more conventional src/protos/ 2022-05-05 11:46:40 -07:00
Martin von Zweigbergk
ffc57310f6 cargo: upgrade protobuf crates to 3.0.1
The biggest difference in the API is that fields are now public. The
exception from that is `oneof` fields, which still require setters and
getters.

I couldn't measure any difference in performance. I didn't expect any
difference either, but it's good that it didn't seem to regress. I
timed `jj debug operation <some hash prefix>`, which will read the
whole operation log (to check that the prefix is unambiguous).
2022-05-04 17:02:11 -07:00
Martin von Zweigbergk
cba89886e5 cleanup: replace some for x in xs.iter() by for x in &xs 2022-05-04 17:02:11 -07:00
dependabot[bot]
8a6cf4bb3b cargo: bump serde_json from 1.0.80 to 1.0.81
Bumps [serde_json](https://github.com/serde-rs/json) from 1.0.80 to 1.0.81.
- [Release notes](https://github.com/serde-rs/json/releases)
- [Commits](https://github.com/serde-rs/json/compare/v1.0.80...v1.0.81)

---
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-05-04 08:58:48 -07:00
Martin von Zweigbergk
e4f83e353e errors: use custom error for failed tree merge
Tree merges can currently fail because of a failure to look up an
object, or because of a failure to read its contents. Both results in
`BackendError` because of a `impl From<std::io::Error> for
BackendError`. That's kind of correct in this case, but it wasn't
intentional (that impl was from `local_backend`), and we need to
making errors more specific for better error handling.
2022-05-03 06:52:00 -07:00
Martin von Zweigbergk
7268e5608e working_copy: propagate errors when snapshotting
Closes #258
2022-05-02 11:23:38 -07:00
dependabot[bot]
6649dbabae cargo: bump serde_json from 1.0.79 to 1.0.80
Bumps [serde_json](https://github.com/serde-rs/json) from 1.0.79 to 1.0.80.
- [Release notes](https://github.com/serde-rs/json/releases)
- [Commits](https://github.com/serde-rs/json/compare/v1.0.79...v1.0.80)

---
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-05-02 18:08:03 +00:00
dependabot[bot]
9ae642e11b cargo: bump thiserror from 1.0.30 to 1.0.31
Bumps [thiserror](https://github.com/dtolnay/thiserror) from 1.0.30 to 1.0.31.
- [Release notes](https://github.com/dtolnay/thiserror/releases)
- [Commits](https://github.com/dtolnay/thiserror/compare/1.0.30...1.0.31)

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

Signed-off-by: dependabot[bot] <support@github.com>
2022-05-02 09:46:59 -07:00
Martin von Zweigbergk
543a95c653 rewrite: propagate backend errors in DescendantRebase::rebase_next() 2022-05-02 08:05:24 -07:00
Martin von Zweigbergk
96b3e05bc5 working_copy: rename write_tree() to snapshot()
I think I copied the name `write_tree()` from Git, but I find it quite
confusing, since it's not clear if it write a tree to the working copy
or reads the working copy and writes a tree to the store (it's the
former).
2022-05-02 08:00:15 -07:00
Martin von Zweigbergk
90c8cb0cba errors: add a custom error type for StackedTable 2022-05-01 23:35:09 -07:00
Martin von Zweigbergk
89476261c0 cleanup: move {read,write}_conflict() methods earlier in Backend trait
The methods working on conflicts are more closely related to those
working on files and trees, so it makes sense for them to be closer.
2022-05-01 23:35:09 -07:00
Martin von Zweigbergk
5893b52fd1 cleanup: use while let Some(...) instead of checking before popping 2022-05-01 13:45:00 -07:00
Martin von Zweigbergk
23d37f9060 git_backend: delete obsolete (?) comment about not avoiding use of index
It seems to me that we have never created a Git index in order to
create a commit, not even in the earliest versions of the code (before
it was moved to Git).
2022-04-29 13:26:27 -07:00
Martin von Zweigbergk
dc32bb1f95 git: avoid creating a HashSet only to convert to a Vec 2022-04-28 22:46:50 -07:00
Martin von Zweigbergk
57ba9a9409 git: when importing refs, abandon commits that were abandoned in git
Now that I'm using GitHub PRs instead of pushing directly to the main
branch, it's quite annoying to have to abandon the old commits after
GitHub rebases them. This patch makes it so we compare the remote's
previous heads to the new heads and abandons any commits that were
removed on the remote. As usual, that means that descendants get
rebased onto the closest remaining commit.

This is half of #241. The other half is to detect rewritten branches
and rebase on top.
2022-04-28 11:28:09 -07:00
Martin von Zweigbergk
e3254fa5c4 rewrite: don't rewrite the "removed" side of a branch conflict
Let's say we have a simple history like this:

```
B C D
 \|/
  A
```

Branch `main` initially points to commit B. Two concurrent operations
then move the branch to commits C and D. When the two concurrent
operations get merged, the branch will be recorded as pointing to
"C+D-B". If a subsequent operation now abandons commit B, we would
update the "removed" side of the branch conflict. That seems a little
dishonest. I think the reason I did it that way was in order to not
keep B visible back when having it present in the "removed" side would
keep it visible (before 33bf6ce1d5).

I noticed this issue while working on #241 because
`test_import_refs_reimport()` started failing. That test case is
pretty much exactly the case above.
2022-04-28 11:28:09 -07:00
Martin von Zweigbergk
0789a8a4c0 revsets: allow single internal - and + characters in symbols (#46) 2022-04-28 08:14:15 -07:00
Martin von Zweigbergk
78da5596b7 working_copy: switch an if let Some() { } else { } to a match 2022-04-26 21:19:09 -07:00
Martin von Zweigbergk
0fbb1d3971 working_copy: don't visit whole ignored tree even if last in order
When committing the working copy, we try to not visit ignored
directories (as e.g. `target/` often is), but we need to visit it if
there are already tracked files in it. I initially missed that in
c1060610bd and then fixed it in a028f33e3b. The fix works by
checking if the next path after the ignored path is inside the ignore
path (viewed as a directory). However, I forgot to handle the case
where there are no paths at all after the ignored path. So, for
example, if the `target/` directory should be ignored and it there
were no tracked paths after `target/` in alphabetical order, we would
still visit the directory. That's why the bug reproduced in the
`git-branchless` repo but not in the `jj` repo (because there are
files under `testing/` and `tests/` here).

Closes #247.
2022-04-26 20:53:49 -07:00
Martin von Zweigbergk
18a64c365a working_copy: respect sparse patterns when writing tree (#52) 2022-04-26 14:52:17 -07:00
Martin von Zweigbergk
0d881de56c working_copy: allow updating sparse patterns (#52)
With this patch, we add support for setting the sparse patterns, and
we respect it when updating the working copy.
2022-04-26 14:52:17 -07:00
Martin von Zweigbergk
ceb6c152a1 working_copy: record sparse patterns in the tree state (#52)
This patch makes room for sparse patterns in the `TreeState` proto
message. We also start setting that value to a list of just the
pattern `.` when we create new working copies. Old working copies
without the sparse patterns are also interpreted as having that single
pattern. Note that this absence of sparse patterns is different from a
present list of no patterns. The latter is a valid state and means
that no paths are included in the sparse checkout.
2022-04-26 14:52:17 -07:00
Martin von Zweigbergk
ed2d2f8a4f working_copy: extract function for updating the working copy files (#52)
Updating the working copy with new sparse patterns is very similar to
updating it with a new tree. We're going to reuse this extracted
function soon.
2022-04-26 14:52:17 -07:00
Martin von Zweigbergk
cb0ab6b360 matchers: add composite matcher for differences (#52)
This adds a matcher that takes two input matchers and creates a new
matcher from them. The composite matcher matches paths matched by the
first matcher but not matched by the second matcher. I plan to use
this for sparse checkouts. They'll also be useful if we add support
for negative patterns to filter e.g. `jj files` by.
2022-04-26 14:52:17 -07:00
Martin von Zweigbergk
4c2c1fedff matchers: add a matcher not matching anything (#52)
It can be useful for at least testing purposes to have a matcher that
doesn't match any paths.
2022-04-26 14:52:17 -07:00
Martin von Zweigbergk
277b9bb08e matchers: let matchers indicate that directory matches recursively (#52)
Knowing that a matchers matches everything recursively from a certain
directory is useful for various optimizations. For example, it lets
you avoid visiting a directory if you're using a matcher with a
negative condition (so you return what does *not* match).
2022-04-26 14:52:17 -07:00
Tal Pressman
4a1576c874 Check SSH_AUTH_SOCK to determine existence of ssh-agent 2022-04-26 08:10:28 -07:00
Martin von Zweigbergk
023e3b7b90 git: fix an obsolete comment about a .jj/ path
The path to the file that indicates the last export to git was changed
when we added support for multiple workspaces.
2022-04-25 15:53:44 -07:00