I am just playing around with Mercurial at the moment and this may never come up as an issue, but I just created a repository and added some changes. I tagged it at one point then created a named branch at another. Both the tag and the branch have the same name. If I do hg update name
it switches to the tagged version. Is there any way to switch to the branch other than by using a revision number on the branch?
I think what made me think about this was that if we were to write some scripts for automatically building a particular revision we would want to just specify either a tag or a branch to build from. If someone happened to use the same name in a tag and a branch then we would run into problems with the script getting the correct revisions. Is the only solution to this to make sure that they are unique, e.g. by pre-pending branch or tag to the name?
Quickly switch to another branch or bookmark In the Status bar, click the Mercurial Branch widget to open the Branches popup. Select the branch or bookmark to which you want to switch and in the menu that opens, click Update.
Creating a branch Branching can happen by committing a changeset within a single repository or by committing diverging changes in distinct (but related) repositories. Two repositories are said to be related if they were once cloned from the same repository but later may have diverged.
A tag is a symbolic identifier for a changeset. It can contain any characters except ":" (colon), "\r" (Carriage Return) or "\n" (Line Feed). Mercurial has two kinds of tags: local and regular.
You get the tip revision of the branch by parsing the output of hg branches
.
Consider this situation (a branch and a tag, both named popular
):
$ hg tags
tip 3:afb4026bfe32
popular 1:cea974d8cfc4
$ hg branches
default 3:afb4026bfe32
popular 2:aa7ede2bb3f6
In bash-like shells, you get the tip revision of branch popular
with:
$ hg branches | grep popular | awk -F ':' '{print $2}'
Getting the tag revision works similar, using hg tags
.
Now your script is able to update to the branch/tag in question.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With