/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-03 18:59:38 UTC
  • mto: This revision was merged to the branch mainline in revision 773.
  • Revision ID: sinzui.is@verizon.net-20120203185938-ra0jl3b1rn69gmmz
Verify the menu and its items are created.

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
31
from bzrlib.plugins.gtk.errors import show_bzr_error
42
40
    have_dbus = False
43
41
 
44
42
 
45
 
def _get_sorted_revisions(tip_revision, revision_ids, parent_map):
46
 
    """Get an iterator which will return the revisions in merge sorted order.
47
 
 
48
 
    This will build up a list of all nodes, such that only nodes in the list
49
 
    are referenced. It then uses MergeSorter to return them in 'merge-sorted'
50
 
    order.
51
 
 
52
 
    :param revision_ids: A set of revision_ids
53
 
    :param parent_map: The parent information for each node. Revisions which
54
 
        are considered ghosts should not be present in the map.
55
 
    :return: iterator from MergeSorter.iter_topo_order()
56
 
    """
57
 
    # MergeSorter requires that all nodes be present in the graph, so get rid
58
 
    # of any references pointing outside of this graph.
59
 
    parent_graph = {}
60
 
    for revision_id in revision_ids:
61
 
        if revision_id not in parent_map: # ghost
62
 
            parent_graph[revision_id] = []
63
 
        else:
64
 
            # Only include parents which are in this sub-graph
65
 
            parent_graph[revision_id] = [p for p in parent_map[revision_id]
66
 
                                            if p in revision_ids]
67
 
    sorter = tsort.MergeSorter(parent_graph, tip_revision)
68
 
    return sorter.iter_topo_order()
69
 
 
70
 
 
71
43
def pending_revisions(wt):
72
44
    """Return a list of pending merges or None if there are none of them.
73
45
 
78
50
    """
79
51
    parents = wt.get_parent_ids()
80
52
    if len(parents) < 2:
81
 
        return
 
53
        return None
82
54
 
83
55
    # The basic pending merge algorithm uses the same algorithm as
84
56
    # bzrlib.status.show_pending_merges
86
58
    branch = wt.branch
87
59
    last_revision = parents[0]
88
60
 
89
 
    graph = branch.repository.get_graph()
90
 
    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([])
91
66
 
92
67
    pm = []
93
68
    for merge in pending:
94
 
        try:
95
 
            merge_rev = branch.repository.get_revision(merge)
96
 
        except errors.NoSuchRevision:
97
 
            # If we are missing a revision, just print out the revision id
98
 
            trace.mutter("ghost: %r", merge)
99
 
            other_revisions.append(merge)
100
 
            continue
101
 
 
102
 
        # Find all of the revisions in the merge source, which are not in the
103
 
        # last committed revision.
104
 
        merge_extra = graph.find_unique_ancestors(merge, other_revisions)
105
 
        other_revisions.append(merge)
106
 
        merge_extra.discard(_mod_revision.NULL_REVISION)
107
 
 
108
 
        # Get a handle to all of the revisions we will need
109
 
        try:
110
 
            revisions = dict((rev.revision_id, rev) for rev in
111
 
                             branch.repository.get_revisions(merge_extra))
112
 
        except errors.NoSuchRevision:
113
 
            # One of the sub nodes is a ghost, check each one
114
 
            revisions = {}
115
 
            for revision_id in merge_extra:
116
 
                try:
117
 
                    rev = branch.repository.get_revisions([revision_id])[0]
118
 
                except errors.NoSuchRevision:
119
 
                    revisions[revision_id] = None
120
 
                else:
121
 
                    revisions[revision_id] = rev
122
 
 
123
 
         # Display the revisions brought in by this merge.
124
 
        rev_id_iterator = _get_sorted_revisions(merge, merge_extra,
125
 
                            branch.repository.get_parent_map(merge_extra))
126
 
        # Skip the first node
127
 
        num, first, depth, eom = rev_id_iterator.next()
128
 
        if first != merge:
129
 
            raise AssertionError('Somehow we misunderstood how'
130
 
                ' iter_topo_order works %s != %s' % (first, merge))
131
 
        children = []
132
 
        for num, sub_merge, depth, eom in rev_id_iterator:
133
 
            rev = revisions[sub_merge]
134
 
            if rev is None:
135
 
                trace.warning("ghost: %r", sub_merge)
136
 
                continue
137
 
            children.append(rev)
138
 
        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
139
90
 
140
91
 
141
92
_newline_variants_re = re.compile(r'\r\n?')
177
128
        self._delta = None
178
129
        self._wt.lock_read()
179
130
        try:
180
 
            self._pending = list(pending_revisions(self._wt))
 
131
            self._pending = pending_revisions(self._wt)
181
132
        finally:
182
133
            self._wt.unlock()
183
134
 
288
239
            self._check_local.hide()
289
240
            return
290
241
        if have_dbus:
291
 
            try:
292
 
                bus = dbus.SystemBus()
293
 
            except dbus.DBusException:
294
 
                trace.mutter("DBus system bus not available")
295
 
                self._check_local.show()
296
 
                return
 
242
            bus = dbus.SystemBus()
297
243
            try:
298
244
                proxy_obj = bus.get_object('org.freedesktop.NetworkManager',
299
245
                                           '/org/freedesktop/NetworkManager')
301
247
                trace.mutter("networkmanager not available.")
302
248
                self._check_local.show()
303
249
                return
304
 
 
 
250
            
305
251
            dbus_iface = dbus.Interface(proxy_obj,
306
252
                                        'org.freedesktop.NetworkManager')
307
253
            try:
333
279
        """Build up the dialog widgets."""
334
280
        # The primary pane which splits it into left and right (adjustable)
335
281
        # sections.
336
 
        self._hpane = Gtk.Paned.new(Gtk.Orientation.HORIZONTAL)
 
282
        self._hpane = Gtk.HPaned()
337
283
 
338
284
        self._construct_left_pane()
339
285
        self._construct_right_pane()