Commit graph

726 commits

Author SHA1 Message Date
Yuya Nishihara
0e1f098376 cli: add WorkspaceCommandHelper::evaluate_revset(expr)
I'll add more workspace-derived parameters to RevsetExpression::evaluate().
2022-10-24 01:48:00 +09:00
Yuya Nishihara
977cfd3d4a repo_path: make FsPathParseError displayable by itself
So it can be easily embedded in other error types such as RevsetError.
2022-10-24 01:48:00 +09:00
Yuya Nishihara
b885dc75f6 cli: inline repo_paths_from_values()
Unlike matcher_from_values(), this function is trivial and isn't widely
used. Let's simply do .map() and .collect().

TODO comment is relocated to matcher_from_values(). I think glob and
fileset-like stuff will be added to the matcher parser, not to the
'Path -> RepoPath' function. And it's probably implemented in lib crate.
2022-10-22 12:40:43 +09:00
Yuya Nishihara
50f327768c cli: move repo_paths|matcher_from_values() to WorkspaceCommandHelper
args.remove resolution in cmd_sparse() is reordered to accommodate with
borrow checker.
2022-10-22 12:40:43 +09:00
Yuya Nishihara
d635d02f06 cli: add WorkspaceCommandHelper::parse_file_path() for convenience
WorkspaceCommandHelper knows the context where user file pattern should
be resolved.
2022-10-22 12:40:43 +09:00
Yuya Nishihara
71ef8e74aa cli: remove now unused Ui::with_cwd() 2022-10-22 12:40:43 +09:00
Yuya Nishihara
3fe6da1b51 repo_path: migrate parse_file_path() from ui
It seems a bit invasive that RepoPath constructor processes an environment
like cwd, but we need an unmodified input string to build a readable error.
The error could be rewrapped at cli boundary, but I don't think it would
worth inserting indirection just for that.

I made s/file_path/fs_path/ change because there's already to_fs_path()
function, and "file path" in RepoPath context may be ambiguous.
2022-10-22 12:40:43 +09:00
Yuya Nishihara
689332aedd file_util: move path handling functions from ui module
We'll need this kind of functions in the library crate to parse user file
patterns.
2022-10-22 12:40:43 +09:00
Benjamin Saunders
037eaaf36c repo: forbid checking out the root commit
Prevents `jj edit root` from succeeding, which would otherwise place
the repo in a state where every operation panics.
2022-10-21 10:10:07 -07:00
Benjamin Saunders
305cb3a7ee cli: search @- for branches to push when @ has none 2022-10-20 22:18:48 -07:00
Benjamin Saunders
b009019d8d cli: add git remote rename subcommand 2022-10-20 11:04:16 -07:00
Yuya Nishihara
bbdcd6faaf cli: apply path normalization to absolute input path, not to relative path
This patch addresses TODOs described in parse_file_path_wc_in_cwd() test.
Since the input string is considered a filesystem path, I think it makes
sense to normalize the cwd + input path first.

These utility functions will probably be moved to lib to implement file()
revset resolution.
2022-10-21 01:56:23 +09:00
Yuya Nishihara
58977f8cbf cli: simplify relative_path() by leveraging ancestors() iterator
Just code cleanup. There should be no behavior change.
2022-10-21 01:56:23 +09:00
Yuya Nishihara
87bcdd4e51 cli: remove redundant maybe_tty flag
It should be valid to test isatty(stdout) even if the output stream is paged.
2022-10-20 10:31:04 +09:00
Yuya Nishihara
0633856ab2 cli: remove 'dyn Write' support from Ui, use terminal output
Let the test harness suppress uninteresting output. Anyway, these tests
would print nothing.

