1
# Copyright (C) 2005 Aaron Bentley
2
# <aaron.bentley@utoronto.ca>
4
# This program is free software; you can redistribute it and/or modify
5
# it under the terms of the GNU General Public License as published by
6
# the Free Software Foundation; either version 2 of the License, or
7
# (at your option) any later version.
9
# This program is distributed in the hope that it will be useful,
10
# but WITHOUT ANY WARRANTY; without even the implied warranty of
11
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
# GNU General Public License for more details.
14
# You should have received a copy of the GNU General Public License
15
# along with this program; if not, write to the Free Software
16
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17
from bzrtools import short_committer
18
1
from dotgraph import Node, dot_output, invoke_dot, invoke_dot_aa, NoDot, NoRsvg
19
2
from dotgraph import RSVG_OUTPUT_TYPES, DOT_OUTPUT_TYPES, Edge, invoke_dot_html
20
3
from bzrlib.branch import Branch
21
4
from bzrlib.errors import BzrCommandError, NoCommonRoot, NoSuchRevision
5
from bzrlib.fetch import greedy_fetch
22
6
from bzrlib.graph import node_distances, select_farthest
23
7
from bzrlib.revision import combined_graph, revision_graph
24
8
from bzrlib.revision import MultipleRevisionSources
9
from datetime import datetime
25
10
import bzrlib.errors
38
23
committer_alias = {'abentley': 'Aaron Bentley'}
24
def short_committer(committer):
25
new_committer = re.sub('<.*>', '', committer).strip(' ')
26
if len(new_committer) < 2:
39
30
def can_skip(rev_id, descendants, ancestors):
40
31
if rev_id not in descendants:
92
83
if rev.message is not None:
93
84
message = rev.message.split('\n')[0]
94
85
gmtime = time.gmtime(rev.timestamp + (rev.timezone or 0))
95
date = time.strftime('%Y/%m/%d', gmtime)
86
date = time.strftime('%Y-%m-%d', gmtime)
96
87
if '@' in committer:
98
89
committer = mail_map[committer]
109
100
object.__init__(self)
110
101
self.branch = branch
111
102
self.other_branch = other_branch
112
revision_a = self.branch.last_revision()
103
revision_a = self.branch.last_patch()
113
104
if other_branch is not None:
114
branch.fetch(other_branch)
115
revision_b = self.other_branch.last_revision()
105
greedy_fetch(branch, other_branch)
106
revision_b = self.other_branch.last_patch()
117
108
self.root, self.ancestors, self.descendants, self.common = \
118
combined_graph(revision_a, revision_b,
119
self.branch.repository)
109
combined_graph(revision_a, revision_b, self.branch)
120
110
except bzrlib.errors.NoCommonRoot:
121
111
raise bzrlib.errors.NoCommonAncestor(revision_a, revision_b)
123
113
self.root, self.ancestors, self.descendants = \
124
revision_graph(revision_a, branch.repository)
114
revision_graph(revision_a, branch)
127
117
self.n_history = branch.revision_history()
174
164
color = "#33ff99"
177
committer, message, date = get_rev_info(node, self.branch.repository)
167
committer, message, date = get_rev_info(node, self.branch)
178
168
if committer is not None:
179
169
label.append(committer)
228
218
def write_ancestry_file(branch, filename, collapse=True, antialias=True,
229
219
merge_branch=None, ranking="forced"):
230
b = Branch.open_containing(branch)[0]
220
b = Branch.open_containing(branch)
231
221
if merge_branch is not None:
232
m = Branch.open_containing(merge_branch)[0]
222
m = Branch.open_containing(merge_branch)
240
grapher = Grapher(b, m)
241
relations = grapher.get_relations(collapse)
225
grapher = Grapher(b, m)
226
relations = grapher.get_relations(collapse)
248
228
ext = filename.split('.')[-1]
249
229
output = dot_output(relations, ranking)
272
252
elif ext == 'dot' and not done:
273
253
my_file = file(filename, 'wb')
274
254
for fragment in output:
275
my_file.write(fragment.encode('utf-8'))
255
my_file.write(fragment)
276
256
elif ext == 'html':
278
258
invoke_dot_html(output, filename)