bookmarks and branches again: files
Simon King
simon at simonking.org.uk
Tue Jul 12 13:42:55 UTC 2016
On Tue, Jul 12, 2016 at 2:31 PM, Uwe Brauer <oub at mat.ucm.es> wrote:
> Hello
>
> Sorry to bother. I think I understand branches which I use most of the
> times, but I still have not understood bookmarks.
>
> Here is an example
>
> hg init
> echo one > test1.txt
> hg add test1.txt
> hg commit -m "0"
> hg branch master
> echo two >> test2.txt
> hg add test2.txt
> hg commit -m "1"
> echo three >> test2.txt
> hg commit -m "2"
> hg update default
>
> Now file test2.tex has been deleted because it belongs to the branch
> master but I am now in the default branch, so this behavior is *very* logical.
>
> Now I try to do something similar with bookmarks
>
> hg init
> echo one > test1.txt
> hg add test1.txt
> hg commit -m "0"
> hg bookmark master
> hg update master
> echo two >> test2.txt
> hg add test2.txt
> hg commit -m "1"
> echo three >> test1.txt
> hg commit -m "2"
> hg update default
> echo four >> test1.txt
> hg commit -m "3"
>
>
> But now test2.tex which «belongs» to the bookmark master has not been
> deleted, which I find odd.
>
> Any comments?
>
In your second example, you never created a bookmark called "default",
and in fact current Mercurial would not allow you to. Instead it would
abort with an error such as:
$: hg bookmark default
abort: a bookmark cannot have the name of an existing branch
So when you executed "hg update default", mercurial interpreted that
to mean "update to the latest revision on the branch 'default'", which
happens to be the same commit pointed at by your "master" bookmark. In
other words, "hg update default" didn't move you to a different
revision, all it did was deactivate your active bookmark.
In mercurial, all commits are part of a named branch, even if you are
using bookmarks. If you haven't used "hg branch" at all, then all
commits are part of the branch called "default".
The output of "hg log -G" before and after the "hg update default"
might help you understand a bit better.
Hope that helps,
Simon
More information about the Mercurial
mailing list