[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Re: svn commit: r1344825 - in /subversion/trunk/tools/dev/mergegraph: mergegraph.py save_as_sh.py

From: Greg Stein <gstein_at_gmail.com>
Date: Thu, 31 May 2012 14:38:55 -0400

On May 31, 2012 1:30 PM, <julianfoad_at_apache.org> wrote:
>...
> +++ subversion/trunk/tools/dev/mergegraph/save_as_sh.py Thu May 31
17:30:17 2012
>...
> +def command(out, cmd, *args):
> + """Write the shell command CMD with the arguments ARGS to the file-like
> + object OUT."""

Please review my earlier comments about standard docstring formatting in
Python. More specifically, PEP 8. (Google it)

>...
> +def write_recipe(graph, out):
> + """Write out a sequence of svn commands that will execute the branching
> + and merging shown in GRAPH. Write to the file-like object OUT."""
> + revs = {} # keyed by revnum
> +
> + def node_branch(node_name):
> + """Extract branch name from a node name.
> + ### TODO: multi-char names."""
> + return node_name[:1]
> +
> + def node_url(node_name):
> + """Extract the URL (in command-line repo-relative URL syntax) from a
> + node name."""
> + return '^/' + node_branch(node_name)
> +
> + def node_rev(node_name):
> + """Extract revnum (as an integer) from a node name.
> + ### TODO: multi-char names."""
> + return int(node_name[1:]) + 1
> +
> + def add(node_name, action, *args):
> + """Add the tuple (ACTION, (ARGS)) to the list REVS[REVNUM]."""
> + revnum = node_rev(node_name)
> + if not revnum in revs:
> + revs[revnum] = []
> + revs[revnum].append((action, args))

There is no need to embed these functions. It makes write_recipe() less
clear to have this clutter in here.

>...
> + raise 'unknown action: %s' % action

This form of exception is deprecated. Please raise an instance of Exception
(or of a subclass).

>...

Cheers,
-g
Received on 2012-05-31 20:39:30 CEST

This is an archived mail posted to the Subversion Dev mailing list.