What is the difference between hg tag and hg bookmark?

What is the difference between tag and bookmark in Mercurial? I don’t seem to know how they differ from each other.

+61
mercurial tags bookmarks
Mar 22 2018-11-11T00:
source share
4 answers

Let's look at your repository as “pick your own adventure books” with different perspectives.

  • Tag it’s like a stamp that the editor put on your manuscript to say “well, we keep a trace of your current work, in case this happens”.
  • A named branch will be the chapter. You must choose at some point which chapter you need to write, and they are there to stay. Some will merge, some will end (sorry, you're dead.)
  • Icon - this is, well, a bookmark. It follows you while you read (commit) a book. This helps you keep track of “what you read at the time,” so you can delete them, move them to another “chapter”. When you share a book (push), you usually don’t share your bookmarks unless you explicitly want to. Therefore, you usually use them in anonymous branches , because their life cycle is shorter than the named branches.
+34
Mar 22 2018-11-11T00:
source share

Bookmarks are used when you want the mnemonics (foo_feature) to point to a changing commit identifier as your work progresses. They are lighter than regular Mercurial branches, and are somewhat similar to git branches.

Tags usually indicate fixed commit identifiers. They can be reassigned manually, but this is not recommended.

+21
Mar 22 2018-11-11T00:
source share

There are actually five concepts:

  • tags
  • local tags
  • bookmarks
  • light branches
  • named branches

Light branches are what happens if you just use mercury. The story of your fork storage and sometimes merges when you change things and move your story.

The other four are ways to annotate light branches and the sets of changes that create them.

named branches and tags are mercury-based concepts where branch names and tags are actually written to the repository, making more commits to the repository. They will be distributed to other repositories in ways that are not necessarily obvious.

local tags and bookmarks are much more like git invoking tags and branches. This is metadata, not mixing with object versions. Therefore, they are not presented as part of the history of the repository. They are usually local to your repository and will not be distributed unless you intentionally distribute them.

At least I think they all work. After about twelve months using the mercury daily, I could not cope with her model. If someone knows better than me, then feel free to edit this answer so that it is corrected.




How I actually use these things in practice.

I am working on one shared repository with about 20 other people. I do a lot of experiments and light branches in my own repository that never end up in our main central repository. Sometimes, as soon as the experiment has worked, I modify the main line and push the set of changes to the central repository, from which it will find its way for all other machines.

Sometimes I will push some revisions to an employee if they are one of those who can work with Mercurial. But a few people are a little afraid of this and prefer if I send them diffs that they can apply with the patch.

For experiments, I expect to be short-lived and private, I just let the light branches where they can and remember what happens. If I feel that my memory slides around a branch that was around a bit, I bookmark it.

I use local tags to mark revisions. Perhaps I wanted to return to one day. They make it easy to find interesting past conditions.

I myself almost never make non-local tags or named branches (except by accident, and I destroy them if I do this). But our people release. Our released major versions have their own branches with names, and minor versions have tags on these branches. This ensures that these important branches and tags look the same for everyone.

Again, I have no idea if it is supposed to use mercurial, but it seems to be a model that works well for our team size.

If three or four of us wanted to collaborate in an experiment, it would probably be worth the named branch, which we would probably share among ourselves, but not put pressure on the central repo. I don’t know how well this will work!

+21
Apr 18 2018-12-18T00:
source share

The biggest difference is that the bookmark automatically moves forward when you commit. Here is an example:

hg init ..edit a file.. hg commit -m 'my commit' # creates revision 0 hg tag -r 0 mytag # creates revision 1 hg bookmark -r 0 mybookmark # doesn't create a revision hg update 0 # get back to r0 ..edit a file.. hg commit -m 'another commit' # creates revision 2 

At this point, mytag still points to revision 0, and mybookmark now points to revision 2. Also, the tags created a set of changes, and the bookmark did not execute.

Also, of course, the bookmark created revisio

+12
Mar 22 '11 at 16:40
source share



All Articles