Assuming I am expanding some project hosted on bitbucket with multiple features (managed by mercurial).
If I build up the features one on top of the other (linear local history) I have a local code base that has all the features I need, but the maintainer of the package cannot pick and choose the features he likes. (Because they build on each other.)
If I build up each feature in a separate branch based on the origin master, all the feature PRs are independent of each other (allowing the maintainer to pick and choose), but I no longer have a unified local code base with all my required features.
How does one solve this problem? With patch queues? If so, how?
I'd go for both actually: create a separate feature branch (anonymous heads, maybe named by means of a bookmark) and pull request for each feature.
Additionally, for your own benefit, and maybe also for others to check it all quickly, merge those into your main development branch, your main line.
In principle mercurial has the system of phases and allows for non-publishing repositories which allows to keep a draft history and allows you to easier make updates - but that's afaik something which bitbucket does not yet (fully?) support.
Related
Suppose I'm working on a new feature.
While working on my new feature, I get enough basic functionality so that I want to release it while continuing to work on the full feature. When the new feature is fully complete, I want to merge that back to the main release, replacing the basic feature.
What is the Mercurial workflow to do this?
The way I would approach this would be to create a feature branch. Mercurial branches can be merged into each other multiple times. So you could merge at milestone 1 (basic / minimal features) and again later (full / complete features) from the feature branch into your main branch.
Branches can be either named or unnamed / anonymous; the workflow will work the same either way. Whether you choose to create a named branch is essentially a personal / team preference; be aware that named branches persist forever in the repository history so typically they are used for long-running projects.
Anonymous branches are so common some people don't even realize that's what they are using. Effectively a branch is created anytime you commit work. Each developer will implicitly be working on their own branch (at least until their new work is pushed and synchronized.) So you could simply work locally on the new feature and only push it to share with others when its ready. Work more, push again later.
Personally I use this approach often because it is very flexible and simple. I often like to keep multiple local repository clones, each dedicated to a single task. These can be easily created, used, and removed at will. If your repository is large then I recommend using hg share instead of hg clone to create the 2nd through nth local repositories, as it will save time & space.
If you prefer to do so you can also use the Mercurial bookmark feature to "label" an anonymous branch, this could be preferable to creating a permanent named branch since bookmarks can be removed later.
We are in the process of moving to Mercurial from Clearcase (for version control) and to Jira/Crucible from ClearQuest (for issue tracking and code reviews). We perform mandatory pre-push reviews.
We have encountered a problem with Crucible and pre-push support, and we are looking for several solutions. The main way to resolve the problem is to make Atlassian products "watch" as least amount of repositories as possible (the issue we encountered is slowness that is directly linked to the amount of repositories watched).
What we do now is watch every single development repository to allow us to perform code reviews on them. We also have one central repository that holds a stable version. My question is how to plan our repository architecture so we can perform code reviews and still keep a clean central repository (I guess some sort of review repository is needed, but I can't figure out how to get it to work for several reviews at once).
We do pre-push reviews the easy way: we use patches instead of having development repositories on a central server.
Only if we need to build something big, we create a development/feature repository on the server, but even then, we still review patches before pushing to those repos.
To enforce this, you need assign roles for pushing to the repos, instead of allowing all development team to push.
Suppose I'm developing software for different clients with a common need.
I develop the system with a single line of development, and that is ok. Each client has the software installed on a server, and updates are made by pulling from a bitbucket repository.
Later, one of the clients asks for a custom module for his own needs only. Other clients may also have other custom needs as well.
My problem is: How can I manage the customization, pulling (updating) new versions of the main line of development, and the customs only when they are present?
One option: make the customisation part of the codebase rather than managed through Mercurial. There are lots of good reasons for doing this, including that there's no danger of you forking and ever maintaining separate version of code, or indeed maintaining separate branches of a repository tree. Both of those are pretty dull tasks that could lead to problems, so I'd favour that if I were you. It depends on your language but I would aim for keeping a load of modules in the MainCodeBase with some way for users to configure which are used.
Second option: sub repositories. Make a repo for Customer1 which includes that customer's modules and has a sub-repository of MainCodeBase. Customer1 just needs to recursively pull their repository to get the latest modules and the latest MainCodeBase. Problem here is it starts to get ugly when you want more than one customer to use the same module.
I'm an hg user since a couple a years and I'm happy about that!
I have to start a project as I never did before.
The idea is to develop a software with a batch mode and an GUI.
So there will be common sources to both batch and GUI mode but each one will also contain specific sources.
And, basically, I would like my coworkers to be able to clone the GUI version, work on it an commit changes.
Then, I'd like to be able to merge their changes on the common files with the batch version.
How can I deal with that?
Since I've been reading a bit on this topic, I would really appreciate any help!!
Thank you.
binoua
As the creator of subrepos, I strongly recommend against using subrepos for this.
While subrepos can be used for breaking up a larger project into smaller pieces, the benefits of this are often outweighed by the additional complexity and fragility that subrepos involve. Unless your project is going to be really large, you should just stick to one project repo for simplicity.
So what are subrepos for, then? Subrepos are best for managing collections of otherwise independent projects. For instance, let's say you're building a large GUI tool that wraps around an existing SCM. I'd recommend you structure it something like this:
scm-gui-build/ <- master build repo with subrepos:
scm-gui/ <- independent repo for all the code in your GUI tool
scm/ <- repo for the third-party SCM itself
gui-toolkit/ <- a third-party GUI toolkit you depend on
extensions/ <- some third-party extension to bundle
extension-foo/
Here you do all your work in a plain old repo (scm-gui), but use a master repo at a higher level to manage building/packaging/versioning/tagging/releasing the whole collection. The master scm-gui-build repo is just a thin wrapper around other normal repos, which means that if something breaks (like one of the repo's URLs goes offline) you can keep working in your project without problems.
(see also: https://www.mercurial-scm.org/wiki/Subrepository#Recommendations)
My company's product is module-based, meaning we ship with five base modules and users can purchase additional ones. We're using Mercurial, to which we are relatively new, for our source control, and since we've released 1.0 of our product, managing the separate module development has been a nightmare.
We want to be able to release minor bugfix updates without having to wait for particular module development to be complete, so one repo for everything doesn't work very well. I read about branching but the Definitive Guide seems to suggest that branching is temporary, and that merging with it is difficult.
Ideally, we'd have a base repo that is the product and then different repos (or branches) with the extra modules, so that QA could build the main product and the main+addons separately, while the developers working on ModuleA don't impact the developers working on BugfixB. I tried this with multiple subrepos but it ended up corrupting my repositories.
Should I be looking at using named branches? Or bookmarks?
I'm looking for suggestions on best practices on how we can take advantage of Mercurial's features to make this process easier.
Thanks!
There is a good tutorial about branching at http://nvie.com/git-model. The main point is to have
a release branch which contains only merges from completed release/bugfix branches
development branches for bug fixes or features
own branches for long-term features
Also there is a reference about the technical differences in mercurial branches at http://stevelosh.com/blog/2009/08/a-guide-to-branching-in-mercurial/
Branching is your solution. I consider named branches to be a Good Thing. However, you should be aware that named branches require a certain level of forethought and discipline in use.
I would suggest that each bug-fix gets its own branch. Developers will fork off that branch, do the bugfix, merge back into the feature-branch.
I would consider splitting your modules into separate repositories, one for each product. Possibly that's not very useful; you'll have to go over different use cases there and determine how the workflow/compile-flow would go.
I don't see why you'd consider having different subrepos for this when the file history is virtually the same throughout - this is a prime job for branches. The only complication is being able to cherry-pick patches for each branch - that may require you to export a patch (or set of patches) and apply them individually to each branch. It's a bit more awkward than it should be, but it's no harder than doing the same across different repositories.
I think the question blurs two different issues:
You have a modular product
You have separate development cycles for each module
For handling the modular product you should use different repositories for each module and bring them together using subrepos as appropriate for each customer configuration. It appears you're already doing this but are having corruption issues. This is certainly the correct way to go so you need to bottom-out whether the corruption is coming from a Mercurial bug or user error.
For handling separate development cycles then personally I'd go for module clones but named branches would also be fine.
Hope this helps.
I am new to Mercurial as well, but I think that your problem is not specific to it.
You need to think about the process of releasing code and the parties involved, and map this model to a branch layout that can support it.
Mercurial is nice because it can support developers well, by allowing them to maintain their own development "branches" without affecting a continuous build or other downstream processes (QA, installers, etc).
[Rel]
^
[RC]
^
[QA]----[QA]------[QA]
^ ^ ^
[Dev]---------------------------------------------------------
^ ^ ^
[Jen] [Paul] [Ken]
this is a possible scheme, where developers merge to Dev, and somebody merges regularly to the [QA] branch, and when that it baked nice goes to [RC] etc.
Every release stays isolated from other activity.
Good Luck!