~abentley/bzrtools/bzrtools.dev

« back to all changes in this revision

Viewing changes to graph.py

  • Committer: Aaron Bentley
  • Date: 2005-09-01 17:03:54 UTC
  • Revision ID: abentley@panoramicfeedback.com-20050901170354-d4284bd69b877fa5
Used rsvga for nice antialiasing

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
from dotgraph import Node, dot_output, invoke_dot, NoDot, mail_map
 
1
from dotgraph import Node, dot_output, invoke_dot, invoke_dot_aa, NoDot 
 
2
from dotgraph import mail_map
2
3
from bzrlib.branch import Branch
3
4
from bzrlib.errors import BzrCommandError
4
5
import bzrlib.errors
105
106
            node_relations.append((nodes[key], nodes[value]))
106
107
    return node_relations
107
108
 
108
 
def write_ancestry_file(branch, filename, collapse=True):
 
109
def write_ancestry_file(branch, filename, collapse=True, antialias=True):
109
110
    b = Branch(branch)
110
111
    relations = graph_ancestry(b, collapse)
111
112
    ext = filename.split('.')[-1]
112
 
    if ext in ('svg', 'svgz', 'gif', 'jpg', 'ps', 'fig', 'mif', 'png'):
 
113
    if antialias and ext in ('png', 'jpg'):
 
114
        try:
 
115
            invoke_dot_aa(dot_output(relations), filename, ext)
 
116
        except NoDot, e:
 
117
            raise BzrCommandError("Can't find 'dot'.  Please ensure Graphviz"\
 
118
                " is installed correctly.")
 
119
        except NoRsvg, e:
 
120
            raise BzrCommandError("Can't find 'rsvg'.  Please ensure "\
 
121
                "librsvg-bin is installed correctly, or use --noantialias.")
 
122
    elif ext in ('svg', 'svgz', 'gif', 'jpg', 'ps', 'fig', 'mif', 'png'):
113
123
        try:
114
124
            invoke_dot(dot_output(relations), filename, ext)
115
125
        except NoDot, e:
116
126
            raise BzrCommandError("Can't find 'dot'.  Please ensure Graphviz"\
117
 
                " is installed correctly.")
 
127
                " is installed correctly, or use --noantialias")
118
128
    elif ext=='dot':
119
129
        file(filename, 'wb').write("".join(list(dot_output(relations))))
120
130
    else: