ok/jj
1
0
Fork 0
forked from mirrors/jj
Commit graph

305 commits

Author SHA1 Message Date
Martin von Zweigbergk
f6a9523b75 revsets: resolve symbol as change id if nothing else matches
This patch makes it so we attempt to resolve a symbol as the
non-obsolete commits in a change id if all other resolutions
fail.

This addresses issue #15. I decided to not require any operator for
looking up by change id. I want to make it as easy as possible to use
change ids instead of commit ids to see how well it works to interact
mostly with change ids instead of commit ids (I'll try to test that by
using it myself).
2021-05-31 08:32:10 -07:00
Martin von Zweigbergk
ca1df00e05 git: make change id the reverse bits of commit id
The fact that the default change id in git repos is currently a prefix
of the commit id makes it impossible to use for resolving a prefix of
the change id to commits. This patch addresses that by reversing the
bits of the change id (relative to the commit id). The next patch will
make it so a change id (or a prefix thereof) is a valid revset.
2021-05-30 22:10:02 -07:00
Martin von Zweigbergk
c7f701fddb revsets: make resolve_symbol() return multiple revisions
I'd like to experiment with mostly using change ids instead of commit
ids on the CLI. Then it needs to be easy to refer to the non-obsolete
commits in a change, which means we probably don't want to require any
operators (i.e. a plain change id should resolve to the non-obsolete
commits in the change). This patch prepares for letting a change id
resolve to (possibly) many commits.
2021-05-30 13:39:24 -07:00
Martin von Zweigbergk
a3cb0ee3d1 index: add a type parameter to PrefixResolution to prepare for ChangeId prefix 2021-05-30 10:24:35 -07:00
Martin von Zweigbergk
0d9d141705 revsets: refactor symbol lookup to prepare for trying to look up change id 2021-05-29 23:48:48 -07:00
Martin von Zweigbergk
e658cc0084 revsets: add a RevsetExpression::evaluate() method for convenience 2021-05-28 09:01:34 -07:00
Martin von Zweigbergk
c4e2e6b598 revsets: remove unnecessary lifetime parameter 2021-05-28 08:58:44 -07:00
Martin von Zweigbergk
ba8ff31e32 cli: make the working copy changes in jj status clearer 2021-05-23 22:08:34 -07:00
Martin von Zweigbergk
ef6e5c7ec2 TreeDiffIterator: simplify conditions by separating trees from non-trees 2021-05-19 21:27:53 -07:00
Martin von Zweigbergk
29fe1e9737 TreeEntryDiffIterator: yield (Option<T>, Option<T>) instead of Diff<T>
This will allow us to simplify `TreeDiffIterator::next()` in the next
commit.
2021-05-19 17:01:12 -07:00
Martin von Zweigbergk
54f6165ef1 repo_path: replace remaining uses of DirRepoPath by RepoPath 2021-05-19 15:11:04 -07:00
Martin von Zweigbergk
69664f57fe working_copy: use RepoPath in write_tree() 2021-05-19 15:11:04 -07:00
Martin von Zweigbergk
5421251e72 repo_path: change representation of RepoPath to have only a list of components 2021-05-19 15:11:04 -07:00
Martin von Zweigbergk
8347d95159 repo_path: remove unnecessary RepoPath::new() and let caller use join() 2021-05-19 15:11:04 -07:00
Martin von Zweigbergk
57d2bc4068 repo_path: remove unused functions 2021-05-19 15:11:04 -07:00
Martin von Zweigbergk
c66990d3a3 repo_path: rename from() to from_internal_{,dir}_string()
Since `RepoPath` can be either a file or a directory, I made its name
not include `file`.
2021-05-19 15:11:04 -07:00
Martin von Zweigbergk
ef726be78b repo_path: rename to_internal_string() to separate names for dir vs file 2021-05-19 15:11:04 -07:00
Martin von Zweigbergk
257ea39e68 gitignore: add assertion that prefix is empty or ends with '/' 2021-05-19 15:11:04 -07:00
Martin von Zweigbergk
03ae1b747c repo_path: remove FileRepoPath in favor of just RepoPath
I had initially hoped that the type-safety provided by the separate
`FileRepoPath` and `DirRepoPath` types would help prevent bugs. I'm
not sure if it has prevented any bugs so far. It has turned out that
there are more cases than I had hoped where it's unknown whether a
path is for a directory or a file. One such example is for the path of
a conflict. Since it can be conflict between a directory and a file,
it doesn't make sense to use either. Instead we end up with quite a
bit of conversion between the types. I feel like they are not worth
the extra complexity. This patch therefore starts simplifying it by
replacing uses of `FileRepoPath` by `RepoPath`. `DirRepoPath` is a
little more complicated because its string form ends with a '/'. I'll
address that in separate patches.
2021-05-19 15:11:04 -07:00
Martin von Zweigbergk
1fe8f6ac27 cli: on init, give a proper error message instead crashing when repo exists 2021-05-19 14:53:37 -07:00
Martin von Zweigbergk
525a5116a2 RepoLoader: stop returning Result since the functions cannot currently fail 2021-05-19 14:12:54 -07:00
Martin von Zweigbergk
6809a88d42 cleanup: use ReadonlyRepo returned from Transaction::commit()
I thought I had looked for this case and cleaned up all the places
when I made `Transaction::commit()` return a new `ReadonlyRepo`. I
must have forgotten to do that, because there we tons of places to
clean up left.
2021-05-19 14:04:52 -07:00
Martin von Zweigbergk
ecc2a6b968 cli: avoid using angle brackets in name/email placeholder, to please git
Git doesn't like seeing "<" and ">" in the user's name or email, so
let's switch to parentheses.
2021-05-19 13:02:39 -07:00
Martin von Zweigbergk
b50be04b43 tests: avoid using to_internal_string() to produce FS path 2021-05-16 22:56:18 -07:00
Martin von Zweigbergk
b6038399f0 matchers: rename AlwaysMatcher to EverythingMatcher 2021-05-16 21:21:34 -07:00
Martin von Zweigbergk
45bb748f9b tests: use OS directory separator in path when writing files to working copy 2021-05-16 21:16:27 -07:00
Martin von Zweigbergk
31f3984728 cli: use placeholder name/email if not configured instead of crashing 2021-05-16 14:52:44 -07:00
Martin von Zweigbergk
b671eca7ad cli: print file paths as relative and using OS directory separator 2021-05-16 13:43:23 -07:00
Martin von Zweigbergk
4d51cd96a1 repo: scan for .jj/ directory up the tree
It's kind of silly that I haven't fixed this earlier. I just don't
need it often myself.
2021-05-16 11:06:13 -07:00
Martin von Zweigbergk
c8f2de1ecc matchers: simplify tests using hashset! macro and improve coverage 2021-05-16 10:44:45 -07:00
Martin von Zweigbergk
0d58060d34 repo: move code for loading store into StoreWrapper 2021-05-16 09:52:08 -07:00
Martin von Zweigbergk
6d61475f66 merge: use recursive merge when there are multiple common ancestors 2021-05-15 14:05:34 -07:00
Martin von Zweigbergk
afe754a4e0 project: bump version to 0.2.0 for release under new name
We need to release on crates.io before the new name gets
taken. Besides, a *lot* has improved since the previous release.
2021-05-15 10:50:26 -07:00
Martin von Zweigbergk
d42e6c77b2 project: rename project from Jujube to Jujutsu
"Jujutsu" is probably much more familiar and relatable to most
people. Also, I'm still not sure how "jujube" is supposed to be
pronounced :P
2021-05-15 10:28:40 -07:00
Martin von Zweigbergk
1cdac0f902 working copy: use system path separator when creating file system path
Hopefully this fixes the failing Windows CI.
2021-05-15 10:04:09 -07:00
Martin von Zweigbergk
a71c56e5e1 evolution: rewrite orphan resolution as iterator 2021-05-15 09:16:19 -07:00
Martin von Zweigbergk
79b5b8d681 evolution: rewrite divergence resolution as iterator
This commit rewites the divergence-resolution part of `evolve()` as an
iterator (though not implementing the `Iterator` trait). Iterators are
just much easier to work with: they can easily be stopped, and errors
are easy to propagate. This patch therefore lets us propagate errors
from writing to stdout (typically pipe errors).
2021-05-15 09:16:19 -07:00
Martin von Zweigbergk
401bd2bd7b evolution: refactor evolve_divergent_change() to return result
I'm going to replace the `evolve()` function and its listener trait by
an iterator or something similar. This commit is to prepare for that.
2021-05-15 09:16:19 -07:00
Martin von Zweigbergk
a028f33e3b working copy: don't remove already-tracked files in ignored directories
The recent optimization to not walk ignored directories did not
account for the case where there already are files in the ignored
directory.
2021-05-15 09:15:45 -07:00
Martin von Zweigbergk
cbc3e915b7 working copy: allow overwriting untracked files
Before this commit, we would crash when checking out a commit that has
a file that's currently ignored in the working copy.
2021-05-15 08:24:56 -07:00
Martin von Zweigbergk
df175f549f working copy: don't assume that $HOME exists (it doesn't on Windows CI) 2021-05-13 23:02:56 -07:00
Martin von Zweigbergk
c1060610bd working copy: optimize simple case of entire directory being ignored
This makes the workging copy walk skip an entire ignored directory if
there are no negative patterns later in the ignore file. That speeds
up `jj st` in this repo with ~13k files in `target/` from ~100 ms to
~25 ms (6.0dB). This closes issue #8.
2021-05-13 22:28:38 -07:00
Martin von Zweigbergk
88f7f4732b gitignores: add own implementation and stop using libgit2's
This is to address issue #8. I haven't added the optimization to avoid
walking all the files in `target/` yet. Even so, this patch still
speeds up `jj st` in this repo, with ~13k files in `target/`, from
~320 ms to ~100 ms (-5.1dB). The time actually checking if paths match
gitignores seems to go down from 116 ms to 6 ms. I think that's mostly
because libgit2 has to look for `.gitignore` files in every parent
directory every time we ask it about a file, while the rewritten code
looks for a `.gitignore` file only when visiting a new directory.
2021-05-13 22:23:59 -07:00
Martin von Zweigbergk
31eff96cb7 cli: record full argv in operation log
When using the command line interface (which is the only interface so
far), it seems more useful to see the exact command that was run than
a logical description of what it does. This patch makes the CLI record
that information in the operation metadata in a new key/value field. I
put it in a generic key/value field instead of a more specialized
field because the key/value field seems like a useful thing to have in
general. However, that means that we "have to" do shell-escaping when
saving the data instead of leaving the data unescaped and adding the
shell-escaping when presenting it. I added very simple shell-escaping
for now.
2021-05-09 22:42:13 -07:00
Martin von Zweigbergk
70b99c960e transaction: make commit() return resulting ReadonlyRepo
I've wanted the API to look like this for a while. It seems like a
good API to me. It means that the caller won't have to reload the repo
after committing. The cost seems relatively small. It involves copying
potentially a lot of data in memory (at least the View object), but it
shouldn't involve reading from disk or any other processing. To reduce
the amount of data to copy, it may be worth switching to persistent
data types. I've also wanted to do that for the copying we do when
start a transaction.

I couldn't measure any slowdown caused by this change.
2021-05-08 13:50:59 -07:00
Martin von Zweigbergk
9e3e6f03a1 repo: store Operation object, not just its ID in ReadonlyRepo
This change simplifies a bit on its own, and it will help with the
next change as well.
2021-05-07 22:53:11 -07:00
Martin von Zweigbergk
c05878b9a6 maintenance: add support for latest nightly toolchain 2021-05-07 22:48:24 -07:00
Martin von Zweigbergk
eb348be32c revsets: make description() lazy by using new FilterRevset 2021-05-02 15:16:51 -07:00
Martin von Zweigbergk
e6f751a24d revsets: generalize merge revset implementation to be a generic filter 2021-05-02 14:58:10 -07:00
Martin von Zweigbergk
7065cecfdc revsets: add revset yielding merge commits 2021-05-02 14:33:38 -07:00