I think Ui::with_cwd() can also be removed after refactoring file path
handling.
2022-10-20 10:31:04 +09:00
Benjamin Saunders
646fc338ab Include @ in the default revset
Yields a less confusing behavior of `jj log` after pushing a commit.
2022-10-19 13:30:16 -07:00
Benjamin Saunders
d188240939 Less opinionated DynWriteLock
Allows easier reuse by future variants of UiOutputPair.
2022-10-18 22:26:13 -07:00
Benjamin Saunders
c046e1c845 Remove superfluous lifetime from Ui 2022-10-19 13:39:46 +09:00
Benjamin Saunders
0a3502453d Simplify UI test stdio 2022-10-19 13:39:46 +09:00
Ilya Grigoriev
4fed26dffd Alias -B for --allow-backwards in branch set
I find myself using this argument almost every time, but it's
long to type. At the same time, fish completion does not work well
for `--allow-backwards` for some reason (though I think an alias would
be nice regardless).
2022-10-16 22:09:00 -07:00
Martin von Zweigbergk
a061ac022e formatter: add a with_label() helper
There's a risk of forgetting to call `remove_label()` and I've wanted
to reduce that risk for a long time. I considered creating RAII
adapters that implement `Drop`, but I didn't like that that would
ignore errors (such as `BrokenPipe`) that can happen while emitting an
escape sequence in `remove_label()`. I would ideally have liked
Python's context managers here, but Rust doesn't have that. Instead,
we get to use closures. That works pretty well, except that we can't
return other errors than `io::Error` inside the closures. Even with
that limitation, we can use the new `with_label()` method in all but a
few cases.

We can't define the `with_label()` method directly in the trait
because `&mut self` is not a trait object, so we can't pass it on to
the closure (which expects a trait object). The solution is to use
`impl dyn Formatter` (thanks to @kupiakos for figuring that
out!). That unfortunately means that we can *only* call the function
on trait objects, so if `f` is a concrete formatter type
(e.g. `PlainTextFormatter`), then `f.with_label()` won't
compile. Since we only ever access the formatters as trait objects,
that's not really a problem, however.
2022-10-13 19:27:18 -07:00
Martin von Zweigbergk
a5f7e09cbb cli: clarify jj branch forget help
Closes #532.
2022-10-12 23:33:49 -07:00
Martin von Zweigbergk
999e31089b cli: don't snapshot when cloning Git repo
There's nothing to snapshot when we have just created an empty repo to
clone into. There are also no Git refs to import.
2022-10-12 06:22:38 -07:00
Martin von Zweigbergk
b4dc105dd7 cli: remove early return after merging operations
This simplifies the control flow by having only one return (plus the
implicit ones from `?`).
2022-10-12 06:22:38 -07:00
Martin von Zweigbergk
94501131ac cli: when merging concurrent operations, snapshot afterwards
It seems simpler to do the snapshotting after merging any concurrent
operations instead of snapshotting on top of one of the operations,
especially since the attempt to snapshot may end up noticing that the
working copy is stale.

More importantly, snapshotting before resolving operations resulted in
a crash if the working copy was modified. That happened because we
held a lock on the operation heads (`locked_op_heads`) while we tried
to record the operation committing the working copy. I noticed this
only after adding the test.
2022-10-12 06:22:38 -07:00
Martin von Zweigbergk
34c24ae035 cli: move call to snapshot() out of for_loaded_repo()
We don't always want to do the snapshotting etc. right away, so let's
have the callers decide when to do it. This is just a refactoring;
I'll change the behavior slightly in separate commits.
2022-10-12 06:22:38 -07:00
Martin von Zweigbergk
94a91d9864 cli: inline WorkspaceCommandHelper::for_loaded_repo() 2022-10-12 06:22:38 -07:00
Martin von Zweigbergk
5ab74ebd5f cli: extract function for snapshotting and importing Git refs
This patch moves most of the remainder of
`WorkspaceCommandHelper::for_loaded_repo()` into a new function. We'll
inline `WorkspaceCommandHelper::for_loaded_repo()` next.
2022-10-12 06:22:38 -07:00
Martin von Zweigbergk
23910f65eb cli: don't snapshot when adding workspace
When we have just created a new workspace, there's no need to snapshot
the working copy and import Git refs, so use the new constructor
there.
2022-10-12 06:22:38 -07:00
Martin von Zweigbergk
8780f86435 cli: add non-snapshotting constructor for WorkspaceCommandHelper
`WorkspaceCommandHelper::for_loaded_repo()` creates a new instance,
imports Git refs (if using the Git backend), and snapshots the working
copy. This patch adds a new constructor function that only does the
first step. I think we'll want that functionality when we add a
command for updating a stale working copy (instead of doing it
automatically as we currently do).
2022-10-12 06:22:38 -07:00
Martin von Zweigbergk
5fa21b612c cli: remind the user to configure their name and email
This commit adds a reminder in `finish_transaction()` if the user
hasn't configured their name and email. That means they'll get a
reminder after most mutating commits, except for commands that only
snapshot the working copy, and a few more cases.

