Commit graph

412 commits

Author SHA1 Message Date
Martin von Zweigbergk
3aa57b1a04 working copy: start defining a trait for a locked working copy
As with the `WorkingCopy` trait, this just contains some trivial
methods for now.
2023-10-15 15:59:49 -07:00
Martin von Zweigbergk
c8184845d7 workspace: replace working_copy_mut() by wrapper type
I'm about to make `LockedLocalWorkingCopy` not borrow from
`LocalWorkingCopy`. That will make it easier to forget to update any
`LocalWorkingCopy` variables when the modifications have been
committed. This patch introduces a wrapper around
`LockedLocalWorkingCopy` to help prevent that.

Thanks to Yuya for the suggestion.
2023-10-15 15:59:49 -07:00
Martin von Zweigbergk
35f9c12cb5 working copy: move LocalWorkingCopy::check_out() to Workspace
`LocalWorkingCopy::check_out()` can be expressed using the planned
`WorkingCopy` trait, so it doesn't need to be in the trait itself
`WorkingCopy`. I wasn't sure if I should make it a free function in
`working_copy`, but I ended up moving it onto `Workspace`.
2023-10-15 15:59:49 -07:00
Yuya Nishihara
35ea607abd view: make get_remote_branch() return RemoteRef instead of RefTarget
I'm going to add tracking state to RemoteRef, and we should compare both
target and state in the tests.
2023-10-16 05:12:19 +09:00
Yuya Nishihara
ab1a6e2f71 view: make remote branches iterator yield RemoteRef instead of RefTarget
git::import_refs() will need to read RemoteRef's tracking state.
2023-10-16 05:12:19 +09:00
Yuya Nishihara
e7d93e5bf1 view: turn BranchTarget into borrowed type
This isn't important, but I'm going to change remote_targets to store RemoteRef
instead of RefTarget, so I went ahead and change the other field types as well.
2023-10-16 05:12:19 +09:00
Yuya Nishihara
92facbf21a view: add method to iterate branches of specified remote 2023-10-16 05:12:19 +09:00
Yuya Nishihara
8bdef924c8 view: rename remote_branches() to all_remote_branches()
I'm going to add a method that iterates branches of certain remote, and I
can't find a better name for it than remote_branches(remote_name).
2023-10-16 05:12:19 +09:00
Yuya Nishihara
f4a6415865 tests: remove stale comment about remote named "git"
Since it's no longer allowed to create/import from remote named "git", there's
no point in testing "jj branch list" with that.
2023-10-15 11:49:09 +09:00
Austin Seipp
d3f9616c51 test_workspaces: fix merge skew from b7c7b19e + 220292ad
Summary: Yuya's changes and mine had a semantic conflict ("merge skew") between
the two of them, as b7c7b19e changed the `op log `output slightly, whereas
220292ad included a new test that used `op log` itself.

Generated by `cargo insta review`.

Signed-off-by: Austin Seipp <aseipp@pobox.com>
Change-Id: I51d4de7316b1abc09be4f9fa0dd0d1a1
2023-10-14 09:01:42 -05:00
Yuya Nishihara
9186d0fd38 workspace: convert external git repo path to store-relative by constructor
We could fix do_git_clone() instead, but it seemed a bit weird that the
git_repo_path is relative to the store path which is unknown to callers.

Fixes #2374
2023-10-14 22:20:09 +09:00
Yuya Nishihara
af70818128 cli: construct "op restore"-d view by cloning each field
This will force us to think about whether new field belongs to "repo" or
"remote".
2023-10-14 22:20:00 +09:00
Yuya Nishihara
b7c7b19eb8 view: migrate in-memory structure to per-remote branches map
There's a subtle behavior change. Unlike the original remove_remote_branch(),
remote_views entry is not discarded when the branches map becomes empty. The
reasoning here is that the remote view can be added/removed when the remote
is added/removed respectively, though that's not implemented yet. Since the
serialized data cannot represent an empty remote, such view may generate
non-unique content hash.
2023-10-14 22:20:00 +09:00
Austin Seipp
220292ad84 workspace: workspace forget multiple names at once
Summary: This allows `workspace forget` to forget multiple workspaces in a
single action; it now behaves more consistently with other verbs like `abandon`
which can take multiple revisions at one time.

There's some hoop-jumping involved to ensure the oplog transaction description
looks nice, but as they say: small conveniences cost a lot.

Signed-off-by: Austin Seipp <aseipp@pobox.com>
Change-Id: Id91da269f87b145010c870b7dc043748
2023-10-14 07:38:00 -05:00
Yuya Nishihara
3fb0a3b926 view: add has_branch(name), replace some of get_branch(name) callers
get_branch(name) will be removed soon.
2023-10-13 18:12:45 +09:00
Benjamin Saunders
7e7735e6b5 cli: fix SSH key discovery on Windows
$HOME isn't set here, but `dirs` has suitable magic for us already.
2023-10-12 23:47:08 -07:00
Martin von Zweigbergk
9e43207911 working copy: don't expose TreeStateError in LocalWorkingCopy API
The `TreeStateError` type is specific to the current local-disk
working-copy backend, so it should not be part of the generic
working-copy interface I'm trying to create.
2023-10-12 16:10:38 -07:00
Martin von Zweigbergk
33d27ed09f working copy: start defining a working copy trait
This just extracts a trait for the trivial bits to start with.
2023-10-12 16:10:38 -07:00
Yuya Nishihara
69a30b47af refs: migrate classify_branch_push_action() to local/remote targets pair 2023-10-12 16:50:09 +09:00
Yuya Nishihara
68545a62b8 cli: inline find_branches_targeting() in a call site
We no longer have multiple callers, and the function signature looks rather
noisy.
2023-10-12 16:50:09 +09:00
Austin Seipp
37f11c7d4e workspace: add '--revision' argument to 'workspace add'
Summary: Workspaces are most useful to test different versions (commits) of
the tree within the same repository, but in many cases you want to check out a
specific commit within a workspace.

Make that trivial with a `--revision` option which will be used as the basis
for the new workspace. If no `-r` option is given, then the previous behavior
applies: the workspace is created with a working copy commit created on top of
the current working copy commit's parent.

