Collapse Extension

This extension is not distributed with Mercurial.

Author: Colin Caughie < c.caughie@indigovision.com >

Maintainer: Peer Stritzinger

Repository: http://bitbucket.org/peerst/hgcollapse

Overview

The collapse extension adds a new command, 'collapse', to Mercurial. This collapses a number of committed changesets into a single changeset. If the last collapsed changeset is not a head, the sequence of changesets that follow it are rebased onto the collapsed one.

So for example:

Before: 1 --> 2 --> 3 --> 4

$ hg collapse -r 2:4

After: 1 --> 2[2-4]

Before: 1 --> 2 --> 3 --> 4

$ hg collapse -r 2:3

After: 1 --> 2[2-3] --> 3[was 4]

Before: 1 --> 2 --> 3 --> 5 --> 6
               \--> 4 ---/

$ hg collapse -r 2:5

After: 1 --> 2[2,3,4,5] --> 3[was 6]

The collapse command will concatenate the commit messages of the original revisions to form the message for the collapsed one, and will invoke your editor to edit it before committing the collapsed revision.

Usage Patterns

This extension is particularly useful when you follow the practice of committing regularly to your local repository, possibly before you've got anything sufficiently complete to be put in a shared repository. Rather than filling the changelog with changes of the "OK it almost works now" type, you can collapse all of your intermediate commits before pushing to the shared repository.

N.B. 'hg collapse' is destructive; it rewrites history. Therefore you should never collapse any changeset that has been pushed to another repository, unless you really know what you are doing.

When you can't collapse

You can't collapse if:

* Any of the revisions to be collapsed other than the last one have child revisions outside of the collapse group. E.g.

1 --> 2 --> 3 --> 4
             \--> 5

$ hg collapse -r 2:4

(In this case you could resolve the issue by using the rebase extension to rebase 5 on 4, and then collapse 2-4.)

* Any of the revisions to be collapsed other than the first one have parent revisions outside of the collapse group. E.g.

1 --> 2 --> 4 --> 5
      3 ---/

$ hg collapse -r 2:5

* The first revision in the collapse group has multiple parents. E.g.

1 --> 2 --> 4 --> 5
      3 ---/

$ hg collapse -r 4:5

See also


CategoryExtensionsByOthers

CollapseExtension (last edited 2013-09-03 03:40:04 by KevinBot)