Closes #530.
2022-10-09 21:24:05 -07:00
Martin von Zweigbergk
f356578b5b cli: clarify that the "first" commit created by split is the parent
This came up in discussion #620.
2022-10-09 19:56:38 -07:00
Martin von Zweigbergk
e11540162a graphlog: use usize::from(:bool) to convert boolean to integer
As suggested by a newer Clippy version.
2022-10-09 12:20:15 -07:00
Martin von Zweigbergk
043d118f1f cli: disallow initializing repo with native backend by default
The native backend is just a proof of concept and there's no real
reason to use it other than for testing, so let's reduce the risk of
accidentally creating repos using it.
2022-10-09 01:00:03 -07:00
Yuya Nishihara
832457d4a5 cli: fix --color=auto to not test isatty() unless initialized for terminal
No behavior change since ui here is always initialized for_terminal().
2022-10-09 09:08:46 +09:00
Yuya Nishihara
6a126bc033 cli: leverage Stdout/errLock in place of Mutex<Box<dyn Write>>
Since stdout/stderr has its own locking mechanism, we don't need yet
another Mutex.
2022-10-09 09:08:46 +09:00
Yuya Nishihara
536cab4cd7 cli: bypass stdout_formatter() for simple write calls 2022-10-09 09:08:46 +09:00
Yuya Nishihara
cb53ccbe5c cli: store bare output streams in ui, create formatter per request
This allows us to reconfigure the formatter without reinitializing the
underlying streams.
2022-10-09 09:08:46 +09:00
Yuya Nishihara
7e83b30d8e cli: remove useless Box wrapper from buffered formatter 2022-10-09 09:08:46 +09:00
Yuya Nishihara
3392e83486 cli: do not abstract away underlying output stream at formatter layer
Since the concrete Formatter type is hidden behind the Ui, there wouldn't
be many reasons to use dyn Write at the formatter layer. This allows us
to create a formatter against MutexGuard<Box<dyn Write>> without one more
Box<dyn Write> wrapper.
2022-10-09 09:08:46 +09:00
Yuya Nishihara
885f1d04d1 cli: introduce FormatterFactory to cache color table
This should help to create a temporary ColorFormatter instantly.

A cached_colors table could also be shared across formatters, but doing that
would require some locking mechanism. Since commands like cmd_log/diff()
use a single formatter instance, I don't think shared mutable cache would be
needed for the moment.
2022-10-09 09:08:46 +09:00
Yuya Nishihara
56191610c7 cli: pass formatter label by reference
All callers do String::from(), .to_string(), or .clone(), but owned label
isn't needed unless formatter is a ColorFormatter.
2022-10-08 00:52:33 +09:00
Yuya Nishihara
a1a93682cb cli: keep and reuse formatter instance at call site 2022-10-08 00:52:33 +09:00
Yuya Nishihara
97f37526e7 cli: extract write_commit_summary() as utility function
This allows callers to instantiate long-lived formatter. ui.write() can't
be invoked while formatter is borrowed. My plan is to make Ui directly hold
output streams so the color settings can be easily reset.
ui.stdout/stderr_formatter() will create a temporary formatter there.

