-
Notifications
You must be signed in to change notification settings - Fork 319
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
cli: make paths to auto-track configurable, add
jj track
- Loading branch information
1 parent
b78c83e
commit 322c363
Showing
13 changed files
with
174 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
// Copyright 2020 The Jujutsu Authors | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// https://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
use std::io::Write; | ||
|
||
use jj_lib::working_copy::SnapshotOptions; | ||
use tracing::instrument; | ||
|
||
use crate::cli_util::CommandHelper; | ||
use crate::command_error::CommandError; | ||
use crate::ui::Ui; | ||
|
||
/// Start tracking specified paths in the working copy | ||
/// | ||
/// By default, all paths are automatically tracked. This command is not useful | ||
/// then. You can configure which paths to automatically track by setting e.g. | ||
/// `snapshot.auto-track = 'none()'`. You will then need to run this command to | ||
/// start tracking new files. | ||
#[derive(clap::Args, Clone, Debug)] | ||
pub(crate) struct TrackArgs { | ||
/// Paths to track. | ||
#[arg(required = true, value_hint = clap::ValueHint::AnyPath)] | ||
paths: Vec<String>, | ||
} | ||
|
||
#[instrument(skip_all)] | ||
pub(crate) fn cmd_track( | ||
ui: &mut Ui, | ||
command: &CommandHelper, | ||
args: &TrackArgs, | ||
) -> Result<(), CommandError> { | ||
let mut workspace_command = command.workspace_helper(ui)?; | ||
let matcher = workspace_command | ||
.parse_file_patterns(&args.paths)? | ||
.to_matcher(); | ||
|
||
let mut tx = workspace_command.start_transaction().into_inner(); | ||
let base_ignores = workspace_command.base_ignores()?; | ||
let (mut locked_ws, _wc_commit) = workspace_command.start_working_copy_mutation()?; | ||
locked_ws.locked_wc().snapshot(SnapshotOptions { | ||
base_ignores, | ||
fsmonitor_settings: command.settings().fsmonitor_settings()?, | ||
progress: None, | ||
start_tracking_matcher: &matcher, | ||
max_new_file_size: command.settings().max_new_file_size()?, | ||
})?; | ||
let num_rebased = tx.mut_repo().rebase_descendants(command.settings())?; | ||
if num_rebased > 0 { | ||
writeln!(ui.status(), "Rebased {num_rebased} descendant commits")?; | ||
} | ||
let repo = tx.commit("track paths"); | ||
locked_ws.finish(repo.op_id().clone())?; | ||
Ok(()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters