[issue3098] Squash merges

Ruslan Yushchenko bugs at mercurial.selenic.com
Thu Nov 10 07:07:31 CST 2011


New submission from Ruslan Yushchenko <yruslan at gmail.com>:

I'd like to propose a feature that is similar to the git's squash merges.
The idea is to merge a branch so that resulting revision will have only one
parent. It will help to push feature branches into a mainstream without
intermediate development commits. 
This scenario can be used in case we want to drop an entire branch so do not
want to have any parent relationships with it.

An example:

Suppose we have our REV1 head and other's REV2 head that we'll like to
squash merge.

--x--x--x--REV1  =>   x--x--x--REV1--Merge (squashed)
   \-y--REV2           \-y--REV2

Right now this can be done in many different ways. The two I could think of
are following:

1. Use shelve extension
$ hg up REV1
$ hg merge REV2
... resolve conflicts if necessary
... do not commit after merge completes!
$ hg shelve --name myshelf
$ hg update -C REV1
$ hg unshelve --name myshelf
$ hg ci -m "Merge (squashed)"

2. Use a hack to backup dirstate (dangerous)
$ cp .hg/dirstate $BACKUPDIR/dirstate.backup
$ hg merge REV2
... resolve conflicts if necessary
... do not commit after merge completes!
$ mv $BACKUPDIR/dirstate.backup .hg/dirstate
$ hg ci -m "Merge (squashed)"

Instead it could be as easy as additional merge option:
$ hg up REV1
$ hg merge REV2 --squash
... resolve conflicts if necessary
$ hg ci -m "Merge (squashed)"

The use of the rebase extension here have a disadvantage. You'll need to
merge with every changeset of source (other) branch and if it contains many
changesets it can be annoying.

----------
messages: 18021
nosy: yruslan
priority: feature
status: unread
title: Squash merges

____________________________________________________
Mercurial issue tracker <bugs at mercurial.selenic.com>
<http://mercurial.selenic.com/bts/issue3098>
____________________________________________________


More information about the Mercurial-devel mailing list