write_commit_summary() could be hosted by WorkspaceCommandHelper to eliminate
some of the function arguments, but that would make the source RepoRef unclear
while transaction is in progress.
2022-10-08 00:52:33 +09:00
Martin von Zweigbergk
18c0b97d9d cli: remove jj bench commands
I haven't used these in a long time. Not including it reduces the
binary size from 16.8 MB to 15.1 MiB.
2022-10-05 22:12:12 -07:00
Yuya Nishihara
f5d0419384 working_copy: return {operation_id, workspace_id} by reference
Let WorkspaceCommandHelper clone it. WorkspaceCommandHelper could return
workspace_id by reference, but doing that would introduce noisy .clone()
calls and lifetime mess.
2022-10-03 21:41:20 -07:00
Yuya Nishihara
1800354465 working_copy: remove .clone() from TreeState proxy methods
Let the caller .clone() as needed.
2022-10-02 22:46:09 +09:00
Tal Pressman
621caa4dcb add default log revset configuration setting 2022-10-02 16:56:18 +09:00
Yuya Nishihara
7faa3c8e81 cli: always call locked_wc.finish() after snapshotting working copy
Otherwise mtime information could be lost, and snapshot() would always
need to build a tree object for comparison.

Closes #554
2022-10-02 15:15:18 +09:00
Yuya Nishihara
a8a3a236b0 working_copy: on finish(), don't serialize tree_state if known to be clean
This allows us to call locked_wc.finish() no matter if the tree is changed
or not.
2022-10-02 15:15:18 +09:00
Yuya Nishihara
e716fe7abf working_copy: remove return value from TreeState::snapshot()
I'll make TreeState::snapshot() return a boolean denoting whether tree_state
is updated or not. New tree_id can be obtained from TreeState, so let's
remove it from the return value.
2022-10-02 15:15:18 +09:00
Martin von Zweigbergk
3b3f6129e6 backend: allow negative timestamps in commits and operations
I was reading a draft of "Git Rev News: Edition 91" [1] where Peff
mentions some unfinished patches to allow negative timestamps in
Git. So I figured I should add support for that before I forget. I
haven't checked if libgit2 supports it, so it might be that our Git
backend still doesn't support it after this patch.

 [1] https://github.com/git/git.github.io/blob/master/rev_news/drafts/edition-91.md
2022-09-30 00:50:17 -07:00
Martin von Zweigbergk
3fc7b549ec cleanup: rename some more variables from checkout_* to ~wc_ 2022-09-29 23:51:34 -07:00
Martin von Zweigbergk
89680b8df9 cli: update off of deprecated clap API 2022-09-29 17:53:36 -07:00
Martin von Zweigbergk
b561a05d25 cargo: upgrade to clap 4.0.4
I changed the "GLOGAL OPTIONS" help heading to use title case, to
match clap's new help style.

I also removed our override of the help text for `-h, --help` because
the default text now includes "(use `-h` for a summary)" (and it's
harder override now).

