[trusted]
# users = ul,hg,equan,sig_gk
# groups = gk,staff,sol_src

[ui]
username =Petr Nyc <petr.nyc@oracle.com>
merge = 

[extensions]

mq=
# cdm = /opt/onbld/lib/python3.7/onbld/hgext/cdm.py
# cdm = /opt/onbld/lib/python/onbld/hgext/cdm.py
# cdm = /home/pnyc/.cdm/lib/python/onbld/hgext/cdm.py
# hgext.sccdm=/ws/sc31u-tools/onbld/lib/python/hgext/sccdm.py
purge=
histedit=
graphlog=
color=
record=
pager=
rebase=
convert=
extdiff=
progress=
transplant=
# prompt = /home/pnyc/.config/hg-prompt/prompt.py
# largefiles=

[email]
from=jetpac@jetpac.org

# tips on mering from great page:
# https://www.mercurial-scm.org/wiki/MergingWithVim

# more userful three way diff
[merge-tools]
# vimdiff.executable = /usr/bin/vimdiff
vimdiff.executable = /opt/homebrew/bin/vim
vimdiff.args = -f -d $output -M $local $base $other -c "wincmd J" -c "set modifiable" -c "set write"
vimdiff.premerge = keep



[alias]
# glog
g = !USER=$($HG showconfig ui.username); A=$( $HG log -r qbase..qtip --template '{rev}|' 2>/dev/null ); $HG glog --template "{rev}:{node|short} \033[33m{branch}\033[0m {phase} {author}\n{desc}\n\n" $@ | perl -pe 's/(^[| o@+-]+\d+:[0-9a-f]{12} \S+ (?!public))(\S+)(.*)/\1\033[31m\2\033[0m\3/; s/(\Q'"${USER//@/\\E\\@\\Q}"'\E)/\033[32m\1\033[0m\3/; s/(^[| o@+-]+)('${A:+(${A%|})}':[0-9a-f]{12})/\1\033[34m\2\033[0m/' 2>/dev/null | less -FRX

# glog on branch
gb = !$HG g -b . $@


# histedit even for older mercurial releases
he = !/bin/bash -O extglob -c '$HG --config extensions.histedit= help histedit 2>&1 | grep -q "failed to import" && P=~/Documents/histedit/hg_histedit.py; case "${@}" in "") set -- $( hg log --template "{rev}" --rev "limit(branch(\".\") and (outgoing() or secret()))" );; esac; set -x; $HG --config extensions.histedit=$P histedit ${@}' blah $@

# clever diff
d = !/bin/bash -O extglob -c 'h="[0-9a-f]"; h="$h$h$h$h"; case "${@}" in "") set -- -c $($HG parent --template '{rev}');; +([0-9])|$h$h$h) set -- -c "$1";; esac; $HG diff ${@}' blah $@

