mirror of
https://github.com/martinvonz/jj.git
synced 2025-05-19 14:14:28 +00:00
cli: indicate each workspace's checkout in log (#13)
It seems helpful to show in the log output which commit is checked out in which workspace, so let's try that. I made it only show the information if there are multiple checkouts for now.
This commit is contained in:
parent
5da9d600fd
commit
bcece02084
@ -2549,6 +2549,7 @@ fn log_template(settings: &UserSettings) -> String {
|
|||||||
" " label("timestamp", author.timestamp())
|
" " label("timestamp", author.timestamp())
|
||||||
" " branches
|
" " branches
|
||||||
" " tags
|
" " tags
|
||||||
|
" " checkouts
|
||||||
if(is_git_head, label("git_head", " HEAD@git"))
|
if(is_git_head, label("git_head", " HEAD@git"))
|
||||||
if(divergent, label("divergent", " divergent"))
|
if(divergent, label("divergent", " divergent"))
|
||||||
if(conflict, label("conflict", " conflict"))
|
if(conflict, label("conflict", " conflict"))
|
||||||
|
@ -88,6 +88,7 @@ fn config_colors(user_settings: &UserSettings) -> HashMap<String, String> {
|
|||||||
result.insert(String::from("author timestamp"), String::from("cyan"));
|
result.insert(String::from("author timestamp"), String::from("cyan"));
|
||||||
result.insert(String::from("committer"), String::from("yellow"));
|
result.insert(String::from("committer"), String::from("yellow"));
|
||||||
result.insert(String::from("committer timestamp"), String::from("cyan"));
|
result.insert(String::from("committer timestamp"), String::from("cyan"));
|
||||||
|
result.insert(String::from("checkouts"), String::from("magenta"));
|
||||||
result.insert(String::from("branch"), String::from("magenta"));
|
result.insert(String::from("branch"), String::from("magenta"));
|
||||||
result.insert(String::from("branches"), String::from("magenta"));
|
result.insert(String::from("branches"), String::from("magenta"));
|
||||||
result.insert(String::from("tags"), String::from("magenta"));
|
result.insert(String::from("tags"), String::from("magenta"));
|
||||||
@ -128,6 +129,10 @@ fn config_colors(user_settings: &UserSettings) -> HashMap<String, String> {
|
|||||||
String::from("checkout committer timestamp"),
|
String::from("checkout committer timestamp"),
|
||||||
String::from("bright cyan"),
|
String::from("bright cyan"),
|
||||||
);
|
);
|
||||||
|
result.insert(
|
||||||
|
String::from("checkout checkouts"),
|
||||||
|
String::from("bright magenta"),
|
||||||
|
);
|
||||||
result.insert(
|
result.insert(
|
||||||
String::from("checkout branch"),
|
String::from("checkout branch"),
|
||||||
String::from("bright magenta"),
|
String::from("bright magenta"),
|
||||||
|
@ -24,10 +24,10 @@ use pest::Parser;
|
|||||||
|
|
||||||
use crate::formatter::PlainTextFormatter;
|
use crate::formatter::PlainTextFormatter;
|
||||||
use crate::templater::{
|
use crate::templater::{
|
||||||
AuthorProperty, BranchProperty, ChangeIdProperty, CommitIdKeyword, CommitterProperty,
|
AuthorProperty, BranchProperty, ChangeIdProperty, CheckoutsProperty, CommitIdKeyword,
|
||||||
ConditionalTemplate, ConflictProperty, ConstantTemplateProperty, CurrentCheckoutProperty,
|
CommitterProperty, ConditionalTemplate, ConflictProperty, ConstantTemplateProperty,
|
||||||
DescriptionProperty, DivergentProperty, DynamicLabelTemplate, GitRefsProperty,
|
CurrentCheckoutProperty, DescriptionProperty, DivergentProperty, DynamicLabelTemplate,
|
||||||
IsGitHeadProperty, LabelTemplate, ListTemplate, LiteralTemplate, OpenProperty,
|
GitRefsProperty, IsGitHeadProperty, LabelTemplate, ListTemplate, LiteralTemplate, OpenProperty,
|
||||||
StringPropertyTemplate, TagProperty, Template, TemplateFunction, TemplateProperty,
|
StringPropertyTemplate, TagProperty, Template, TemplateFunction, TemplateProperty,
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -243,6 +243,7 @@ fn parse_commit_keyword<'a>(
|
|||||||
"author" => Property::Signature(Box::new(AuthorProperty)),
|
"author" => Property::Signature(Box::new(AuthorProperty)),
|
||||||
"committer" => Property::Signature(Box::new(CommitterProperty)),
|
"committer" => Property::Signature(Box::new(CommitterProperty)),
|
||||||
"open" => Property::Boolean(Box::new(OpenProperty)),
|
"open" => Property::Boolean(Box::new(OpenProperty)),
|
||||||
|
"checkouts" => Property::String(Box::new(CheckoutsProperty { repo })),
|
||||||
"current_checkout" => Property::Boolean(Box::new(CurrentCheckoutProperty {
|
"current_checkout" => Property::Boolean(Box::new(CurrentCheckoutProperty {
|
||||||
repo,
|
repo,
|
||||||
workspace_id: workspace_id.clone(),
|
workspace_id: workspace_id.clone(),
|
||||||
|
@ -205,6 +205,26 @@ impl<'r> TemplateProperty<Commit, bool> for OpenProperty {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub struct CheckoutsProperty<'a> {
|
||||||
|
pub repo: RepoRef<'a>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl TemplateProperty<Commit, String> for CheckoutsProperty<'_> {
|
||||||
|
fn extract(&self, context: &Commit) -> String {
|
||||||
|
let checkouts = self.repo.view().checkouts();
|
||||||
|
if checkouts.len() <= 1 {
|
||||||
|
return "".to_string();
|
||||||
|
}
|
||||||
|
let mut names = vec![];
|
||||||
|
for (workspace_id, checkout_id) in checkouts.iter().sorted() {
|
||||||
|
if checkout_id == context.id() {
|
||||||
|
names.push(format!("{}@", workspace_id.as_str()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
names.join(" ")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub struct CurrentCheckoutProperty<'a> {
|
pub struct CurrentCheckoutProperty<'a> {
|
||||||
pub repo: RepoRef<'a>,
|
pub repo: RepoRef<'a>,
|
||||||
pub workspace_id: WorkspaceId,
|
pub workspace_id: WorkspaceId,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user