mirror of
https://github.com/martinvonz/jj.git
synced 2025-01-19 19:08:08 +00:00
cli: deprecate -l
short alias for --limit
in favour of -n
This better matches `git log` and affects `jj log`, `jj op log` and `jj obslog`
This commit is contained in:
parent
059fc26df1
commit
72438fc9d2
6 changed files with 63 additions and 13 deletions
|
@ -21,6 +21,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||
|
||||
### Deprecations
|
||||
|
||||
* Replacing `-l` shorthand for `--limit` with `-n` in `jj log`, `jj op log` and `jj obslog`.
|
||||
|
||||
### New features
|
||||
|
||||
* Show paths to config files when configuration errors occur
|
||||
|
|
|
@ -49,8 +49,16 @@ pub(crate) struct LogArgs {
|
|||
/// Limit number of revisions to show
|
||||
///
|
||||
/// Applied after revisions are filtered and reordered.
|
||||
#[arg(long, short)]
|
||||
#[arg(long, short = 'n')]
|
||||
limit: Option<usize>,
|
||||
// TODO: Delete `-l` alias in jj 0.25+
|
||||
#[arg(
|
||||
short = 'l',
|
||||
hide = true,
|
||||
conflicts_with = "limit",
|
||||
value_name = "LIMIT"
|
||||
)]
|
||||
deprecated_limit: Option<usize>,
|
||||
/// Don't show the graph, show a flat list of revisions
|
||||
#[arg(long)]
|
||||
no_graph: bool,
|
||||
|
@ -137,6 +145,14 @@ pub(crate) fn cmd_log(
|
|||
let mut formatter = ui.stdout_formatter();
|
||||
let formatter = formatter.as_mut();
|
||||
|
||||
if args.deprecated_limit.is_some() {
|
||||
writeln!(
|
||||
ui.warning_default(),
|
||||
"The -l shorthand is deprecated, use -n instead."
|
||||
)?;
|
||||
}
|
||||
let limit = args.limit.or(args.deprecated_limit).unwrap_or(usize::MAX);
|
||||
|
||||
if !args.no_graph {
|
||||
let mut graph = get_graphlog(command.settings(), formatter.raw());
|
||||
let forward_iter = TopoGroupedGraphIterator::new(revset.iter_graph());
|
||||
|
@ -145,7 +161,7 @@ pub(crate) fn cmd_log(
|
|||
} else {
|
||||
Box::new(forward_iter)
|
||||
};
|
||||
for (commit_id, edges) in iter.take(args.limit.unwrap_or(usize::MAX)) {
|
||||
for (commit_id, edges) in iter.take(limit) {
|
||||
// The graph is keyed by (CommitId, is_synthetic)
|
||||
let mut graphlog_edges = vec![];
|
||||
// TODO: Should we update revset.iter_graph() to yield this flag instead of all
|
||||
|
@ -222,7 +238,7 @@ pub(crate) fn cmd_log(
|
|||
} else {
|
||||
Box::new(revset.iter())
|
||||
};
|
||||
for commit_or_error in iter.commits(store).take(args.limit.unwrap_or(usize::MAX)) {
|
||||
for commit_or_error in iter.commits(store).take(limit) {
|
||||
let commit = commit_or_error?;
|
||||
with_content_format
|
||||
.write(formatter, |formatter| template.format(&commit, formatter))?;
|
||||
|
|
|
@ -39,8 +39,16 @@ pub(crate) struct ObslogArgs {
|
|||
#[arg(long, short, default_value = "@")]
|
||||
revision: RevisionArg,
|
||||
/// Limit number of revisions to show
|
||||
#[arg(long, short)]
|
||||
#[arg(long, short = 'n')]
|
||||
limit: Option<usize>,
|
||||
// TODO: Delete `-l` alias in jj 0.25+
|
||||
#[arg(
|
||||
short = 'l',
|
||||
hide = true,
|
||||
conflicts_with = "limit",
|
||||
value_name = "LIMIT"
|
||||
)]
|
||||
deprecated_limit: Option<usize>,
|
||||
/// Don't show the graph, show a flat list of revisions
|
||||
#[arg(long)]
|
||||
no_graph: bool,
|
||||
|
@ -107,7 +115,13 @@ pub(crate) fn cmd_obslog(
|
|||
|commit: &Commit| commit.id().clone(),
|
||||
|commit: &Commit| commit.predecessors().collect_vec(),
|
||||
)?;
|
||||
if let Some(n) = args.limit {
|
||||
if args.deprecated_limit.is_some() {
|
||||
writeln!(
|
||||
ui.warning_default(),
|
||||
"The -l shorthand is deprecated, use -n instead."
|
||||
)?;
|
||||
}
|
||||
if let Some(n) = args.limit.or(args.deprecated_limit) {
|
||||
commits.truncate(n);
|
||||
}
|
||||
if !args.no_graph {
|
||||
|
|
|
@ -45,8 +45,16 @@ pub enum OperationCommand {
|
|||
#[derive(clap::Args, Clone, Debug)]
|
||||
pub struct OperationLogArgs {
|
||||
/// Limit number of operations to show
|
||||
#[arg(long, short)]
|
||||
#[arg(long, short = 'n')]
|
||||
limit: Option<usize>,
|
||||
// TODO: Delete `-l` alias in jj 0.25+
|
||||
#[arg(
|
||||
short = 'l',
|
||||
hide = true,
|
||||
conflicts_with = "limit",
|
||||
value_name = "LIMIT"
|
||||
)]
|
||||
deprecated_limit: Option<usize>,
|
||||
/// Don't show the graph, show a flat list of operations
|
||||
#[arg(long)]
|
||||
no_graph: bool,
|
||||
|
@ -191,7 +199,14 @@ fn cmd_op_log(
|
|||
ui.request_pager();
|
||||
let mut formatter = ui.stdout_formatter();
|
||||
let formatter = formatter.as_mut();
|
||||
let iter = op_walk::walk_ancestors(&head_ops).take(args.limit.unwrap_or(usize::MAX));
|
||||
if args.deprecated_limit.is_some() {
|
||||
writeln!(
|
||||
ui.warning_default(),
|
||||
"The -l shorthand is deprecated, use -n instead."
|
||||
)?;
|
||||
}
|
||||
let limit = args.limit.or(args.deprecated_limit).unwrap_or(usize::MAX);
|
||||
let iter = op_walk::walk_ancestors(&head_ops).take(limit);
|
||||
if !args.no_graph {
|
||||
let mut graph = get_graphlog(command.settings(), formatter.raw());
|
||||
for op in iter {
|
||||
|
|
|
@ -1097,7 +1097,8 @@ Spans of revisions that are not included in the graph per `--revisions` are rend
|
|||
|
||||
Possible values: `true`, `false`
|
||||
|
||||
* `-l`, `--limit <LIMIT>` — Limit number of revisions to show
|
||||
* `-n`, `--limit <LIMIT>` — Limit number of revisions to show
|
||||
* `-l <LIMIT>`
|
||||
* `--no-graph` — Don't show the graph, show a flat list of revisions
|
||||
|
||||
Possible values: `true`, `false`
|
||||
|
@ -1236,7 +1237,8 @@ Name is derived from Merciual's obsolescence markers.
|
|||
* `-r`, `--revision <REVISION>`
|
||||
|
||||
Default value: `@`
|
||||
* `-l`, `--limit <LIMIT>` — Limit number of revisions to show
|
||||
* `-n`, `--limit <LIMIT>` — Limit number of revisions to show
|
||||
* `-l <LIMIT>`
|
||||
* `--no-graph` — Don't show the graph, show a flat list of revisions
|
||||
|
||||
Possible values: `true`, `false`
|
||||
|
@ -1314,7 +1316,8 @@ Show the operation log
|
|||
|
||||
###### **Options:**
|
||||
|
||||
* `-l`, `--limit <LIMIT>` — Limit number of operations to show
|
||||
* `-n`, `--limit <LIMIT>` — Limit number of operations to show
|
||||
* `-l <LIMIT>`
|
||||
* `--no-graph` — Don't show the graph, show a flat list of operations
|
||||
|
||||
Possible values: `true`, `false`
|
||||
|
|
|
@ -449,7 +449,7 @@ fn test_op_abandon_ancestors() {
|
|||
insta::assert_snapshot!(stderr, @r###"
|
||||
Nothing changed.
|
||||
"###);
|
||||
insta::assert_snapshot!(test_env.jj_cmd_success(&repo_path, &["op", "log", "-l1"]), @r###"
|
||||
insta::assert_snapshot!(test_env.jj_cmd_success(&repo_path, &["op", "log", "-n1"]), @r###"
|
||||
@ 445e93662d71 test-username@host.example.com 2001-02-03 04:05:21.000 +07:00 - 2001-02-03 04:05:21.000 +07:00
|
||||
│ undo operation 70112b4447b65fa811038b2b119fe22e959e3b3194b461a32475f6528c2b684ac6baebc86cce7ad7e0bb92c033852850e561506508ca43e823626f107e81ed76
|
||||
│ args: jj undo
|
||||
|
@ -480,7 +480,7 @@ fn test_op_abandon_without_updating_working_copy() {
|
|||
Current tree: Merge(Resolved(TreeId("4b825dc642cb6eb9a060e54bf8d69288fbee4904")))
|
||||
"###);
|
||||
insta::assert_snapshot!(
|
||||
test_env.jj_cmd_success(&repo_path, &["op", "log", "-l1", "--ignore-working-copy"]), @r###"
|
||||
test_env.jj_cmd_success(&repo_path, &["op", "log", "-n1", "--ignore-working-copy"]), @r###"
|
||||
@ ae6364994418 test-username@host.example.com 2001-02-03 04:05:10.000 +07:00 - 2001-02-03 04:05:10.000 +07:00
|
||||
│ commit 268f5f16139313ff25bef31280b2ec2e675200f3
|
||||
│ args: jj commit -m 'commit 3'
|
||||
|
@ -500,7 +500,7 @@ fn test_op_abandon_without_updating_working_copy() {
|
|||
Current tree: Merge(Resolved(TreeId("4b825dc642cb6eb9a060e54bf8d69288fbee4904")))
|
||||
"###);
|
||||
insta::assert_snapshot!(
|
||||
test_env.jj_cmd_success(&repo_path, &["op", "log", "-l1", "--ignore-working-copy"]), @r###"
|
||||
test_env.jj_cmd_success(&repo_path, &["op", "log", "-n1", "--ignore-working-copy"]), @r###"
|
||||
@ 51192a90e899 test-username@host.example.com 2001-02-03 04:05:10.000 +07:00 - 2001-02-03 04:05:10.000 +07:00
|
||||
│ commit 268f5f16139313ff25bef31280b2ec2e675200f3
|
||||
│ args: jj commit -m 'commit 3'
|
||||
|
|
Loading…
Reference in a new issue