3

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?

ecm
  • 2,583
  • 4
  • 21
  • 29
arrowd
  • 33,231
  • 8
  • 79
  • 110

1 Answers1

3

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
Lazy Badger
  • 94,711
  • 9
  • 78
  • 110
  • So, topic name gets associated with every commit belonging to it? However, once commit goes public this information gets removed, right? – arrowd Oct 11 '22 at 07:36
  • 1
    @arrowd - yes, topic's changesets will be returned to topic "target" (see `hg topics --list` or `hg stack`) branch – Lazy Badger Oct 12 '22 at 11:01
  • @arrowd - no, technically the topic name is meta data of the changset which remains constant. But if the changeset becomes public `hg log` didnt show the topic-name of these changesets. – fhgd Feb 03 '23 at 04:55