# clever log (requires also the 'style' alias)
l = !/bin/bash -O extglob -c 'h="[0-9a-f]"; h="$h$h$h$h"; case "${@}" in "") set -- -r $($HG parent --template '{rev}');; +([0-9])|$h$h$h) set -- -r "$1" ;; esac; $HG log -v --style <(hg style) ${@}' blah $@
style = !echo $'changeset = \'changeset:   {rev}:{node|short}\\\\n{branches}{tags}{parents}user:        {author}\\\\ndate:        {date|date}\\\\ndescription:\\\\n\\\\t{desc|strip|tabindent}\\\\n\\\\n\'\nchangeset_quiet = \'{rev}:{node|short}\\\\n\'\nchangeset_verbose = \'\\\\n\\\\033[33mchangeset:   {rev}:{node|short}\\\\033[0m\\\\n{branches}{tags}{parents}user:        {author}\\\\ndate:        {date|date}\\\\n\\\\ndescription:\\\\n\\\\t{desc|strip|tabindent}\\\\n\\\\n{file_mods}{file_adds}{file_dels}{file_copies}\\\\n\'\nchangeset_debug = \'changeset:   {rev}:{node}\\\\n{branches}{tags}{parents}{manifest}{extras}user:        {author}\\\\ndate:        {date|date}\\\\ndescription:\\\\n\\\\t{desc|strip|tabindent}\\\\n\\\\n{file_mods}{file_adds}{file_dels}{file_copies}\\\\n\'\nstart_files = \'files:\\\\n\'\nfile = \'   {file}\\\\n\'\nend_files = \'\'\nstart_file_mods = \'\\\\033[34mmodified:\\\\033[0m\\\\n\'\nfile_mod = \'   {file_mod}\\\\n\'\nend_file_mods = \'\'\nstart_file_adds = \'\\\\033[32madded:\\\\033[0m\\\\n\'\nfile_add = \'   {file_add}\\\\n\'\nend_file_adds = \'\'\nstart_file_dels = \'\\\\033[31mremoved:\\\\033[0m\\\\n\'\nfile_del = \'   {file_del}\\\\n\'\nend_file_dels = \'\'\nstart_file_copies = \'copied:\\\\n\'\nfile_copy = \'   {name}\\\\n      (from {source})\\\\n\'\nend_file_copies = \'\'\nparent = \'parent:      {rev}:{node|formatnode}\\\\n\'\nmanifest = \'manifest:    {rev}:{node}\\\\n\'\nbranch = \'branch:      {branch}\\\\n\'\ntag = \'tag:         {tag}\\\\n\'\nextra = \'extra:       {key}={value|stringescape}\\\\n\''

# status with paths relative to current directory
s = !/bin/bash -O extglob -c 'h="[0-9a-f]"; h="$h$h$h$h"; case "${@}" in "") set -- $($HG root) ;; +([0-9])|$h$h$h) set -- --rev "$1^:$1" ;; esac; $HG status ${@}' blah $@

# show current directory history
h = !USER=$(hg showconfig ui.username); B=""; echo "$@" | grep -q -- -b || B="-b ."; $HG log -C --removed --template "{rev}:{node|short} \033[33m{branch}\033[0m {author}\n{desc}\n\n" $B -r 'sort(file("'$(pwd)'/**") or modifies("path:.hgtags") or limit(branch(".")), -rev)' $@ | /usr/bin/perl -p -e 's/('"$USER"')/\033[32m\1\033[0m\3/' 2>/dev/null | /usr/bin/perl -p -e 's/(^Added tag )(.*)( for changeset.*)/\1\033[34m\2\033[0m\3/' 2>/dev/null | less -FRX

[progress]
delay = 1

[pager]
pager = LESS='FRX' less
attend =  l, log, glog, status, annotate, cat, diff, export, tags, inc, incoming, outgoing, sglog, out

[color]
diff.diffline = yellow
diff.file_a = yellow
diff.file_b = yellow
diff.hunk = blue
diff.extended = cyan bold
diff.deleted = red bold
diff.inserted = green
diff.changed = white
diff.trailingwhitespace = bold red_background
tags.local = cyan

[hostfingerprints]
hg.java.net = fa:cc:49:a7:d6:c8:66:03:3b:b4:50:d1:86:11:a4:a9:a5:d3:f2:be


# alias for extdiff taken from http://stackoverflow.com/questions/2130960/how-to-set-hg-diff-output-shows-in-gvim
[extdiff]
cmd.vimdiff =

[alias]
vi  = vimdiff
vim = vimdiff
# vi = nvim
# vim = nvim -d
sglog = glog --style ~/.hgstyle/sglog
out = outgoing --style ~/.hgstyle/nlog

# bout - hg out with branch
bout = outgoing --style ~/.hgstyle/bout


ci = commit -X Makefile.inc -X requirements.txt -X .hgignore
st = status -X Makefile.inc -X requirements.txt -X .hgignore
