This extension builds on the RebaseExtension but adds some simple logic that chooses a merge instead of a rebase if there are any file conflicts.

1. Status

This extension is not distributed with Mercurial.

Author: MarcusLindblom

2. Overview

The extension provides both a new command rebaseif as well as a new option to pull --rebaseif that invoke the rebaseif procedure after pulling. (Similar to RebaseExtension 's --rebase option).

The extension's usefulness lies in the fact that, if one wants a linear history, rebase is a good tool. However, rebase is fraught with danger as the conflict resolution is (mostly) manual. The conflict resolution(s) one make for a rebase that are afterwards pushed can never be inspected manually. The "merge" changes are lost, as they are incorporated in the output from the rebase command.

Reverting to a merge is the safe choice, since the choices (mine, theirs or a combo) is preserved in the merge commit. This can then be inspected to see if any conflicts where resolved in an inappropriate way.

If you prefer doing merges all the time (which is safe), this is not an extension for you. The more linear revision history is preferred by some people, but we can do better than heedlessly rebasing everything. This extension aims to provide a middle ground that makes the safe choice automatically.

Note that problems caused by changes in different files still can make your build fail (or cause other bugs or errors), so rebasing is never _entirely_ safe. However, most of us find that it's a good tool for keeping the history graph human-parseable.

A rebase operation is in many senses very equivalent to hg pull --update (or svn update) with local changes. I.e. your local changes are merged with the incoming ones, and you may pray that it still works as intended. If we are pragmatic about it, most hard-to-detect-and-fix errors come from bad conflict resolutions, not unrelated file changes.

The origin for this extension came from this StackOverflow question.

3. Configuration

Configure your .hgrc to enable the extension by adding following lines:

rebaseif = path/to/

4. Usage

> hg rebaseif

> hg pull --rebaseif

5. See also


RebaseIfExtension (last edited 2012-02-15 22:36:20 by ks3095497)