add explicit support for tags or changeset ID for 'branch'

This pull request explicits support for setting a tag or changeset ID as "branch", as well as using env variable.
Testcase included.