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 GCloneDialog
42
window = GCloneDialog()
43
if window.run() == gtk.RESPONSE_OK:
45
print 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
bzrdir = BzrDir.open_containing(".")[0]
60
repos = bzrdir.open_repository()
61
branch = bzrdir.open_branch()
62
tree2 = repos.revision_tree(branch.last_revision())
63
tree1 = WorkingTree.open_containing(".")[0]
65
from viz.diffwin import DiffWindow
68
except RuntimeError, e:
69
if str(e) == "could not open display":
72
window.connect("destroy", lambda w: gtk.main_quit())
73
window.set_diff("Working Tree", tree1, tree2)
78
register_command(cmd_gdiff)
80
class cmd_visualise(Command):
81
"""Graphically visualise this branch.
83
Opens a graphical window to allow you to see the history of the branch
84
and relationships between revisions in a visual manner,
86
The default starting point is latest revision on the branch, you can
87
specify a starting point with -r revision.
91
Option('limit', "maximum number of revisions to display",
93
takes_args = [ "location?" ]
94
aliases = [ "visualize", "vis", "viz" ]
96
def run(self, location=".", revision=None, limit=None):
97
(branch, path) = Branch.open_containing(location)
99
branch.repository.lock_read()
102
revid = branch.last_revision()
106
(revno, revid) = revision[0].in_history(branch)
108
from viz.bzrkapp import BzrkApp
111
app.show(branch, revid, limit)
113
branch.repository.unlock()
118
register_command(cmd_visualise)
120
class cmd_gannotate(Command):
123
Browse changes to FILENAME line by line in a GTK+ window.
126
takes_args = ["filename"]
128
Option("all", help="show annotations on all lines"),
129
Option("plain", help="don't highlight annotation lines"),
130
Option("line", type=int, argname="lineno",
131
help="jump to specified line number")
133
aliases = ["gblame", "gpraise"]
135
def run(self, filename, all=False, plain=False, line=1):
141
except RuntimeError, e:
142
if str(e) == "could not open display":
145
from annotate.gannotate import GAnnotateWindow
146
from annotate.config import GAnnotateConfig
148
(wt, path) = WorkingTree.open_containing(filename)
151
file_id = wt.path2id(path)
154
raise NotVersionedError(filename)
156
window = GAnnotateWindow(all, plain)
157
window.connect("destroy", lambda w: gtk.main_quit())
158
window.set_title(path + " - gannotate")
159
config = GAnnotateConfig(window)
163
window.annotate(branch, file_id)
166
window.jump_to_line(line)
170
register_command(cmd_gannotate)
172
class cmd_gcommit(Command):
173
"""GTK+ commit dialog
175
Graphical user interface for committing revisions"""
180
def run(self, filename=None):
186
except RuntimeError, e:
187
if str(e) == "could not open display":
190
from commit import GCommitDialog
191
from bzrlib.commit import Commit
192
from bzrlib.errors import (BzrCommandError, PointlessCommit, ConflictsInTree,
195
(wt, path) = WorkingTree.open_containing(filename)
198
file_id = wt.path2id(path)
201
raise NotVersionedError(filename)
203
dialog = GCommitDialog(wt)
204
dialog.set_title(path + " - Commit")
205
if dialog.run() != gtk.RESPONSE_CANCEL:
206
Commit().commit(working_tree=wt,message=dialog.message,
207
specific_files=dialog.specific_files)
209
register_command(cmd_gcommit)
211
class NoDisplayError(BzrCommandError):
212
"""gtk could not find a proper display"""
215
return "No DISPLAY. gannotate is disabled."