# .hgrc for use with hgshort.
#
# Adds generated single letter revision and file shorthand names to the outputs
# of 'hg l/xl/ll' and 'hg status'.
#
#   * For hg l/xl/ll, modifies the defaults set by:
#     http://google3/devtools/piper/hgfission/client/config/google-ui-tweaks.rc
#
#   * For hg status, overrides the default template (no extensible template
#     available), but with one that looks the same.
#
# To use, add the following line to your ~/.hgrc:
# %include /google/src/head/depot/google3/experimental/fig_contrib/hgshort/hgshort.hgrc
#
# To make hg and other commands actually recognize the outputted shorthand
# names, follow go/hgshort#initial-setup.
#
# If you have already customized the outputs of 'hg l/xl/ll' or 'hg status',
# including this file would override them. Instead:
#
#   * If you only aliased or added default arguments for 'hg status', add the
#     following argument:
#     --template=hgshort_status
#
#   * If you customized the outputs themselves, copy the "extensions" and
#     optionally the "color" sections and use:
#
#     + hgshort_revision_shorthand — in your log templates.
#     + hgshort_file_shorthand — in your status templates.

[extensions]
hgshort = /google/src/head/depot/google3/experimental/fig_contrib/hgshort/hgshort.py

[color]
# The color used for hgshort's single letter aliases.
hgshort.alias = red bold

[color256]
# The color used for hgshort's single letter aliases.
hgshort.alias = orange bold

##### hg l/xl/ll configuration #####

[templatealias]
# Get an alias for the current revision (node) with an uppercase letter.
hgshort_revision_shorthand='{hgshort(node,"A")}'
# Add the revision hgshort shorthand name to the output of 'hg l/xl/ll'.
google_compact_line_1_part_1 = '{hgshort_revision_shorthand}{google_compact_uniq_id}'

##### hg status configuration #####

[templatealias]
# Get an alias for the current file with a lowercase letter.
hgshort_file_shorthand='{hgshort(relpath(path),"a")}'
# Get the right built-in label (style) for the file's status.
# See http://screen/8A5ynkOdEED.png for an example output,
# and 'hg help status' for details.
hgshort_status_label(status) = '{ifeq(status, "?", "status.unknown", ifeq(status, "!", "status.deleted", get(dict(A="status.added", M="status.modified", R="status.removed", I="status.ignored", C="status.clean"), status)))}'
hgshort_status_line1 = '{hgshort_file_shorthand}{label(hgshort_status_label(status), '{status} {relpath(path)}')}'
hgshort_status_line2 = '{if(source, "  {label("status.copied", "  {relpath(source)}")}")}'

[templates]
# Add the hgshort file shorthand name to the output of 'hg status'.
# In conflict resolution mode, we get empty entries. Filter them out.
hgshort_status = '{if(path,"{separate("\n", hgshort_status_line1, hgshort_status_line2)}\n","")}'

[defaults]
# Override the default 'hg status' command, but keep -n working.
status = --template=hgshort_status

[alias]
# Override the default 'hg pstatus' template.
pstatus = pstatus --template=hgshort_status
