/b-gtk/fix-viz

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/b-gtk/fix-viz

« back to all changes in this revision

Viewing changes to tests/test_diff.py

  • Committer: Jelmer Vernooij
  • Date: 2011-12-20 16:16:57 UTC
  • Revision ID: jelmer@canonical.com-20111220161657-zjn6rqjrw8ouehf8
Drop support for old bencode location.

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
from cStringIO import StringIO
19
19
import os
20
20
 
21
 
from bzrlib import errors, tests
 
21
from bzrlib import (
 
22
    conflicts,
 
23
    errors,
 
24
    tests,
 
25
    )
 
26
try:
 
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
23
31
 
24
32
from bzrlib.plugins.gtk.diff import (
69
77
class TestDiffView(tests.TestCaseWithTransport):
70
78
 
71
79
    def test_unicode(self):
72
 
        self.requireFeature(tests.UnicodeFilenameFeature)
 
80
        self.requireFeature(UnicodeFilenameFeature)
73
81
 
74
82
        tree = self.make_branch_and_tree('tree')
75
83
        self.build_tree([u'tree/\u03a9'])
80
88
        view.show_diff(None)
81
89
        buf = view.buffer
82
90
        start, end = buf.get_bounds()
83
 
        text = buf.get_text(start, end)
 
91
        text = buf.get_text(start, end, True)
84
92
        self.assertContainsRe(text,
85
93
            "=== added file '\xce\xa9'\n"
86
94
            '--- .*\t1970-01-01 00:00:00 \\+0000\n'
98
106
 
99
107
 
100
108
class MockWindow(object):
 
109
 
101
110
    def __init__(self):
102
111
        self.diff = MockDiffWidget()
103
112
        self.merge_successful = False
303
312
            [('a-id', 'a', 'removed', 'a'),
304
313
             ('b-id', 'b', 'removed', 'b/'),
305
314
            ], tree)
 
315
 
 
316
    def test_status_missing_file(self):
 
317
        this = self.make_branch_and_tree('this')
 
318
        self.build_tree(['this/foo'])
 
319
        this.add(['foo'], ['foo-id'])
 
320
        this.commit('add')
 
321
 
 
322
        other = this.bzrdir.sprout('other').open_workingtree()
 
323
 
 
324
        os.remove('this/foo')
 
325
        this.remove('foo', force=True)
 
326
        this.commit('remove')
 
327
 
 
328
        f = open('other/foo', 'wt')
 
329
        try:
 
330
            f.write('Modified\n')
 
331
        finally:
 
332
            f.close()
 
333
        other.commit('modified')
 
334
 
 
335
        this.merge_from_branch(other.branch)
 
336
        conflicts.resolve(this)
 
337
 
 
338
        self.assertStatusEqual(
 
339
            [('foo-id', 'foo.OTHER', 'missing', 'foo.OTHER'),],
 
340
            this)
 
341
 
 
342
    def test_status_missing_directory(self):
 
343
        this = self.make_branch_and_tree('this')
 
344
        self.build_tree(['this/foo/', 'this/foo/bar'])
 
345
        this.add(['foo', 'foo/bar'], ['foo-id', 'bar-id'])
 
346
        this.commit('add')
 
347
 
 
348
        other = this.bzrdir.sprout('other').open_workingtree()
 
349
 
 
350
        os.remove('this/foo/bar')
 
351
        os.rmdir('this/foo')
 
352
        this.remove('foo', force=True)
 
353
        this.commit('remove')
 
354
 
 
355
        f = open('other/foo/bar', 'wt')
 
356
        try:
 
357
            f.write('Modified\n')
 
358
        finally:
 
359
            f.close()
 
360
        other.commit('modified')
 
361
 
 
362
        this.merge_from_branch(other.branch)
 
363
        conflicts.resolve(this)
 
364
 
 
365
        self.assertStatusEqual(
 
366
            [('foo-id', u'foo', 'added', u'foo/'),
 
367
             ('bar-id', u'foo/bar.OTHER', 'missing', u'foo/bar.OTHER'),],
 
368
            this)