[PATCH] Add script to rewrite manifest to workaround lack of parent deltas

Greg Ward greg-hg at gerg.ca
Thu Aug 27 08:30:19 CDT 2009


On Tue, Aug 25, 2009 at 10:16 AM, Benoit
Boissinot<benoit.boissinot at ens-lyon.org> wrote:
> I tested it in the kernel repo, and there are some nodes with duplicate
> parents (p1 = p2), so it needs the fix below.
>> +
>> +def toposort(rl):
>> +    write = sys.stdout.write
>> +
>> +    children = {}
>> +    root = []
>> +    # build children and roots
>> +    write('reading %d revs ' % len(rl))
>> +    try:
>> +        for i in rl:
>> +            children[i] = []
> use set()
>> +            parents = [p for p in rl.parentrevs(i) if p != node.nullrev]
>> +            for p in parents:
>> +                assert p in children
>> +                children[p].append(i)
> use .add(i)

How about this instead:

        for i in rl:
            children[i] = []
            parents = [p for p in rl.parentrevs(i) if p != node.nullrev]
            # in case of duplicate parents
            if len(parents) == 2 and parents[0] == parents[1]:
                del parents[1]
            for p in parents:
                assert p in children
                children[p].append(i)

? A set with max 2 members seems silly.

Dirkjan:
> I prefer -revlog. Making it an extension that adds a command called
> shrink (without args, manifest, with arg, filelog) might be even
> better (although it should probably be in contrib, not hgext).

OK, I'll rename it to shrink-revlog and make it possible to shrink any
manifest or filelog.  I like the "shrink manifest of current repo by
default" behaviour, though, so I'll keep that.

As for making it an extension: later, please?  I suspect that would be
more controversial, since it promotes a workaround for a design flaw
into a more visible place.  I would prefer to get this committed as a
contrib/ script now and refactor it later.

Oh yeah, the same holds for algorithm tweaks that shrink more.  Again
I'm all in favour of them, but I'd like to get this basic algorithm
committed first.

Greg



More information about the Mercurial-devel mailing list