views:

49

answers:

1

What's the simplest way to have hg ... --template '{branches}' return default instead of an empty string when the changeset being printed is part of the default branch?

+2  A: 

I've not found an in-template way to do that. If I'm in a shellscript I do something like:

BRANCH=$(hg log --revision 0 --template '{branches}')
echo ${BRANCH:=default}

Though if you have the excellent hg prompt extension in place you could do:

hg prompt '{branch}'
Ry4an
Dang. Yea, I'd thought about that… But it kind of sucks, and relies on being inside a shell script (ex, it doesn't work in `notify.template`).
David Wolever
`hg log --debug` shows a line with `extra: branch=default` (or whatever branch), so the information _is_ available. Looking at the default style file shows it using an `{extras}` keyword, which I can't find mention of in the documentation.
Niall C.
oh the info is definitely available, I just don't think it can be exposed via the template system. Certainly sed or shell can be used to produce it from extras or whole cloth.
Ry4an