qrebase extension

Gilles Moris gilles.moris at free.fr
Mon May 5 16:14:51 CDT 2008


Here am I again with the qrebase command but this time bundled as an extension. This should be much easier to maintain and to make it work with different versions of mercurial.

Introduction:
The qrebase extension has to be used with the MQ extension. Its goal is to merge a collection of patches with possibly the 3-way merge machinery of mercurial in a simple command.
The qrebase command is built on the MqMerge wiki page:
http://www.selenic.com/mercurial/wiki/index.cgi/MqMerge
So there is nothing new, and this is just a macro command to avoid a lengthy and error prone process.
I tried to refactor it so that you usually only have to type: hg qrebase

Development status:
Experimental, even though the test cases are fairly complete (92%), this code is not yet used in a production environment. I have only a few patches on top of the crew repository with no conflicts so far.
So be careful and watch out for bugs.
This extension has been tested OK with 1.0 and latest crew. It also works with 0.9.5 but I had to modify the test scripts. Not tested before.
Tested on Fedora 8, Fedora 5 and Cygwin under WinXP.

Usage:
  hg qrebase [--from-rev FROM_REV]   --to-rev TO_REV | [PULL_SOURCE]
There are 2 main forms to use qrebase. The first will pull changes and rebase the queue upstream, if there is only one head on the current pulled branch.

hg qrebase [PULL_SOURCE]
ex: hg qrebase
    hg qrebase http://hg.intevation.org/mercurial/crew

The second form is used to rebase the queue on another revision/branch. In that case you provide the revision/branch to which to rebase, and there is no pull of changesets.

hg qrebase -r TO_REV
ex: hg qrebase -r 234
    hg qrebase -r default

By default, the parent of the working directory is supposed to be the revision from which the queue last cleanly applied. But the option --from-rev can be used to checkout an alternate revision for that purpose.

Installation:
Clone the qrebase repo and add the extension in your hgrc:
 hg clone http://freehg.org/u/morisgi/qrebase/ qrebase
 vi ~/.hgrc
 [extensions]
 qrebase = /path/to/qrebase/qrebase.py

You can also link the test scripts in the tests directory of mercurial to pass the tests bench. In this case, define the QREBASE environment variable to the qrebase.py file.

Limitations:
It is only designed to work with the mq.py extension.
It implements a fairly complex process of mercurial commands, so that interrupting qrebase could leave you in an inconfortable state.
I have also blocked rebasing backward in history, as I found that 3 way merge was not triggered, and that the patch queue was left corrupted. I am not yet experienced enough to undertand where is the problem (possibly me).

Alternate usage:
I guess that if you have a branch with a linear history, you should be able to qimport it and qrebase it. But not tested.

Last word: I hope that you will find it useful. Normally, with a GSoC on the topic, it might be replaced soon by a better builtin support.
PS: I have been quite verbose and probably forgot to mention some important informations. I am open to questions / suggestions.


More information about the Mercurial mailing list