Perhaps the most obvious difference to users will be the changed help
output
(https://epage.github.io/blog/2022/09/clap4/#polishing-help-output). It
no longer has color, and long lines are not wrapped. I suppose we
should wrap the text ourselves instead..
2022-09-29 17:53:36 -07:00
Martin von Zweigbergk
1665e1dd21 cli: reuse default_app() in test 2022-09-29 17:53:36 -07:00
Martin von Zweigbergk
d1565fb6eb cli: on push, indicate which branches we're going to force-push 2022-09-27 02:23:05 -07:00
Martin von Zweigbergk
4f0ccedd31 cli: don't call process::exit() in create_ui()
This patch move the call to `process::exit()` out of `create_ui()` by
letting that function return a `(Ui, Result<(), CommandError>)`.
2022-09-25 19:43:47 -07:00
Martin von Zweigbergk
cc30cb6ca8 aliases: when invalid command found, let clap handle it
When we resolve aliases and we try to resolve something that is not a
real command and not an alias, we currently replicate `clap`'s error
message. I don't know why I did that because it seems that we should
just stop resolving aliases and let `clap` try to parse what we have
resolved at that point. This patch makes that change, thereby removing
an additional call to `process::exit()`.
2022-09-25 19:40:06 -07:00
Martin von Zweigbergk
3e0d49e847 workspace: make capable of loading with out-of-tree backend 2022-09-25 09:40:42 -07:00
Martin von Zweigbergk
ea5aa0a96d cleanup: replace some PathBuf args by &Path
In many of these places, we don't need an owned value, so using a
reference means we don't force the caller to clone the value. I really
doubt it will have any noticeable impact on performance (I think these
are all once-per-repo paths); it's just a little simpler this way.
2022-09-25 09:40:42 -07:00
Yuya Nishihara
3a6c6d8bf4 commit: make parent_ids() return slice instead of cloned vec
I feel it doesn't make sense for a simple getter function to create an
owned vec after 0108673087 "backend: let each backend handle root commit
on write."
2022-09-25 22:29:07 +09:00
Martin von Zweigbergk
7a9f9a14db cli: extract a function for creating a default Ui
This will also be reused by binaries that want to add custom commands.
2022-09-24 07:28:10 -07:00
Martin von Zweigbergk
a0dfd4a4a8 cli: extract function for top-level error reporting
This will also be reused by custom commands.
2022-09-24 07:28:10 -07:00
Martin von Zweigbergk
a7f19b85f8 cli: move command-agnostic parts of dispatch() into cli_util
The idea is that these parts can be reused for custom commands.
2022-09-24 07:28:10 -07:00
Martin von Zweigbergk
7f6cf1e6d9 cli: extract new cli_util module
This commit moves much of the `commands` module that isn't specific to
a particular command into a new `cli_util`.

Much of this is actually not even CLI-specific, so we should move that
further down into the library, but that can come later. That includes
the code in `WorkspaceCommandHelper` for snapshotting the working copy
and automatically importing/exporting to a colocated Git working copy.
2022-09-24 07:28:10 -07:00
Martin von Zweigbergk
92d792f144 cli: add subcommands using clap's builder API
I want to make most of the `dispatch()` code unaware of which commands
exist, so it becomes easier to tweak that set of commands in a custom
binary.
2022-09-24 07:28:10 -07:00
Martin von Zweigbergk
d1f0008d32 cli: use the "dynamic" clap::Command while resolving aliases
I'm trying to make it easier to create a custom `jj` binary with
custom commands, without having to replace the `Args` type we parse
arguments into. For that to work, we need to resolve aliases using the
`clap::Command` type instead.
2022-09-24 07:28:10 -07:00
Martin von Zweigbergk
20f6f45cfe cli: make dispatch() less generic
We don't need it to be generic, so let's simplify.
2022-09-24 07:28:10 -07:00
Yuya Nishihara
51cb4d901c cli: abbreviate operation id embedded in warning/error messages
Operation id is quite long and these messages looked noisy with the full
hash.
2022-09-22 22:06:54 +09:00
Martin von Zweigbergk
e5da4df243 cli: hide jj close/commit and jj open/uncommit
Now that open commits are disabled by default, seeing `close` and
`open` in `jj help` is confusing.

I'm a little ambivalent about hiding `jj commit` because it's useful
as a way of adding a description and starting a new change with a
single command. We can always add a new command for that if we want
to.
2022-09-21 23:06:40 -07:00
Martin von Zweigbergk
b654a1fe84 cleanup: remove extern crate declarations
`extern crate` is no longer needed since edition 2018.
2022-09-21 22:24:09 -07:00
Martin von Zweigbergk
76fd6a830d CommitBuilder: take parents as argument in for_new_commit()
It's rare to want to create a commit directly off of the root commit,
so let's have the caller tell us which parents they want.
2022-09-20 21:20:57 -07:00
Martin von Zweigbergk
5270c165ed cli: lift a return statement out of an if-else block
As pointed out by IntelliJ (maybe it came from rust-analyzer or
something, I don't know). I also lifted out
`Err(CommandError::UserError())` and extracted a variable.
2022-09-19 15:10:54 -07:00
Martin von Zweigbergk
ff055a0701 cli: accept -r and ignore where revision is positional
Commands that take both paths and revisions as arguments take paths as
positional arguments and use `-r` for revisions (or more specific
options like `--from` and `--to`). It's therefore natural for the user
to think that they can run e.g. `jj describe -r abc123`. However,
since `jj describe` doesn't accept paths, it doesn't have a `-r`
argument either. Let's allow the user to specify a superfluous `-r`
that we just ignore.

This handling means that the user could run `jj show -r` (without a
revision argument) and it would use the default revision. That's
confusing, but at least we won't accept e.g. `jj show -r README.md`
(unless `README.md` is a revision), so it's probably okay?
2022-09-19 09:44:33 -07:00
Martin von Zweigbergk
6812bd9584 cleanup: rename checkout to wc_commit
`wc_commit` seems clearer than `checkout` and not too much longer. I
considered `working_copy` but it was less clear (could be the path to
the working copy, or an instance of `WorkingCopy`). I also considered
`working_copy_commit`, but that seems a bit too long.
2022-09-18 16:19:58 -07:00
Martin von Zweigbergk
c36b720dd4 cli: rename checkout to working_copy in template 2022-09-18 16:19:58 -07:00
Martin von Zweigbergk
46578fb892 cli: don't show open commits in green when open commits are disabled
I had missed that `Ui::write_commit_summary()` still shows open
commits in green even when open commits are disabled (as they are by
default these days). This patch fixes that.

The user can still override templates to format open commits
differently, but I'm not sure it's worth fixing that.
2022-09-17 22:52:20 -07:00
Yuya Nishihara
f3d39c7820 cli: add value_hint to support basic path completion
Otherwise 'jj diff [TAB]' doesn't provide completion on my zsh.
2022-09-18 00:02:30 +09:00
Yuya Nishihara
c9c3735faf cli: add basic support for 'jj log PATH'
In the current implementation, tree is diffed twice if both PATH and -p
are specified. If this adds significant cost, we'll need to reimplement
it without using a revset abstraction (or maybe adjust revset/graph API.)
2022-09-16 13:02:58 +09:00
Yuya Nishihara
873b5ba771 cli: pass in matcher to show_patch() 2022-09-16 13:02:58 +09:00
Kyle Lippincott
f173f59932 Fix typo in error message 2022-09-14 15:29:53 -07:00
Ilya Grigoriev
3244398e89 Fix rebase -r of a parent of a merge commit
Previously, using `rebase -r` on the parent of a merge commit
turned it into a non-merge commit. In other words, starting
with

```
    o   d
    |\
    o | c
    o | b
    | o a
    |/  
    o 
```

and doing `rebase -r c -d a` resulted in

```
    o d
    o b
    | o c
    | o a
    |/  
    o 
```

where `d` is no longer a merge commit.

For reference, here's a complete test that passed before this commit (but should NOT pass; see the diff for a test that should pass):

```
#[test]
fn test_rebase_single_revision_merge_parent() {
    let test_env = TestEnvironment::default();
    test_env.jj_cmd_success(test_env.env_root(), &["init", "repo", "--git"]);
    let repo_path = test_env.env_root().join("repo");

    create_commit(&test_env, &repo_path, "a", &[]);
    create_commit(&test_env, &repo_path, "b", &[]);
    create_commit(&test_env, &repo_path, "c", &["b"]);
    create_commit(&test_env, &repo_path, "d", &["a", "c"]);
    // Test the setup
    insta::assert_snapshot!(get_log_output(&test_env, &repo_path), @r###"
    @
    o   d
    |\
    o | c
    o | b
    | o a
    |/
    o
    "###);

    let stdout = test_env.jj_cmd_success(&repo_path, &["rebase", "-r", "c", "-d", "a"]);
    insta::assert_snapshot!(stdout, @r###"
    Also rebased 2 descendant commits onto parent of rebased commit
    Working copy now at: 3e176b54d680 (no description set)
    Added 0 files, modified 0 files, removed 2 files
    "###);
    insta::assert_snapshot!(get_log_output(&test_env, &repo_path), @r###"
    @
    o d
    | o c
    o | b
    | o a
    |/
    o
    "###);
}
```
2022-09-12 12:23:21 -07:00
Yuya Nishihara
b21a123bc8 cli: ensure rebase destinations are unique and not form a merge with root 2022-09-12 23:46:15 +09:00
Yuya Nishihara
cf0ab8b12b cli: extract helper function that resolves revisions to be used as base
We'll apply this logic to 'rebase -d'.
2022-09-12 23:46:15 +09:00
Martin von Zweigbergk
135fc93898 cli: document repeated -d arguments for jj rebase 2022-09-11 18:25:44 -07:00
Martin von Zweigbergk
5b17d82cf8 cli: add a version command
Closes #529.
2022-09-11 18:25:09 -07:00
Yuya Nishihara
459f2f78ba cli: on finish_transaction(), record operation id even if working copy is clean
While debugging stale working-copy recovery, I noticed the checkout commit
resurrected from the ancestor_op was way beyond the ancestor commit made by
jj squash. This patch is a workaround for the problem.

I'm not pretty sure if updating operation id is the right thing. If not, maybe
we'll need to look up more recent operation corresponding to the wc tree id from
the <ancestor_op>: range?
2022-09-11 16:18:10 +09:00
Josh Soref
99746a018b spelling: shouldn't
Signed-off-by: Josh Soref <2119212+jsoref@users.noreply.github.com>
2022-09-09 11:58:37 -07:00
Josh Soref
257baf8dfb spelling: changes
Signed-off-by: Josh Soref <2119212+jsoref@users.noreply.github.com>
2022-09-09 11:58:37 -07:00
Yuya Nishihara
3b60769874 diff_edit: do not make directories readonly
Otherwise directories containing files cannot be removed.

I think making files readonly is enough to tell user that the left side
cannot be edited, but I haven't tested that with Meld. If that's not enough,
we'll probably need to undo set_readonly_recursively() at exit.
2022-09-07 23:50:06 +09:00
Yuya Nishihara
e4a39137c9 diff_edit: create temporary directory with stable prefix 2022-09-07 23:50:06 +09:00
Yuya Nishihara
872081c867 tests: use testutils::new_temp_dir() thoroughly 2022-09-07 23:49:46 +09:00
Martin von Zweigbergk
4ea304a47d cli: add jj hide as an alias for jj abandon
I keep explaining the functionality as hiding the commit, so it seems
that `jj hide` is a natural name for it. Let's start by adding it as
an alias. My only hesitation with making `hide` the real command name
and `abandon` an alias that we start phasing out is that it feels more
natural to `abandon` the working copy in order to start working on a
new change than it does to `hide` it.
2022-09-04 20:43:01 -07:00
Glen Choo
468418f1ce cli: add interdiff command
Add the `jj interdiff` command for comparing only the diffs of commits.
Its args are identical to that of `jj diff`, minus `--revision` (because
interdiff always requires two commits).

Like `jj obslog -p`, Changes introduced by intervening commits are
ignored by rebasing `--from` onto `--to` 's parents.
2022-09-02 02:59:37 +08:00
Glen Choo
ed415c17b0 cli: refactor out rebase_to_destination_parent()
Refactor out the parent-rebasing parts of show_predecessor_patch() to
create rebase_to_destination_parent(). This will be reused for `jj
interdiff`.
2022-09-02 02:59:37 +08:00
Yuya Nishihara
c5aab9fe29 cli: fix crash on "jj merge whatever root" 2022-09-01 13:36:17 +09:00
Yuya Nishihara
1cc7fc4cd9 cli: error out if "new" parent revisions aren't unique
If more than one parents are specified, the user would expect a merge
commit.
2022-09-01 13:36:17 +09:00
Martin von Zweigbergk
3a46623446 cli: make jj merge delegate to jj new 2022-08-31 07:51:32 -07:00
Martin von Zweigbergk
a1a980d395 cli: make jj new create a merge commit if more than one arg given
`jj merge` just creates an empty change, which is practically the same
as `jj new`. The main difference is that the former requires more than
one argument and the latter requires at most one argument. It seems
cleaner to generalize them and make them aliases. This patch starts
doing that by making `jj new` accept more than one argument.

Instead of having `jj merge` be exactly an alias for `jj new`, we may
want to make it a thin wrapper that just checks that more than one
argument was given. That would probably be less confusing to users who
run `jj merge` without arguments to see what it does.

We should probably make `jj checkout` also be an alias for `jj new`,
but that will have to wait until we have removed support for open
commits (since `jj checkout` still has logic for dealing with open
commits).
2022-08-31 07:51:32 -07:00