[PATCH] csplit support in hg import

Bryan O'Sullivan bos at serpentine.com
Wed Aug 31 01:36:21 CDT 2005


On Tue, 2005-08-30 at 19:41 -0700, TK Soh wrote:

> +    def csplit(pf):

Please give this a descriptive name, such as perhaps splitpatch.

> +        flist = []
> +        nodes = []
> +        f = None
> +        node = None
> +        for line in file(pf):
> +            if line.startswith("# HG changeset patch"):
> +                if f:
> +                    f.close()
> +                    flist.append(tfile)
> +                    nodes.append(node)

Please get rid of tfile, and use f.name instead.

> +                tfile = tempfile.mktemp()
> +                f = open(tfile, 'w')
> +                f.write(line)

tempfile.mktemp is deprecated because it is not secure.

> +            elif f:
> +                if line.startswith("# Node ID "):
> +                    node = line[10:]
> +                    node = node.rstrip()
> +                f.write(line)

I don't see much value in saving this information and printing it.  In
particular, patches generated with mq don't contain this information.

If you want to print something more useful, just ui.status the number of
Mercurial patches that a patch file contains, if that number is > 1.

	<b



More information about the Mercurial mailing list