Commit Graph

779 Commits

Author SHA1 Message Date
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
Martin von Zweigbergk
aa78f97d55 git: refactor tests by extracting some common setup (#44) 2021-12-10 23:12:22 -08:00
Martin von Zweigbergk
c678a89794 cleanup: fix some issues reported by new clippy and/or rustc 2021-12-10 14:12:45 -08:00
Martin von Zweigbergk
c058ffeed7 rewrite: avoid accessing MutRepo::view() when rebasing descendants
Since 94e03f5ac8, we lazily filter out non-heads from `View`'s set
of head. Accessing the `MutRepo::view()` triggers that filtering. This
patch makes `DescendantRebaser` not unnecessarily do that. That speeds
up the rebasing of 162 descendants in the git.git repo from ~3.6 s to
~330 ms. Rebasing 1272 descendants takes ~885 ms.
2021-12-08 08:49:42 -08:00
Martin von Zweigbergk
f084a05c0e rewrite: optimize for rebase onto metadata-only change
When you run e.g. `jj describe <some old commit>` or `jj squash -r
<some old commit>`, the descendants' tree objects will not change, so
we can avoid calculating them. This speeds up rebasing of 126 commits
in the git.git repo from ~9.8 s to ~3.6 s.
2021-12-08 08:49:42 -08:00
Martin von Zweigbergk
7b724512dd repo: don't use stale view when checking for changes
I recently (0c441d9558) made it so we don't create an operation when
nothing changed. Soon thereafter (94e03f5ac8), I broke that when I
introduced a cache-invalidation bug when I made the filtering-out of
non-heads be lazy. This patch fixes that and also adds a test to
prevent regressions.
2021-12-05 22:01:48 -08:00
Martin von Zweigbergk
d451c1adf8 cli: add .jj/ to .git/info/exclude when collocated
When initializing a jj repo in the same directory as its backing git
repo, add `.jj/` to `.git/info/exclude` so it doesn't show up to `git`
commands.

This is part of #44.
2021-12-01 17:18:08 -08:00
Martin von Zweigbergk
e587071ffe cli: follow git HEAD update if collocated
If the workspace's working copy is shared with the backing Git repo,
we now automatically update the checkout in jj to match Git's HEAD
when that has changed.

With this change, I think users should be able to run `jj init
--git-store=.` and then continue to use `git` commands and
non-mutating `jj` commands without issue.

This is part of issue #44.
2021-12-01 16:29:50 -08:00
Martin von Zweigbergk
75f0abf396 cli: automatically import git refs if repos are collocated
This change makes commands automatically import git refs if they're
run in a workspace that shares its working copy with the underlying
git repo. The import is done in a separate transaction.

This is part of #44.
2021-12-01 16:18:53 -08:00
Martin von Zweigbergk
94e03f5ac8 repo: enforce view invariants lazily
It's very slow to remove non-heads from the set of heads every time we
add an head. For example, in the git.git repo, a no-op `jj git import`
takes ~15 s. This patch changes makes us just mark the set of heads
dirty when a commit has been added and then we remove non-heads when
needed. That cuts down the `jj git import` time to ~200 ms.
2021-12-01 16:18:23 -08:00
Martin von Zweigbergk
f1bfe85f45 revsets: add git_head() revset
This is part of #44.
2021-12-01 11:08:53 -08:00
Martin von Zweigbergk
626fbee0dd cli: show Git HEAD in log output
It's useful to know which commit is checked out in the underlying Git
repo (if there is one), so let's show that. This patch indicates that
commit with `HEAD@git` in the log output. It's probably not very
useful when the Git repo is "internal" (i.e. stored inside `.jj/`),
because then it's unlikely to change often. I therefore considered not
showing it when the Git repo is internal. However, it turned out that
`HEAD` points to a non-existent branch in the repo I use, so it won't
get imported anyway (by the function added in the previous patch). We
can always review this decision later.

This is part of #44.
2021-12-01 11:08:53 -08:00
Martin von Zweigbergk
8a2f630ac0 git: start tracking HEAD of underlying Git repo
This patch adds a place for tracking the current `HEAD` commit in the
underlying Git repo. It updates `git::import_refs()` to record it. We
don't use it anywhere yet.

This is part of #44.
2021-12-01 11:08:53 -08:00
Martin von Zweigbergk
d06c74f5b8 cli: add option to edit description while closing commit
This lets you do `jj close -e` to edit the description even if it's
already set (we normally bring up the editor only if the description
is empty).
2021-12-01 10:44:24 -08:00
Martin von Zweigbergk
1f68de64d4 debug: upgrade Drop implementations to non-debug assert!
I think these remaining implementations of `Drop` are for types that
are infrequently dropped (unlike `Transaction`), so it be fine to be
more strict about them.
2021-12-01 10:32:11 -08:00
Martin von Zweigbergk
06bccb3387 transaction: remove Drop implementation
I can't remember when the `Drop` implementation last helped me find a
bug, so let's just remove it.
2021-12-01 10:31:35 -08:00
Martin von Zweigbergk
698b92adc4 docs: update tutorial to mention jj untrack
I forgot to update the tutorial when I closed #14.
2021-12-01 09:56:58 -08:00
Martin von Zweigbergk
14e7d894f3 cli: report failure to import Git refs as internal error 2021-12-01 09:51:20 -08:00
Martin von Zweigbergk
0c441d9558 cli: don't commit no-op transaction
If nothing changed in a transaction, it's rarely useful to commit it,
so let's avoid that. For example, if you run `jj git import` without
changing the anything in the Git repo, we now just print "Nothing
changed.".
2021-12-01 09:51:20 -08:00
Martin von Zweigbergk
a27e77205a git: don't import refs/remotes/origin/HEAD as a branch called "HEAD"
`refs/remotes/origin/*` are usually (remote-tracking) branches, but
`refs/remotes/origin/HEAD` is not.
2021-12-01 08:15:36 -08:00
Martin von Zweigbergk
1143b1ab6c cargo: run cargo upgrade
For no particular reason other than to stay up to date.
2021-12-01 08:13:20 -08:00
Martin von Zweigbergk
905c45ddd7 cargo: upgrade to backoff 0.3
For no particular reason other than to stay up to date.
2021-12-01 08:13:20 -08:00
Martin von Zweigbergk
ba01c512ae cli: don't update working copy when running command at old operation
Some time ago, I made commands not commit the working copy when run at
an old operation, but it seems that I forgot to make it not update the
working copy. If you run e.g. `jj --at-op=<some operation> rebase -d
<some commit>`, it doesn't make sense for that to update the working
copy.
2021-11-26 23:49:00 -08:00
Martin von Zweigbergk
b8168bd106 cli: on checkout, don't create transaction for no-op update 2021-11-26 23:47:13 -08:00
Martin von Zweigbergk
f27f110d10 repo: remove now-unused working copy path 2021-11-25 21:14:24 -08:00
Martin von Zweigbergk
b4f2b88522 workspace: move initialization of WorkingCopy from ReadonlyRepo 2021-11-25 21:14:24 -08:00
Martin von Zweigbergk
c6cba59c27 workspace: move creation of .jj/ directory from Repo to Workspace 2021-11-25 21:08:43 -08:00
Martin von Zweigbergk
f17aced374 workspace: move search for .jj/ directory from Repo to Workspace 2021-11-25 21:08:43 -08:00
Martin von Zweigbergk
ea172f5f24 tests: when reloading a repo, pass in repo path, not workspace root
I'm about to change `ReadonlyRepo::load()` to take the path to the
`.jj/` directory, so this patch prepares for that. It already works
because `ReadonlyRepo::load()` will search up the directory tree for
the `.jj/` entry.
2021-11-25 21:07:28 -08:00
Martin von Zweigbergk
831a0a7707 tests: remove some more calls to Repo::working_copy_path() 2021-11-25 21:07:28 -08:00
Martin von Zweigbergk
466d35d4bc workspace: add functions for initializing a repo
`ReadonlyRepo::init_*()` currently calls `WorkingCopy::init()`. In
order to remove that dependency, this patch wraps the
`ReadonlyRepo::init_*()` functions in new `Workspace` functions. A
later patch will have those functions call `WorkspaceCopy::init()`.`
2021-11-25 21:07:28 -08:00
Martin von Zweigbergk
c08adba424 repo: remove working_copy(), only used in tests
This is another step towards removing coupling between the repo and
the working copy, so we can have multiple working copies for a single
repo (#13).
2021-11-25 21:04:56 -08:00