how to combine old revisions into one?

Tom Widmer tom.widmer at gmail.com
Tue Aug 30 13:08:51 UTC 2011


On 26/08/2011 19:48, TJ wrote:
> Hello!
>
> I've got a repository. In the middle of its life-cycle I deleted a lot
> of unnecessary files from it (I decided to keep them unversioned).
> hg remove
> hg commit
>
>
> The repo grows bigger and bigger.
>
> And I decided to get rid of old revisions the from initial one to the
> revision where lot of files were removed (let's name it X).
> Other words I want combine these revisions (from the initial to the X)
> into one initial revision.

Is that definitely what you want, or do you really want to remove those 
files from the history but keep the old revisions? Both are possible 
using http://mercurial.selenic.com/wiki/ConvertExtension, which is 
bundled with Mercurial - use --filemap for stripping files, --splicemap 
for stripping revisions.

> But same time to keep the history of the following revisions (X+1,
> etc..) as they are.
>
> I googled for the solution, but failed.
>
> And found nothing clever than do this:
>
> hg init newrepo
> cd oldrepo
> hg archive -r X newrepo
> hg export -r X+1: -o "~/patches/%R-%h.diff"
> cd newrepo
> hg commit -A -m 'initial release (after archiving)'
> hg import ~/patches/*.diff
>
>
> And damn it, after few successfully applied patches
> I receive:
>
> Hunk #1 FAILED at xxx
> Hunk #2 FAILED at xxx
> 2 out of 2 hunks FAILED -- saving rejects to file xxx.rej
> abort: patch failed to apply
>
>
> What I do wrong?
>
> I've got 1 repo without branches (to be more exact to the revision X all
> branches were merged).

I think you can use HG convert to do this more easily and reliably. You 
should create a splicemap text file with a single line consisting of 
(separated by a single space):

<full sha of first revision you want to keep> 
0000000000000000000000000000000000000000

(revision 00000... is the initial 'null' revision in every repo).

then do:
hg convert --splicemap <my splicemap file> oldrepo newrepo

See http://mercurial.selenic.com/wiki/ConvertExtension for details.

Kind regards,

Tom



More information about the Mercurial mailing list