Commit Graph

727 Commits

Author SHA1 Message Date
Martin von Zweigbergk
2c21ed40d8 working_copy: don't crash if file becomes directory while snapshotting
If a file gets replaced by a directory right after list files in a
directory but before we stat the file, we currently crash. Let's
instead treat it as a missing file, using the mechanism introduced for
#258.
2022-06-21 05:38:28 +07:00
dependabot[bot]
0c3334e4e4 cargo: bump insta from 1.14.1 to 1.15.0
Bumps [insta](https://github.com/mitsuhiko/insta) from 1.14.1 to 1.15.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/compare/1.14.1...1.15.0)

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

Signed-off-by: dependabot[bot] <support@github.com>
2022-06-21 04:10:57 +07:00
Martin von Zweigbergk
29a71c619a working_copy: ignore special files
This patch makes us treat special files (e.g. Unix sockets) as absent
when snapshotting the working copy. We can consider later reporting
such files back to the caller (possibly via callback) so it can inform
the user about them.

Closes #258
2022-06-20 09:26:29 +07:00
Martin von Zweigbergk
a42b24c014 working_copy: on checkout, record file state's type and size
This patch is essentially f6a516ff6d taken further, to also apply to
when we write a symlink or a conflict. As with regular files, these
races seem very unlikely to happen, but I found these cases while
working on #258, so let's fix. Fixing it also means that we don't need
to handle these transition cases in the next patch (when
`file_states()` can indicate that the file is e.g. a socket).
2022-06-20 09:26:29 +07:00
dependabot[bot]
2716f17d71 cargo: bump uuid from 1.1.1 to 1.1.2
Bumps [uuid](https://github.com/uuid-rs/uuid) from 1.1.1 to 1.1.2.
- [Release notes](https://github.com/uuid-rs/uuid/releases)
- [Commits](https://github.com/uuid-rs/uuid/compare/1.1.1...1.1.2)

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

Signed-off-by: dependabot[bot] <support@github.com>
2022-06-13 10:06:25 -07:00
Martin von Zweigbergk
e8e03880cf matchers: add IntersectionMatcher
I plan to use this matcher for some future `jj add` command (for
#323). The idea is that we'll do a path-restricted walk of the working
copy based on the intersection of the sparse patterns and any patterns
specified by the user. However, I think it will be useful before that,
for @arxanas's fsmonitor feature (#362).
2022-06-09 21:27:51 -07:00
Martin von Zweigbergk
4fda0f8b6a matchers: simplify DifferenceMatcher slightly
The new `Visit::Nothing` variant lets us more easily restructure
`DifferenceMatcher::visit()` to make it handle the case of not
removing anything. I think this makes the code a little clearer.
2022-06-09 21:27:51 -07:00
Martin von Zweigbergk
169261ca21 matchers: add a Visit::Nothing variant
I didn't initially create a `Visit::Nothing` variant because I was
worried that the fact that there then are two ways of expressing this
value (there's also `Visit::Specific` with empty sets). However, the
value is quite useful for pattern matching, so I'm now thinking it's
worth the risk.
2022-06-09 21:27:51 -07:00
Martin von Zweigbergk
bcf94bd70e CommitBuilder: when rewriting commit, replace placeholder user/email
If a commit's author field has the placeholder user/email values
(i.e. "(no name configured)" and "(no email configured)"), and they
have now configured their email and username, they probably want us to
update the author field with the new information, so that's what this
patch does. Thanks to durin42@ for the suggestion on #322.
2022-06-06 17:31:01 -07:00
dependabot[bot]
1e87edb917 cargo: bump uuid from 1.1.0 to 1.1.1
Bumps [uuid](https://github.com/uuid-rs/uuid) from 1.1.0 to 1.1.1.
- [Release notes](https://github.com/uuid-rs/uuid/releases)
- [Commits](https://github.com/uuid-rs/uuid/compare/1.1.0...1.1.1)

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

Signed-off-by: dependabot[bot] <support@github.com>
2022-06-01 09:07:34 -07:00
dependabot[bot]
f6e95decb4 cargo: bump insta from 1.14.0 to 1.14.1
Bumps [insta](https://github.com/mitsuhiko/insta) from 1.14.0 to 1.14.1.
- [Release notes](https://github.com/mitsuhiko/insta/releases)
- [Changelog](https://github.com/mitsuhiko/insta/blob/master/CHANGELOG.md)
- [Commits](https://github.com/mitsuhiko/insta/compare/1.14.0...1.14.1)

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

Signed-off-by: dependabot[bot] <support@github.com>
2022-05-31 09:09:14 -07:00
Martin von Zweigbergk
8ae9540f2c cli: make move/squash/unsquash keep empty working-copy commit
If the source commit becomes empty as a result of
`move/squash/unsquash`, we abandon it. However, perhaps we shouldn't
do that if the source commit is a working-copy commit because
working-copy commits are often work-in-progress commits.

The background for this change is that @arxanas had just started a new
change and had set a description on it, and then decided to make some
changes in the working copy that should be in the parent
commit. Running `jj squash` then abandoned the working-copy commit,
resuling in the description getting lost.
2022-05-30 07:52:24 -07:00
Martin von Zweigbergk
540f2eb583 errors: avoid using Debug formatting on error types
The regular `Display` format is (not surprisingly) more user-friendly,
as pointed out by @yuja.

I also switched to using format strings for these cases, and some
nearby strings for consistency.
2022-05-25 19:33:59 -07:00
dependabot[bot]
ee87215e1c cargo: bump uuid from 1.0.0 to 1.1.0
Bumps [uuid](https://github.com/uuid-rs/uuid) from 1.0.0 to 1.1.0.
- [Release notes](https://github.com/uuid-rs/uuid/releases)
- [Commits](https://github.com/uuid-rs/uuid/compare/1.0.0...1.1.0)

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

Signed-off-by: dependabot[bot] <support@github.com>
2022-05-25 12:25:15 -07:00
Martin von Zweigbergk
c9ab0a20d3 working_copy: stat path without traversing from root in one case
We can easily make the `DirEntry` available here, so we can call
`.metadata()` on that instead of on the `Path`. I think that avoids
walking the path. I'm sure this has no significant impact on
performance, but it's also almost as readable.
2022-05-25 11:51:18 -07:00
Martin von Zweigbergk
f6a516ff6d working_copy: record expected written size, not actual size, on checkout
When we have just written a file to disk on checkout, let's record the
size we expected instead of what we got from `fstat()`. This should
address a race where the file was modified between the time we wrote
it and the time we requested its stat. I just happened to notice this
while going through the code; it seems very unlikely to be noticed in
practice.
2022-05-25 11:51:18 -07:00
Martin von Zweigbergk
fa4b5aa2c7 working_copy: propagate most errors on checkout 2022-05-25 11:51:18 -07:00
Martin von Zweigbergk
9aa2009320 working_copy: improve error handling when getting file stats 2022-05-25 11:51:18 -07:00
Martin von Zweigbergk
9feb786a51 working_copy: extract function for getting mtime
We had a few lines of duplicated code for this, so I moved it into a
function and added better error handling.
2022-05-25 11:51:18 -07:00
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