Commit graph

1303 commits

Author SHA1 Message Date
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
Jason R. Coombs
2d4e653e90 Add hint on including completions with xonsh shell. 2022-04-26 16:31:51 -07:00
Jason R. Coombs
99cce19774 Avoid hard-coding homebrew install prefix. 2022-04-26 16:31:51 -07:00
Jason R. Coombs
c2dbbf434d Minor editorial changes for native backend footnote. 2022-04-26 16:31:51 -07:00
Martin von Zweigbergk
9e9727af4e diff_edit: use sparse checkouts instead of emulating it (#52)
I think we can simply use sparse checkouts for the diff-editing
functionality now that we have it. I'm really happy with how simple it
got :)
2022-04-26 14:52:17 -07:00
Martin von Zweigbergk
885c780642 cli: add commands for working with sparse patterns (#52)
This adds a `jj sparse` command with options to list and manage the
set of paths to include in the working copy. It only supports includes
(postive matches) for now.

I'm not sure "sparse" is the best name for the feature. Perhaps it
would make sense as a subcommand under `jj workspace` - maybe `jj
workspace track`? However, there's also `jj untrack` for removing a
file from the working copy and leaving it in the working copy. I'm
happy to hear suggestions, or we can get back to the naming later.
2022-04-26 14:52:17 -07:00
Martin von Zweigbergk
b2f6725a04 cli: extract helper for making changes to the working copy (#52)
Most commands that are going to make changes to the working copy want
to share some logic for detecting concurrent changes, so let's extract
that to a function.
2022-04-26 14:52:17 -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
d4732574f4 cli: let caller of select_diff() create matcher
The function becomes more flexible by getting a matcher instead of
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
Waleed Khan
38455503fc build: set default-run to jj
If not set, then `cargo run` produces this error:

```
error: `cargo run` could not determine which binary to run. Use the `--bin` option to specify a binary, or the `default-run` manifest key.
available binaries: fake-diff-editor, fake-editor, jj
```
2022-04-26 11:04:01 -07:00
Martin von Zweigbergk
6ec3afc75d cli: error out if jj untrack is run at non-head operation 2022-04-26 10:42:29 -07:00
Martin von Zweigbergk
f71047c823 cli: add hard-coded support for specifying previous operation
It's useful for testing to be able to specify some operation that's
not the latest one.

I didn't update the changelog because this feature is mostly for
testing.
2022-04-26 10:42:29 -07:00
Martin von Zweigbergk
01407f261d cli: make resolve_single_op() reusable for loaded repos
When loading a repo, `@` means the latest operation, possibly even
merging any concurrent operations. After loading a repo, `@` means the
operation the repo was loaded at. For example, when running `jj
--at-op=abc123 undo -o @`, `@` will undo operation `abc123`. This
patch therefore makes `resolve_single_op()` more generic by letting
the caller pass in what `@` should resolve to. I also added version of
the function on `WorkspaceCommandHelper` for convenience.
2022-04-26 10:42:29 -07:00
Martin von Zweigbergk
76751edb81 cli: extract a function for resolving the --at-op operation 2022-04-26 10:42:29 -07:00
Martin von Zweigbergk
456a6b3108 cli: inline RepoLoader::load_at_head() in CommandHelper
The function doesn't make anything simpler for us, and I think it will
be easier to implement simple "opsets" (like "revsets" for operations)
if we work directly with the operation objects (instead of repo
objects).
2022-04-26 10:42:29 -07:00
Martin von Zweigbergk
f8512226fc cli: return specialized message on non-hex operation ID 2022-04-26 10:42:29 -07:00
Martin von Zweigbergk
6619a18056 tests: add test for jj op log and --at-op
We can't easily test much of the output of `jj op log` because it's
unstable, but here are at least a few tests.
2022-04-26 10:42:29 -07:00
Tal Pressman
4a1576c874 Check SSH_AUTH_SOCK to determine existence of ssh-agent 2022-04-26 08:10:28 -07:00
Tal Pressman
ad79d89e4b Remove out-of-date parenthetical in tutorial.md 2022-04-26 08:10:28 -07:00
Waleed Khan
4948f631d1 build: mark Cargo.lock as binary for merging
Otherwise, Git tries to resolve the conflict textually and introduces conflict markers, which make `cargo` unable to process the file (and therefore unable to resolve the conflicts automatically, such as with `cargo update`).
2022-04-25 22:58:15 -07:00
Martin von Zweigbergk
8744015f33 cli: make operation to undo or restore to a positional argument
I originally made the operation argument a named argument
(`--operation`) to allow for a change ID to be passed as a positional
argument, matching e.g. `hg revert -r <rev> <path>`. However, even if
we add support for undoing changes only to certain change IDs, it's
going to be done much less frequently than full undo/restore. We can
therefore make that a named argument if we ever add it.
2022-04-25 17:29:48 -07:00
Martin von Zweigbergk
0058236a43 cli: make jj restore --to <rev> restore from the working copy 2022-04-25 17:29:48 -07:00
Martin von Zweigbergk
9f9af78c45 cli: provide better error message for no-arg jj move 2022-04-25 17:29:48 -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
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
cc7e20859c tests: add tests of jj move to ancestor, showing lost branch
I noticed earlier today that branches get lost (stuck on a hidden
commit) when you move part of a change to an ancestor. This patch adds
tests for both of those cases, showing the bug. There's no special
logic for this case in the CLI crate, so we should be able to test it
in the library crate instead, but since I have already written the
tests, maybe we can keep them.
2022-04-25 14:05:27 -07:00
Martin von Zweigbergk
9d440ca835 tests: remove a duplicate log output in jj move test 2022-04-25 14:05:27 -07:00
Martin von Zweigbergk
cf7bef88fe tests: extract a function for getting log output in jj move test 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
Tal Pressman
c2ba83af71 Remove out-of-date parenthetical in tutorial.md 2022-04-22 21:49:42 -07:00
Martin von Zweigbergk
2e0d80919d cli: some fixes and touch-ups for jj workspace, plus tests 2022-04-22 15:45:35 -07:00
Martin von Zweigbergk
90edd670d9 tests: move tests of Ui from tests/ into ui module
The tests only test the `Ui` type and don't need anything from
`testutils`, so it seems they should be treated as unit tests.
2022-04-22 15:45:35 -07:00
dependabot[bot]
781307ddbd cargo: bump clap from 3.1.10 to 3.1.12
Bumps [clap](https://github.com/clap-rs/clap) from 3.1.10 to 3.1.12.
- [Release notes](https://github.com/clap-rs/clap/releases)
- [Changelog](https://github.com/clap-rs/clap/blob/master/CHANGELOG.md)
- [Commits](https://github.com/clap-rs/clap/compare/v3.1.10...v3.1.12)

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

Signed-off-by: dependabot[bot] <support@github.com>
2022-04-22 08:38:27 -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
dependabot[bot]
6076c01d20 github: bump actions/checkout from 3.0.1 to 3.0.2
Bumps [actions/checkout](https://github.com/actions/checkout) from 3.0.1 to 3.0.2.
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](dcd71f6466...2541b1294d)

---
updated-dependencies:
- dependency-name: actions/checkout
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-04-21 09:10:26 -07:00
Martin von Zweigbergk
f5e9444456 cargo: upgrade uuid to 1.0.0 2022-04-20 14:18:59 -07:00
dependabot[bot]
56f7478603 cargo: bump clap_mangen from 0.1.4 to 0.1.6
Bumps [clap_mangen](https://github.com/clap-rs/clap) from 0.1.4 to 0.1.6.
- [Release notes](https://github.com/clap-rs/clap/releases)
- [Changelog](https://github.com/clap-rs/clap/blob/master/CHANGELOG.md)
- [Commits](https://github.com/clap-rs/clap/compare/clap_mangen-v0.1.4...clap_mangen-v0.1.6)

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

Signed-off-by: dependabot[bot] <support@github.com>
2022-04-20 14:08:46 -07:00
Martin von Zweigbergk
8745ee7030 cli: use . in output for current directory instead of empty string 2022-04-20 13:52:25 -07:00
dependabot[bot]
724e2af529 cargo: bump clap_complete from 3.1.1 to 3.1.2
Bumps [clap_complete](https://github.com/clap-rs/clap) from 3.1.1 to 3.1.2.
- [Release notes](https://github.com/clap-rs/clap/releases)
- [Changelog](https://github.com/clap-rs/clap/blob/master/CHANGELOG.md)
- [Commits](https://github.com/clap-rs/clap/compare/clap_complete-v3.1.1...clap_complete-v3.1.2)

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

Signed-off-by: dependabot[bot] <support@github.com>
2022-04-20 13:51:31 -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
5e729eced7 github: also run tests on our MSRV (1.58)
This patch sets up an additional CI strategy running tests on 1.58, to
make sure we don't accidentally use newer features. I've only made it
run on one platform (Linux) to avoid wasting resources. There's of
course a small risk that we start depending on platform-specific APIs
from newer versions.
2022-04-19 16:47:42 -07:00
dependabot[bot]
d2d0f8c03e cargo: bump clap_mangen from 0.1.3 to 0.1.4
Bumps [clap_mangen](https://github.com/clap-rs/clap) from 0.1.3 to 0.1.4.
- [Release notes](https://github.com/clap-rs/clap/releases)
- [Changelog](https://github.com/clap-rs/clap/blob/master/CHANGELOG.md)
- [Commits](https://github.com/clap-rs/clap/compare/clap_mangen-v0.1.3...clap_mangen-v0.1.4)

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

Signed-off-by: dependabot[bot] <support@github.com>
2022-04-19 09:15:40 -07:00