Hi,
I am running into a following (or similar) situation:
Someone creates a feature "xyz".
Two developers now work on the same feature on their local development environment.
One of them is finished, says "drush features-update xyz", git commit and push.
How can the other developer merge that feature into his own dev environment, without losing any work?
Is there any recommended strategy?

This is what I did so far:
1. Always "drush fu", before you "git pull" or merge.
2. Merge the changes from other developers
3. Resolve merge conflicts
4. "drush features-revert" to actually enable the stuff done by other developers.

Problems:
- Merge conflicts can be insanely long, and git cuts the code at awkward positions.
- Huge features are especially nasty to merge.
- If you leave those features unmerged for a long time, the merge conflicts will be even worse.
- It is easy to forget the "drush fu", before you pull. Then you end up with a situation where you don't know if you should "drush fu" or "drush fr".
- If your fellow developer has repackaged a feature, moving stuff around from one feature to another, you are in a complete mess.
- If the two versions of a feature were created with different versions of the associated modules (such as display suite 1.x vs display suite 2.x), the feature code might look very different. See #1435080: Save fields with canonical order and weight

Now that features is around and popular for quite a while, I can't be the only one who ran into this situation. Is there any recommended way out?

Thanks!

Comments

donquixote’s picture

Title: Merge strategy different feature versions? » Merge strategy for different feature versions?

Forgot the "for" in the title.

xtfer’s picture

As much as I sympathise with your predicament, I suspect this is more a problem with your development workflow than Features itself.

Ensuring your developers having matching codebases, don't work on the same features at the same time, and keep your features small and modular is the easiest way out of this mess. Use the Kit specification for Features (http://drupal.org/project/kit), if you need a guide, though beware that some of its recommendations can cause other problems. Permissions are sometimes better off in their own feature, or not included, and content types tend to work better namespaced. In general, limit a Feature to the actual feature it provides, for example "Event" or "News".

Edit: In addition, if you can find a graphical git client for your environment that supports line-by-line commit and discard (e.g Sourcetree for OSX, which is free), its much easier to do the actual merge on these big complicated merges.

Edit 2: One other thing I forgot, keep a strict rule that Features are NEVER overridden except while explicitly working on a specific feature. As a rule of thumb, before and after working on a feature, you should be able to run drush fr-all without any problems.

donquixote’s picture

Thanks, this is quite helpful already.

As much as I sympathise with your predicament, I suspect this is more a problem with your development workflow than Features itself.

Probably yes :)
On this particular project I am slowly introducing features. However, a lot is still happening without features.
Also, there is one big and nasty feature around from long ago, when I really had no idea that splitting a feature up is a non-trivial task.

I wish it was easier to split up features, or disable them and keep the site functionality, etc. And then let this split-up travel to staging and production, or to your fellow developers.

Kit specification for Features

Nice thing!
Actually, this describes more or less the way I intend to work today. But, there are still older features around, which do not work well with this spec.

content types tend to work better namespaced

Hm, I don't get it. If I create the feature with features module, everything is "namespaced" (in D6, that is "prefixed") with the module name of the created feature. E.g., for a site where everything tends to begin with "bw_", typical feature module names are "bwf_groups", "bwf_events", etc, distinguishing it from regular hand-coded site-specific custom modules such as "bw_groups" or "bw_events". What more is there about namespacing?

Edit: In addition, if you can find a graphical git client for your environment that supports line-by-line commit and discard (e.g Sourcetree for OSX, which is free), its much easier to do the actual merge on these big complicated merges.

Good idea.
It would already help if git merge would not cut the code at arbitrary positions in case of merge conflict, but consider the brackets or indentation.

don't work on the same features at the same time

Nice thing to ask for, but..
I had the idea that merge conflicts in feature modules are often more nasty than those in hand-coded modules, for some minor changes. Hand-coded modules tend to be more forgiving to more than one developer working on the closely related stuff, if none of the developers does any heavy refactoring or moving lines around.

Edit 2: One other thing I forgot, keep a strict rule that Features are NEVER overridden except while explicitly working on a specific feature. As a rule of thumb, before and after working on a feature, you should be able to run drush fr-all without any problems.

Good one.
I hope we can get to this point once.
For this existing project, I don't expect it to happen that soon.
For new projects, any time.

Anonymous’s picture

I share the same situation as donquixote. We're using a branching model similar to this one : http://nvie.com/posts/a-successful-git-branching-model/

The problem is that, we have over 50 Features in our site
And seriously, when it come to merging Features in our dev branch, it is a pain in the ***.

I don't have much to bring in to make it easier to work with features than what xtfer says tho.

mpotter’s picture

Status: Active » Closed (works as designed)

Nothing to be done here since Features is at the mercy of the code export format supplied by other modules (Views, etc)

mpotter’s picture

Issue summary: View changes

If the two versions of a feature were created with different versions of the associated modules