~abentley/bzrtools/bzrtools.dev

« back to all changes in this revision

Viewing changes to graph.py

Make work with integration again.

Show diffs side-by-side

added added

removed removed

Lines of Context:
14
14
#    You should have received a copy of the GNU General Public License
15
15
#    along with this program; if not, write to the Free Software
16
16
#    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
17
 
from bzrtools import short_committer
18
17
from dotgraph import Node, dot_output, invoke_dot, invoke_dot_aa, NoDot, NoRsvg
19
18
from dotgraph import RSVG_OUTPUT_TYPES, DOT_OUTPUT_TYPES, Edge, invoke_dot_html
20
19
from bzrlib.branch import Branch
21
20
from bzrlib.errors import BzrCommandError, NoCommonRoot, NoSuchRevision
 
21
from bzrlib.fetch import greedy_fetch
22
22
from bzrlib.graph import node_distances, select_farthest
23
23
from bzrlib.revision import combined_graph, revision_graph
24
24
from bzrlib.revision import MultipleRevisionSources
36
36
            }
37
37
 
38
38
committer_alias = {'abentley': 'Aaron Bentley'}
 
39
def short_committer(committer):
 
40
    new_committer = re.sub('<.*>', '', committer).strip(' ')
 
41
    if len(new_committer) < 2:
 
42
        return committer
 
43
    return new_committer
 
44
 
39
45
def can_skip(rev_id, descendants, ancestors):
40
46
    if rev_id not in descendants:
41
47
        return False
111
117
        self.other_branch = other_branch
112
118
        revision_a = self.branch.last_revision()
113
119
        if other_branch is not None:
114
 
            branch.fetch(other_branch)
 
120
            greedy_fetch(branch, other_branch)
115
121
            revision_b = self.other_branch.last_revision()
116
122
            try:
117
123
                self.root, self.ancestors, self.descendants, self.common = \
118
 
                    combined_graph(revision_a, revision_b,
119
 
                                   self.branch.repository)
 
124
                    combined_graph(revision_a, revision_b, self.branch)
120
125
            except bzrlib.errors.NoCommonRoot:
121
126
                raise bzrlib.errors.NoCommonAncestor(revision_a, revision_b)
122
127
        else:
123
128
            self.root, self.ancestors, self.descendants = \
124
 
                revision_graph(revision_a, branch.repository)
 
129
                revision_graph(revision_a, branch)
125
130
            self.common = []
126
131
 
127
132
        self.n_history = branch.revision_history()
174
179
            color = "#33ff99"
175
180
 
176
181
        label = [name]
177
 
        committer, message, date = get_rev_info(node, self.branch.repository)
 
182
        committer, message, date = get_rev_info(node, self.branch)
178
183
        if committer is not None:
179
184
            label.append(committer)
180
185
 
232
237
        m = Branch.open_containing(merge_branch)[0]
233
238
    else:
234
239
        m = None
235
 
    b.lock_write()
 
240
    b.lock_read()
236
241
    try:
237
242
        if m is not None:
238
243
            m.lock_read()
272
277
    elif ext == 'dot' and not done:
273
278
        my_file = file(filename, 'wb')
274
279
        for fragment in output:
275
 
            my_file.write(fragment.encode('utf-8'))
 
280
            my_file.write(fragment)
276
281
    elif ext == 'html':
277
282
        try:
278
283
            invoke_dot_html(output, filename)