Differences between revisions 7 and 8
Revision 7 as of 2012-04-24 21:09:57
Size: 2493
Editor: ks3095497
Comment: Remove the [[...]]] around the repository location.
Revision 8 as of 2012-11-06 19:48:51
Size: 2491
Editor: jaraco
Comment: Corrected invalid syntax
Deletions are marked like this. Additions are marked like this.
Line 2: Line 2:
Line 5: Line 4:
''Author: Colin Caughie <c.caughie@indigovision.com>'' ''Author: Colin Caughie < c.caughie@indigovision.com >''
Line 12: Line 11:
Line 37: Line 35:
Line 41: Line 38:
Line 47: Line 43:
Line 51: Line 46:
Line 60: Line 56:
Line 64: Line 61:
$ hg collapse 2:5 $ hg collapse -r 2:5
Line 66: Line 63:
* The first revision in the collapse group has multiple parents. E.g.
Line 67: Line 65:
* The first revision in the collapse group has multiple parents. E.g.
Line 72: Line 69:
$ hg collapse 4:5 $ hg collapse -r 4:5
Line 74: Line 71:

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)