46
def _get_sorted_revisions(tip_revision, revision_ids, parent_map):
47
"""Get an iterator which will return the revisions in merge sorted order.
49
This will build up a list of all nodes, such that only nodes in the list
50
are referenced. It then uses MergeSorter to return them in 'merge-sorted'
53
:param revision_ids: A set of revision_ids
54
:param parent_map: The parent information for each node. Revisions which
55
are considered ghosts should not be present in the map.
56
:return: iterator from MergeSorter.iter_topo_order()
58
# MergeSorter requires that all nodes be present in the graph, so get rid
59
# of any references pointing outside of this graph.
61
for revision_id in revision_ids:
62
if revision_id not in parent_map: # ghost
63
parent_graph[revision_id] = []
65
# Only include parents which are in this sub-graph
66
parent_graph[revision_id] = [p for p in parent_map[revision_id]
68
sorter = tsort.MergeSorter(parent_graph, tip_revision)
69
return sorter.iter_topo_order()
72
43
def pending_revisions(wt):
73
44
"""Return a list of pending merges or None if there are none of them.
88
59
last_revision = parents[0]
90
graph = branch.repository.get_graph()
91
other_revisions = [last_revision]
61
if last_revision is not None:
62
graph = branch.repository.get_graph()
63
ignore = set([r for r,ps in graph.iter_ancestry([last_revision])])
94
68
for merge in pending:
96
merge_rev = branch.repository.get_revision(merge)
97
except errors.NoSuchRevision:
98
# If we are missing a revision, just print out the revision id
99
trace.mutter("ghost: %r", merge)
100
other_revisions.append(merge)
103
# Find all of the revisions in the merge source, which are not in the
104
# last committed revision.
105
merge_extra = graph.find_unique_ancestors(merge, other_revisions)
106
other_revisions.append(merge)
107
merge_extra.discard(_mod_revision.NULL_REVISION)
109
# Get a handle to all of the revisions we will need
111
revisions = dict((rev.revision_id, rev) for rev in
112
branch.repository.get_revisions(merge_extra))
113
except errors.NoSuchRevision:
114
# One of the sub nodes is a ghost, check each one
116
for revision_id in merge_extra:
118
rev = branch.repository.get_revisions([revision_id])[0]
119
except errors.NoSuchRevision:
120
revisions[revision_id] = None
122
revisions[revision_id] = rev
124
# Display the revisions brought in by this merge.
125
rev_id_iterator = _get_sorted_revisions(merge, merge_extra,
126
branch.repository.get_parent_map(merge_extra))
127
# Skip the first node
128
num, first, depth, eom = rev_id_iterator.next()
130
raise AssertionError('Somehow we misunderstood how'
131
' iter_topo_order works %s != %s' % (first, merge))
133
for num, sub_merge, depth, eom in rev_id_iterator:
134
rev = revisions[sub_merge]
136
trace.warning("ghost: %r", sub_merge)
139
yield (merge_rev, children)
71
rev = branch.repository.get_revision(merge)
73
pm.append((rev, children))
75
# This does need to be topo sorted, so we search backwards
76
inner_merges = branch.repository.get_ancestry(merge)
77
assert inner_merges[0] is None
79
for mmerge in reversed(inner_merges):
82
rev = branch.repository.get_revision(mmerge)
86
except errors.NoSuchRevision:
87
print "DEBUG: NoSuchRevision:", merge
142
92
_newline_variants_re = re.compile(r'\r\n?')
560
505
Gtk.CellRendererText(), text=3))
562
507
def _construct_diff_view(self):
508
from bzrlib.plugins.gtk.diff import DiffView
563
510
# TODO: jam 2007-10-30 The diff label is currently disabled. If we
564
511
# decide that we really don't ever want to display it, we should
565
512
# actually remove it, and other references to it, along with the
574
521
self._add_to_right_table(self._diff_view, 4, True)
575
522
self._diff_view.show()
578
def get_line_height(widget):
579
pango_layout = widget.create_pango_layout("X");
580
ink_rectangle, logical_rectangle = pango_layout.get_pixel_extents()
581
return logical_rectangle.height
583
524
def _construct_file_message(self):
584
525
scroller = Gtk.ScrolledWindow()
585
526
scroller.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
592
533
self._file_message_text_view.modify_font(Pango.FontDescription("Monospace"))
593
534
self._file_message_text_view.set_wrap_mode(Gtk.WrapMode.WORD)
594
535
self._file_message_text_view.set_accepts_tab(False)
595
line_height = self.get_line_height(self._file_message_text_view)
596
self._file_message_text_view.set_size_request(-1, line_height * 2)
597
536
self._file_message_text_view.show()
599
538
self._file_message_expander = Gtk.Expander(