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

2081 commits

Author SHA1 Message Date
Yuya Nishihara
52e26a8d9a cli: move merge-tools name to [table] header
Even though we need to repeat "merge-tools", I feel it's a bit better to
group parameters by tool name. Tools are sorted by name.
2022-12-15 15:16:50 +09:00
Yuya Nishihara
c86f7f87e4 cli: add comment why stock config isn't add_source()-d to main config_builder 2022-12-15 15:16:50 +09:00
Yuya Nishihara
0a28b2c508 cli: extract stock merge-tools config to file, embed it in binary
I think a separate .toml file is easier to maintain as the merge-tools
table will grow.
2022-12-15 15:16:50 +09:00
Martin von Zweigbergk
7f9a0a2820 cleanup: let new Clippy move variables into format strings
I ran an upgraded Clippy on the codebase. All the changes seem to be
about using variables directly in format strings instead of passing
them as separate arguments.
2022-12-14 21:30:58 -08:00
Martin von Zweigbergk
c8a04d6f69 cli: use .display() instead of debug format in two errors 2022-12-14 21:30:58 -08:00
Yuya Nishihara
cec4d6c214 cli: allow multiple diff outputs
"jj log -p --summary" now shows summary and color-words diff, like
"hg log -p --stat".

Handling of "-p" is tricky. I first considered "-p" would turn on the default
diff output, but I found it would be confusing if "jj log -p --git" showed
both color-words and git diffs. So the default format is inserted only if
no --git nor --color-words is explicitly specified.
2022-12-15 11:41:42 +09:00
Yuya Nishihara
07cf103ac1 cli: pass from/to_tree in to show_diff() instead of TreeDiffIterator
This allows us to generate diff in different formats. There are various ways
to achieve that:

 a. build TreeDiffIterator for each format (this patch)
 b. make TreeDiffIterator clonable
 c. collect TreeDiffIterator and reuse the resulting vec

