Commit Graph

1225 Commits

Author SHA1 Message Date
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
b97fd381e5 diff_edit: delete unused error variant (since 9e9727af4e) 2022-05-01 22:58:18 -07:00
Martin von Zweigbergk
5bad272e90 docs: update stale references to -o argument deleted in 8744015f33 2022-05-01 16:33:27 -07:00
Martin von Zweigbergk
5893b52fd1 cleanup: use while let Some(...) instead of checking before popping 2022-05-01 13:45:00 -07:00
Waleed Khan
00a8abcdbb diff_edit: improve error handling
Used to produce a message like this:

```
thread 'main' panicked at 'failed to run diff editor: Os { code: 2, kind: NotFound, message: "No such file or directory" }', src/diff_edit.rs:136:10
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
```

Now produces a message like this:

```
Error: Failed to edit diff: Error executing editor 'meld': No such file or directory (os error 2)
```
2022-04-30 13:28:38 -07:00
Waleed Khan
2b843d418b cli: don't show bench/debug subcommands by default 2022-04-30 12:56:23 -07:00
Martin von Zweigbergk
81a8cfefcb cli: add a mode of pushing with branch taken from change ID
This adds `jj git push --change <revision>` which creates a branch
with a name based on the revision's change ID, and then pushes that
like with `--branch`. That can be useful so you don't have to manually
add the branch (and come up with a name for it). The created branch
behaves like any other branch, so it's possible to make it point to a
commit with a different change ID.
2022-04-29 15:55:03 -07:00
Martin von Zweigbergk
bc75b08f4b cli: extract a function for finding single-branch push update
This will be reused in the next commit.
2022-04-29 15:55:03 -07:00
Martin von Zweigbergk
6e30bd76f9 cargo: move some test deps to [dev-dependencies] 2022-04-29 14:25:55 -07:00
Martin von Zweigbergk
d42c71f48d errors: fix some easy error propagation in commands.rs
This is actually enough to fix #248, but I'll continue to work on
error handling for a while. I'd like to at least include the bad
object ID in this type of error messages.

Closes #248.
2022-04-29 14:10:16 -07:00
Martin von Zweigbergk
0719dae975 cli: add a command for listing git remotes and their URLs
As requested by @talpr. I added this is a separate new command `jj git
remote list`. One could also imagine showing the listing when there is
no sub-command specified to `jj git remote`, but we don't have other
commands that behave that way yet.

Closes #243
2022-04-29 14:08:24 -07:00
Martin von Zweigbergk
491d0e3b06 cli: add a debug command for showing information about an operation
This adds `jj debug operation <operation ID>`, which will print the
operation object and its associated view object.
2022-04-29 13:50:22 -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
8ef00a3498 tests: re-run with insta crate version b9d99e87065b 2022-04-28 16:55:10 -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
dependabot[bot]
aff2293e1d github: bump github/codeql-action from 2.1.8 to 2.1.9
Bumps [github/codeql-action](https://github.com/github/codeql-action) from 2.1.8 to 2.1.9.
- [Release notes](https://github.com/github/codeql-action/releases)
- [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md)
- [Commits](1ed1437484...7502d6e991)

---
updated-dependencies:
- dependency-name: github/codeql-action
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-04-28 08:49:42 -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
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