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, 'patch'), ('a', 'a', 'patch')])
120
MockMethod.bind(self, widget.diff_view, 'show_diff')
121
widget.treeview.set_cursor(Gtk.TreePath(path=1), None, False)
122
widget._treeview_cursor_cb(None)
123
self.assertTrue(widget.diff_view.show_diff.called)
124
self.assertEqual((['a'],), widget.diff_view.show_diff.args)
126
def test_treeview_cursor_cb_with_destroyed_treeview(self):
127
widget = FakeDiffWidget()
128
widget.set_diff_text_sections(
129
[('', None, 'patch'), ('a', 'a', 'patch')])
130
MockMethod.bind(self, widget.diff_view, 'show_diff')
131
widget.treeview.destroy()
132
widget._treeview_cursor_cb(None)
133
self.assertFalse(widget.diff_view.show_diff.called)
94
136
class MockDiffWidget(object):
96
138
def set_diff_text_sections(self, sections):
303
346
[('a-id', 'a', 'removed', 'a'),
304
347
('b-id', 'b', 'removed', 'b/'),
350
def test_status_missing_file(self):
351
this = self.make_branch_and_tree('this')
352
self.build_tree(['this/foo'])
353
this.add(['foo'], ['foo-id'])
356
other = this.bzrdir.sprout('other').open_workingtree()
358
os.remove('this/foo')
359
this.remove('foo', force=True)
360
this.commit('remove')
362
f = open('other/foo', 'wt')
364
f.write('Modified\n')
367
other.commit('modified')
369
this.merge_from_branch(other.branch)
370
conflicts.resolve(this)
372
self.assertStatusEqual(
373
[('foo-id', 'foo.OTHER', 'missing', 'foo.OTHER'),],
376
def test_status_missing_directory(self):
377
this = self.make_branch_and_tree('this')
378
self.build_tree(['this/foo/', 'this/foo/bar'])
379
this.add(['foo', 'foo/bar'], ['foo-id', 'bar-id'])
382
other = this.bzrdir.sprout('other').open_workingtree()
384
os.remove('this/foo/bar')
386
this.remove('foo', force=True)
387
this.commit('remove')
389
f = open('other/foo/bar', 'wt')
391
f.write('Modified\n')
394
other.commit('modified')
396
this.merge_from_branch(other.branch)
397
conflicts.resolve(this)
399
self.assertStatusEqual(
400
[('foo-id', u'foo', 'added', u'foo/'),
401
('bar-id', u'foo/bar.OTHER', 'missing', u'foo/bar.OTHER'),],