Signed-off-by: Austin Seipp <aseipp@pobox.com>
Change-Id: I23549efe29bc23fb9f75437b6023c237
2023-10-11 22:02:24 -05:00
Martin von Zweigbergk
ebec82ee0c cli: allow overwriting non-scalar with jj config set
Before this patch, it was an error to run `jj config set --user foo
'[1]'` twice. But it's only been broken since the previous commit
because '[1]' was interpreted as a string before then.
2023-10-11 07:40:08 -07:00
Martin von Zweigbergk
f654801c20 cli: accept TOML arrays and tables to jj config set 2023-10-11 07:40:08 -07:00
Yuya Nishihara
e6f49552d0 ui: remove write*() and flush() methods
This will force us to think about the output stream to print to. Typically
we'll use stdout_formatter() for data, and stderr() for the other messages.
2023-10-11 19:24:01 +09:00
Yuya Nishihara
7a3e72415c cli: send status messages to stderr, specify stdout/stderr explicitly
Many of &mut UI can be changed to immutable borrows, but I'm not gonna
update them in this patch.
2023-10-11 19:24:01 +09:00
Yuya Nishihara
58acc1d111 tests: replace jj_cmd_success() involving mutation to allow stderr output 2023-10-11 19:24:01 +09:00
Yuya Nishihara
98bf0836bf ui: move UiOutput definition close to stdout/stderr wrappers
UiStdout/Stderr wrappers are declared at top because they have macro. Let's
move UiOutput closer as it is quite similar to these wrappers.
2023-10-11 19:24:01 +09:00
Yuya Nishihara
0e22a42a41 ui: add thin stdout/stderr wrappers to be used with write!() macros
I'm going to replace all ui.write*() callers with these wrappers. Status
messages will be sent to stderr.
2023-10-11 19:24:01 +09:00
Yuya Nishihara
95de0c8002 cli: add missing newline to debug watchman outputs 2023-10-11 19:24:01 +09:00
Yuya Nishihara
f397349db4 cli: make non-colocated repo also preserve git_refs on op undo/restore
Now we have a separate map for "git" tracking remote, we can always preserve
the last imported/exported git_refs. The option to restore git-tracking refs
has been removed. Perhaps, --what can be reorganized as --local and --remote
<NAME>.
2023-10-11 06:18:36 +09:00
Martin von Zweigbergk
4d2402831a cli: describe what workspaces are in jj workspace help 2023-10-10 16:08:20 -05:00
Yuya Nishihara
e160970b79 git: migrate import_refs() to diffing git_refs and known remote refs 2023-10-09 22:31:20 +09:00
Martin von Zweigbergk
5174489959 backend: make read functions async
The commit backend at Google is cloud-based (and so are the other
backends); it reads and writes commits from/to a server, which stores
them in a database. That makes latency much higher than for disk-based
backends. To reduce the latency, we have a local daemon process that
caches and prefetches objects. There are still many cases where
latency is high, such as when diffing two uncached commits. We can
improve that by changing some of our (jj's) algorithms to read many
objects concurrently from the backend. In the case of tree-diffing, we
can fetch one level (depth) of the tree at a time. There are several
ways of doing that:

 * Make the backend methods `async`
 * Use many threads for reading from the backend
 * Add backend methods for batch reading

I don't think we typically need CPU parallelism, so it's wasteful to
have hundreds of threads running in order to fetch hundreds of objects
in parallel (especially when using a synchronous backend like the Git
backend). Batching would work well for the tree-diffing case, but it's
not as composable as `async`. For example, if we wanted to fetch some
commits at the same time as we were doing a diff, it's hard to see how
to do that with batching. Using async seems like our best bet.

I didn't make the backend interface's write functions async because
writes are already async with the daemon we have at Google. That
daemon will hash the object and immediately return, and then send the
object to the server in the background. I think any cloud-based
solution will need a similar daemon process. However, we may need to
reconsider this if/when jj gets used on a server with a custom backend
that writes directly to a database (i.e. no async daemon in between).

I've tried to measure the performance impact. That's the largest
difference I've been able to measure was on `jj diff
--ignore-working-copy -s --from v5.0 --to v6.0` in the Linux repo,
which increases from 749 ms to 773 ms (3.3%). In most cases I've
tested, there's no measurable difference. I've tried diffing from the
root commit, as well as `jj --ignore-working-copy log --no-graph -r
'::v3.0 & author(torvalds)' -T 'commit_id ++ "\n"'` (to test a
commit-heavy load).
2023-10-08 23:36:49 -07:00
Martin von Zweigbergk
44eb902171 working_copy: don't crash when updating and tracked file exits on disk
Before this patch, when updating to a commit that has a file that's
currently an ignored file on disk, jj would crash. After this patch,
we instead leave the conflicting files or directories on disk. We
print a helpful message about how to inspect the differences between
the intended working copy and the actual working copy, and how to
discard the unintended changes.

Closes #976.
2023-10-07 14:02:31 -07:00
Yuya Nishihara
7f4fe22a98 tests: disable parsing of system CA certificates in CLI tests
On my Debian laptop, openssl_init() takes ~30ms to load the default CA
certificates serialized in PEM format, and the cost is added to each jj
invocation. This change saves 20s (of 50s) on my machine.

% wc -l /usr/lib/ssl/cert.pem
3517 /usr/lib/ssl/cert.pem
2023-10-08 02:41:20 +09:00
Yuya Nishihara
d94c325d6c tests: use if cfg!(..) instead of #[cfg(..)] to insert Windows-specific config
The code compiles on all platforms, so I think `if cfg!(..)` is better.
2023-10-08 02:41:20 +09:00
Yuya Nishihara
aea135cb8f cli: in colocated repo, don't restore view.git_head on undo
Otherwise, undone HEAD wouldn't be exported if we tried to preserve the
symbolic HEAD target (#2210). Unborn branch already has this problem.
2023-10-08 02:37:02 +09:00
Martin von Zweigbergk
187ba9430a working_copy: rename to local_working_copy
It's about time we make the working copy a pluggable backend like we
have for the other storage. We will use it at Google for at least two
reasons:

 * To support our virtual file system. That will be a completely
   separate working copy backend, which will interact with the virtual
   file system to update and snapshot the working copy.

 * On local disk, we need to tell our build system where to find the
   paths that are not in the sparse patterns. We plan to do that by
   wrapping the standard local working copy backend (the one moved in
   this commit), writing a symlink that points to the mainline commit
   where the "background" files can be read from.

Let's start by renaming the exising implementation to
`local_working_copy`.
2023-10-07 08:19:03 -07:00
Yuya Nishihara
1eb8b95a6c cli: rephrase @git branch with no local counterpart as "deleted"
Since forgotten branches are now removed at all, the only situation where @git
branch persists is that the branch got removed but is not exported yet.
2023-10-07 19:33:35 +09:00
Yuya Nishihara
28e5ee35aa cli: filter out branches to list without cloning the map 2023-10-07 19:33:35 +09:00
Yuya Nishihara
d0bc34e0f2 git: look up "git" remote branches normally 2023-10-07 19:33:35 +09:00
Yuya Nishihara
717d0d3d6d git: on deserialize/import/export, copy refs/heads/* to remote named "git"
I've added a boolean flag to the store to ensure that the migration never runs
more than once after the view gets "op restore"-d. I'll probably reorganize the
branches structure to support non-tracking branches later, but updating the
storage format in a single commit would be too involved.

If jj is downgraded, these "git" remote refs would be exported to the Git repo.
Users might have to remove them manually.
2023-10-07 19:33:35 +09:00
Martin von Zweigbergk
2ccb17b7b3 cli: enable tree-level conflicts by default
I have used the tree-level conflict format for several weeks without
problem (after the fix in 51b5d168ae). Now - right after the 0.10.0
release - seems like a good time to enable the config by default.

I enabled the config in our default configs in the CLI crate to reduce
impact on tests (compared to changing the default in `settings.rs`).
2023-10-05 10:31:47 -07:00
Martin von Zweigbergk
ce933507df release: release version 0.10.0
Thanks to everyone who's contributed!
2023-10-04 16:45:45 -07:00
Yuya Nishihara
a302090de9 git: add hack to unset Git HEAD by using placeholder ref
As we can set HEAD to an arbitrary ref by using .reference_symbolic(), we don't
have to manage a ref that can also be valid as a branch name.

Fixes #1495
2023-10-05 01:32:48 +09:00
Yuya Nishihara
be3d588449 cli: inline export_head_to_git(), use the same wc_commit to update working copy 2023-10-04 01:43:34 +09:00
Yuya Nishihara
df716888c9 cli: reorder working-copy commit lookup bits in finish_transaction()
Just to make the next commit look slightly nicer. tx.mut_repo() is no longer
assigned to local variable to narrow scope of mutable borrow.
2023-10-04 01:43:34 +09:00
Yuya Nishihara
7ccbc0424c git: extract function that resets Git HEAD
I'll add a workaround for the root parent issue #1495 there. We can pass in
the wc parent id instead of the wc_commit object, but we might want to use
wc_commit.id() to generate a unique placeholder ref name.
2023-10-04 01:43:34 +09:00
Yuya Nishihara
7c96cead34 git_backend: rename git_repo_clone() as it isn't just cloning, propagate error
Since git2::Repository::open() will access to the filesystem, it can technically
fail.
2023-10-04 00:04:24 +09:00
Yuya Nishihara
837dc4f47c git_backend: rewrite remaining git_repo() callers, make it private
While debugging git issues, I often ended up creating a deadlock by adding
debug prints. It's also not obvious that git::export_refs() works even if the
git_repo() has already been locked, whereas git::import_refs() wouldn't. Let's
consolidate lock handling to the backend implementation.
2023-10-04 00:04:24 +09:00
Yuya Nishihara
0d63223dad git_backend: proxy git2::Repository methods to manage lock scope internally
Since git_repo() acquires Mutex, it's super easy to create a deadlock.
2023-10-04 00:04:24 +09:00
Yuya Nishihara
902a43a341 cli: don't list commits abandoned by import/fetch, just print the number
Apparently, it gets too verbose if the remote history is actively rewritten.
Let's summarize the output for now. The plan is to show the list of moved refs
instead of the full list of abandoned commits.
2023-10-03 14:07:56 +09:00
Martin von Zweigbergk
5947387a3d cli_utils: fix a typo in a comment
The codespell GitHub action fails because of the typo. I don't know
why it started failing now. The comment is 8 months old and the
codespell action hasn't been updated in 5 months.
2023-10-02 18:29:25 -07:00
Yuya Nishihara
0fe25575ba cli: ensure first new HEAD is detached
The problem is that the first non-working-copy commit moves the unborn current
branch to that commit, but jj doesn't "export" the moved branch. Therefore,
the next jj invocation notices the "external" ref change, which was actually
made by jj.

I'm not sure why we play nice by setting the "current" HEAD, but I *think* it's
okay to set the "new" HEAD and reset to the same commit to clear Git index.
2023-10-03 00:58:22 +09:00
Yuya Nishihara
480efc1503 cli: add context to checkout/abandon messages triggered by automated git import
Otherwise, it's unclear why "jj status" abandoned commits for example.
2023-10-02 17:31:05 +09:00
Yuya Nishihara
8579bc479f cli: print commits abandoned by git::import_refs() or fetch()
This will probably help to understand why you've got conflicts after fetching.
Maybe we can also report changed local refs.

I think the stats should be redirected to stderr, but we have many other similar
messages printed to stdout. I'll probably fix them all at once later.
2023-10-02 17:31:05 +09:00
Yuya Nishihara
fb08e16238 cli: return early if git::import_some_refs() is noop
I'll make it a bit more verbose if mut_repo().has_changes().
2023-10-02 17:31:05 +09:00
Yuya Nishihara
16d3bcd4c5 git: make import_refs() return abandoned commits to caller
It'll be reported to user.
2023-10-02 17:31:05 +09:00
Martin von Zweigbergk
58de7c292b cli: redefine default log revset using immutable_heads()
I think most users who change the set of immutable heads away from
`trunk() | tags()` are going to also want to change the default log
revset to include the newly mutable commit and to exclude the newly
immutable commits. So let's update the default log revset to use
`immutable_heads()` instead.

`test_templater` changed because we have overridden the set of
immutable commits there so `jj log` now includes the remote branch.
2023-10-01 11:15:30 -07:00
Martin von Zweigbergk
8ec402fc90 cli: report error on bad short-prefixes revset 2023-10-01 11:15:30 -07:00
Waleed Khan
d58664d40c command: add --interactive flag to jj commit 2023-09-30 22:03:51 -05:00
Waleed Khan
946a6e0bf7 commands: support path arguments to jj commit 2023-09-30 21:45:06 -05:00
Waleed Khan
d91dcc0c78 commands: add --interactive flag to jj split
`jj split` with no arguments operates interactively, but I am nonetheless constantly running `jj split -i` because I expect an `--interactive` flag to exist for consistency.

However, `jj split <paths>` before this commit always operates non-interactively, so this commit has the nice practical effect that you can restrict your interactive splitting to a certain set of paths.
2023-09-30 21:45:06 -05:00
Yuya Nishihara
f0f1d72cf3 view: add method that iterates remote branches only
There aren't many callers, but let's add it for consistency.
2023-09-30 12:02:35 +09:00
Yuya Nishihara
c5474ff505 view: extract method that iterates local branches only
I'll probably reorganize the local/remote branches structure, so let's
minimize call sites which rely on the BranchTarget struct.
2023-09-30 12:02:35 +09:00
Martin von Zweigbergk
af80e4e407 files: take Merge argument to merge()
All non-test callers already have a `Merge` object, so let's pass that
instead. We thereby simplify the callers a little, and we enforce the
"adds.len() == removes.len() + 1" constraint in the type.
2023-09-27 22:14:39 -07:00
Martin von Zweigbergk
e50f6acab1 templater: fast-path empty and conflict to not read trees
When there's a single parent, we can determine if a commit is empty by
just comparing the tree ids. Also, when using tree-level conflicts, we
don't need to read the trees to determine if there's a conflict. This
patch adds both of those fast paths, speeding up `jj log -r ::main`
from 317 ms to 227 ms (-28.4%). It has much larger impact with our
cloud-based backend at Google (~5x faster).

I made the same fix in the revset engine and the Git push code (thanks
to Yuya for the suggestion).
2023-09-26 18:18:52 -07:00
Martin von Zweigbergk
a6ef3f0b6c cli: make set of immutable commits configurable
This adds a new `revset-aliases.immutable_heads()s` config for
defining the set of immutable commits. The set is defined as the
configured revset, as well as its ancestors, and the root commit
commit (even if the configured set is empty).

This patch also adds enforcement of the config where we already had
checks preventing rewrite of the root commit. The working-copy commit
is implicitly assumed to be writable in most cases. Specifically, we
won't prevent amending the working copy even if the user includes it
in the config but we do prevent `jj edit @` in that case. That seems
good enough to me. Maybe we should emit a warning when the working
copy is in the set of immutable commits.

Maybe we should add support for something more like [Mercurial's
phases](https://wiki.mercurial-scm.org/Phases), which is propagated on
push and pull. There's already some affordance for that in the view
object's `public_heads` field. However, this is simpler, especially
since we can't propagate the phase to Git remotes, and seems like a
good start. Also, it lets you say that commits authored by other users
are immutable, for example.

For now, the functionality is in the CLI library. I'm not sure if we
want to move it into the library crate. I'm leaning towards letting
library users do whatever they want without being restricted by
immutable commits. I do think we should move the functionality into a
future `ui-lib` or `ui-util` crate. That crate would have most of the
functionality in the current `cli_util` module (but in a
non-CLI-specific form).
2023-09-25 15:41:45 -07:00
Martin von Zweigbergk
ab85b9e938 cli: make check_rewritable() accept multiple commits
I'm going to make this function check against a configurable revset
indicating immutable commits. It's more efficient to do that by
evaluating the revset only once.

We may want to have a version of the function where we pass in an
unevaluated revset expression. That would allow us to error out if the
user accidentally tries to rebase a large set of commits, without
having to evaluate the whole set first.
2023-09-25 15:41:45 -07:00
Martin von Zweigbergk
3fbfd17182 cli: jj duplicate should refuse to duplicate only the root commit
Once we add support for immutable commits, `jj duplicate` should be
allowed to create duplicate of them. The reason it can't duplicate the
root commit is that it would mean there would be multiple root
commits, which would break the invariant that the single root commit
is the only root commit (and the backends refuse to write a commit
without parents). So let's have `jj duplicate` check specifically that
the user doesn't try to duplicate the root commit instead.
2023-09-25 15:41:45 -07:00
Waleed Khan
642ac8c799 merge_tools: pass Matcher in for interactive use
For `jj split --interactive`, the user will want to select changes from a subset of files. This means that we need to pass the `Matcher` object when materializing the list of changed files. I also updated the parameter lists so that the matcher always immediately follows the tree objects.
2023-09-25 02:48:57 +02:00
Martin von Zweigbergk
acf84f5cd8 cargo: add LICENSE file to each crate we publish
According to https://github.com/clap-rs/clap/pull/2810, the Apache
license must be distributed with sources, including with the sources
we publish to crates.io.
2023-09-22 21:48:28 -07:00
Willian Mori
4894636d10 cli: hint for same change ids 2023-09-21 22:53:46 -03:00
Willian Mori
15e2cc22ce cli: hint for conflicted branches 2023-09-21 22:53:46 -03:00
Willian Mori
a3ed43efc3 cli: extract commits_summary variable 2023-09-21 22:53:46 -03:00
Martin von Zweigbergk
6873438b85 cli: compdef _jj jj isn't necessary for Zsh completion setup
We missed this in 8f1dc490 and 38e61511.
2023-09-21 18:29:06 -07:00
Hong Shin
a736c153ae Add desc as an alias for description 2023-09-21 16:07:29 -07:00
Waleed Khan
409356fa5b merge_tools: enable :builtin as default diff/merge editor 2023-09-21 03:29:27 +02:00
Ilya Grigoriev
86767e47d7 cargo: make jj installable with cargo binstall
https://github.com/cargo-bins/cargo-binstall

Note that `jj` will only become installable once the next release
is published to crates.io. For this reason, I am planning to
wait until then before documenting the fact that `jj` can be
installed this way.

At that point, `cargo binstall jj-cli` should be sufficient.

Before then, it's possible to test that this will work by doing

```
cargo binstall jj-cli --force --strategies crate-meta-data --log-level debug  --dry-run --manifest-path cli/Cargo.toml
``` 

Without --dry-run, this should install the 0.9 release if run
on `cli/Cargo.toml` form this commit.
2023-09-20 09:35:18 -07:00
Ilya Grigoriev
d79e8293aa cargo: stop cargo install from installing fake-editor & co.
Among other things, this prevented `jj` from working with
`cargo binstall`.

The trick is taken from
https://github.com/rust-lang/cargo/issues/2911#issuecomment-1483256987.

We could now also remove `--bin jj` from the installation commands
in `install-and-setup.md`, but I'm not sure we should. That argument
makes it clear that the binary is `jj`, not `jj-cli`.

Fixes #216.
2023-09-20 09:01:54 -07:00
Ilya Grigoriev
6d5390d1db cli: add upstream remote to default trunk()
This makes trunk() correct after `jj git fetch --remote upstream --branch
main`.
2023-09-19 20:51:23 -07:00
Martin von Zweigbergk
0f7054e8c3 tests: wherever we test with only one backend, use the test backend
I don't think there's any reason to use the local backend in tests
instead of using the stricter test backend.

I think we should generally use the test backend in tests and only use
the local backend or git backend when there's a particular reason to
do so (such as in `test_bad_locking` where the on-disk directory
structure matters). But this patch only deals with the simpler cases
where we were only testing with the local backend.
2023-09-19 20:49:41 -07:00
Yuya Nishihara
aa3dfaa859 cli: fix operation id recorded on unmanaged Git HEAD move
This appears to be broken at db0d14569b "cli: wrap repo in a struct to
prepare for adding cached data." Testing this isn't easy since the operation
id recorded here will be overwritten immediately by snapshot_working_copy(),
and the snapshotting should work fine so long as the tree id matches.
2023-09-19 21:30:40 +09:00
Martin von Zweigbergk
d575aaeca8 backend: move constant functions first
`root_commit_id()`, `root_change_id()`, and `empty_tree_id()` were
strangely ordered between `write_symlink()` and `read_tree().
2023-09-19 05:24:51 -07:00
Waleed Khan
742df2758b merge_tools: reorder editor_args_from_settings
The rest of the functions in this file are defined before they are used, so it confused me when trying to track down this function in the static call graph.
2023-09-19 07:27:21 +02:00
Martin von Zweigbergk
9c30d7500b testutils: delete bool-typed init() in favor of enum-typed version
It makes the call sites clearer if we pass the `TestRepoBackend` enum
instead of the boolean `use_git` value. It's also more extensible (I
plan to add another backend for tests).
2023-09-18 07:15:37 -07:00
Waleed Khan
393b035498 merge_tools: create builtin merge editor 2023-09-18 06:33:29 +02:00
Ruben Slabbert
f2f5ded5f0 revsets: add trunk alias with default to main/master/root 2023-09-17 10:17:23 +10:00
Ilya Grigoriev
33087bcd90 cli docs: document that --config-toml can be repeated 2023-09-14 18:09:27 -07:00
Zachary Dremann
2177dc0657 Allow \0 escape for nulls
This allows safely getting e.g. multiple descriptions, and knowing where the
boundaries are
2023-09-14 17:11:05 -04:00
Martin von Zweigbergk
8bfb6c10fd cli: add jj op log --no-graph
Seems useful, and makes it consistent with the `jj log` and `jj
obslog`.
2023-09-10 15:17:43 -07:00
Martin von Zweigbergk
70f6e0a452 cargo: enable the watchman feature by default
I think the feature is requested by enough users that we should
include it by default, also for people who install from source (we
include it in the `packaging` feature already).