(a) and (b) are practically the same. (c) would be more efficient if building
and iterating TreeDiffIterator were expensive, but I don't think it is because
Tree is cached by Store. If we add $GIT_EXTERNAL_DIFF-like feature, we'll
probably need Tree objects to snapshot them to /tmp. So I chose (a).
2022-12-15 11:41:42 +09:00
Yuya Nishihara
69e57daa64 cli: enable diff output by 'log --color-words'
It doesn't make sense that --git implies -p, but --color-words doesn't.
2022-12-15 11:41:42 +09:00
Yuya Nishihara
b4d6c9e8da cli: extract helper that resolves diff arguments for log-like commands 2022-12-15 11:41:42 +09:00
Yuya Nishihara
cdf3bfa55f cli: extract default_diff_format() from diff_format_for()
I'll make "jj log -p --summary" show both summary and diff, where -p will
be resolved to the default diff format.
2022-12-15 11:41:42 +09:00
Yuya Nishihara
f26582d0a3 cli: leverage show_patch() helper to implement show command 2022-12-15 11:41:42 +09:00
Martin von Zweigbergk
b28ff2fbd9 cli: use committer timestamp instead of author timestamp in log output
The author timestamp is rarely useful (in my experience). The
committer timestamp, on the other hand, can be useful for
understanding when a change was most recently modified. IIRC, I
originally picked the author timestamp to match the email (which is
the author's), but it's probably not confusing to use the author email
and the committer timestamp. I suspect few users will even reflect on
it.
2022-12-14 15:48:11 -08:00
Daniel Ploch
bd31bfd2d7 repo: give OpStore factory load semantics 2022-12-14 14:10:30 -08:00
Daniel Ploch
0f62c795d8 repo: move backend loading onto the StoreFactories struct 2022-12-14 14:10:30 -08:00
Daniel Ploch
25c379429c op_store: init/load by &Path, for consistency with other stores 2022-12-14 14:10:30 -08:00
Daniel Ploch
7cbea42a24 repo: rename BackendFactories to StoreFactories 2022-12-14 14:10:30 -08:00
Daniel Ploch
7756cfa61b op_store: op store delegates should not implement the OpStore trait directly 2022-12-14 14:10:30 -08:00
Yuya Nishihara
ffbd6eb945 tree: ensure Tree outlives its iterator on dropping self-referential struct
Just for sanity. It wouldn't matter unless the iterator implements Drop.

https://doc.rust-lang.org/reference/destructors.html
2022-12-15 01:51:25 +09:00
dependabot[bot]
1f3cfcec9d github: bump github/codeql-action from 2.1.36 to 2.1.37
Bumps [github/codeql-action](https://github.com/github/codeql-action) from 2.1.36 to 2.1.37.
- [Release notes](https://github.com/github/codeql-action/releases)
- [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md)
- [Commits](a669cc5936...959cbb7472)

---
updated-dependencies:
- dependency-name: github/codeql-action
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-12-14 07:35:59 -08:00
Yuya Nishihara
dce45794df cli: move show_patch() to diff_util
I think this belongs to the same category as show_diff().
2022-12-14 15:24:50 +09:00
Yuya Nishihara
dff53b1200 cli: simplify match arms in diff_format_for() 2022-12-14 15:24:50 +09:00
Yuya Nishihara
5e490f310f cli: extract show_diff*() functions and structs to new module
I think these functions are big enough to be separated from random chunk
of command functions.
2022-12-14 15:24:50 +09:00
Yuya Nishihara
73ea5cd56e cli: parse early args in/after alias properly
Follows up aa2ce88544 'cli: process args to "--help" and "help"'.
2022-12-14 13:51:23 +09:00
Yuya Nishihara
5dc73ab7ad cli: do not raise ClapError from resolve_aliases()
This allows us to process early args after alias resolution.
2022-12-14 13:51:23 +09:00
Glen Choo
aa2ce88544 cli: process args to "--help" and "help"
Clap bails parsing when an "error" is encountered, e.g. a subcommand is missing,
"--help" is passed, or the "help" subcommand is invoked. This means that the
current approach of parsing args does not handle flags like `--no-pager` or
`--color` when an error is encountered.

Fix this by separating early args into their own struct and preprocessing them
using `ignore_errors` (per https://github.com/clap-rs/clap/issues/1880).

The early args are in a new `EarlyArgs` struct because of a known bug where
`ignore_errors` causes default values not to be respected
(https://github.com/clap-rs/clap/issues/4391 specifically calls out bool, but
strings may also be ignored), so when `ignore_errors` is given, the default
values will be missing and parsing will fail unless the right arg types are used
(e.g`. Option`). By parsing only early args (using the new struct) we only need
to adjust `no_pager`, instead of adjusting all args with a default value.
2022-12-14 04:50:14 +08:00
Glen Choo
a31897146f cli: paginate help
This does not respect "--no-pager", support will be added in the next
commit.
2022-12-14 04:50:14 +08:00
dependabot[bot]
ae981ff33a github: bump actions/checkout from 3.1.0 to 3.2.0
Bumps [actions/checkout](https://github.com/actions/checkout) from 3.1.0 to 3.2.0.
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](93ea575cb5...755da8c3cf)

---
updated-dependencies:
- dependency-name: actions/checkout
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-12-13 11:35:27 -08:00
dependabot[bot]
2a357ac2df cargo: bump insta from 1.22.0 to 1.23.0
Bumps [insta](https://github.com/mitsuhiko/insta) from 1.22.0 to 1.23.0.
- [Release notes](https://github.com/mitsuhiko/insta/releases)
- [Changelog](https://github.com/mitsuhiko/insta/blob/master/CHANGELOG.md)
- [Commits](https://github.com/mitsuhiko/insta/compare/1.22.0...1.23.0)

---
updated-dependencies:
- dependency-name: insta
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-12-13 11:32:05 -08:00
dependabot[bot]
5c7877cb5a cargo: bump serde from 1.0.149 to 1.0.150
Bumps [serde](https://github.com/serde-rs/serde) from 1.0.149 to 1.0.150.
- [Release notes](https://github.com/serde-rs/serde/releases)
- [Commits](https://github.com/serde-rs/serde/compare/v1.0.149...v1.0.150)

---
updated-dependencies:
- dependency-name: serde
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-12-13 11:31:53 -08:00
dependabot[bot]
9ec24dae00 cargo: bump timeago from 0.3.1 to 0.4.0
Bumps [timeago](https://github.com/vi/timeago) from 0.3.1 to 0.4.0.
- [Release notes](https://github.com/vi/timeago/releases)
- [Commits](https://github.com/vi/timeago/compare/v0.3.1...v0.4.0)

---
updated-dependencies:
- dependency-name: timeago
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-12-13 11:03:44 -08:00
Martin von Zweigbergk
b87c1cb514 github: new attempt at Dependabot auto-merge
This is an updated version of the workflow deleted in f5fc3c35f5,
trying the advice from
https://github.com/cli/cli/issues/6695#issuecomment-1348430969.
2022-12-13 10:39:58 -08:00
Yuya Nishihara
6237f3cdfd revset: fold nested parents expressions
Some other ancestors() expressions can also be substituted. Practically,
this is the rule to fold repeated '-' operators to evaluate them lazily.
2022-12-13 15:55:18 +09:00
Yuya Nishihara
069a8ed9bc revset: reimplement parents() as ancestors() with generation filter
This wouldn't make things any better by itself, but it allows us to merge
nested parents().
2022-12-13 15:55:18 +09:00
Yuya Nishihara
46b1465324 revset: add generation parameter to RevsetExpression::Ancestors/Range
Parents(heads) will be translated to Ancestors(heads, 1..2).
2022-12-13 15:55:18 +09:00
Yuya Nishihara
29a565e3fb revset: add substitution rule for roots..heads
While working on ancestor generation, I noticed Mercurial has this
substitution rule. Since it's easier to deal with Ancestors() than Range {},
'roots..heads' is first decomposed to ':heads & ~:roots'.
2022-12-13 15:55:18 +09:00
Yuya Nishihara
e6229e6d77 revset: turn RevWalkRevset into generic wrapper of cloneable iterator
I failed to solve type puzzle for to_predicate_fn<'a>(&'a self) where
'repo: 'a, so struct RevWalkRevset<'repo, T> is bounded by T to consume
the lifetime parameter.
2022-12-13 15:55:18 +09:00
Martin von Zweigbergk
bf5a00a3e5 github: add reminder about adding tests
Thanks, GitHub Copilot, for adding this item to the checklist :)
2022-12-12 21:43:42 -08:00
Martin von Zweigbergk
7de8ac0744 github: don't ask PR authors to add themselves to the changelog
Most people seem to have forgotten to add themselves despite the
reminder in the PR tempalte. I (or whoever does the release) will fill
it out just before each release instead, like I did for 0.6.0. I
didn't remove the people already on the list for this release, but
I'll regenerate it for next release anyway.
2022-12-12 21:43:42 -08:00
Yuya Nishihara
67be440f4a cli: resolve operation symbol first and apply '-' postfix repeatedly
Just like revsets.
2022-12-13 09:28:48 +09:00
Yuya Nishihara
c46c150542 cli: add one more operation to test_op_log()
Also made op id variables less dynamic as operation ids are now stable
in tests.
2022-12-13 09:28:48 +09:00
Yuya Nishihara
57e5a3be65 cli: reorder resolve_op_for_load() to fall back to resolve_single_op()
I'll add multiple '-' resolution to resolve_single_op().
2022-12-13 09:28:48 +09:00
Martin von Zweigbergk
9d040fef78 docs: indent conflict marker examples to not confuse tools
When importing `conflicts.md` into the Google repo, our internal tools
complained that it contained conflict markers. Similarly, if you ever
get an actual merge conflict in the file, the working-copy
snapshotting would parse our sample conflict markers here, forcing you
to work around it. Let's avoid that by indenting the conflict
markers. Hopefully readers will understand that the leading space is
not part of the markers.
2022-12-12 16:20:40 -08:00
Yuya Nishihara
4a889b986c index: implement generation filter on RevWalkGenerationRange
This will be a building block of 'parents(base)' revset. 'base---' will
be .filter_by_generation(3..4) for example. I think 'ancestors(base)' can
also have an optional generation parameter, but I haven't considered any
particular syntax yet.
2022-12-11 13:14:19 +09:00
Yuya Nishihara
832cf8d838 index: add RevWalk variant that tracks generation
Even though I couldn't determine if RevWalkGenerationRange has a measurable
cost compared to RevWalk, I'm not comfortable with enabling generation
tracking by default. So this patch adds a separate struct. I duplicated
Iterator::next() method as it seemed rather complicated to extract a common
iterator wrapper.

Actual filtering function and tests will be added by the next commit.
2022-12-11 13:14:19 +09:00
Yuya Nishihara
4740d7fac1 index: add slot to track state of wanted RevWalk items
RevWalkWorkItem<u32> to track generation for example.
2022-12-11 13:14:19 +09:00
Yuya Nishihara
03eff13d52 index: extract a couple of RevWalk helper functions to inner struct 2022-12-11 13:14:19 +09:00
Yuya Nishihara
a124f84949 index: move core RevWalk logic to inner struct
I'll add a RevWalk that can filter entries by generation range.
2022-12-11 13:14:19 +09:00
Waleed Khan
91ead75e43 feat(branch): support jj branch forget --glob 2022-12-10 16:51:10 -08:00
Waleed Khan
cd1e27a037 cleanup: alphabetize Cargo.toml 2022-12-10 16:51:10 -08:00
Martin von Zweigbergk
29db672a5c tutorial: mention jj edit and when it's useful
I made some other little touchups while at it.

Closes #840
2022-12-09 22:28:33 -08:00