18
18
from cStringIO import StringIO
21
from bzrlib import errors, tests
27
from bzrlib.tests.features import UnicodeFilenameFeature
28
except ImportError: # bzr < 2.5
29
from bzrlib.tests import UnicodeFilenameFeature
22
30
from bzrlib.merge_directive import MergeDirective2
24
32
from bzrlib.plugins.gtk.diff import (
27
36
iter_changes_to_status,
28
37
MergeDirectiveController,
39
from bzrlib.plugins.gtk.tests import MockMethod
31
43
=== modified file 'tests/test_diff.py'
32
44
--- tests/test_diff.py 2008-03-11 13:18:28 +0000
69
81
class TestDiffView(tests.TestCaseWithTransport):
71
83
def test_unicode(self):
72
self.requireFeature(tests.UnicodeFilenameFeature)
84
self.requireFeature(UnicodeFilenameFeature)
74
86
tree = self.make_branch_and_tree('tree')
75
87
self.build_tree([u'tree/\u03a9'])
80
92
view.show_diff(None)
82
94
start, end = buf.get_bounds()
83
text = buf.get_text(start, end)
95
text = buf.get_text(start, end, True)
84
96
self.assertContainsRe(text,
85
97
"=== added file '\xce\xa9'\n"
86
98
'--- .*\t1970-01-01 00:00:00 \\+0000\n'
107
class FakeDiffWidget(DiffWidget):
112
class TestDiffWidget(tests.TestCaseWithTransport):
114
def test_treeview_cursor_cbd_with_destroyed_treeview(self):
115
widget = FakeDiffWidget()
116
widget.set_diff_text_sections([('a', None, 'patch')])
117
MockMethod.bind(self, widget.diff_view, 'show_diff')
118
widget.treeview.destroy()
119
widget._treeview_cursor_cb(None)
120
self.assertFalse(widget.diff_view.show_diff.called)
94
123
class MockDiffWidget(object):
96
125
def set_diff_text_sections(self, sections):
303
333
[('a-id', 'a', 'removed', 'a'),
304
334
('b-id', 'b', 'removed', 'b/'),
337
def test_status_missing_file(self):
338
this = self.make_branch_and_tree('this')
339
self.build_tree(['this/foo'])
340
this.add(['foo'], ['foo-id'])
343
other = this.bzrdir.sprout('other').open_workingtree()
345
os.remove('this/foo')
346
this.remove('foo', force=True)
347
this.commit('remove')
349
f = open('other/foo', 'wt')
351
f.write('Modified\n')
354
other.commit('modified')
356
this.merge_from_branch(other.branch)
357
conflicts.resolve(this)
359
self.assertStatusEqual(
360
[('foo-id', 'foo.OTHER', 'missing', 'foo.OTHER'),],
363
def test_status_missing_directory(self):
364
this = self.make_branch_and_tree('this')
365
self.build_tree(['this/foo/', 'this/foo/bar'])
366
this.add(['foo', 'foo/bar'], ['foo-id', 'bar-id'])
369
other = this.bzrdir.sprout('other').open_workingtree()
371
os.remove('this/foo/bar')
373
this.remove('foo', force=True)
374
this.commit('remove')
376
f = open('other/foo/bar', 'wt')
378
f.write('Modified\n')
381
other.commit('modified')
383
this.merge_from_branch(other.branch)
384
conflicts.resolve(this)
386
self.assertStatusEqual(
387
[('foo-id', u'foo', 'added', u'foo/'),
388
('bar-id', u'foo/bar.OTHER', 'missing', u'foo/bar.OTHER'),],