It increases the size of the binary from 16.5 MiB to 17.8 MiB. I
suspect we'd see some of that increase in size soon anyway, as I'm
probably going to use Tokio for making async backend requests.
2023-09-08 09:34:55 -07:00
Yuya Nishihara
8b825796ff cli: rewrite "x | x-" in default log revset as "ancestors(x, 2)" 2023-09-08 09:28:14 +09:00
Martin von Zweigbergk
8640eacfbd cargo: don't expose the criterion feature
There should be no reason to include `criterion` without the `bench`
feature. Adding the `dep:` prefix to any dependency makes cargo not
expose the implicit `criterion` feature.
2023-09-07 11:00:25 -07:00
Vamsi Avula
ddb6e1b954 cli: label working copies when writing commit summaries 2023-09-07 12:43:58 +05:30
Yuya Nishihara
c4769e0b7c revset: translate symbol rules in error message
Since we have overloaded operator symbols, we need to deduplicate them
upfront. Legacy and compat operators are also removed from the suggestion.

It's a bit ugly to mutate the error struct before calling Error::renamed_rule(),
but I think it's still better than reimplementing message formatting function.
2023-09-07 15:29:39 +09:00
Martin von Zweigbergk
7c8f66ab0c cli: make jj abandon print commit info as it was before the command
As we discussed in #1928, it seems better to print information about
abandoned commits in the context of the pre-abandon state. For
example, that means that we'll include any branches that pointed to
the now-abandoned commits.
2023-09-05 21:51:32 -07:00
Philip Metzger
f131dc9814 commands: Implement next and prev
This is a naive implementation, which cannot deal with multiple children
or parents stemming from merges.

