Commit graph

1044 commits

Author SHA1 Message Date
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
819ad475f5 docs: give Google credit for letting this be my 20% project
This has been my 20% for at least a year (dedicating most of my
Wednesdays to it), so let's give Google some credit for that in the
README.
2022-02-08 09:59:28 -08:00
Martin von Zweigbergk
2dbdff1ad1 cli: add support for matching directories
A few commands (`restore`, `diff`, and `untrack` so far) accept path
arguments, but they only support files. Let's make them work with
directories too.
2022-02-06 14:49:22 -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
80aeae48b5 cli: fix git diff to not add context lines to count twice
We add `num_after_lines` to the line ranges just a few lines before
the place I removed the addition from in this patch.
2022-02-05 16:00:54 -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
Martin von Zweigbergk
db47e14f69 tests: don't create workspaces in repo-loading tests 2022-02-05 13:47:48 -08:00
Martin von Zweigbergk
0fd3b8ef1a tests: don't create workspaces in view tests
Even the checkout tests need only a repo!
2022-02-05 13:47:48 -08:00
Martin von Zweigbergk
785212d05d tests: don't create workspaces in git tests 2022-02-05 13:45:41 -08:00
Martin von Zweigbergk
e871f64d1e tests: don't create workspaces in index tests 2022-02-05 13:45:41 -08:00
Martin von Zweigbergk
abedeeaacf tests: rename init_repo() to init_workspace()
Most tests need a repo but don't need a working copy. Let's have a
function for setting up a test repo. But first, let's free up the name
`init_repo()` by renaming it to `init_workspace()` (which is also more
accurate).
2022-02-05 13:02:19 -08:00
Martin von Zweigbergk
731aa7578e cli: allow specifying a custom workspace name
We use the destination directory's basename as the workspace
name. Let's allow the user to choose a different name.
2022-02-05 11:27:41 -08:00
Martin von Zweigbergk
0ee09c9f29 cli: don't allow creating multiple workspaces with the same name
It's harmless but potentially confusing to have multiple workspaces
with the same ID (it would mean that they always have the same
checkout). Let's just prevent it for now. We can add an override later
if people think of usecases for it.
2022-02-05 11:15:51 -08:00
Martin von Zweigbergk
53b458a601 cli: clarify error when trying to forget non-existent workspace
When you try to forget a workspace that doesn't exist, we say "Nothing
changed.", since the transaction is empty. Let's have a specific error
instead.
2022-02-05 11:04:11 -08:00
Martin von Zweigbergk
62f541e8cd tests: check that workspace's repo path match canonicalized source path
Hopefully this will fix the failing test on Windows.
2022-02-02 22:22:52 -08:00
Martin von Zweigbergk
f6628923dc cli: when checking if jj co destination is checked out, handle absence (#13)
When you run `jj co abc123` and that commit is already checked out, we
just print a message. The condition for that assumed that the checkout
existed, which it won't if you just ran `jj workspace forget`. Let's
avoid that crash, especially since `jj co` is an easy way to restore
the working copy if you had accidentally run `jj workspace forget`
(though `jj undo` is even easier).
2022-02-02 21:56:58 -08:00
Martin von Zweigbergk
ef60da0472 cli: add a command for forgetting a workspace (#13) 2022-02-02 21:52:40 -08:00
Martin von Zweigbergk
4eddb72edb cli: add a command for listing workspaces (#13) 2022-02-02 21:37:34 -08:00
Martin von Zweigbergk
bcece02084 cli: indicate each workspace's checkout in log (#13)
It seems helpful to show in the log output which commit is checked out
in which workspace, so let's try that. I made it only show the
information if there are multiple checkouts for now.
2022-02-02 21:36:14 -08:00
Martin von Zweigbergk
5da9d600fd cli: add a command for adding an additional workspace (#13)
With all the groudwork done, everything should just work with multiple
workspaces now. So let's add a command for creating workspaces.
2022-02-02 17:00:03 -08:00
Martin von Zweigbergk
c09a4e15c5 workspace: add a function for initializing additional workspace (#13) 2022-02-02 17:00:03 -08:00
Martin von Zweigbergk
5fd060ca18 workspace: load repo from another workspace if .jj/repo is a file (#13)
In workspaces added after the initial one, the idea is to have
`.jj/repo` be a file whose contents is a path to the location of the
repo directory in some other workspace.
2022-02-02 13:47:07 -08:00
Martin von Zweigbergk
a6ef792ba6 repo: initialize without checkouts, let Workspace add it (#13)
As part of creating a new repository, we create an open commit on top
of the root and set that as the current checkout. Now that we have
support for multiple checkouts in the model, we also have support for
zero checkouts, which means we don't need to create that commit on top
of the root when creating the repo. We can therefore move out of
`ReadonlyRepo`'s initialization code and let `Workspace` instead take
care of it. A user-visible effect of this change is that we now create
one operation for initilizing the repo and another one for checking
out the root commit. That seems fine, and will be consistent with the
additional operation we will create when adding further workspaces.
2022-02-02 11:09:12 -08:00
Martin von Zweigbergk
f2e7086172 cli: make jj [obs]log highlight current workspace's checkout (#13)
We should highlight (with bright colors by default) the current
workspace's checkout, not the default workspace's checkout.
2022-02-02 10:44:13 -08:00
Martin von Zweigbergk
92af544de0 templater: make current_checkout be about the current workspace (#13)
We don't use the `current_checkout` keyword in out default templates,
but let's still fix it, so it refers to the current workspace.
2022-02-02 10:33:10 -08:00
Martin von Zweigbergk
012b4c4d8e revsets: add syntax for a particular workspace's checkout (#13)
Because we record each workspace's checkout in the repo view, we can
-- unlike other VCSs -- let the user refer to any workspace's checkout
in revsets. This patch adds syntax for that, so you can show the
contents of the checkout in workspace "foo" with `jj show foo@`. That
won't automatically commit that workspace's working copy, however.
2022-02-02 10:05:31 -08:00
Martin von Zweigbergk
5b46fa3282 cli: make jj status show status for the current workspace (#13)
`jj status` shows the status for the default workspace. Make it use
the current workspace instead.
2022-02-02 08:15:22 -08:00
Martin von Zweigbergk
3588934fc1 cli: when updating onto new commit from jj new, use right workspace (#13)
`jj new` will update onto the new commit if the previous commit was
the current checkout. That code needs to use the current workspace's
checkout.
2022-02-02 08:15:22 -08:00
Martin von Zweigbergk
ee641bf7ad cli: when exporting Git HEAD, use right workspace's new checkout (#13)
If the workspace is shared with a Git repo, we sometimes update Git's
HEAD ref. We should get the new checkout from the right workspace ID
when doing that (though I'm not sure we'll ever support sharing the
working copy with Git in a non-default workspace).
2022-02-02 08:15:22 -08:00
Martin von Zweigbergk
72b5d9a8c5 cli: when importing Git HEAD, abandon right workspace's old commit (#13)
When importing Git HEAD, we already use the right workspace ID for the
new checkout, but the old checkout we abandon is always the default
workspace's. We should fix that even if we will never support sharing
a working copy with Git in a non-default workspace.
2022-02-02 08:15:22 -08:00
Martin von Zweigbergk
48bbb3abc0 cli: use right workspace when checking if working copy has changed (#13)
Before committing the working copy, we check if the working copy is
checked out to the commit we expect based on the repo's view. We
always use the default workspace's checkout, so we need to fix that.
2022-02-02 08:15:22 -08:00
Martin von Zweigbergk
9cabb7eb35 cli: add an early return and reduce indentation (#13) 2022-02-02 08:15:22 -08:00
Martin von Zweigbergk
daaf735e4b cli: update working copy to current workspace's checkout (#13)
When updating the working copy after committing a transaction, we
should update it based on the right checkout.
2022-02-02 08:15:22 -08:00
Martin von Zweigbergk
5f38213e91 cli: detect concurrent working copy change in right workspace (#13)
We detect concurrent working copy changes by checking that the old
commit matches the repo's view. We should use the current workspace
when looking up the checkout in the view.
2022-02-02 08:15:22 -08:00
Martin von Zweigbergk
a41fcb39eb repo: respect workspace ID for old checkout (#13)
When checking out a new commit, we look at the old checkout to see if
it's empty so we should abandon it. We current use the default
workspace's checkout. We need to respect the workspace ID we're given
in `MutableRepo::check_out()`, and we need to be able to deal with
that workspace not existing yet (i.e. this being the first checkout in
that workspace).
2022-02-02 08:15:22 -08:00
Martin von Zweigbergk
ac0d040bb5 rewrite: update all checkouts, not just the default workspace's (#13) 2022-02-02 08:15:22 -08:00
Martin von Zweigbergk
6d3e2017f8 view: merge checkouts for all workspaces, not just the default one (#13) 2022-02-02 08:15:22 -08:00
Martin von Zweigbergk
766c01a6d9 view: add workspace_id argument to set_checkout() (#13) 2022-02-02 08:15:22 -08:00
Martin von Zweigbergk
fb8fbdc4b3 working_copy: keep track of workspace ID (#13)
This patch makes it so the workspace ID can be stored in
`.jj/working_copy/checkout`. The workspace ID is still always
"default".
2022-02-02 08:15:22 -08:00