1
# Copyright (C) 2007 by Jelmer Vernooij <jelmer@samba.org>
3
# This program is free software; you can redistribute it and/or modify
4
# it under the terms of the GNU General Public License as published by
5
# the Free Software Foundation; either version 2 of the License, or
6
# (at your option) any later version.
8
# This program is distributed in the hope that it will be useful,
9
# but WITHOUT ANY WARRANTY; without even the implied warranty of
10
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
# GNU General Public License for more details.
13
# You should have received a copy of the GNU General Public License
14
# along with this program; if not, write to the Free Software
15
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16
"""Simple popup menu for revisions."""
26
from bzrlib import (errors, ui)
28
class RevisionPopupMenu(gtk.Menu):
29
def __init__(self, repository, revids, branch=None, wt=None):
30
super(RevisionPopupMenu, self).__init__()
32
self.repository = repository
37
def create_items(self):
38
if len(self.revids) == 1:
39
item = gtk.MenuItem("View _Diff")
40
item.connect('activate', self.show_diff)
44
item = gtk.MenuItem("_Push")
45
item.connect('activate', self.show_push)
49
item = gtk.MenuItem("_Tag Revision")
50
item.connect('activate', self.show_tag)
54
item = gtk.MenuItem("_Merge Directive")
55
item.connect('activate', self.store_merge_directive)
56
# FIXME: self.append(item)
60
item = gtk.MenuItem("_Revert to this revision")
61
item.connect('activate', self.revert)
65
def store_merge_directive(self, item):
66
from bzrlib.plugins.gtk.mergedirective import CreateMergeDirectiveDialog
67
window = CreateMergeDirectiveDialog(self.branch, self.revids[0])
70
def show_diff(self, item):
71
from bzrlib.plugins.gtk.diff import DiffWindow
72
window = DiffWindow(parent=self.parent)
73
parentid = self.repository.revision_parents(self.revids[0])[0]
74
(parent_tree, rev_tree) = self.repository.revision_trees(
75
[parentid, self.revids[0]])
76
window.set_diff(self.revids[0], rev_tree, parent_tree)
79
def show_push(self, item):
80
from bzrlib.plugins.gtk.push import PushDialog
81
dialog = PushDialog(self.repository, self.revids[0], self.branch)
84
def show_tag(self, item):
85
from bzrlib.plugins.gtk.tags import AddTagDialog
86
dialog = AddTagDialog(self.repository, self.revids[0], self.branch)
87
response = dialog.run()
88
if response != gtk.RESPONSE_NONE:
91
if response == gtk.RESPONSE_OK:
92
self.branch.lock_write()
93
self.branch.tags.set_tag(dialog.tagname, dialog._revid)
98
def revert(self, item):
99
pb = ui.ui_factory.nested_progress_bar()
100
revision_tree = self.branch.repository.revision_tree(self.revids[0])
102
self.wt.revert(old_tree = revision_tree, pb = pb)