/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to breezy/plugins/git/tests/test_workingtree.py

  • Committer: Breezy landing bot
  • Author(s): Jelmer Vernooij
  • Date: 2018-07-02 01:50:36 UTC
  • mfrom: (6973.13.15 python3-l)
  • Revision ID: breezy.the.bot@gmail.com-20180702015036-p7h30yemu44e4p01
Fix more tests on Python3.

Merged from https://code.launchpad.net/~jelmer/brz/python3-l/+merge/348782

Show diffs side-by-side

added added

removed removed

Lines of Context:
90
90
 
91
91
    def test_missing(self):
92
92
        delta = TreeDelta()
93
 
        delta.removed.append(('a', 'a-id', 'file'))
94
 
        changes = [(('a', 'a'), (stat.S_IFREG | 0o755, 0), ('a' * 40, 'a' * 40))]
 
93
        delta.removed.append(('a', b'a-id', 'file'))
 
94
        changes = [(('a', 'a'), (stat.S_IFREG | 0o755, 0), (b'a' * 40, b'a' * 40))]
95
95
        self.assertEqual(
96
96
            delta,
97
97
            tree_delta_from_git_changes(changes, default_mapping,
98
 
                (GitFileIdMap({'a': 'a-id'}, default_mapping),
99
 
                 GitFileIdMap({'a': 'a-id'}, default_mapping))))
 
98
                (GitFileIdMap({'a': b'a-id'}, default_mapping),
 
99
                 GitFileIdMap({'a': b'a-id'}, default_mapping))))
100
100
 
101
101
 
102
102
class ChangesBetweenGitTreeAndWorkingCopyTests(TestCaseWithTransport):
127
127
    def test_added_file(self):
128
128
        self.build_tree(['a'])
129
129
        self.wt.add(['a'])
130
 
        a = Blob.from_string('contents of a\n')
 
130
        a = Blob.from_string(b'contents of a\n')
131
131
        t = Tree()
132
 
        t.add("a", stat.S_IFREG | 0o644, a.id)
 
132
        t.add(b"a", stat.S_IFREG | 0o644, a.id)
133
133
        self.expectDelta(
134
 
            [((None, ''), (None, stat.S_IFDIR), (None, t.id)),
135
 
             ((None, 'a'), (None, stat.S_IFREG | 0o644), (None, a.id))])
 
134
            [((None, b''), (None, stat.S_IFDIR), (None, t.id)),
 
135
             ((None, b'a'), (None, stat.S_IFREG | 0o644), (None, a.id))])
136
136
 
137
137
    def test_added_unknown_file(self):
138
138
        self.build_tree(['a'])
139
139
        t = Tree()
140
140
        self.expectDelta(
141
 
            [((None, ''), (None, stat.S_IFDIR), (None, t.id))])
142
 
        a = Blob.from_string('contents of a\n')
 
141
            [((None, b''), (None, stat.S_IFDIR), (None, t.id))])
 
142
        a = Blob.from_string(b'contents of a\n')
143
143
        t = Tree()
144
 
        t.add("a", stat.S_IFREG | 0o644, a.id)
 
144
        t.add(b"a", stat.S_IFREG | 0o644, a.id)
145
145
        self.expectDelta(
146
 
            [((None, ''), (None, stat.S_IFDIR), (None, t.id)),
147
 
             ((None, 'a'), (None, stat.S_IFREG | 0o644), (None, a.id))],
148
 
            ['a'],
 
146
            [((None, b''), (None, stat.S_IFDIR), (None, t.id)),
 
147
             ((None, b'a'), (None, stat.S_IFREG | 0o644), (None, a.id))],
 
148
            [b'a'],
149
149
            want_unversioned=True)
150
150
 
151
151
    def test_missing_added_file(self):
152
152
        self.build_tree(['a'])
153
153
        self.wt.add(['a'])
154
154
        os.unlink('a')
155
 
        a = Blob.from_string('contents of a\n')
 
155
        a = Blob.from_string(b'contents of a\n')
156
156
        t = Tree()
157
 
        t.add("a", 0, ZERO_SHA)
 
157
        t.add(b"a", 0, ZERO_SHA)
