tags:

views:

54

answers:

2

Hi!

I am looking for best practices to do the following:

When I need to implement a feature or fix a bug, I am creating new Mercurial repository from the main one (a trunk). Then, within some days, or weeks, I am implementing the task in newly created repository, making commits and periodically merging with trunk. After the code in new repository will pass all code reviews, I should provide a repository with all changes collapsed into single revision.

My common way to do this (rdiff extension should be enabled):

hg clone ~/repos/trunk ~/repos/new-collapsed
cd ~/repos/new-collapsed
hg diff ~/repos/new > new.diff
patch -p1 < new.diff
hg commit

This works almost well except when there are binary files present in the changes from ~/repos/new. Another way could be:

hg clone ~/repos/trunk ~/repos/new-collapsed
cd ~/repos/new-collapsed
hg pull ~/repos/new
hg update
hg rollback
then resolve possible conflicts and manually commit the changes

Both ways look for me somewhat ugly and non-native, so I am looking how this operation could be simplified. I've played with rebase extension, but seems its hg rebase --collapse command does not work with workflow described above.

Any ideas are welcome.

A: 

I do something similar with the histedit extension.

My workflow is something like:

  • clone a central repo
  • commit incremental changes to local repo
  • clone my local repo to make collapsed repo
  • hg histedit and select/discard/fold the revisions as needed
  • hg push the collapsed repo to central repo
  • pull central repo to local or refresh local from scratch

I ensure that my local repo never gets pushed to the central repo by adding an invalid default-push path to the .hg/hgrc file in the local repo root directory.

ataylor
Hmmm I've looked onto histedit extension some time ago ... usually I have a lot of revisions that should be collapsed (my own record was 600+ commits), so in a lot of cases manual revision manipulating isn't suitable.
Serge Tarkovski
+1  A: 

Sounds like a good case for mercurial queues.

Paul Nathan