/b-gtk/fix-viz

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/b-gtk/fix-viz

« back to all changes in this revision

Viewing changes to commit.py

  • Committer: Jelmer Vernooij
  • Date: 2012-07-09 15:23:26 UTC
  • mto: This revision was merged to the branch mainline in revision 794.
  • Revision ID: jelmer@samba.org-20120709152326-dzxb8zoz0btull7n
Remove bzr-notify.

Show diffs side-by-side

added added

removed removed

Lines of Context:
25
25
    bencode,
26
26
    errors,
27
27
    osutils,
 
28
    revision as _mod_revision,
28
29
    trace,
 
30
    tsort,
29
31
    )
30
32
from bzrlib.plugins.gtk.dialog import question_dialog
 
33
from bzrlib.plugins.gtk.diff import DiffView
31
34
from bzrlib.plugins.gtk.errors import show_bzr_error
32
35
from bzrlib.plugins.gtk.i18n import _i18n
33
36
from bzrlib.plugins.gtk.commitmsgs import SavedCommitMessagesManager
40
43
    have_dbus = False
41
44
 
42
45
 
 
46
def _get_sorted_revisions(tip_revision, revision_ids, parent_map):
 
47
    """Get an iterator which will return the revisions in merge sorted order.
 
48
 
 
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'
 
51
    order.
 
52
 
 
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()
 
57
    """
 
58
    # MergeSorter requires that all nodes be present in the graph, so get rid
 
59
    # of any references pointing outside of this graph.
 
60
    parent_graph = {}
 
61
    for revision_id in revision_ids:
 
62
        if revision_id not in parent_map: # ghost
 
63
            parent_graph[revision_id] = []
 
64
        else:
 
65
            # Only include parents which are in this sub-graph
 
66
            parent_graph[revision_id] = [p for p in parent_map[revision_id]
 
67
                                            if p in revision_ids]
 
68
    sorter = tsort.MergeSorter(parent_graph, tip_revision)
 
69
    return sorter.iter_topo_order()
 
70
 
 
71
 
43
72
def pending_revisions(wt):
44
73
    """Return a list of pending merges or None if there are none of them.
45
74
 
50
79
    """
51
80
    parents = wt.get_parent_ids()
52
81
    if len(parents) < 2:
53
 
        return None
 
82
        return
54
83
 
55
84
    # The basic pending merge algorithm uses the same algorithm as
56
85
    # bzrlib.status.show_pending_merges
58
87
    branch = wt.branch
59
88
    last_revision = parents[0]
60
89
 
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])])
64
 
    else:
65
 
        ignore = set([])
 
90
    graph = branch.repository.get_graph()
 
91
    other_revisions = [last_revision]
66
92
 
67
93
    pm = []
68
94
    for merge in pending:
69
 
        ignore.add(merge)
70
 
        try:
71
 
            rev = branch.repository.get_revision(merge)
72
 
            children = []
73
 
            pm.append((rev, children))
74
 
 
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
78
 
            inner_merges.pop(0)
79
 
            for mmerge in reversed(inner_merges):
80
 
                if mmerge in ignore:
81
 
                    continue
82
 
                rev = branch.repository.get_revision(mmerge)
83
 
                children.append(rev)
84
 
 
85
 
                ignore.add(mmerge)
86
 
        except errors.NoSuchRevision:
87
 
            print "DEBUG: NoSuchRevision:", merge
88
 
 
89
 
    return pm
 
95
        try:
 
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)
 
101
            continue
 
102
 
 
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)
 
108
 
 
109
        # Get a handle to all of the revisions we will need
 
110
        try:
 
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
 
115
            revisions = {}
 
116
            for revision_id in merge_extra:
 
117
                try:
 
118
                    rev = branch.repository.get_revisions([revision_id])[0]
 
119
                except errors.NoSuchRevision:
 
120
                    revisions[revision_id] = None
 
121
                else:
 
122
                    revisions[revision_id] = rev
 
123
 
 
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()
 
129
        if first != merge:
 
130
            raise AssertionError('Somehow we misunderstood how'
 
131
                ' iter_topo_order works %s != %s' % (first, merge))
 
132
        children = []
 
133
        for num, sub_merge, depth, eom in rev_id_iterator:
 
134
            rev = revisions[sub_merge]
 
135
            if rev is None:
 
136
                trace.warning("ghost: %r", sub_merge)
 
137
                continue
 
138
            children.append(rev)
 
139
        yield (merge_rev, children)
90
140
 
91
141
 
92
142
_newline_variants_re = re.compile(r'\r\n?')
128
178
        self._delta = None
129
179
        self._wt.lock_read()
130
180
        try:
131
 
            self._pending = pending_revisions(self._wt)
 
181
            self._pending = list(pending_revisions(self._wt))
132
182
        finally:
133
183
            self._wt.unlock()
134
184
 
239
289
            self._check_local.hide()
240
290
            return
241
291
        if have_dbus:
242
 
            bus = dbus.SystemBus()
 
292
            try:
 
293
                bus = dbus.SystemBus()
 
294
            except dbus.DBusException:
 
295
                trace.mutter("DBus system bus not available")
 
296
                self._check_local.show()
 
297
                return
243
298
            try:
244
299
                proxy_obj = bus.get_object('org.freedesktop.NetworkManager',
245
300
                                           '/org/freedesktop/NetworkManager')
247
302
                trace.mutter("networkmanager not available.")
248
303
                self._check_local.show()
249
304
                return
250
 
            
 
305
 
251
306
            dbus_iface = dbus.Interface(proxy_obj,
252
307
                                        'org.freedesktop.NetworkManager')
253
308
            try:
279
334
        """Build up the dialog widgets."""
280
335
        # The primary pane which splits it into left and right (adjustable)
281
336
        # sections.
282
 
        self._hpane = Gtk.HPaned()
 
337
        self._hpane = Gtk.Paned.new(Gtk.Orientation.HORIZONTAL)
283
338
 
284
339
        self._construct_left_pane()
285
340
        self._construct_right_pane()
505
560
                                             Gtk.CellRendererText(), text=3))
506
561
 
507
562
    def _construct_diff_view(self):
508
 
        from bzrlib.plugins.gtk.diff import DiffView
509
 
 
510
563
        # TODO: jam 2007-10-30 The diff label is currently disabled. If we
511
564
        #       decide that we really don't ever want to display it, we should
512
565
        #       actually remove it, and other references to it, along with the
521
574
        self._add_to_right_table(self._diff_view, 4, True)
522
575
        self._diff_view.show()
523
576
 
 
577
    @staticmethod
 
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
 
582
 
524
583
    def _construct_file_message(self):
525
584
        scroller = Gtk.ScrolledWindow()
526
585
        scroller.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
533
592
        self._file_message_text_view.modify_font(Pango.FontDescription("Monospace"))
534
593
        self._file_message_text_view.set_wrap_mode(Gtk.WrapMode.WORD)
535
594
        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)
536
597
        self._file_message_text_view.show()
537
598
 
538
599
        self._file_message_expander = Gtk.Expander(