Subversion user considerations: what is a branch in Mercurial?

I am a Subversion user and I think that now I have a head mostly around all this. Therefore, of course, now we are thinking of switching to Mercurial, and I need to start again.

In our only repository we have a typical layout branches , tags , trunk . When I want to create a branch of function I:

  • Use the repo browser to copy trunk to branches/Features/[FeatureName] .
  • Checkout a new working copy from branches/Features/[FeatureName] .
  • Start working with him.
  • Sometimes commit, merge trunk in, resolves conflicts and commits.
  • Upon completion, another trunk merge, then "Reintegrate" the function branch into the trunk.

(Please note that this process is simplified since it does not take into account the branches of release candidates, etc.).

So, I have questions about how to fulfill the same requirements (for example, function branches, and not work on a chest) in Mercurial:

  • Does Mercurial have a branch in the repository, or is it a whole new local repository?
  • If each of us has a copy of the entire repository, does this mean that we all have copies of different branches of functions (which transmit a lot of data) from each other?
  • I know that Mercurial is DCVS, but does this mean that we push / pull changes from each other directly, and not through a peer-to-peer repository on the server?
+7
branch dvcs mercurial
source share
3 answers

Does Mercurial have a branch, still inside the repository, or is it a completely new local repository?

The equivalent of the subversion method of operation would be a repository with several heads in the mercury. However, this is not an idiomatic way of doing things. As a rule, you will have only one head in this repository, therefore separate repositories for each branch.

If each of us has a copy of the whole repository, does this mean that we all have copies of each other in different branches (which is a lot of data transfer)?

Yes, if you look at the history of the chapter of your local repository, you can see all the branches of the functions that were combined. But mercury repositories are extremely efficient in space. For example, I did hg clone https://www.mercurial-scm.org/repo/hg to get the source for mercurial itself, and this is only 34.3 MB on the NTFS file system (compared to source, loading the code , which is 1 , 8 MB). Mercurial will also use hard links if your file system supports it, so there is little overhead when cloning a repository to another location on the same drive.

I know that Mercurial is DCVS, but does this mean that we push / pull changes from each other, and not through the peer repository on the server?

One way of working really is for each developer to publish a public repository in which they push their own changes. All other developers can then pull what they want.

However, as a rule, you will have one or more โ€œblessedโ€ repositories where all changes will be integrated. All developers then only need to pull from the blissful repository. Even if you obviously didnโ€™t have such a blessed repository, I think that people automatically organize themselves in this way, for example. everyone draws from the lead developer.

+7
source share
+9
source share

Steve Losch's article on branching in the mercury conjunction above is fantastic. I also explained the fork and how the DAG works in the presentation that I gave a couple of months ago at Mercurial, which is a slideshow . Corresponding slides begin with slide # 43.

I think that understanding that all commits in the same repository are stored in a DAG (Directed Acyclic Graph) with some simple rules really helps to demystify what is happening.

  • a node without child nodes is the "head"
  • root node has no parents
  • Regular nodes have one parent
  • nodes that are the result of a merger have two parents
  • if the merge of the parent node comes from different branches, the child branch of the node inherits from the first parent

Named branches are actually just metadata labels on the commit, but in fact they are no different from the anonymous branches that occur when you merge someone working in your repository, or if you revert to an earlier version and then do fixing there to create a new head (which you can later combine).

+5
source share

All Articles