Note: I gave each command separate a separate argument struct
for extensibility. 

Fixes #878
2023-09-05 23:13:39 +02:00
Martin von Zweigbergk
2b9c9d22cf cli: make it allowed to have a branch on the root commit again
Closes #1529.
2023-09-04 20:08:11 -07:00
Martin von Zweigbergk
4ea6b4a75b cli: make hint about foo and foo/bar branches more targeted
Many failure to export refs to Git are not about conflicts between a
branch named `foo` and a branch named `foo/bar`, so don't give that
hint in most cases.
2023-09-04 20:08:11 -07:00
Martin von Zweigbergk
ef550a9d6d git: include reason for each failed ref export 2023-09-04 20:08:11 -07:00
Yuya Nishihara
b0c8e9ef62 revset: add 0-ary "::" and ".." operators as short for "all()" and "~root()"
Suppose "x::y" is the operator that defaults to "root()::visible_heads()"
respectively, "::" is identical to "all()". Since we've just changed the
behavior of "..y", ".." is now "root()..visible_heads()" meaning "~root()".
2023-09-05 10:40:04 +09:00
Yuya Nishihara
e3c85d6ecc revset: convert root symbol to function
The idea is that we can fully eliminate special symbols that would otherwise
shadow user branches, tags, or change ID prefixes.

