Commit graph

810 commits

Author SHA1 Message Date
Martin von Zweigbergk
9a640bfe13 working_copy: save TreeState later, just before releasing lock
I was surprised that we save the `TreeState` before
`LockedWorkingCopy::finish()`. That means that even if the caller
instead decides to discard the changes, some changes will already have
been written.
2022-01-19 08:32:59 -08:00
Martin von Zweigbergk
25d19e8a65 working_copy: start improving interface for mutations
This patch changes the interface for making changes to the working
copy by replacing `write_tree()` and `untrack()` by a single
`start_mutation()` method. The two functions now live on the returned
`LockedWorkingCopy` object instead. That is more flexible because the
caller can make multiple changes while the working copy is locked. It
also helps us reduce the risk of buggy callers that read the commit ID
before taking the lock, because we can now make it accessible only on
`LockedWorkingCopy`.
2022-01-19 08:32:59 -08:00
Martin von Zweigbergk
2916dc3423 working_copy: make a &mut self argument not mutable 2022-01-19 08:32:51 -08:00
Martin von Zweigbergk
1fc19dbbaf working_copy: take initial commit in init() function
The working copy object knows the currently checked out commit ID. It
is set to `None` when the object is initialized. It is also set to
`None` when an existing working copy is loaded. In that case, it's
used only to facilitate lazy loading. However, that means that
`WorkingCopy::current_commit_id()` fails if the working copy has been
initalized but no checkout has been specified. I've never run into
that case, but it's ugly that it can happen. This patch fixes it by
having `WorkingCopy::init()` take a `CommitId`.
2022-01-17 14:12:55 -08:00
Martin von Zweigbergk
6fcd3b3af6 cli: avoid an unnecessary read of the working copy commit 2022-01-16 17:37:24 -08:00
Martin von Zweigbergk
9ce56f6cb7 cli: use color only when stdout is a TTY
This adds a `ui.color` config that can be set to "always", "never", or
"auto". If set to "auto", we use color iff stdout is a TTY.
2022-01-16 17:37:14 -08:00
Martin von Zweigbergk
0fadac38d6 working_copy: remove current_commit() (leaving current_commit_id()
`WorkingCopy::current_commit()` has been there from the beginning. It
has made less sense since we made the repo view keep track of the
current checkout. Let's remove it.
2022-01-15 17:11:56 -08:00
Martin von Zweigbergk
91c8c27cc5 cli: when untracking paths, get old commit id while under lock
Before this patch, we got the old commit ID before we took the lock on
the working copy, which means we might unnecessarily create divergence
if another process just committed the working copy.
2022-01-15 11:15:01 -08:00
Martin von Zweigbergk
ed9c23281b cli: make jj untrack not create divergent commit
We need to call `workspace_command.finish_transaction()` to rebase
descendants and hide the old heads.
2022-01-15 11:09:41 -08:00
Martin von Zweigbergk
4e20548e32 docs: some futher touch-ups of concurrency.md 2022-01-12 23:20:22 -08:00
Martin von Zweigbergk
8a0afc3016 gitignore: don't apply patterns to parent directories
If you create a `dir/.gitignore` file with pattern "dir" in it, it'll
currently match the parent directory, making e.g. the `dir/.gitignore`
file itself ignored. That was quite confusing, and it doesn't match
how Git behaves. This patch fixes the bug.
2022-01-12 11:27:49 -08:00
Martin von Zweigbergk
5b84e192fc gitignore: ignore a single CR at EOL
I ran into a tool that produced a `.gitignore` file with CRLF line
endings. I had not considered that case when implementing support for
`.gitignore`, so we interpreted the CR as part of the string, which of
course made the files not match.

This patch fixes the bug by ignoring a single CR at EOL. That seems to
be what Git does (I didn't see any information about it in the
documentation).
2022-01-12 10:58:09 -08:00
Martin von Zweigbergk
1e07b95e7b gitignore: derive Debug on structs 2022-01-12 09:37:36 -08:00
Martin von Zweigbergk
c47bb9373c cli: remove unnecessary override of --help description on subcommands
It turns out that the `--help` option is "global", so the description
we set on the top-level command already applies to subcommands (and
subsubcommands, etc.).
2022-01-12 09:23:19 -08:00
Martin von Zweigbergk
67b731b34a docs: mention concurrency as a feature in README 2022-01-10 13:05:29 -08:00
Martin von Zweigbergk
4c45844aba docs: fix a typo in concurrency doc 2022-01-10 07:58:27 -08:00
Martin von Zweigbergk
94fda7935a docs: add technical doc about lock-free concurrency design 2022-01-09 22:03:19 -08:00
Martin von Zweigbergk
2d6b66a274 stacked_table: rename start_modification() to start_mutation()
`start_mutation()` better matches the return type's name.
2022-01-05 15:17:24 -08:00
Martin von Zweigbergk
69ff505338 view: replace start_modification() by Clone impl
I'm pretty sure the `start_modification()` function is a leftover from
when there was `ReadonlyView` and `MutableView`.
2022-01-05 15:11:07 -08:00
Martin von Zweigbergk
504148a81f cli: upgrade to clap 3.0 now that it's released 2022-01-05 12:43:14 -08:00
Martin von Zweigbergk
9ec0e4c1bb docs: use Git-style unified diff in the tutorial
The default (color-based) diffs are not readable in Markdown. Also,
it's useful for the user to learn about the `--git` flag.
2022-01-05 12:38:52 -08:00
Martin von Zweigbergk
037d66965d docs: start documenting Git compatibility 2022-01-03 22:40:58 -08:00
Martin von Zweigbergk
93250fe6c8 docs: link from README to post about rebase speed
For now, the best documentation we have of how fast `jj` is is the
GitHub discussion about rebase speed.
2022-01-03 21:36:56 -08:00
Martin von Zweigbergk
91e471cb73 clippy: disable return_self_not_must_use
A new Clippy version added a new warning when a function that returns
`Self` doesn't have `#[must_use]`. I feel like all the cases reported
by it were false positives. Most were functions on `CommitBuilder`,
where we take `mut self` and return `Self`. I don't think I've ever
forgotten to use the result of those.
2022-01-03 21:34:39 -08:00
Martin von Zweigbergk
f9e6b263a1 docs: explain how not exposing "the index" in the UI is a good thing 2021-12-18 09:22:35 -08:00
Martin von Zweigbergk
9eb4390a4d cli: fix a typo in help text of jj squash 2021-12-18 08:58:09 -08:00
Martin von Zweigbergk
71b0233efb docs: add doc about a first-class conflicts 2021-12-18 08:07:28 -08:00
Martin von Zweigbergk
ef4dbf216f docs: add links from README to detailed docs 2021-12-18 08:01:47 -08:00
Martin von Zweigbergk
423a894cba docs: consistently use hyphens in filenames 2021-12-18 07:56:48 -08:00
Martin von Zweigbergk
7b09a232bc docs: update doc about working copy now that conflicts are preserved
Conflicts are preserved in the working copy since ea82340654, I just
forgot to update the documentation.
2021-12-17 16:29:20 -08:00
Martin von Zweigbergk
66cedc804e docs: explain how to untrack a file while keeping it in the working copy
Issue #14 was fixed a while ago, but I forgot to update the
documentation.
2021-12-17 15:58:20 -08:00
Martin von Zweigbergk
006cb37183 docs: replace jj concepts by markdown docs
I wanted to have all the documentation available on the command line,
but that makes it harder to maintain and link to. Let's move it to
markdown instead. We may later be able to add some way of presenting
the markdown in the terminal (or maybe by first converting it to
reStructuredText).
2021-12-17 15:18:41 -08:00
Martin von Zweigbergk
9e591def26 cli: add jj show command for showing commit description and diff
This functionality is probably what I miss most from git/hg.
2021-12-17 13:28:09 -08:00
Martin von Zweigbergk
8d3ad34009 cli: extract function for showing diff style based on args and config
I'm about to add a `jj show` command (like `git show`), and that'll
have the same arguments and config for deciding which style of diff to
show.
2021-12-17 11:28:07 -08:00
Martin von Zweigbergk
277f42d98a revsets: add author() and committer() functions (#46)
Filtering by the author or committer is quite common.
2021-12-15 22:50:29 -08:00
Martin von Zweigbergk
7d3d0fe83c revsets: allow the .. operator to be used as prefix or suffix (#46)
It makes sense to omit either of the arguments of the `..` operator,
even though `..x` is equivalent to `:x`. `x..`, with a implied right
argument of `heads()` is more useful.
2021-12-15 22:16:22 -08:00
Martin von Zweigbergk
bc92b82ed4 revsets: use a single grammar rule for the : operator (#46) 2021-12-15 21:57:55 -08:00
Martin von Zweigbergk
588389e89f docs: add pointer to new revset doc in tutorial (#46) 2021-12-15 21:41:11 -08:00
Martin von Zweigbergk
4c71c763e9 docs: document revsets (#46)
Now that revset operators are not as embarrassing as before, let's
document them.
2021-12-15 16:56:45 -08:00
Martin von Zweigbergk
60c43cfc0d cargo: upgrade to Rust 2021 (just to stay up to date) 2021-12-13 21:47:00 -08:00
Martin von Zweigbergk
c185b395f6 revsets: swap meaning of operators ~ and - (#46)
As suggested by @arxanas, this makes `-` symmetric with `+` and `-` is
easier to type than `~`.
2021-12-12 23:02:29 -08:00
Martin von Zweigbergk
35a712cc48 revsets: change Git-like range operator ,,, operator to .. (#46) 2021-12-12 00:20:00 -08:00
Martin von Zweigbergk
98659a16e1 revsets: change DAG range operator ,, operator to : (#46) 2021-12-12 00:20:00 -08:00
Martin von Zweigbergk
63c90c04c8 revsets: change parent/children operators to foo~/foo+ (#46) 2021-12-11 23:47:34 -08:00
Martin von Zweigbergk
7f61deeb21 cli: when run in git repo, hint about setting up collocated jj workspace (#44)
Now that it's much easier to use a shared working copy between git and
jj, let's update the hint about how to set up a jj repo backed by the
git repo to use a shared working copy.
2021-12-11 11:23:29 -08:00
Martin von Zweigbergk
ccfaf0f601 git: on import, only add ref target as head if target changed (#44)
If you import Git refs, then rebase a commit pointed to by some Git
ref, and then re-import Git refs, you don't want the old commit to be
made a visible head again. That's particularly annoying when Git refs
are automatically updated by every command.
2021-12-11 11:03:40 -08:00
Martin von Zweigbergk
63d1a87ef3 cli: automatically update Git refs and HEAD after command if collocated (#44) 2021-12-11 11:03:40 -08:00
Martin von Zweigbergk
9898547932 cli: add jj git export command (#44) 2021-12-11 10:20:30 -08:00
Martin von Zweigbergk
cd0192e1b3 cli: extract a function for importing Git refs and HEAD (#44)
`WorkspaceCommandHelper::for_loaded_repo()` was getting a bit long.
2021-12-11 10:20:30 -08:00
Martin von Zweigbergk
47b3abd0f7 git: add function for exporting to underlying Git repo (#44) 2021-12-11 09:30:12 -08:00