What does it mean for different segments of the graph in the Mercurial Repository Explorer to have different colors?
Mainly to help distinguishing the branches and their merges, including merges from anonymous branches (See A Guide to Branching in Mercurial).
For instance, for the named branch 'stable', you will see:
Related
I really like the Hg Flow for Mercurial repositories. we are currently using Bitbucket, and in each product multiple developers are working. basically they can work as below:
a team might work on a single feature.
another team might work on a release/hot fix.
So do i keep the "develop" branch in BitBucket or local repositories. and how about feature branches, should i push them to the central repository and remove when required. i assume we should do so right?
Thanks
I personally neither use git flow or hg flow as tools, but I do use some of the methods for my own projects (manually).
Before going into detail, you always need to provide branches in the main/bitbucket repository when multiple people need to merge or branch from them.
This definately includes "develop" and probably also features/fixes multiple people need to work on (unless you have another repository or method to exchange branches/commits between them)
The difference between using git and mercurial/hg is relevant here, since the branching models are quite different.
See A Guide to Branching in Mercurial for details. Using hg bookmarks would be quite similar to what git does with branches, but there is no full support for the bookmark branching model on BitBucket (see this ticket).
hg flow (the tool) uses named branches. In contrast to git branches, these are not at all light-weight, but permanent and global (they can at least be closed now).
This means whenever any commit created on any (named) branch other than "default" is pushed to bitbucket (even after merging) this will create the branch in the bitbucket repository.
So you don't have any other choice than keeping all branches in the main repository.
However, You can decide when to push and when to close these.
I would advise using hg push -r to push only the branches/heads you want to push and only pushing these when they are either needed by somebody else or finished and merged.
Branches should be closed as soon they are not needed anymore. (This is probably done by hg flow automatically)
You should close branches locally whenever possible. This way they might not even appear in the bitbucket interface. Some might reach the bitbucket repository only in closed state (which hides them from the interface).
Obviously you should often push any branches multiple people need to merge from.
In my understanding of the workflow the "develop" branch is always exactly one branch per project that should be pushed frequently (after local testing).
In case you are either not using hg-flow or named branches things are a bit different.
Both, using forks/clones or bookmarks as a branching method doesn't generate permanent or necessarily global branches.
Like mentioned above, you can't use bookmarks (reliably) when you also want to use bitbucket pull requests. You have to push bookmarks separately. A normal push will only update (a head of) the branch so you might miss commits from other team members when marging later. Hg will tell you when a new head is created. In that case you might want to merge the branch with the remote bookmark into your branch before pushing.
When using forks as branches it works a bit like with bookmarks, but bitbucket has full support for that. You need to have a new fork on bitbucket for every branch.
You naturally only want to create extra forks if you need different people to work on it and you don't have other means of commit exchange for them. You will need at least a separate "develop" repository then.
I personally wouldn't use the full "flow" with hg on bitbucket.
For my projects the "develop" branch is the same as master/default, since I don't roll out releases with git (other than development builds, that wouldn't use the release branch anyways). I don't need a separate "production" branch, since tags can mostly be used for production usage.
I also don't create a separate "release-preparation" branch. There is only a point in time when I only apply bugfixes on develop and stop merging features. That obviously won't work when you need to work at the same time on features that are dependendant on features not to be released in the next release.
Always using the full "git flow" is easy because git branching is easy and light-weight.
Depending on the branching model you use and how supportive the other tools are,
using the full "hg flow" might not be "worth it".
The hg guide actually discourages use of named branches for short-lived branches.
See Feature separation through named branches.
The "easy" branching concept promoted in the guide is forking/cloning. Bookmarks would be the natural way to translate git flow if the tool/bitbucket support would be better (and bookmarks longer a core hg feature).
Disclaimer:
I prefer git when I can choose. I do use hg, but not as my personal choice.
You also might have considered most of this, but since you didn't state any of these details and accept an answer (in the comments) that is quite different to what you are asking, I wanted to elaborate a bit.
Edit:
To follow-up on the comments:
I think hg bookmarks are comparable to git branches because both are just movable pointers to commits.
The main difference is, that when you delete a branch in git, the commits are possibly lost (when not part of other branches or pointed to in a another branch before they are garbage collected). When you delete a bookmark in hg, then the commits are still part of the repository (part of the (named or default) branch) unless manually stripped.
Anonymous heads are related, but only as something the bookmarks point to. Without bookmarks pointing to them the anonymous heads are not usable as a branch to work with (for more than just a local merge) and share. When you have anonymous heads in a repository you don't know what they are supposed to be or where they came from, unless you remember or have other clues. In my eyes anonymous heads are only a workaround for late implementation of bookmarks and no good implementation of remotes/remote heads.
Named branches are rather unrelated, as the only thing they have in common with git branches is having a name. They are light-weight in comparision to cloning the whole repository (forking as branch model), but not in terms of "you can't get rid of them". They are permanent.
Most places tell you not to use named branches unless you have a very good reason or it is a long-running branch.
The problem is following:
We have default and feature branch and at some point we have to bring changes from default to feature branch.
The changes are numerous and cannot be merged by one team member because the different changes were introduced by different people and the conflicts that are numerous need to be resolved by the people who introduced them.
Is it possible to perform multiple stage merge so that everybody on the team resolves their own conflicts on their workstation using some mechanism within the Mercurial itself?
Any idea how to do it other then put everyone into one office on one computer and lock them up until they are finished?
You can merge specific changesets from one branch to another. If you're willing to to do them in order you can just use hg merge one after another - but that will require scheduling the developers. Identify a range of changesets that should be merged (from when the default and feature branches divererged), identify the developer that should merge them. Do the merges in sequence.
If the changes from the various developers are independent then you could also use hg graft which would allow a more parallel merge. Each developer would graft their sets of changes to the feature branch, and then you would do a final hg merge (which may be a no-op) to finish everything up.
In both cases it might be easiest to branch one or more merge branches off the feature branch and merge/graft to there, resolve any issues, then merge that branch to the feature branch.
I like Mercurial Queues for its flexibility and agileness. However, for my personal use, I think it's awkward the patches are not true Mercurial changesets. Is there any plan for this extension to use true changesets? Or are there any alternatives that do so?
There is a very interesting Mercurial extension that will address some of these issues.
Mercurial Evolve provides a new approach to safe yet still mutable history, combining the flexibility of MQ with true Mercurial changesets.
They also have an interesting concept of "obsolete" changesets which can enhance collaboration between developers.
As of right now it is not in production use, but is making rapid progress in becoming an officially released extension for Mercurial.
There is also a fuller description of the roadmap available.
The user's guide gives multiple examples of typical uses.
And this MQ->evolve reference guide gives mappings from MQ commands to mercurial evolve commands.
As long as you're careful not to share history prematurely, you can do a lot with hg rebase: You can develop normally in a branch, rearrange and collapse groups of changesets, and finally graft them to the tip of your regular development (the branch name disappears, unless you ask rebase to keep it). You could also simply rearrange default, but playing around in a branch is closer to the mq model. I experimented with mq but switched to using rebase, and I've never looked back. It does everything I could wish for. (What you could wish for is a different question, but you don't say).
To support working with rebase, you can use mercurial phases to keep your changesets from leaking prematurely.
I'm a Subversion user, and I think I've got my head mostly around it all now. So of course now we're thinking of switching to Mercurial, and I need to start again.
In our single repository, we have the typical branches, tags, trunk layout. When I want to create a feature branch I:
Use the repo browser to copy trunk to branches/Features/[FeatureName].
Checkout a new working copy from branches/Features/[FeatureName].
Start working on it.
Occasionally commit, merge trunk in, resolve conflicts and commit.
When complete, one more merge of trunk, then "Reintegrate" the feature branch into trunk.
(Please note this process is simplified as it doesn't take into account release candidate branches etc).
So I have questions about how I'd fulfil the same requirements (i.e. feature branches rather than working on trunk) in Mercurial:
In Mercurial, is a branch still within the repository, or is it a whole new local repository?
If we each have a copy of the whole repository, does that mean we all have copies of each other's various feature branches (that's a lot of data transfer)?
I know Mercurial is a DCVS, but does that mean we push/pull changes from each other directly, rather than via a peer repository on a server?
I recommend reading this guide
http://stevelosh.com/blog/2009/08/a-guide-to-branching-in-mercurial//
In Mercurial, is a branch still within
the repository, or is it a whole new
local repository?
The equivalent of the subversion way of working would be a repository with multiple heads in mercurial. However, this is not the idiomatic way of doing things. Typically you will have only one head in a given repository, so separate repositories for each branch.
If we each have a copy of the whole
repository, does that mean we all have
copies of each other's various feature
branches (that's a lot of data
transfer)?
Yes, if you look at the history of the head of your local repository, then you'll be able to see all the feature branches that were merged in. But mercurial repositories are remarkably space efficient. For example, I have done a hg clone https://www.mercurial-scm.org/repo/hg to get the source for mercurial itself, and it is only 34.3 MB on an NTFS file system (compared to the source code download, which is 1.8 MB). Mercurial will also make use of hardlinks if your file system supports it, so there is little overhead if you clone a repository to another location on the same disk.
I know Mercurial is a DCVS, but does
that mean we push/pull changes from
each other directly, rather than via a
peer repository on a server?
One way of working is indeed to have each developer expose a public repository in which he pushes his own changes. All other developers can then pull what they want.
However, typically you'll have one or more "blessed" repositories where all the changes are integrated. All developers then only need to pull from the blessed repository. Even if you didn't explicitly have such a blessed repository I imagine people would automatically organize themselves like that, e.g. by all pulling from a lead developer.
Steve Losh's article on branching in mercurial linked above is fantastic. I also got into some explaining of branching and how the DAG works in a presentation I gave a couple of months ago on mercurial that's out on slideshare. The pertinent slides start at slide #43.
I think that understanding that all commits to the same repository are stored in a DAG (Directed Acyclic Graph) with some simple rules really helps demystify what's going on.
a node with no child nodes is a "head"
the root node has no parents
regular nodes have a single parent
nodes that are the result of a merge have two parents
if a merge node's parents are from different branches, the child node's branch is inherited from the first parent
Named branches are really just metadata labels on commits, but really aren't any different than the anonymous branches that happen when you merge someone elses work into your repository, or if you go back to an earlier version and then make a commit there to make a new head (which you can later merge).
I'm looking at the mercurial handbook, chapter 6 "Working with multiple branches". In there the author states that if you have separate versions/branches of the same software that it makes sense in an implied obvious way to host each branch of the software in a separate repository.
I know that Mercurial supports tags (which is the way that branches are done in subversion AFAIK). Why would you use different repositories instead of tags for branch managing?
Mercurial's tags are not the same as Subversion's branches. In Subversion, making a branch creates a separate copy of the code (with hardlinks at least, I think) while tags in Mercurial just point to a specific commit.
A while ago I wrote about Mercurial's branching models (of which branching-with-clones is one of four options), maybe you'd find it useful?
There are advantages in having different repositories in Mercurial, and problem in handling branches.
Branches mean multiple heads, the graphs are much more complicated then, and even the graphical representation may not be able to accommodate so many convoluted paths... and I don't even talk about the human brain!
On the other hand, having multiple repositories mean that each repository will have a much simpler structure, therefore easing the brain trauma of having to deal with multiple branches/merges (that you have anyway, since two developers working from the same changeset and onward develop concurrently).
Furthermore, with multiple repositories, you can read/edit any file on a given repository easily with whatever editor you are using (if you maintain the working dir up to date relatively to the tip).
On subversion you HAVE to deal with multiple branches, there is no other way around, and you have to use tags.
On Mercurial, tags are not supposed to move (it needlessly introduce changesets) and branches are handled off-the-shelf: you always have branches. However, since you can have multiple repositories, you are offered another dimension. It is your choice whether you use it or not, it made my life easier anyway.