Closes #2095
2023-09-04 10:36:30 +09:00
Yuya Nishihara
4394bf8de8 templater: add boolean literals
They are implemented as literal expressions so that user cannot override
them by false and true aliases.
2023-09-03 07:01:40 +09:00
Yuya Nishihara
08e66fb7d4 templater: fix span of method call expression
Spotted while experimenting with field expression. This span is unused,
so no test output changes.
2023-09-03 07:01:40 +09:00
Yuya Nishihara
e36237426a cli: elide path in snapshot progress in the same way 2023-09-02 08:21:33 +09:00
Yuya Nishihara
1c7d2b9a96 cli: make diff stat calculate path length based on unicode width 2023-09-02 08:21:33 +09:00
Yuya Nishihara
643b2d4974 cli: include both ascii and non-ascii file names in diff stat test
ASCII file names can be used as reference widths.
2023-09-02 08:21:33 +09:00
Yuya Nishihara
3d54df9806 cli: add helper to elide text from left
I don't think this implements unicode layout stuff thoroughly, but it can at
least handle Latin and unambiguous East-Asian characters.
2023-09-02 08:21:33 +09:00
Martin von Zweigbergk
b8f71a4b30 working_copy: in LockedWorkingCopy::drop(), discard unsaved changes
In `LockedWorkingCopy::drop()`, we panic if the caller had not called
`finish()`. IIRC, the idea was both to find bugs where we forgot to
call `finish()` and to prevent continuing with a modified
`WorkingCopy` instance. I don't think the former has been a problem in
practice. It has been a problem in practice to call `discard()` to
avoid the panic, though. To address that, we can make the `Drop`
implementation discard the changes (forcing a reload of the state if
the working copy is accessed again).
2023-09-01 12:25:47 -07:00
Martin von Zweigbergk
f3a16eb964 cli: add hint when snapshot fails due to large file
I also converted the error from `InternalError` to `UserError`. So far
I've intented to use `InternalError` only to indicate bugs or corrupt
repos. I'm not sure that's a good idea, and we can revisit it later.
2023-09-01 12:25:47 -07:00
Martin von Zweigbergk
b18c97aa12 cli: trim path in diff stat if it's long, to give room for stat
If the path is too long to fit on the screen, this patch makes it so
we elide the first part of it. It goes a bit further and trims it down
to ~70% of the screen, giving some room for the stat. This seems
somewhat similar to what Git does.
2023-08-31 16:26:43 -07:00
Martin von Zweigbergk
497f4a952c cli: fix indentation of two insta snapshots
`insta` ignores leading indentation (as long as it's consistent within
the snapshot), but when a test case fails and you let `cargo insta`
update it, it's going to use a specific indentation. There were a few
tests that didn't match that indentation, which could lead to
surprising diffs if the tests fail at some point.
2023-08-31 16:26:43 -07:00
Martin von Zweigbergk
5ecc95a245 cli: make diff stat determine path length in chars, not bytes 2023-08-31 16:26:43 -07:00
Martin von Zweigbergk
0493e2b50e cli: use non-ascii chars in diff stat test
This shows that there's too much padding because we pad based on
number of bytes.

