speed up relink script

Alexis S. L. Carvalho alexis at cecm.usp.br
Mon Mar 19 14:54:32 CDT 2007


Thus spake TK Soh:
> I was trying out the relink script recently added to crew repo. While
> it works, it seemed a bit slow running on those hugh repos I have
> (some of the .hg/ are coming close to 1GB). So I tried the following
> patch to speed things up a little. See if anyone find it useful, or
> probably spot any problem with it.
> 
> diff -r 7663780b55a7 contrib/hg-relink
> --- a/contrib/hg-relink Mon Mar 19 09:36:06 2007 -0700
> +++ b/contrib/hg-relink Mon Mar 19 14:05:49 2007 -0500
> @@ -72,6 +72,8 @@ def relink(src, dst, files):
>         tgt = os.path.join(dst, f)
>         sfp = file(source)
>         dfp = file(tgt)
> +        sfp.seek(CHUNKLEN, 2)
> +        dfp.seek(CHUNKLEN, 2)
>         sin = sfp.read(CHUNKLEN)
>         while sin:
>             din = dfp.read(CHUNKLEN)

Maybe I'm missing something obvious, but doesn't this seek beyond EOF,
making sfp.read(CHUNKLEN) return an empty string, which means the loop
doesn't get executed and you unconditionally relink stuff, possibly
losing data?

Alexis


More information about the Mercurial mailing list