Folding

Folding is the act of combining multiple local commits into a single revision to push.

Clone your repository

Before attempting anything here you should clone your repository. This can be done easily in TortoiseHG by right-clicking your hg directory and selecting “Clone a repository”. Seriously, do this.

Edit mercurial.ini

Make sure Mercurial.ini file in your user home dirctory (i.e. C:\Documents and Settings\rdis\Mercurial.ini) has the MQ extension enabled:

[extensions]
rebase =
mq =

# allows to do qstatus and will show changes for last patch
[alias]
qstatus = status --rev -2:.

# ensures use git format for patches, which handles binaries better
[diff]
git=1

[defaults]
qdiff = --git
qnew = --git
qimport = --git
qrefresh = --git

Step-by-step instructions

All changes to be folded must be committed locally

  • Make sure that “Link with Editor” is disabled in Eclipse
  • Open Mercurial Patch queue view in Eclipse (Window->show view->other->mercurial->mercurial patch view
  • Click qimport
    1. Check “place existing revisions under mq control”
    2. Select the revisions to be folded
    3. Click finish
  • Select the first changeset
  • Click on ‘qpop’ to unapply the subsequent changes
    1. All revisions except the first should now show as ‘UNAPPLIED’
  • Select all ‘UNAPPLIED’ changesets
  • Click qfold
  • Update the commit messages
    1. By default, the comment for the revision is all of the comments of the combined revisions separated by a line separator.
    2. To create a new comment for the folded revision, go to the command line and type ‘hg qrefresh -e’, type the new comment, and save the file
    3. C:\RDIS\workspace_hg_tip\hg>hg qrefresh -e
  • Commit the changes
    1. Go to command line and run the following command from the repository directory
    2. C:\RDIS\workspace_hg_tip\hg>hg qfinish -a
  • All your changes have now been folded locally so you can push them to the central repo.

It's only fair to share...
Share on FacebookGoogle+Tweet about this on TwitterShare on LinkedIn

Leave a Reply