I had to reduce the path names for the file names not to get too long
for my file system.
2023-08-31 16:26:43 -07:00
Martin von Zweigbergk
4377c08f83 cli: don't crash diffstat on very narrow terminals
We can still crash on terminals that are less than 4 characters wide
(maybe it doesn't matter if we do because the user can't tell the
crash report from a diffstat in such a terminal?). This patch fixes
the crash.
2023-08-31 16:26:43 -07:00
Martin von Zweigbergk
5a054fcd20 cli: reuse number_padding instead of calculating twice in diff stat 2023-08-31 16:26:43 -07:00
Martin von Zweigbergk
5ce4ed45de cli: allow diff stat bar to be one character longer
I think the `+ 1` here came from an old iteration of this feature
where there was a single space before each line.
2023-08-31 16:26:43 -07:00
Martin von Zweigbergk
939528122d cli: fix crash on diff stat with long path name
We would run into a panic due to "attempt to subtract with overflow"
if the path was long. This patch fixes that and adds tests showing the
current behavior when there are long paths and/or large diffs.
2023-08-31 16:26:43 -07:00
Martin von Zweigbergk
61501db8ec merged_trees: consider conflict-format-change-only commits empty
When we start writing tree-level conflicts in an existing repo, we
don't want commits that change the format to be non-empty if they
don't change any content. This patch updates `MergeTreeId::eq()` to
consider two resolved trees equal even if only their `MergedTreeId`
variant is different (one is path-level and one is tree-level).

I think I've gone through all places we compare tree ids and checked
that it's safe to compare them this way. One consequence is that
rebasing a commit without changing the parents (typically
auto-rebasing after `jj describe`) will not lead to the tree id
getting upgraded, due to an optimization we have for that case. I
don't think that's serious enough to handle specially; we'll have to
support the old format for existing repos for a while regardless of a
few commits not getting upgraded right away.

The number of failing tests with the config option enabled drop from
108 to 11 with this patch.
2023-08-30 06:17:21 -07:00
Martin von Zweigbergk
8e47d2d66f merged_tree: add config option to write trees using new format
We're finally ready to start writing trees using the new format where
we represent conflicts by having multiple trees in the commit instead
of having a single tree with multiple entries at a path. This patch
adds a config option for that. It's not ready to be used yet, so I
haven't updated the release notes or other documentation.

I added only a simple CLI test for testing what happens when the
config is enabled in an existing repo. 108 tests currently fail if we
flip the default.
2023-08-30 06:17:21 -07:00
Waleed Khan
56c61fd047 merge_tools: create builtin diff editor 2023-08-30 05:38:10 -04:00
Waleed Khan
ccd67e8156 merge_tools: rename MergeTool::Internal -> MergeTool::Builtin
The name we will expose to the user is `builtin`, so this changes the internal messaging to match that.
2023-08-30 04:10:39 -04:00
Vamsi Avula
32377a13f4 templates: default placeholders to red
With the idea that less severe placeholders (like description) could
(and should) explicitly "opt out".

(Both email and name placeholders will be red with this change.)
2023-08-30 12:54:15 +08:00
Vamsi Avula
dbf13a5250 tests: add test for log builtin templates with colors 2023-08-30 12:54:15 +08:00
Martin von Zweigbergk
145b0b24d8 commit: drop merged_ prefix from tree() and tree_id()
The old `tree()` and `tree_id()` functions are now gone, so we can use
those names for the new functions.
2023-08-29 08:32:04 -07:00
Martin von Zweigbergk
67832a3940 merged_tree: take store argument to write_tree() instead of new()
The store isn't needed until we write the trees, so I think it makes
more sense to pass it there.
2023-08-29 08:32:04 -07:00
Yuya Nishihara
55c6e90555 git: remove handling of real remote named "git", always override
#1690
2023-08-29 22:50:46 +09:00
Yuya Nishihara
ce3d28e234 git: do not import refs from remote named "git"
I made it simply fail on explicit fetch/import, and ignored on implicit import.
Since the error mode is predictable and less likely to occur. I don't think it
makes sense to implement warning propagation just for this.

Closes #1690.
2023-08-29 22:50:46 +09:00
Yuya Nishihara
35a596ff66 git: prohibit creation of remote named "git"
#1690
2023-08-29 22:50:46 +09:00
Yuya Nishihara
0e26ef7733 git: add constant for pseudo remote name "git" 2023-08-29 22:50:46 +09:00
Martin von Zweigbergk
dc06bbc7d1 commit: migrate remaining uses of Commit::tree_id() and delete it 2023-08-28 15:58:34 -07:00
Martin von Zweigbergk
90e78a1424 rewrite: return MergedTree from merge_commit_trees() 2023-08-28 15:58:34 -07:00
Martin von Zweigbergk
494026a9bf cli: merge trees via MergedTree in rebase_to_dest_parent() 2023-08-28 15:58:34 -07:00
Martin von Zweigbergk
bd6098e09e cli: merge trees via MergedTree in jj move 2023-08-28 15:58:34 -07:00
Martin von Zweigbergk
1674a421ec commit_builder: take MergedTreeId for root id argument 2023-08-28 15:58:34 -07:00
Martin von Zweigbergk
b19afb6d45 cli: migrate jj untrack to MergedTree API 2023-08-28 15:58:34 -07:00
Martin von Zweigbergk
6d89f0c0a0 cli: migrate jj restore to MergedTree API 2023-08-28 15:58:34 -07:00
Martin von Zweigbergk
a0291e99d7 cli: migrate cat, files & git submodule print to MergedTree API 2023-08-28 15:58:34 -07:00
Martin von Zweigbergk
d753c85e01 cli: migrate most diff-editing functions to MergedTree API 2023-08-28 15:58:34 -07:00
Martin von Zweigbergk
732e448458 diff_util: use MergedTree throughout
This switches the whole `diff_util` module to working with
`MergedTree`, `Merge<Option<TreeValue>>` etc., so it can support
tree-level conflicts.

