Oleksandr Gavenko's blog
2017-02-10 21:45 Joining two commits in Mercurial

Suppose you have two unpublished commits in Mercurial and like to join them into single commit:

... --> THIS --> ... --> THAT --> ... --> LAST

Check that your commits are not published:

$ hg glog -r "draft() & ($THIS | $THAT)"

Update to LAST commit:

$ hg up

and import commits up to THIS into MQ:

$ hg qimport $THIS::.

Un-apply all patches and apply only first THIS:

$ hg qpop -a
$ hg qpush
$ hg qapplied
... THIS ...

Join with THAT:

$ hg qfold $THATNAME

To find name THATNAME use:

$ hg qseries

qfold preserve commit messages!

Apply all patches and move them to repository history:

$ hg qpush -a
$ hg qfinish -a

You can rearrange patches in MQ when they unapplied. In this way you may perform join in any point of drafted changes. For this purposes edit .hg/patches/series manually.

With hg qfold $(hg qunapp) you can join all unapplied patches into current patch. Commit messages would be preserved.

https://www.mercurial-scm.org/wiki/ConcatenatingChangesets

Tips on official Mercurial wiki about concatenating changesets.

https://www.mercurial-scm.org/wiki/RebaseExtension

Tips on official Mercurial wiki about rebase extension.

http://stackoverflow.com/questions/1725607/can-i-squash-commits-in-mercurial

Can I squash commits in Mercurial?

http://stackoverflow.com/questions/1200691/with-mercurial-how-can-i-compress-a-series-of-changesets-into-one-before-push

With Mercurial, how can I “compress” a series of changesets into one?

hg, vcs

Feeds

all / emacs / java / python

Tags

admin(1), anki(1), blog(1), css(2), cygwin(2), emacs(3), fs(1), git(2), gradle(1), hg(2), html(1), interview(11), java(2), js(3), lang(2), lighttpd(1), mobile(1), naming(1), oracle(1), print(1), problem(5), quiz(6), rst(1), security(1), sql(2), srs(1), style(1), unit(1), utils(1), vcs(3), web(2), win(2)

Archive