/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 viz/branchwin.py

  • Committer: Javier Derderian
  • Date: 2008-04-11 20:28:08 UTC
  • mfrom: (461.1.3 trunk)
  • mto: (465.1.1 gtk.patch)
  • mto: This revision was merged to the branch mainline in revision 466.
  • Revision ID: javierder@gmail.com-20080411202808-1b11f86go14pik5o
Merged from patch

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
from bzrlib.plugins.gtk.tags import AddTagDialog
19
19
from bzrlib.plugins.gtk.preferences import PreferencesWindow
20
20
from bzrlib.plugins.gtk.branchview import TreeView, treemodel
 
21
from bzrlib.plugins.gtk.dialog import _chooserevison_dialog
21
22
from bzrlib.revision import Revision, NULL_REVISION
22
23
from bzrlib.config import BranchConfig
23
24
from bzrlib.config import GlobalConfig
 
25
from bzrlib.tsort import merge_sort
24
26
 
25
27
class BranchWindow(Window):
26
28
    """Branch window.
196
198
        revision_menu_diff = gtk.MenuItem("View Changes")
197
199
        revision_menu_diff.connect('activate', 
198
200
                lambda w: self.treeview.show_diff())
199
 
 
 
201
        
 
202
        revision_menu_compare = gtk.MenuItem("Compare with...")
 
203
        revision_menu_compare.connect('activate',
 
204
                self._compare_with_cb)
 
205
        
200
206
        revision_menu_tag = gtk.MenuItem("Tag Revision")
201
207
        revision_menu_tag.connect('activate', self._tag_revision_cb)
202
208
 
203
209
        revision_menu.add(revision_menu_tag)
204
210
        revision_menu.add(revision_menu_diff)
 
211
        revision_menu.add(revision_menu_compare)
205
212
 
206
213
        branch_menu = gtk.Menu()
207
214
        branch_menuitem = gtk.MenuItem("_Branch")
377
384
        self.show_diff(revid, parentid)
378
385
        self.treeview.grab_focus()
379
386
 
 
387
    def _compare_with_cb(self,w):
 
388
        """Callback for revision 'compare with' menu. Will show a small
 
389
            dialog with branch revisions to compare with selected revision in TreeView"""
 
390
        
 
391
        start_revs = (self.branch.last_revision(),) #create touple with only last revision
 
392
        graph = self.branch.repository.get_graph()
 
393
 
 
394
        graph_parents = {} # this code is copied from "branchview/linegraph.linegraph()" and is the
 
395
                           # only way I found to generate a list of revision numbers...
 
396
                           
 
397
        for (revid, parent_revids) in graph.iter_ancestry(start_revs):
 
398
            graph_parents[revid] = parent_revids
 
399
 
 
400
        graph_parents["top:"] = start_revs
 
401
 
 
402
        if len(graph_parents)>0:
 
403
            merge_sorted_revisions = merge_sort(
 
404
                graph_parents,
 
405
                "top:",
 
406
                generate_revno=True)
 
407
        else:
 
408
            merge_sorted_revisions = ()
 
409
 
 
410
        response, revid2 = _chooserevison_dialog(merge_sorted_revisions) # show dialog passing revisions
 
411
 
 
412
        if response == gtk.RESPONSE_OK and revid2 != '':
 
413
            (path, focus) = self.treeview.treeview.get_cursor()
 
414
            revid = self.treeview.model[path][treemodel.REVID]
 
415
 
 
416
            from bzrlib.plugins.gtk.diff import DiffWindow
 
417
            window = DiffWindow(parent=self)
 
418
            rev_tree = self.branch.repository.revision_tree(revid)
 
419
            parent_tree = self.branch.repository.revision_tree(revid2)
 
420
            window.set_diff(revid, rev_tree, parent_tree)
 
421
            window.show()
 
422
 
 
423
        elif response == gtk.RESPONSE_OK and revid2 == '':
 
424
            error_dialog("Bad revision","You must select a revision")
 
425
            
380
426
    def _set_revision_cb(self, w, revision_id):
381
427
        self.treeview.set_revision_id(revision_id)
382
428