15
15
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17
17
"""GTK+ frontends to Bazaar commands """
18
from bzrlib.commands import Command, register_command, display_command
19
from bzrlib.errors import NotVersionedError, BzrCommandError
20
from bzrlib.commands import Command, register_command
21
from bzrlib.option import Option
22
from bzrlib.branch import Branch
23
from bzrlib.workingtree import WorkingTree
24
from bzrlib.bzrdir import BzrDir
26
class cmd_gbranch(Command):
36
except RuntimeError, e:
37
if str(e) == "could not open display":
40
from clone import CloneDialog
42
window = CloneDialog()
43
if window.run() == gtk.RESPONSE_OK:
44
bzrdir = BzrDir.open(window.url)
45
bzrdir.sprout(window.dest_path)
47
register_command(cmd_gbranch)
49
class cmd_gdiff(Command):
50
"""Show differences in working tree in a GTK+ Window.
52
Otherwise, all changes for the tree are listed.
58
def run(self, revision=None, file_list=None):
59
tree1 = WorkingTree.open_containing(".")[0]
61
tree2 = tree1.branch.repository.revision_tree(branch.last_revision())
63
from bzrlib.plugins.gtk.viz.diffwin import DiffWindow
66
window.connect("destroy", lambda w: gtk.main_quit())
67
window.set_diff("Working Tree", tree1, tree2)
72
register_command(cmd_gdiff)
74
class cmd_visualise(Command):
75
"""Graphically visualise this branch.
77
Opens a graphical window to allow you to see the history of the branch
78
and relationships between revisions in a visual manner,
80
The default starting point is latest revision on the branch, you can
81
specify a starting point with -r revision.
85
Option('limit', "maximum number of revisions to display",
87
takes_args = [ "location?" ]
88
aliases = [ "visualize", "vis", "viz" ]
90
def run(self, location=".", revision=None, limit=None):
91
(branch, path) = Branch.open_containing(location)
93
branch.repository.lock_read()
96
revid = branch.last_revision()
100
(revno, revid) = revision[0].in_history(branch)
102
from viz.bzrkapp import BzrkApp
105
app.show(branch, revid, limit)
107
branch.repository.unlock()
112
register_command(cmd_visualise)
114
class cmd_gannotate(Command):
117
Browse changes to FILENAME line by line in a GTK+ window.
120
takes_args = ["filename"]
122
Option("all", help="show annotations on all lines"),
123
Option("plain", help="don't highlight annotation lines"),
124
Option("line", type=int, argname="lineno",
125
help="jump to specified line number")
127
aliases = ["gblame", "gpraise"]
129
def run(self, filename, all=False, plain=False, line=1):
135
except RuntimeError, e:
136
if str(e) == "could not open display":
139
from annotate.gannotate import GAnnotateWindow
140
from annotate.config import GAnnotateConfig
142
(wt, path) = WorkingTree.open_containing(filename)
145
file_id = wt.path2id(path)
148
raise NotVersionedError(filename)
150
window = GAnnotateWindow(all, plain)
151
window.connect("destroy", lambda w: gtk.main_quit())
152
window.set_title(path + " - gannotate")
153
config = GAnnotateConfig(window)
157
window.annotate(branch, file_id)
160
window.jump_to_line(line)
164
register_command(cmd_gannotate)
166
class cmd_gcommit(Command):
167
"""GTK+ commit dialog
169
Graphical user interface for committing revisions"""
174
def run(self, filename=None):
180
except RuntimeError, e:
181
if str(e) == "could not open display":
184
from commit import GCommitDialog
185
from bzrlib.commit import Commit
186
from bzrlib.errors import (BzrCommandError, PointlessCommit, ConflictsInTree,
189
(wt, path) = WorkingTree.open_containing(filename)
192
file_id = wt.path2id(path)
195
raise NotVersionedError(filename)
197
dialog = GCommitDialog(wt)
198
dialog.set_title(path + " - Commit")
199
if dialog.run() != gtk.RESPONSE_CANCEL:
200
Commit().commit(working_tree=wt,message=dialog.message,
201
specific_files=dialog.specific_files)
203
register_command(cmd_gcommit)
205
class NoDisplayError(BzrCommandError):
206
"""gtk could not find a proper display"""
209
return "No DISPLAY. gannotate is disabled."