mercurialbranching-and-mergingmercurial-topics

What is the difference between Mercurial bookmarks and Evolve topics?


A lot of "git vs. hg" explanations align Mercurial bookmarks with usual git branches in terms of functionality. I'm trying to understand the differences not between Mercurial branches and git ones, but between bookmarks and topics coming from Evolve extension.

One of the important differences I figured out is the topic name gets embedded into every commit, while bookmark is just a tag moving from one commit to another. But what does it entail? And what are the other differences?


Solution

  • But what does it entail?

    Bookmark is (mutable) pointer to single changeset, topics are (after all) "classic" hg-branches with most branch-specific things

    And what are the other differences?

    Topic branches are lightweight branches which disappear when changes are finalized (moved to the public phase). Bookmarks have to be deleted by hand.

    Bookmarks can be (easy) pushed and pulled between repositories. Topic-exchange (as topics) require some additional actions for work through a non-publishing server.

    Sample (shortened) of topic lifecycle from Topic Tutorial

    Repo with topic before push

    >hg log --graph --rev "topic('food')"
    @  changeset:   2:86d4fa8dfae9
    |  tag:         tip
    |  topic:       food
    |  user:        lazybadger
    |  date:        Wed Oct 12 15:49:32 2022 +0500
    |  summary:     Adding fruits
    |
    o  changeset:   1:c7451c53346d
    |  topic:       food
    |  user:        lazybadger
    |  date:        Wed Oct 12 15:47:26 2022 +0500
    |  summary:     Adding condiments
    |
    o  changeset:   0:e4aaf76d4cb3
       topic:       food
       user:        lazybadger
       date:        Wed Oct 12 15:44:28 2022 +0500
       summary:     Shopping list
    

    Because food was created on base of default

    >hg stack
    ### topic: food
    ### target: default (branch)
    s3@ Adding fruits (current)
    s2: Adding condiments
    s1: Shopping list
    

    after pushing to the publishing server I got the same changesets, just in target branch only

    >hg log --graph
    @  changeset:   2:86d4fa8dfae9
    |  tag:         tip
    |  user:        lazybadger
    |  date:        Wed Oct 12 15:49:32 2022 +0500
    |  summary:     Adding fruits
    |
    o  changeset:   1:c7451c53346d
    |  user:        lazybadger
    |  date:        Wed Oct 12 15:47:26 2022 +0500
    |  summary:     Adding condiments
    |
    o  changeset:   0:e4aaf76d4cb3
       user:        lazybadger
       date:        Wed Oct 12 15:44:28 2022 +0500
       summary:     Shopping list