bzr branch
http://gegoxaren.bato24.eu/bzr/b-gtk/fix-viz
226
by Jelmer Vernooij
Add context menu in bzrk. |
1 |
# Copyright (C) 2007 by Jelmer Vernooij <jelmer@samba.org>
|
2 |
#
|
|
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.
|
|
7 |
#
|
|
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.
|
|
12 |
#
|
|
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."""
|
|
17 |
||
18 |
try: |
|
19 |
import pygtk |
|
20 |
pygtk.require("2.0") |
|
21 |
except: |
|
22 |
pass
|
|
23 |
||
24 |
import bzrlib |
|
25 |
import gtk |
|
26 |
||
27 |
class RevisionPopupMenu(gtk.Menu): |
|
230
by Jelmer Vernooij
Initial work towards supporting multiple revisions. |
28 |
def __init__(self, repository, revids, branch=None): |
226
by Jelmer Vernooij
Add context menu in bzrk. |
29 |
super(RevisionPopupMenu, self).__init__() |
227
by Jelmer Vernooij
Add push item in revision menu, clean up push code. |
30 |
self.branch = branch |
226
by Jelmer Vernooij
Add context menu in bzrk. |
31 |
self.repository = repository |
230
by Jelmer Vernooij
Initial work towards supporting multiple revisions. |
32 |
self.revids = revids |
227
by Jelmer Vernooij
Add push item in revision menu, clean up push code. |
33 |
self.create_items() |
226
by Jelmer Vernooij
Add context menu in bzrk. |
34 |
|
35 |
def create_items(self): |
|
230
by Jelmer Vernooij
Initial work towards supporting multiple revisions. |
36 |
if len(self.revids) == 1: |
37 |
item = gtk.MenuItem("View _Diff") |
|
38 |
item.connect('activate', self.show_diff) |
|
39 |
self.append(item) |
|
40 |
self.show_all() |
|
41 |
||
42 |
item = gtk.MenuItem("_Push") |
|
43 |
item.connect('activate', self.show_push) |
|
44 |
self.append(item) |
|
45 |
self.show_all() |
|
226
by Jelmer Vernooij
Add context menu in bzrk. |
46 |
|
232
by Jelmer Vernooij
Make 'Add tag' dialog accessible from bzrk. |
47 |
item = gtk.MenuItem("_Tag Revision") |
48 |
item.connect('activate', self.show_tag) |
|
49 |
self.append(item) |
|
50 |
self.show_all() |
|
51 |
||
254.1.1
by Jelmer Vernooij
Add Merge Directive option to revision menu. |
52 |
item = gtk.MenuItem("_Merge Directive") |
53 |
item.connect('activate', self.store_merge_directive) |
|
54 |
self.append(item) |
|
55 |
self.show_all() |
|
56 |
||
57 |
def store_merge_directive(self, item): |
|
58 |
from bzrlib.plugins.gtk.mergedirective import CreateMergeDirectiveDialog |
|
59 |
window = CreateMergeDirectiveDialog(self.branch, self.revids[0]) |
|
60 |
window.show() |
|
61 |
||
226
by Jelmer Vernooij
Add context menu in bzrk. |
62 |
def show_diff(self, item): |
63 |
from bzrlib.plugins.gtk.diff import DiffWindow |
|
64 |
window = DiffWindow() |
|
230
by Jelmer Vernooij
Initial work towards supporting multiple revisions. |
65 |
parentid = self.repository.revision_parents(self.revids[0])[0] |
66 |
(parent_tree, rev_tree) = self.repository.revision_trees( |
|
67 |
[parentid, self.revids[0]]) |
|
68 |
window.set_diff(self.revids[0], rev_tree, parent_tree) |
|
226
by Jelmer Vernooij
Add context menu in bzrk. |
69 |
window.show() |
227
by Jelmer Vernooij
Add push item in revision menu, clean up push code. |
70 |
|
71 |
def show_push(self, item): |
|
72 |
from bzrlib.plugins.gtk.push import PushDialog |
|
230
by Jelmer Vernooij
Initial work towards supporting multiple revisions. |
73 |
dialog = PushDialog(self.repository, self.revids[0], self.branch) |
227
by Jelmer Vernooij
Add push item in revision menu, clean up push code. |
74 |
dialog.run() |
232
by Jelmer Vernooij
Make 'Add tag' dialog accessible from bzrk. |
75 |
|
76 |
def show_tag(self, item): |
|
77 |
from bzrlib.plugins.gtk.tags import AddTagDialog |
|
78 |
dialog = AddTagDialog(self.repository, self.revids[0], self.branch) |
|
79 |
response = dialog.run() |
|
80 |
if response != gtk.RESPONSE_NONE: |
|
81 |
dialog.hide() |
|
82 |
||
83 |
if response == gtk.RESPONSE_OK: |
|
84 |
self.branch.lock_write() |
|
85 |
self.branch.tags.set_tag(dialog.tagname, dialog._revid) |
|
86 |
self.branch.unlock() |
|
87 |
||
88 |
dialog.destroy() |