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 |
||
734.1.1
by Curtis Hovey
Mechanical changes made by pygi.convert.sh. |
18 |
from gi.repository import Gtk |
19 |
from gi.repository import GObject |
|
724
by Jelmer Vernooij
Fix formatting, imports. |
20 |
from bzrlib import ui |
330.4.3
by Daniel Schierbeck
Switched to using NULL_REVISION instead of None. |
21 |
from bzrlib.revision import NULL_REVISION |
226
by Jelmer Vernooij
Add context menu in bzrk. |
22 |
|
734.1.1
by Curtis Hovey
Mechanical changes made by pygi.convert.sh. |
23 |
class RevisionMenu(Gtk.Menu): |
423.7.8
by Daniel Schierbeck
Made the revision popup menu correctly add tags. |
24 |
|
25 |
__gsignals__ = { |
|
26 |
'tag-added': ( |
|
734.1.1
by Curtis Hovey
Mechanical changes made by pygi.convert.sh. |
27 |
GObject.SignalFlags.RUN_FIRST, |
28 |
None, |
|
29 |
(GObject.TYPE_STRING, GObject.TYPE_STRING) |
|
423.7.8
by Daniel Schierbeck
Made the revision popup menu correctly add tags. |
30 |
)
|
31 |
}
|
|
32 |
||
523.3.2
by Jelmer Vernooij
Share same menu for context menu and main menu. |
33 |
def __init__(self, repository, revids, branch=None, wt=None, parent=None): |
523.3.1
by Jelmer Vernooij
Rename RevisionPopupMenu -> RevisionMenu. |
34 |
super(RevisionMenu, self).__init__() |
523.3.2
by Jelmer Vernooij
Share same menu for context menu and main menu. |
35 |
self._parent = parent |
227
by Jelmer Vernooij
Add push item in revision menu, clean up push code. |
36 |
self.branch = branch |
226
by Jelmer Vernooij
Add context menu in bzrk. |
37 |
self.repository = repository |
328
by Jelmer Vernooij
Use repository instead of branch in more places, to make it easier to support multiple branches in viz. |
38 |
self.wt = wt |
523.3.1
by Jelmer Vernooij
Rename RevisionPopupMenu -> RevisionMenu. |
39 |
self.set_revision_ids(revids) |
40 |
||
41 |
def set_revision_ids(self, revids): |
|
523.3.2
by Jelmer Vernooij
Share same menu for context menu and main menu. |
42 |
assert isinstance(revids, list) |
523.3.1
by Jelmer Vernooij
Rename RevisionPopupMenu -> RevisionMenu. |
43 |
for c in self.get_children(): |
44 |
self.remove(c) |
|
230
by Jelmer Vernooij
Initial work towards supporting multiple revisions. |
45 |
self.revids = revids |
227
by Jelmer Vernooij
Add push item in revision menu, clean up push code. |
46 |
self.create_items() |
226
by Jelmer Vernooij
Add context menu in bzrk. |
47 |
|
48 |
def create_items(self): |
|
230
by Jelmer Vernooij
Initial work towards supporting multiple revisions. |
49 |
if len(self.revids) == 1: |
734.1.38
by Curtis Hovey
Menu fixes. |
50 |
item = Gtk.MenuItem.new_with_mnemonic("View _Changes") |
230
by Jelmer Vernooij
Initial work towards supporting multiple revisions. |
51 |
item.connect('activate', self.show_diff) |
52 |
self.append(item) |
|
53 |
||
734.1.38
by Curtis Hovey
Menu fixes. |
54 |
item = Gtk.MenuItem.new_with_mnemonic("_Push") |
230
by Jelmer Vernooij
Initial work towards supporting multiple revisions. |
55 |
item.connect('activate', self.show_push) |
56 |
self.append(item) |
|
226
by Jelmer Vernooij
Add context menu in bzrk. |
57 |
|
734.1.38
by Curtis Hovey
Menu fixes. |
58 |
item = Gtk.MenuItem.new_with_mnemonic("_Tag Revision") |
232
by Jelmer Vernooij
Make 'Add tag' dialog accessible from bzrk. |
59 |
item.connect('activate', self.show_tag) |
60 |
self.append(item) |
|
61 |
||
734.1.38
by Curtis Hovey
Menu fixes. |
62 |
item = Gtk.MenuItem.new_with_mnemonic("_Merge Directive") |
254.1.1
by Jelmer Vernooij
Add Merge Directive option to revision menu. |
63 |
item.connect('activate', self.store_merge_directive) |
270
by Jelmer Vernooij
Hie merge directive menu for now. |
64 |
# FIXME: self.append(item)
|
523.1.2
by Jelmer Vernooij
Add 'Send Merge Directive' option in viz popup menu. |
65 |
|
734.1.38
by Curtis Hovey
Menu fixes. |
66 |
item = Gtk.MenuItem.new_with_mnemonic("_Send Merge Directive") |
523.1.2
by Jelmer Vernooij
Add 'Send Merge Directive' option in viz popup menu. |
67 |
item.connect('activate', self.send_merge_directive) |
68 |
self.append(item) |
|
724
by Jelmer Vernooij
Fix formatting, imports. |
69 |
|
328
by Jelmer Vernooij
Use repository instead of branch in more places, to make it easier to support multiple branches in viz. |
70 |
if self.wt: |
734.1.38
by Curtis Hovey
Menu fixes. |
71 |
item = Gtk.MenuItem.new_with_mnemonic( |
72 |
"_Revert to this revision") |
|
313.2.1
by Gary van der Merwe
Add a revert option to the revision menu. |
73 |
item.connect('activate', self.revert) |
74 |
self.append(item) |
|
523.1.2
by Jelmer Vernooij
Add 'Send Merge Directive' option in viz popup menu. |
75 |
|
76 |
self.show_all() |
|
254.1.1
by Jelmer Vernooij
Add Merge Directive option to revision menu. |
77 |
|
78 |
def store_merge_directive(self, item): |
|
79 |
from bzrlib.plugins.gtk.mergedirective import CreateMergeDirectiveDialog |
|
80 |
window = CreateMergeDirectiveDialog(self.branch, self.revids[0]) |
|
81 |
window.show() |
|
82 |
||
523.1.2
by Jelmer Vernooij
Add 'Send Merge Directive' option in viz popup menu. |
83 |
def send_merge_directive(self, item): |
84 |
from bzrlib.plugins.gtk.mergedirective import SendMergeDirectiveDialog |
|
85 |
from cStringIO import StringIO |
|
86 |
window = SendMergeDirectiveDialog(self.branch, self.revids[0]) |
|
734.1.1
by Curtis Hovey
Mechanical changes made by pygi.convert.sh. |
87 |
if window.run() == Gtk.ResponseType.OK: |
523.1.2
by Jelmer Vernooij
Add 'Send Merge Directive' option in viz popup menu. |
88 |
outf = StringIO() |
523.1.3
by Jelmer Vernooij
Fix syntax. |
89 |
outf.writelines(window.get_merge_directive().to_lines()) |
523.1.2
by Jelmer Vernooij
Add 'Send Merge Directive' option in viz popup menu. |
90 |
mail_client = self.branch.get_config().get_mail_client() |
91 |
mail_client.compose_merge_request(window.get_mail_to(), "[MERGE]", |
|
92 |
outf.getvalue()) |
|
93 |
window.destroy() |
|
94 |
||
226
by Jelmer Vernooij
Add context menu in bzrk. |
95 |
def show_diff(self, item): |
96 |
from bzrlib.plugins.gtk.diff import DiffWindow |
|
523.3.2
by Jelmer Vernooij
Share same menu for context menu and main menu. |
97 |
window = DiffWindow(parent=self._parent) |
522
by Jelmer Vernooij
Remove use of upstream removed Repository.revision_parents() |
98 |
parentids = self.repository.get_revision(self.revids[0]).parent_ids |
330.4.2
by Daniel Schierbeck
Made it work when right-clicking, too. |
99 |
if len(parentids) == 0: |
330.4.3
by Daniel Schierbeck
Switched to using NULL_REVISION instead of None. |
100 |
parentid = NULL_REVISION |
330.4.2
by Daniel Schierbeck
Made it work when right-clicking, too. |
101 |
else: |
102 |
parentid = parentids[0] |
|
103 |
rev_tree = self.repository.revision_tree(self.revids[0]) |
|
104 |
parent_tree = self.repository.revision_tree(parentid) |
|
230
by Jelmer Vernooij
Initial work towards supporting multiple revisions. |
105 |
window.set_diff(self.revids[0], rev_tree, parent_tree) |
226
by Jelmer Vernooij
Add context menu in bzrk. |
106 |
window.show() |
227
by Jelmer Vernooij
Add push item in revision menu, clean up push code. |
107 |
|
108 |
def show_push(self, item): |
|
109 |
from bzrlib.plugins.gtk.push import PushDialog |
|
230
by Jelmer Vernooij
Initial work towards supporting multiple revisions. |
110 |
dialog = PushDialog(self.repository, self.revids[0], self.branch) |
401
by Daniel Schierbeck
Made the push dialog close when the cancel button is clicked. |
111 |
response = dialog.run() |
112 |
||
734.1.1
by Curtis Hovey
Mechanical changes made by pygi.convert.sh. |
113 |
if response != Gtk.ResponseType.NONE: |
401
by Daniel Schierbeck
Made the push dialog close when the cancel button is clicked. |
114 |
dialog.destroy() |
232
by Jelmer Vernooij
Make 'Add tag' dialog accessible from bzrk. |
115 |
|
116 |
def show_tag(self, item): |
|
117 |
from bzrlib.plugins.gtk.tags import AddTagDialog |
|
118 |
dialog = AddTagDialog(self.repository, self.revids[0], self.branch) |
|
119 |
response = dialog.run() |
|
401
by Daniel Schierbeck
Made the push dialog close when the cancel button is clicked. |
120 |
|
734.1.1
by Curtis Hovey
Mechanical changes made by pygi.convert.sh. |
121 |
if response != Gtk.ResponseType.NONE: |
232
by Jelmer Vernooij
Make 'Add tag' dialog accessible from bzrk. |
122 |
dialog.hide() |
724
by Jelmer Vernooij
Fix formatting, imports. |
123 |
|
734.1.1
by Curtis Hovey
Mechanical changes made by pygi.convert.sh. |
124 |
if response == Gtk.ResponseType.OK: |
423.7.8
by Daniel Schierbeck
Made the revision popup menu correctly add tags. |
125 |
self.emit('tag-added', dialog.tagname, dialog._revid) |
724
by Jelmer Vernooij
Fix formatting, imports. |
126 |
|
232
by Jelmer Vernooij
Make 'Add tag' dialog accessible from bzrk. |
127 |
dialog.destroy() |
724
by Jelmer Vernooij
Fix formatting, imports. |
128 |
|
313.2.1
by Gary van der Merwe
Add a revert option to the revision menu. |
129 |
def revert(self, item): |
130 |
pb = ui.ui_factory.nested_progress_bar() |
|
131 |
revision_tree = self.branch.repository.revision_tree(self.revids[0]) |
|
132 |
try: |
|
133 |
self.wt.revert(old_tree = revision_tree, pb = pb) |
|
134 |
finally: |
|
135 |
pb.finished() |