Since we want to avoid using `ConflictId`s, I switched the hash we use
for conflicts in `--git` style diffs to use an all-'0' id instead of
using the conflict id.
2023-08-27 07:50:28 -07:00
Martin von Zweigbergk
5309335405 diff_util: make diff_content() return empty for missing path
I'm not sure this is a win on its own, but it simplifies coming
patches.
2023-08-27 07:50:28 -07:00
Martin von Zweigbergk
5ef925deb8 diff_util: unify handling of unexpected cases
This moves the error cases last in each `match` block, switches to
using format strings, and includes the full value in the message.
2023-08-27 07:50:28 -07:00
Martin von Zweigbergk
6df7db3dc0 merge_tools: pass MergedTree to run_mergetool() 2023-08-27 07:35:01 -07:00
Martin von Zweigbergk
17fe5e39c5 merge_tools: pass MergedTrees to edit_diff() 2023-08-27 07:35:01 -07:00
Martin von Zweigbergk
54b9ecce68 merge_tools: pass MergeTree to run_mergetool_external() 2023-08-27 07:35:01 -07:00
Martin von Zweigbergk
1895a55157 working_copy: make old_checkout argument be MergedTreeId
I think this was the last piece for making the working copy handle
tree-level conflicts.
2023-08-27 06:49:45 -07:00
Martin von Zweigbergk
abf3853717 working_copy: return MergedTreeId on snapshot 2023-08-27 06:49:45 -07:00
Martin von Zweigbergk
88e9933462 working_copy: enable storing multiple tree ids in state file 2023-08-27 06:49:45 -07:00
Yuya Nishihara
a0ae09f461 templates: reword signature placeholders to match description 2023-08-27 09:38:36 +09:00
Yuya Nishihara
f422f1300c templater: move empty signature placeholder to user template
This patch also extracts format_detailed_signature() function to deduplicate
the "show" template bits.

The added placeholder templates aren't labeled as "empty". If needed, I think
the whole template can be labeled as "empty" (or "empty_commit") just like
"working_copy".

