/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: Curtis Hovey
  • Date: 2012-02-09 02:55:06 UTC
  • mto: This revision was merged to the branch mainline in revision 776.
  • Revision ID: sinzui.is@verizon.net-20120209025506-qa8yd8livobyv5yy
Replace unsupports notify event with an new strategy to set and pane size
when the config is saved.
Hush lint.

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,
29
28
    trace,
30
 
    tsort,
31
29
    )
32
30
from bzrlib.plugins.gtk.dialog import question_dialog
33
 
from bzrlib.plugins.gtk.diff import DiffView
34
31
from bzrlib.plugins.gtk.errors import show_bzr_error
35
32
from bzrlib.plugins.gtk.i18n import _i18n
36
33
from bzrlib.plugins.gtk.commitmsgs import SavedCommitMessagesManager
43
40
    have_dbus = False
44
41
 
45
42
 
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
 
 
72
43
def pending_revisions(wt):
73
44
    """Return a list of pending merges or None if there are none of them.
74
45
 
79
50
    """
80
51
    parents = wt.get_parent_ids()
81
52
    if len(parents) < 2:
82
 
        return
 
53
        return None
83
54
 
84
55
    # The basic pending merge algorithm uses the same algorithm as
85
56
    # bzrlib.status.show_pending_merges
87
58
    branch = wt.branch
88
59
    last_revision = parents[0]
89
60
 
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])])
 
64
    else:
 
65
        ignore = set([])
92
66
 
93
67
    pm = []
94
68
    for merge in pending:
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)
 
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
140
90
 
141
91
 
142
92
_newline_variants_re = re.compile(r'\r\n?')
178
128
        self._delta = None
179
129
        self._wt.lock_read()
180
130
        try:
181
 
            self._pending = list(pending_revisions(self._wt))
 
131
            self._pending = pending_revisions(self._wt)
182
132
        finally:
183
133
            self._wt.unlock()
184
134
 
289
239
            self._check_local.hide()
290
240
            return
291
241
        if have_dbus:
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
 
242
            bus = dbus.SystemBus()
298
243
            try:
299
244
                proxy_obj = bus.get_object('org.freedesktop.NetworkManager',
300
245
                                           '/org/freedesktop/NetworkManager')
302
247
                trace.mutter("networkmanager not available.")
303
248
                self._check_local.show()
304
249
                return
305
 
 
 
250
            
306
251
            dbus_iface = dbus.Interface(proxy_obj,
307
252
                                        'org.freedesktop.NetworkManager')
308
253
            try:
334
279
        """Build up the dialog widgets."""
335
280
        # The primary pane which splits it into left and right (adjustable)
336
281
        # sections.
337
 
        self._hpane = Gtk.Paned.new(Gtk.Orientation.HORIZONTAL)
 
282
        self._hpane = Gtk.HPaned()
338
283
 
339
284
        self._construct_left_pane()
340
285
        self._construct_right_pane()
560
505
                                             Gtk.CellRendererText(), text=3))
561
506
 
562
507
    def _construct_diff_view(self):
 
508
        from bzrlib.plugins.gtk.diff import DiffView
 
509
 
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()
576
523
 
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
 
 
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()
598
537
 
599
538
        self._file_message_expander = Gtk.Expander(