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

templates: Split oplog template into hookable functions

This is to allow modifying default templates without completely overriding
them, for example to change the oplog snapshots but keep other defaults
This commit is contained in:
Anton Bulakh 2024-04-05 14:35:29 +03:00
parent 29729e844d
commit 0f2573abae
2 changed files with 18 additions and 20 deletions

View file

@ -11,6 +11,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Breaking changes ### Breaking changes
* The default template alias `builtin_op_log_root(op_id: OperationId)` was replaced by `format_root_operation(root: Operation)`.
### New features ### New features
* The list of conflicted paths is printed whenever the working copy changes. * The list of conflicted paths is printed whenever the working copy changes.

View file

@ -102,18 +102,11 @@ concat(
''' '''
builtin_op_log_compact = ''' builtin_op_log_compact = '''
if(root, label(if(current_operation, "current_operation"),
builtin_op_log_root(id), coalesce(
label(if(current_operation, "current_operation"), if(snapshot, format_snapshot_operation(self)),
concat( if(root, format_root_operation(self)),
separate(" ", format_operation(self),
id.short(),
user,
format_time_range(time),
) ++ "\n",
description.first_line() ++ "\n",
if(tags, tags ++ "\n"),
),
) )
) )
''' '''
@ -128,13 +121,6 @@ separate(" ",
) ++ "\n" ) ++ "\n"
''' '''
'builtin_op_log_root(op_id)' = '''
separate(" ",
op_id.short(),
label("root", "root()"),
) ++ "\n"
'''
description_placeholder = ''' description_placeholder = '''
label(if(empty, "empty ") ++ "description placeholder", "(no description set)")''' label(if(empty, "empty ") ++ "description placeholder", "(no description set)")'''
@ -156,6 +142,16 @@ commit_summary_separator = 'label("separator", " | ")'
time_range.start().ago() ++ label("time", ", lasted ") ++ time_range.duration()''' time_range.start().ago() ++ label("time", ", lasted ") ++ time_range.duration()'''
'format_timestamp(timestamp)' = 'timestamp.local().format("%Y-%m-%d %H:%M:%S")' 'format_timestamp(timestamp)' = 'timestamp.local().format("%Y-%m-%d %H:%M:%S")'
'format_operation(op)' = '''
concat(
separate(" ", op.id().short(), op.user(), format_time_range(op.time())), "\n",
op.description().first_line(), "\n",
if(op.tags(), op.tags() ++ "\n"),
)
'''
'format_snapshot_operation(op)' = 'format_operation(op)'
'format_root_operation(root)' = 'separate(" ", root.id().short(), label("root", "root()")) ++ "\n"'
# We have "hidden" override "divergent", since a hidden revision does not cause # We have "hidden" override "divergent", since a hidden revision does not cause
# change id conflicts and is not affected by such conflicts; you have to use the # change id conflicts and is not affected by such conflicts; you have to use the
# commit id to refer to a hidden revision regardless. # commit id to refer to a hidden revision regardless.