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

How could you join two unpublished 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

Tags

adb(1), admin(1), android(1), anki(1), ansible(2), aop(1), blog(2), bytecode(1), c(1), css(2), cygwin(2), driver(1), emacs(3), fs(1), git(3), google(1), gradle(1), hardware(1), hg(2), html(1), interview(13), java(4), js(3), lang(2), lighttpd(1), markdown(1), mobile(1), naming(1), oracle(1), print(1), problem(5), python(1), quiz(6), rst(2), security(3), spring(2), sql(2), srs(1), style(1), tls(2), txt(1), unit(1), utils(1), vcs(3), web(2), win(2), windows(1)

Archive