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?
views:
49answers:
1
+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
2010-08-18 15:54:19
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
2010-08-18 16:31:15
`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.
2010-08-18 16:38:36
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
2010-08-18 16:50:45