167
167
def run(self, revision=None, filename=None):
169
169
wt = workingtree.WorkingTree.open_containing(".")[0]
171
if revision is not None:
172
if len(revision) == 1:
173
if revision is not None:
174
if len(revision) == 1:
176
revision_id = revision[0].in_history(branch).rev_id
177
tree2 = branch.repository.revision_tree(revision_id)
178
elif len(revision) == 2:
179
revision_id_0 = revision[0].in_history(branch).rev_id
180
tree2 = branch.repository.revision_tree(revision_id_0)
181
revision_id_1 = revision[1].in_history(branch).rev_id
182
tree1 = branch.repository.revision_tree(revision_id_1)
174
revision_id = revision[0].in_history(branch).rev_id
175
tree2 = branch.repository.revision_tree(revision_id)
176
elif len(revision) == 2:
177
revision_id_0 = revision[0].in_history(branch).rev_id
178
tree2 = branch.repository.revision_tree(revision_id_0)
179
revision_id_1 = revision[1].in_history(branch).rev_id
180
tree1 = branch.repository.revision_tree(revision_id_1)
183
tree2 = tree1.basis_tree()
185
from diff import DiffWindow
187
window = DiffWindow()
188
window.connect("destroy", gtk.main_quit)
189
window.set_diff("Working Tree", tree1, tree2)
190
if filename is not None:
191
tree_filename = wt.relpath(filename)
193
window.set_file(tree_filename)
195
if (tree1.inventory.path2id(tree_filename) is None and
196
tree2.inventory.path2id(tree_filename) is None):
197
raise NotVersionedError(filename)
198
raise BzrCommandError('No changes found for file "%s"' %
185
tree2 = tree1.basis_tree()
187
from diff import DiffWindow
189
window = DiffWindow()
190
window.connect("destroy", gtk.main_quit)
191
window.set_diff("Working Tree", tree1, tree2)
192
if filename is not None:
193
tree_filename = wt.relpath(filename)
195
window.set_file(tree_filename)
197
if (tree1.inventory.path2id(tree_filename) is None and
198
tree2.inventory.path2id(tree_filename) is None):
199
raise NotVersionedError(filename)
200
raise BzrCommandError('No changes found for file "%s"' %
204
208
register_command(cmd_gdiff)
282
286
from annotate.gannotate import GAnnotateWindow
283
287
from annotate.config import GAnnotateConfig
286
(tree, path) = workingtree.WorkingTree.open_containing(filename)
288
except errors.NoWorkingTree:
289
(br, path) = branch.Branch.open_containing(filename)
289
wt, br, path = BzrDir.open_containing_tree_or_branch(filename)
290
293
tree = br.basis_tree()
292
295
file_id = tree.path2id(path)
307
310
config = GAnnotateConfig(window)
311
316
window.annotate(tree, br, file_id)
317
window.jump_to_line(line)
314
window.jump_to_line(line)
318
324
register_command(cmd_gannotate)
429
435
def test_suite():
430
436
from unittest import TestSuite
433
result.addTest(tests.test_suite())
439
default_encoding = sys.getdefaultencoding()
442
result.addTest(tests.test_suite())
445
sys.setdefaultencoding(default_encoding)