You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by ju...@apache.org on 2012/05/31 22:14:49 UTC
svn commit: r1344888 - in /subversion/trunk/tools/dev/mergegraph:
mergegraph.py save_as_sh.py
Author: julianfoad
Date: Thu May 31 20:14:49 2012
New Revision: 1344888
URL: http://svn.apache.org/viewvc?rev=1344888&view=rev
Log:
* tools/dev/mergegraph/mergegraph.py,
tools/dev/mergegraph/save_as_sh.py
Put doc string close-quotes on a line by themselves, as per PEP-8.
Suggested by: gstein
Modified:
subversion/trunk/tools/dev/mergegraph/mergegraph.py
subversion/trunk/tools/dev/mergegraph/save_as_sh.py
Modified: subversion/trunk/tools/dev/mergegraph/mergegraph.py
URL: http://svn.apache.org/viewvc/subversion/trunk/tools/dev/mergegraph/mergegraph.py?rev=1344888&r1=1344887&r2=1344888&view=diff
==============================================================================
--- subversion/trunk/tools/dev/mergegraph/mergegraph.py (original)
+++ subversion/trunk/tools/dev/mergegraph/mergegraph.py Thu May 31 20:14:49 2012
@@ -65,7 +65,8 @@ from pydot import Node, Edge
def mergeinfo_to_node_list(mi):
"""Convert a mergeinfo string such as '/foo:1,3-5*' into a list of
- node names such as ['foo1', 'foo3', 'foo4', 'foo5']."""
+ node names such as ['foo1', 'foo3', 'foo4', 'foo5'].
+ """
### Doesn't yet strip the leading slash.
l = []
if mi:
@@ -89,7 +90,8 @@ def mergeinfo_to_node_list(mi):
class MergeGraph(pydot.Graph):
"""Base class, not intended for direct use. Use MergeDot for the main
- graph and MergeSubgraph for a subgraph."""
+ graph and MergeSubgraph for a subgraph.
+ """
def mk_origin_node(graph, name, label):
"""Add a node to the graph"""
@@ -169,13 +171,15 @@ class MergeGraph(pydot.Graph):
def add_annotation(graph, node, label, color='lightblue'):
"""Add a graph node that serves as an annotation to a normal node.
- More than one annotation can be added to the same normal node."""
+ More than one annotation can be added to the same normal node.
+ """
subg_name = node + '_annotations'
def get_subgraph(graph, name):
"""Equivalent to pydot.Graph.get_subgraph() when there is no more than
one subgraph of the given name, but working aroung a bug in
- pydot.Graph.get_subgraph()."""
+ pydot.Graph.get_subgraph().
+ """
for subg in graph.get_subgraph_list():
if subg.get_name() == name:
return subg
@@ -298,7 +302,8 @@ class MergeDot(MergeGraph, pydot.Dot):
"""Save this merge graph to the given file format. If filename is None,
construct a filename from the basename of the original file (as passed
to the constructor and then stored in graph.basename) and the suffix
- according to the given format."""
+ according to the given format.
+ """
if not filename:
filename = graph.basename + '.' + format
if format == 'sh':
Modified: subversion/trunk/tools/dev/mergegraph/save_as_sh.py
URL: http://svn.apache.org/viewvc/subversion/trunk/tools/dev/mergegraph/save_as_sh.py?rev=1344888&r1=1344887&r2=1344888&view=diff
==============================================================================
--- subversion/trunk/tools/dev/mergegraph/save_as_sh.py (original)
+++ subversion/trunk/tools/dev/mergegraph/save_as_sh.py Thu May 31 20:14:49 2012
@@ -30,35 +30,42 @@ def shebang_line(out):
def command(out, cmd, *args):
"""Write the shell command CMD with the arguments ARGS to the file-like
- object OUT."""
+ object OUT.
+ """
print >> out, ' '.join((cmd,) + args)
def svn(out, subcmd, *args):
"""Write an svn command with the given subcommand and arguments. Write
- to the file-like object OUT."""
+ to the file-like object OUT.
+ """
command(out, 'svn', subcmd, *args)
def comment(out, text):
- """Write the comment TEXT to the file-like object OUT."""
+ """Write the comment TEXT to the file-like object OUT.
+ """
print >> out, '#', text
def node_branch(node_name):
"""Extract branch name from a node name.
- ### TODO: multi-char names."""
+ ### 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."""
+ 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."""
+ ### TODO: multi-char names.
+ """
return int(node_name[1:]) + 1
def add(revs, node_name, action, *args):
- """Add the tuple (ACTION, (ARGS)) to the list REVS[REVNUM]."""
+ """Add the tuple (ACTION, (ARGS)) to the list REVS[REVNUM].
+ """
revnum = node_rev(node_name)
if not revnum in revs:
revs[revnum] = []
@@ -66,7 +73,8 @@ def add(revs, node_name, action, *args):
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."""
+ and merging shown in GRAPH. Write to the file-like object OUT.
+ """
revs = {} # keyed by revnum
for br, orig, r1, head in graph.branches:
@@ -121,7 +129,8 @@ def write_recipe(graph, out):
def write_sh_file(graph, filename):
"""Write a file containing a sequence of 'svn' commands that when run will
perform the branching and merging described by the MergeDot object
- GRAPH. Write to a new file named FILENAME."""
+ GRAPH. Write to a new file named FILENAME.
+ """
out_stream = open(filename, 'w')
shebang_line(out_stream)
write_recipe(graph, out_stream)