Closes #2112
2023-08-27 09:38:36 +09:00
Yuya Nishihara
b45da80c12 tests: add more tests for empty signature
As I'm going to change the Signature type to not fill out a placeholder
message, we need to test the builtin templates as well.
2023-08-27 09:38:36 +09:00
Yuya Nishihara
88b509f857 tests: do not use "author" template keyword to test string functions
I'm going to change the default formatting of empty Signature type, and
these tests should use a non-empty keyword.
2023-08-27 09:38:36 +09:00
Martin von Zweigbergk
a186b5ffce cli: use MergedTree in jj chmod 2023-08-26 08:16:57 -07:00
Martin von Zweigbergk
d0fb154e7e cli: use MergedTreeBuilder in jj chmod 2023-08-26 08:16:57 -07:00
Martin von Zweigbergk
f877610792 merge: add Merge::num_sides()
An alternative name for it would be `arity()`, but `num_sides()`
probably more clearly says that it's not about the number of removes
or the total number of terms.
2023-08-25 08:54:49 -07:00
Martin von Zweigbergk
85bdba5bea working_copy: use MergedTree for diffing in reset() 2023-08-25 07:06:20 -07:00
Yuya Nishihara
3f7d884d00 templater: fix offset of negative substr() index to be char-based 2023-08-25 22:59:31 +09:00
Yuya Nishihara
3bf92a0914 templater: make .short(negative_len) return 0-length string
I think this is less surprising than falling back to the default length.
i64-to-usize conversion can also overflow on 32 bit environment, but I'm not
bothered to handle overflow scenario.
2023-08-25 22:59:20 +09:00
Martin von Zweigbergk
23509e939e working_copy: get diff from MergedTrees
To support tree-level conflicts, we're going to need to update the
working copy from one `MergedTree` to another. We're going need to
store multiple tree ids in the `tree_state` file. This patch gets us
closer to that by getting the diff from `MergedTree`s`, even though we
assume that they are legacy trees for now, so we can write to the
single-tree `tree_state` file.
2023-08-25 06:40:36 -07:00
Vamsi Avula
89b7b0bfe8 templates: colorize description_placeholder
Also, see https://github.com/martinvonz/jj/pull/2100.
2023-08-25 10:03:30 +05:30
Zachary Dremann
ac448202da templates: Add more string methods
Add starts_with/ends_with/remove_prefix/remove_suffix/substr methods to string when templating.
2023-08-24 11:24:07 -04:00
Zachary Dremann
9702a425e5 Allow negative numbers in the template grammar
This allows negative numbers, which also means functions which took numbers can now take negative numbers

Luckily, they all already handled this exactly as expected.
2023-08-24 11:24:07 -04:00
Martin von Zweigbergk
6b5544f335 tree_builder: add a set_or_remove() and simplify callers
Many of the `TreeBuilder` users have an `Option<TreeValue>` and call
either `set()` or `remove()` or the builder depending on whether the
value is present. Let's centralize this logic in a new
`TreeBuilder::set_or_remove()`.
2023-08-24 06:08:25 -07:00
Vladimir Petrzhikovskii
386f002f5a git: add --all-remotes to git fetch 2023-08-24 12:52:41 +02:00
Martin von Zweigbergk
0dcd2fa265 cli: make jj git push default to -r 'remote_branches()..@'
The way `jj git push` without arguments chooses branches pointing to
either `@` or `@-` is unusual and difficult to explain. Now that we
have `-r`, we could instead default it to `-r '@-::@'`. However, I
think it seems likely that users will want to push all local branches
leading up to `@` from the closest remote branch. That's typically
what I want. This patch changes the default to do that.
2023-08-23 15:00:03 -07:00
Martin von Zweigbergk
14d35b0198 cli: make jj git push -r just warn if no branches targeted
If there are branches in the revset that don't need to be pushed
because they already match the destination, we currently just print
`Nothing changed.` It seems consistent with that to also treat it as
success if there are no branches in the specified set to start
with. This patch makes the command print a warning in that case
instead.
2023-08-23 15:00:03 -07:00
Martin von Zweigbergk
d9bd578662 cli: reduce scope of a variable in jj git push 2023-08-23 15:00:03 -07:00
Oscar Bonilla
31f71f29bf Enable wrapping help in clap 2023-08-22 22:24:03 -07:00
Piotr Kufel
2109a7b488 Fix .gitignore handling of ignored directories
- Ignore .gitignore files from untracked directories
 - Do not allow un-ignoring files within ignored directories
2023-08-22 22:08:32 -07:00
Waleed Khan
1633eccdca Use { workspace = true } to appease VS Code's Cargo.toml parser
The VS Code "Better TOML" plugin (which I think most of our VS Code developers use?) doesn't support the `x.y = z` syntax at the top level, even though it's valid TOML. 

This is also useful if we ever want to add additional properties in different sub-crates (although unlikely for the near future).
2023-08-22 21:38:53 -07:00
Oscar Bonilla
30c2a21a14 Fix docs for diff --stat 2023-08-22 20:38:15 -07:00
Yuya Nishihara
c5b6e9705d git: extract add_remote() function, and map git2::Error there
I'm going to add check for remote named "git" there.
2023-08-23 10:02:52 +09:00
Yuya Nishihara
61172b1c1e git: on rename_remote(), check conflicts of new remote name 2023-08-23 10:02:52 +09:00
Yuya Nishihara
46dd6dd9c6 git: handle remote not found error by remove/rename_remote() 2023-08-23 10:02:52 +09:00
Ilya Grigoriev
872a0932cd cli tests: Move current_operation_id to test_utils 2023-08-22 17:39:56 -07:00
Zachary Dremann
1221e306a1 Make find_all_variables lazy, and not allocate
There's no need for it to allocate the variable names, and the only place it's
currently used can benefit from returning early if `$output` is found
2023-08-22 13:15:56 -04:00
Zachary Dremann
562b9d42bf No need for Lazy in LIVE_GUARDS
Mutex::new and Slab::new are both const, so we can use a static mutex directly
2023-08-22 02:12:05 -04:00
Ilya Grigoriev
038867fd3f merge_tools: Allow 3-pane diff editing
As discussed in https://github.com/martinvonz/jj/discussions/1905#discussioncomment-6589673
2023-08-21 20:19:15 -07:00
Ilya Grigoriev
ccd4f8e159 merge_tools: function to extract all variables from tool arguments
To be used in the next commit
2023-08-21 20:19:15 -07:00
Ilya Grigoriev
e743ba78b0 fake_diff_editor: Allow specifying extra arguments to be ignored 2023-08-21 20:19:15 -07:00
Ilya Grigoriev
54d4c9c475 cli_utils: reduce duplication in select_diff 2023-08-21 20:19:15 -07:00
Ilya Grigoriev
fdf1a56178 test_diffedit_command: Show that diffedit ignores unknown files
To me, this behavior seems a bit unexpected. We may want to fix it later
2023-08-21 19:02:19 -07:00
Martin von Zweigbergk
c43a3067eb revset: pass all context arguments to parse() via an object
`revset::parse()` already has a `RevsetWorkspaceContext` argument, so
I think it makes sense to put that and the other context arguments
into a larger `RevsetParseContext` object.
2023-08-20 21:30:06 -07:00
Martin von Zweigbergk
5f3df4aaea revset: resolve "@" symbol's workspace id earlier (while parsing)
We resolve file paths into repo-relative paths while parsing the
revset expression, so I think it's consistent to also resolve which
workspace "@" refers to while parsing it. That means we won't need the
workspace context both while parsing and while resolving symbols.

In order to break things like `author("martinvonz@")` (thanks to @yuja
for catching this), I also changed the parsing of working-copy
expressions so they are not allowed to be
quoted. `author(martinvonz@)` will therefore be an error now. That
seems like a small improvement anyway, since we have recently talked
about making `root` and `[workspace]@` not parsed as other symbols.
2023-08-20 17:57:18 -07:00
Preston Van Loon
ac5d8eb784 Add UTC format for timestamp formats. Thanks to @rauljordan for these changes.
Add tests for new UTC timestamp format

Add documentation for timestamp utc

Update CHANGELOG.md
2023-08-20 17:24:09 -05:00
Oscar Bonilla
5bd726f77d Add jj diffs --stat option 2023-08-19 23:49:16 -07:00
Martin von Zweigbergk
c3d9ba9ca9 cli: let custom binaries add extra default configs
Custom binaries will often want to provide e.g. additional command
aliases, additional revset aliases, custom colors, etc. This adds a
mechanism for them to do that.
2023-08-19 06:48:29 -07:00
Emily Fox
2062abdc9d templates: replace empty name and email strings with placeholders
New placeholders say "(no name availalbe)" and "(no email available)",
because empty strings aren't _necessarily_ a configuration issue.
2023-08-18 17:22:59 -05:00
Emily Fox
3f8ac2198d commits: use empty strings instead of placeholders for missing name or email
This commit replaces the functions `UserSettings::user_name_placeholder()`` and
`UserSettings::user_email_placeholder()` with `const` `&str`s to emphasize that
the placeholder strings must not be changed to support commits without
names or email addresses made before this change.
2023-08-18 17:22:59 -05:00
Vamsi Avula
956bd02977 templates: add placeholder label for no description 2023-08-18 11:14:45 +05:30
Benjamin Saunders
6c4b8a7383 settings: support human-readable byte sizes for max-new-file-size 2023-08-17 19:29:38 -07:00
Ben Saunders
351e7feef5 working_copy: don't snapshot new files larger than 1MiB by default 2023-08-17 19:29:38 -07:00
Ilya Grigoriev
863f1760f9 log template: make root commit green instead of bright green
Bright green really pops on my screen, and I don't think there is a reason
for the root commit to be attention-grabbing.

This follows up on https://github.com/martinvonz/jj/pull/2084.
2023-08-16 17:26:36 -07:00
Yuya Nishihara
81f1ae38b3 revset: add literal:"string" pattern syntax
The syntax is slightly different from Mercurial. In Mercurial, a pattern must
be quoted like "<kind>:<needle>". In JJ, <kind> is a separate parsing node, and
it must not appear in a quoted string. This allows us to report unknown prefix
as an error.

There's another subtle behavior difference. In Mercurial, branch(unknown) is
an error, whereas our branches(literal:unknown) is resolved to an empty set.
I think erroring out doesn't make sense for JJ since branches() by default
performs substring matching, so its behavior is more like a filter.

The parser abuses DAG range syntax for now. It can be rewritten once we remove
the deprecated x:y range syntax.
2023-08-17 07:42:12 +09:00
Benjamin Brittain
313670d3c2 Fixed missing quote in "jj config set" help 2023-08-16 14:57:48 -04:00
Emily Fox
9ba9ecd708 revset: add function mine() 2023-08-16 11:00:14 -05:00
Martin von Zweigbergk
873634a80e cli: when splitting change without description, skip it on second part
One use case for `jj split` is when creating a new commit from some of
the changes in the working copy. If there's no description on the
working-copy commit in that case, it seems better to not ask the user
to provide one when they're splitting the commit either.
2023-08-15 10:12:12 -07:00
Vamsi Avula
3869b7c2ac cli: refactor default_description to UserSettings 2023-08-15 21:25:50 +05:30
Vamsi Avula
72d6e20a08 cli: replace CommandHelper with UserSettings where sufficient 2023-08-15 21:25:50 +05:30