18
18
from cStringIO import StringIO
21
from bzrlib import errors, tests
21
from gi.repository import Gtk
29
from bzrlib.tests.features import UnicodeFilenameFeature
30
except ImportError: # bzr < 2.5
31
from bzrlib.tests import UnicodeFilenameFeature
22
32
from bzrlib.merge_directive import MergeDirective2
24
34
from bzrlib.plugins.gtk.diff import (
27
38
iter_changes_to_status,
28
39
MergeDirectiveController,
41
from bzrlib.plugins.gtk.tests import MockMethod
31
45
=== modified file 'tests/test_diff.py'
32
46
--- tests/test_diff.py 2008-03-11 13:18:28 +0000
69
83
class TestDiffView(tests.TestCaseWithTransport):
71
85
def test_unicode(self):
72
self.requireFeature(tests.UnicodeFilenameFeature)
86
self.requireFeature(UnicodeFilenameFeature)
74
88
tree = self.make_branch_and_tree('tree')
75
89
self.build_tree([u'tree/\u03a9'])
80
94
view.show_diff(None)
82
96
start, end = buf.get_bounds()
83
text = buf.get_text(start, end)
97
text = buf.get_text(start, end, True)
84
98
self.assertContainsRe(text,
85
99
"=== added file '\xce\xa9'\n"
86
100
'--- .*\t1970-01-01 00:00:00 \\+0000\n'
109
class FakeDiffWidget(DiffWidget):
114
class TestDiffWidget(tests.TestCaseWithTransport):
116
def test_treeview_cursor_cb(self):
117
widget = FakeDiffWidget()
118
widget.set_diff_text_sections(
119
[('', None, 'patch1'), ('a', 'a', 'patch2')])
120
widget.treeview.set_cursor(Gtk.TreePath(path=1), None, False)
121
widget._treeview_cursor_cb(None)
122
self.assertTrue('patch2', widget.diff_view.buffer.props.text)
124
def test_treeview_cursor_cb_with_destroyed_treeview(self):
125
widget = FakeDiffWidget()
126
widget.set_diff_text_sections(
127
[('', None, 'patch1'), ('a', 'a', 'patch2')])
128
MockMethod.bind(self, widget.diff_view, 'show_diff')
129
widget.treeview.destroy()
130
widget._treeview_cursor_cb(None)
131
self.assertFalse(widget.diff_view.show_diff.called)
94
134
class MockDiffWidget(object):
96
136
def set_diff_text_sections(self, sections):
303
344
[('a-id', 'a', 'removed', 'a'),
304
345
('b-id', 'b', 'removed', 'b/'),
348
def test_status_missing_file(self):
349
this = self.make_branch_and_tree('this')
350
self.build_tree(['this/foo'])
351
this.add(['foo'], ['foo-id'])
354
other = this.bzrdir.sprout('other').open_workingtree()
356
os.remove('this/foo')
357
this.remove('foo', force=True)
358
this.commit('remove')
360
f = open('other/foo', 'wt')
362
f.write('Modified\n')
365
other.commit('modified')
367
this.merge_from_branch(other.branch)
368
conflicts.resolve(this)
370
self.assertStatusEqual(
371
[('foo-id', 'foo.OTHER', 'missing', 'foo.OTHER'),],
374
def test_status_missing_directory(self):
375
this = self.make_branch_and_tree('this')
376
self.build_tree(['this/foo/', 'this/foo/bar'])
377
this.add(['foo', 'foo/bar'], ['foo-id', 'bar-id'])
380
other = this.bzrdir.sprout('other').open_workingtree()
382
os.remove('this/foo/bar')
384
this.remove('foo', force=True)
385
this.commit('remove')
387
f = open('other/foo/bar', 'wt')
389
f.write('Modified\n')
392
other.commit('modified')
394
this.merge_from_branch(other.branch)
395
conflicts.resolve(this)
397
self.assertStatusEqual(
398
[('foo-id', u'foo', 'added', u'foo/'),
399
('bar-id', u'foo/bar.OTHER', 'missing', u'foo/bar.OTHER'),],