158
158
        self.expectDelta(
159
 
            [((None, ''), (None, stat.S_IFDIR), (None, t.id)),
160
 
             ((None, 'a'), (None, 0), (None, ZERO_SHA))],
 
159
            [((None, b''), (None, stat.S_IFDIR), (None, t.id)),
 
160
             ((None, b'a'), (None, 0), (None, ZERO_SHA))],
161
161
            [])
162
162
 
163
163
    def test_missing_versioned_file(self):
165
165
        self.wt.add(['a'])
166
166
        self.wt.commit('')
167
167
        os.unlink('a')
168
 
        a = Blob.from_string('contents of a\n')
 
168
        a = Blob.from_string(b'contents of a\n')
169
169
        oldt = Tree()
170
 
        oldt.add("a", stat.S_IFREG | 0o644, a.id)
 
170
        oldt.add(b"a", stat.S_IFREG | 0o644, a.id)
171
171
        newt = Tree()
172
 
        newt.add("a", 0, ZERO_SHA)
 
172
        newt.add(b"a", 0, ZERO_SHA)
173
173
        self.expectDelta(
174
 
                [(('', ''), (stat.S_IFDIR, stat.S_IFDIR), (oldt.id, newt.id)),
175
 
                 (('a', 'a'), (stat.S_IFREG|0o644, 0), (a.id, ZERO_SHA))])
 
174
                [((b'', b''), (stat.S_IFDIR, stat.S_IFDIR), (oldt.id, newt.id)),
 
175
                 ((b'a', b'a'), (stat.S_IFREG|0o644, 0), (a.id, ZERO_SHA))])
176
176
 
177
177
    def test_versioned_replace_by_dir(self):
178
178
        self.build_tree(['a'])
180
180
        self.wt.commit('')
181
181
        os.unlink('a')
182
182
        os.mkdir('a')
183
 
        olda = Blob.from_string('contents of a\n')
 
183
        olda = Blob.from_string(b'contents of a\n')
184
184
        oldt = Tree()
185
 
        oldt.add("a", stat.S_IFREG | 0o644, olda.id)
 
185
        oldt.add(b"a", stat.S_IFREG | 0o644, olda.id)
186
186
        newt = Tree()
187
187
        newa = Tree()
188
 
        newt.add("a", stat.S_IFDIR, newa.id)
 
188
        newt.add(b"a", stat.S_IFDIR, newa.id)
189
189
        self.expectDelta([
190
 
            (('', ''),
 
190
            ((b'', b''),
191
191
            (stat.S_IFDIR, stat.S_IFDIR),
192
192
            (oldt.id, newt.id)),
193
 
            (('a', 'a'), (stat.S_IFREG | 0o644, stat.S_IFDIR), (olda.id, newa.id))
 
193
            ((b'a', b'a'), (stat.S_IFREG | 0o644, stat.S_IFDIR), (olda.id, newa.id))
194
194
            ], want_unversioned=False)
195
195
        self.expectDelta([
196
 
            (('', ''),
 
196
            ((b'', b''),
197
197
            (stat.S_IFDIR, stat.S_IFDIR),
198
198
            (oldt.id, newt.id)),
199
 
            (('a', 'a'), (stat.S_IFREG | 0o644, stat.S_IFDIR), (olda.id, newa.id))
 
199
            ((b'a', b'a'), (stat.S_IFREG | 0o644, stat.S_IFDIR), (olda.id, newa.id))
200
200
            ], want_unversioned=True)
201
201
 
202
202
    def test_extra(self):
203
203
        self.build_tree(['a'])
204
204
        newa = Blob.from_string(b'contents of a\n')
205
205
        newt = Tree()
206
 
        newt.add("a", stat.S_IFREG | 0o644, newa.id)
 
206
        newt.add(b"a", stat.S_IFREG | 0o644, newa.id)
207
207
        self.expectDelta([
208
 
            ((None, ''),
 
208
            ((None, b''),
209
209
            (None, stat.S_IFDIR),
210
210
            (None, newt.id)),
211
 
            ((None, 'a'), (None, stat.S_IFREG | 0o644), (None, newa.id))
212
 
            ], ['a'], want_unversioned=True)
 
211
            ((None, b'a'), (None, stat.S_IFREG | 0o644), (None, newa.id))
 
212
            ], [b'a'], want_unversioned=True)