/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar
0.5.66 by John Arbash Meinel
Refactoring, moving test code into test (switching back to assert is None)
1
import bzrlib
2
import unittest
3
from StringIO import StringIO
4
5
from bzrlib.selftest import TestCaseInTempDir
0.5.97 by Aaron Bentley
Updated tests
6
0.5.78 by John Arbash Meinel
Working on test cases, starting with the empty project issues.
7
from bzrlib.diff import internal_diff
0.5.66 by John Arbash Meinel
Refactoring, moving test code into test (switching back to assert is None)
8
from read_changeset import ChangesetTree
9
10
class MockTree(object):
11
    def __init__(self):
12
        from bzrlib.inventory import RootEntry, ROOT_ID
0.6.1 by Aaron Bentley
Fleshed out MockTree, fixed all test failures
13
        object.__init__(self)
0.5.66 by John Arbash Meinel
Refactoring, moving test code into test (switching back to assert is None)
14
        self.paths = {ROOT_ID: ""}
0.6.1 by Aaron Bentley
Fleshed out MockTree, fixed all test failures
15
        self.ids = {"": ROOT_ID}
16
        self.contents = {}
0.5.66 by John Arbash Meinel
Refactoring, moving test code into test (switching back to assert is None)
17
        self.root = RootEntry(ROOT_ID)
0.6.1 by Aaron Bentley
Fleshed out MockTree, fixed all test failures
18
19
    inventory = property(lambda x:x)
20
0.5.66 by John Arbash Meinel
Refactoring, moving test code into test (switching back to assert is None)
21
    def __iter__(self):
22
        return self.paths.iterkeys()
23
24
    def __getitem__(self, file_id):
0.6.1 by Aaron Bentley
Fleshed out MockTree, fixed all test failures
25
        if file_id == self.root.file_id:
26
            return self.root
27
        else:
28
            return self.make_entry(file_id, self.paths[file_id])
29
30
    def parent_id(self, file_id):
31
        from os.path import dirname
32
        parent_dir = dirname(self.paths[file_id])
33
        if parent_dir == "":
34
            return None
35
        return self.ids[parent_dir]
36
37
    def iter_entries(self):
38
        for path, file_id in self.ids.iteritems():
39
            yield path, self[file_id]
40
41
    def get_file_kind(self, file_id):
42
        if file_id in self.contents:
43
            kind = 'file'
44
        else:
45
            kind = 'directory'
46
        return kind
47
48
    def make_entry(self, file_id, path):
49
        from os.path import basename
50
        from bzrlib.inventory import InventoryEntry
51
        name = basename(path)
52
        kind = self.get_file_kind(file_id)
53
        parent_id = self.parent_id(file_id)
54
        text_sha_1, text_size = self.contents_stats(file_id)
55
        ie = InventoryEntry(file_id, name, kind, parent_id)
56
        ie.text_sha1 = text_sha_1
0.5.91 by Aaron Bentley
Updated to match API change
57
        ie.text_size = text_size
0.6.1 by Aaron Bentley
Fleshed out MockTree, fixed all test failures
58
        return ie
59
60
    def add_dir(self, file_id, path):
0.5.66 by John Arbash Meinel
Refactoring, moving test code into test (switching back to assert is None)
61
        self.paths[file_id] = path
62
        self.ids[path] = file_id
63
    
64
    def add_file(self, file_id, path, contents):
65
        self.add_dir(file_id, path)
66
        self.contents[file_id] = contents
67
68
    def path2id(self, path):
69
        return self.ids.get(path)
70
71
    def id2path(self, file_id):
72
        return self.paths.get(file_id)
73
74
    def has_id(self, file_id):
75
        return self.id2path(file_id) is not None
76
77
    def get_file(self, file_id):
78
        result = StringIO()
79
        result.write(self.contents[file_id])
80
        result.seek(0,0)
81
        return result
82
83
    def contents_stats(self, file_id):
0.6.1 by Aaron Bentley
Fleshed out MockTree, fixed all test failures
84
        from bzrlib.osutils import sha_file
85
        if file_id not in self.contents:
86
            return None, None
87
        text_sha1 = sha_file(self.get_file(file_id))
88
        return text_sha1, len(self.contents[file_id])
89
90
91
class CTreeTester(unittest.TestCase):
0.5.66 by John Arbash Meinel
Refactoring, moving test code into test (switching back to assert is None)
92
    """A simple unittest tester for the ChangesetTree class."""
93
94
    def make_tree_1(self):
95
        mtree = MockTree()
96
        mtree.add_dir("a", "grandparent")
97
        mtree.add_dir("b", "grandparent/parent")
98
        mtree.add_file("c", "grandparent/parent/file", "Hello\n")
99
        mtree.add_dir("d", "grandparent/alt_parent")
100
        return ChangesetTree(mtree), mtree
101
        
102
    def test_renames(self):
103
        """Ensure that file renames have the proper effect on children"""
104
        ctree = self.make_tree_1()[0]
105
        self.assertEqual(ctree.old_path("grandparent"), "grandparent")
106
        self.assertEqual(ctree.old_path("grandparent/parent"), "grandparent/parent")
107
        self.assertEqual(ctree.old_path("grandparent/parent/file"),
108
            "grandparent/parent/file")
109
110
        self.assertEqual(ctree.id2path("a"), "grandparent")
111
        self.assertEqual(ctree.id2path("b"), "grandparent/parent")
112
        self.assertEqual(ctree.id2path("c"), "grandparent/parent/file")
113
114
        self.assertEqual(ctree.path2id("grandparent"), "a")
115
        self.assertEqual(ctree.path2id("grandparent/parent"), "b")
116
        self.assertEqual(ctree.path2id("grandparent/parent/file"), "c")
117
118
        assert ctree.path2id("grandparent2") is None
119
        assert ctree.path2id("grandparent2/parent") is None
120
        assert ctree.path2id("grandparent2/parent/file") is None
121
122
        ctree.note_rename("grandparent", "grandparent2")
123
        assert ctree.old_path("grandparent") is None
124
        assert ctree.old_path("grandparent/parent") is None
125
        assert ctree.old_path("grandparent/parent/file") is None
126
127
        self.assertEqual(ctree.id2path("a"), "grandparent2")
128
        self.assertEqual(ctree.id2path("b"), "grandparent2/parent")
129
        self.assertEqual(ctree.id2path("c"), "grandparent2/parent/file")
130
131
        self.assertEqual(ctree.path2id("grandparent2"), "a")
132
        self.assertEqual(ctree.path2id("grandparent2/parent"), "b")
133
        self.assertEqual(ctree.path2id("grandparent2/parent/file"), "c")
134
135
        assert ctree.path2id("grandparent") is None
136
        assert ctree.path2id("grandparent/parent") is None
137
        assert ctree.path2id("grandparent/parent/file") is None
138
139
        ctree.note_rename("grandparent/parent", "grandparent2/parent2")
140
        self.assertEqual(ctree.id2path("a"), "grandparent2")
141
        self.assertEqual(ctree.id2path("b"), "grandparent2/parent2")
142
        self.assertEqual(ctree.id2path("c"), "grandparent2/parent2/file")
143
144
        self.assertEqual(ctree.path2id("grandparent2"), "a")
145
        self.assertEqual(ctree.path2id("grandparent2/parent2"), "b")
146
        self.assertEqual(ctree.path2id("grandparent2/parent2/file"), "c")
147
148
        assert ctree.path2id("grandparent2/parent") is None
149
        assert ctree.path2id("grandparent2/parent/file") is None
150
151
        ctree.note_rename("grandparent/parent/file", 
152
                          "grandparent2/parent2/file2")
153
        self.assertEqual(ctree.id2path("a"), "grandparent2")
154
        self.assertEqual(ctree.id2path("b"), "grandparent2/parent2")
155
        self.assertEqual(ctree.id2path("c"), "grandparent2/parent2/file2")
156
157
        self.assertEqual(ctree.path2id("grandparent2"), "a")
158
        self.assertEqual(ctree.path2id("grandparent2/parent2"), "b")
159
        self.assertEqual(ctree.path2id("grandparent2/parent2/file2"), "c")
160
161
        assert ctree.path2id("grandparent2/parent2/file") is None
162
163
    def test_moves(self):
164
        """Ensure that file moves have the proper effect on children"""
165
        ctree = self.make_tree_1()[0]
166
        ctree.note_rename("grandparent/parent/file", 
167
                          "grandparent/alt_parent/file")
168
        self.assertEqual(ctree.id2path("c"), "grandparent/alt_parent/file")
169
        self.assertEqual(ctree.path2id("grandparent/alt_parent/file"), "c")
170
        assert ctree.path2id("grandparent/parent/file") is None
171
172
    def unified_diff(self, old, new):
173
        out = StringIO()
174
        internal_diff("old", old, "new", new, out)
175
        out.seek(0,0)
176
        return out.read()
177
178
    def make_tree_2(self):
179
        ctree = self.make_tree_1()[0]
180
        ctree.note_rename("grandparent/parent/file", 
181
                          "grandparent/alt_parent/file")
182
        assert ctree.id2path("e") is None
183
        assert ctree.path2id("grandparent/parent/file") is None
184
        ctree.note_id("e", "grandparent/parent/file")
185
        return ctree
186
187
    def test_adds(self):
188
        """File/inventory adds"""
189
        ctree = self.make_tree_2()
190
        add_patch = self.unified_diff([], ["Extra cheese\n"])
191
        ctree.note_patch("grandparent/parent/file", add_patch)
192
        self.adds_test(ctree)
193
194
    def adds_test(self, ctree):
195
        self.assertEqual(ctree.id2path("e"), "grandparent/parent/file")
196
        self.assertEqual(ctree.path2id("grandparent/parent/file"), "e")
197
        self.assertEqual(ctree.get_file("e").read(), "Extra cheese\n")
198
199
    def test_adds2(self):
200
        """File/inventory adds, with patch-compatibile renames"""
201
        ctree = self.make_tree_2()
202
        ctree.contents_by_id = False
203
        add_patch = self.unified_diff(["Hello\n"], ["Extra cheese\n"])
204
        ctree.note_patch("grandparent/parent/file", add_patch)
205
        self.adds_test(ctree)
206
207
    def make_tree_3(self):
208
        ctree, mtree = self.make_tree_1()
209
        mtree.add_file("e", "grandparent/parent/topping", "Anchovies\n")
210
        ctree.note_rename("grandparent/parent/file", 
211
                          "grandparent/alt_parent/file")
212
        ctree.note_rename("grandparent/parent/topping", 
213
                          "grandparent/alt_parent/stopping")
214
        return ctree
215
216
    def get_file_test(self, ctree):
217
        self.assertEqual(ctree.get_file("e").read(), "Lemon\n")
218
        self.assertEqual(ctree.get_file("c").read(), "Hello\n")
219
220
    def test_get_file(self):
221
        """Get file contents"""
222
        ctree = self.make_tree_3()
223
        mod_patch = self.unified_diff(["Anchovies\n"], ["Lemon\n"])
224
        ctree.note_patch("grandparent/alt_parent/stopping", mod_patch)
225
        self.get_file_test(ctree)
226
227
    def test_get_file2(self):
228
        """Get file contents, with patch-compatibile renames"""
229
        ctree = self.make_tree_3()
230
        ctree.contents_by_id = False
231
        mod_patch = self.unified_diff([], ["Lemon\n"])
232
        ctree.note_patch("grandparent/alt_parent/stopping", mod_patch)
233
        mod_patch = self.unified_diff([], ["Hello\n"])
234
        ctree.note_patch("grandparent/alt_parent/file", mod_patch)
235
        self.get_file_test(ctree)
236
237
    def test_delete(self):
238
        "Deletion by changeset"
239
        ctree = self.make_tree_1()[0]
240
        self.assertEqual(ctree.get_file("c").read(), "Hello\n")
241
        ctree.note_deletion("grandparent/parent/file")
242
        assert ctree.id2path("c") is None
243
        assert ctree.path2id("grandparent/parent/file") is None
244
245
    def sorted_ids(self, tree):
246
        ids = list(tree)
247
        ids.sort()
248
        return ids
249
250
    def test_iteration(self):
251
        """Ensure that iteration through ids works properly"""
252
        ctree = self.make_tree_1()[0]
253
        self.assertEqual(self.sorted_ids(ctree), ['a', 'b', 'c', 'd'])
254
        ctree.note_deletion("grandparent/parent/file")
255
        ctree.note_id("e", "grandparent/alt_parent/fool", kind="directory")
0.6.1 by Aaron Bentley
Fleshed out MockTree, fixed all test failures
256
        self.assertEqual(self.sorted_ids(ctree), ['a', 'b', 'd', 'e'])
0.5.66 by John Arbash Meinel
Refactoring, moving test code into test (switching back to assert is None)
257
258
class CSetTester(TestCaseInTempDir):
0.5.97 by Aaron Bentley
Updated tests
259
0.5.80 by John Arbash Meinel
Starting to write tests for changeset, discovering some errors as I go.
260
    def get_valid_cset(self, base_rev_id, rev_id, auto_commit=False, checkout_dir=None):
0.5.88 by John Arbash Meinel
Fixed a bug in the rename code, added more tests.
261
        """Create a changeset from base_rev_id -> rev_id in built-in branch.
0.5.80 by John Arbash Meinel
Starting to write tests for changeset, discovering some errors as I go.
262
        Make sure that the text generated is valid, and that it
263
        can be applied against the base, and generate the same information.
264
        
265
        :return: The in-memory changeset
266
        """
267
        from cStringIO import StringIO
268
        from gen_changeset import show_changeset
0.5.78 by John Arbash Meinel
Working on test cases, starting with the empty project issues.
269
        from read_changeset import read_changeset
270
0.5.80 by John Arbash Meinel
Starting to write tests for changeset, discovering some errors as I go.
271
        cset_txt = StringIO()
272
        show_changeset(self.b1, base_rev_id, self.b1, rev_id, to_file=cset_txt)
273
        cset_txt.seek(0)
274
        self.assertEqual(cset_txt.readline(), '# Bazaar-NG changeset v0.0.5\n')
275
        self.assertEqual(cset_txt.readline(), '# \n')
276
277
        rev = self.b1.get_revision(rev_id)
278
        self.assertEqual(cset_txt.readline().decode('utf-8'),
0.5.87 by John Arbash Meinel
Handling international characters, added more test cases.
279
                u'# committer: %s\n' % rev.committer)
280
0.5.80 by John Arbash Meinel
Starting to write tests for changeset, discovering some errors as I go.
281
        open(',,cset', 'wb').write(cset_txt.getvalue())
0.5.83 by John Arbash Meinel
Tests pass. Now ChangesetTree has it's own inventory.
282
        cset_txt.seek(0)
0.5.80 by John Arbash Meinel
Starting to write tests for changeset, discovering some errors as I go.
283
        # This should also validate the generate changeset
284
        cset = read_changeset(cset_txt, self.b1)
285
        info, tree = cset
0.5.83 by John Arbash Meinel
Tests pass. Now ChangesetTree has it's own inventory.
286
        for cset_rev in info.real_revisions:
0.5.80 by John Arbash Meinel
Starting to write tests for changeset, discovering some errors as I go.
287
            # These really should have already been checked in read_changeset
288
            # since it computes the sha1 hash for the revision, which
289
            # only will match if everything is okay, but lets be
290
            # explicit about it
291
            branch_rev = self.b1.get_revision(cset_rev.revision_id)
292
            for a in ('inventory_id', 'inventory_sha1', 'revision_id',
293
                    'timestamp', 'timezone', 'message', 'committer'):
294
                self.assertEqual(getattr(branch_rev, a), getattr(cset_rev, a))
295
            self.assertEqual(len(branch_rev.parents), len(cset_rev.parents))
296
            for b_par, c_par in zip(branch_rev.parents, cset_rev.parents):
297
                self.assertEqual(b_par.revision_id, c_par.revision_id)
298
                # Foolishly, pending-merges generates parents which
299
                # may not have revision entries
300
                if b_par.revision_sha1 is None:
301
                    if b_par.revision_id in self.b1.revision_store:
302
                        sha1 = self.b1.get_revision_sha1(b_par.revision_id)
303
                    else:
304
                        sha1 = None
305
                else:
306
                    sha1 = b_par.revision_sha1
307
                if sha1 is not None:
308
                    self.assertEqual(sha1, c_par.revision_sha1)
309
310
        self.valid_apply_changeset(base_rev_id, cset,
0.5.88 by John Arbash Meinel
Fixed a bug in the rename code, added more tests.
311
                auto_commit=auto_commit, checkout_dir=checkout_dir)
312
0.5.80 by John Arbash Meinel
Starting to write tests for changeset, discovering some errors as I go.
313
        return cset
0.5.83 by John Arbash Meinel
Tests pass. Now ChangesetTree has it's own inventory.
314
0.5.80 by John Arbash Meinel
Starting to write tests for changeset, discovering some errors as I go.
315
    def get_checkout(self, rev_id, checkout_dir=None):
0.5.88 by John Arbash Meinel
Fixed a bug in the rename code, added more tests.
316
        """Get a new tree, with the specified revision in it.
0.5.80 by John Arbash Meinel
Starting to write tests for changeset, discovering some errors as I go.
317
        """
318
        from bzrlib.branch import find_branch
319
        import tempfile
320
        from bzrlib.merge import merge
321
322
        if checkout_dir is None:
0.5.88 by John Arbash Meinel
Fixed a bug in the rename code, added more tests.
323
            checkout_dir = tempfile.mkdtemp(prefix='test-branch-', dir='.')
324
        else:
0.5.89 by John Arbash Meinel
Updating for explicitly defined directories.
325
            import os
326
            if not os.path.exists(checkout_dir):
327
                os.mkdir(checkout_dir)
328
        to_branch = find_branch(checkout_dir, init=True)
0.5.88 by John Arbash Meinel
Fixed a bug in the rename code, added more tests.
329
        # TODO: Once root ids are established, remove this if
0.5.80 by John Arbash Meinel
Starting to write tests for changeset, discovering some errors as I go.
330
        if hasattr(self.b1, 'get_root_id'):
331
            to_branch.set_root_id(self.b1.get_root_id())
332
        if rev_id is not None:
333
            # TODO Worry about making the root id of the branch
334
            # the same
335
            rh = self.b1.revision_history()
336
            self.assert_(rev_id in rh, 'Missing revision %s in base tree' % rev_id)
337
            revno = self.b1.revision_history().index(rev_id) + 1
338
            to_branch.update_revisions(self.b1, stop_revision=revno)
339
            merge((checkout_dir, -1), (checkout_dir, 0), this_dir=checkout_dir,
0.5.88 by John Arbash Meinel
Fixed a bug in the rename code, added more tests.
340
                    check_clean=False, ignore_zero=True)
0.5.80 by John Arbash Meinel
Starting to write tests for changeset, discovering some errors as I go.
341
        return to_branch
342
343
    def valid_apply_changeset(self, base_rev_id, cset,
0.5.88 by John Arbash Meinel
Fixed a bug in the rename code, added more tests.
344
            auto_commit=False, checkout_dir=None):
345
        """Get the base revision, apply the changes, and make
0.5.80 by John Arbash Meinel
Starting to write tests for changeset, discovering some errors as I go.
346
        sure everything matches the builtin branch.
347
        """
348
        from apply_changeset import _apply_cset
349
350
        to_branch = self.get_checkout(base_rev_id, checkout_dir=checkout_dir)
0.5.88 by John Arbash Meinel
Fixed a bug in the rename code, added more tests.
351
        auto_committed = _apply_cset(to_branch, cset, auto_commit=auto_commit)
0.5.86 by John Arbash Meinel
Updated the auto-commit functionality, and adding to pending-merges, more testing.
352
0.5.80 by John Arbash Meinel
Starting to write tests for changeset, discovering some errors as I go.
353
        info = cset[0]
354
        for rev in info.real_revisions:
355
            self.assert_(rev.revision_id in to_branch.revision_store,
356
                'Missing revision {%s} after applying changeset' 
357
                % rev.revision_id)
358
359
        self.assert_(info.target in to_branch.inventory_store)
0.5.86 by John Arbash Meinel
Updated the auto-commit functionality, and adding to pending-merges, more testing.
360
        for file_id, ie in to_branch.get_inventory(info.target).iter_entries():
361
            if hasattr(ie, 'text_id') and ie.text_id is not None:
362
                self.assert_(ie.text_id in to_branch.text_store)
363
364
365
        # Don't call get_valid_cset(auto_commit=True) unless you
366
        # expect the auto-commit to succeed.
367
        self.assertEqual(auto_commit, auto_committed)
368
369
        if auto_committed:
370
            # We might also check that all revisions are in the
371
            # history for some changeset applications which
372
            # merge multiple revisions.
373
            self.assertEqual(to_branch.last_patch(), info.target)
374
        else:
375
            self.assert_(info.target in to_branch.pending_merges())
376
377
378
        rev = info.real_revisions[-1]
0.5.80 by John Arbash Meinel
Starting to write tests for changeset, discovering some errors as I go.
379
        base_tree = self.b1.revision_tree(rev.revision_id)
380
        to_tree = to_branch.revision_tree(rev.revision_id)
381
        
382
        # TODO: make sure the target tree is identical to base tree
383
        #       we might also check the working tree.
0.5.86 by John Arbash Meinel
Updated the auto-commit functionality, and adding to pending-merges, more testing.
384
385
        base_files = list(base_tree.list_files())
386
        to_files = list(to_tree.list_files())
387
        self.assertEqual(len(base_files), len(to_files))
388
        self.assertEqual(base_files, to_files)
389
390
        for path, status, kind, fileid in base_files:
391
            # Check that the meta information is the same
392
            self.assertEqual(base_tree.get_file_size(fileid),
393
                    to_tree.get_file_size(fileid))
394
            self.assertEqual(base_tree.get_file_sha1(fileid),
395
                    to_tree.get_file_sha1(fileid))
396
            # Check that the contents are the same
397
            # This is pretty expensive
398
            # self.assertEqual(base_tree.get_file(fileid).read(),
399
            #         to_tree.get_file(fileid).read())
400
0.5.80 by John Arbash Meinel
Starting to write tests for changeset, discovering some errors as I go.
401
    def runTest(self):
0.5.81 by John Arbash Meinel
Cleaning up from pychecker.
402
        from bzrlib.branch import find_branch
0.5.80 by John Arbash Meinel
Starting to write tests for changeset, discovering some errors as I go.
403
        import common
0.5.78 by John Arbash Meinel
Working on test cases, starting with the empty project issues.
404
405
        import os, sys
0.5.80 by John Arbash Meinel
Starting to write tests for changeset, discovering some errors as I go.
406
        pjoin = os.path.join
0.5.78 by John Arbash Meinel
Working on test cases, starting with the empty project issues.
407
408
        os.mkdir('b1')
409
        self.b1 = find_branch('b1', init=True)
410
411
        open(pjoin('b1/one'), 'wb').write('one\n')
412
        self.b1.add('one')
413
        self.b1.commit('add one', rev_id='a@cset-0-1')
414
415
        cset = self.get_valid_cset(None, 'a@cset-0-1')
0.5.80 by John Arbash Meinel
Starting to write tests for changeset, discovering some errors as I go.
416
417
        # Make sure we can handle files with spaces, tabs, other
418
        # bogus characters
419
        self.build_tree([
0.5.82 by John Arbash Meinel
Lots of changes, changing separators, updating tests, updated ChangesetTree to include text_ids
420
                'b1/with space.txt'
0.5.84 by John Arbash Meinel
(broken) problem with removes.
421
                , 'b1/dir/'
422
                , 'b1/dir/filein subdir.c'
423
                , 'b1/dir/WithCaps.txt'
424
                , 'b1/dir/trailing space '
0.5.87 by John Arbash Meinel
Handling international characters, added more test cases.
425
                , 'b1/sub/'
0.5.84 by John Arbash Meinel
(broken) problem with removes.
426
                , 'b1/sub/sub/'
427
                , 'b1/sub/sub/nonempty.txt'
428
                # Tabs are not valid in filenames on windows
0.5.82 by John Arbash Meinel
Lots of changes, changing separators, updating tests, updated ChangesetTree to include text_ids
429
                #'b1/with\ttab.txt'
430
                ])
431
        open('b1/sub/sub/emptyfile.txt', 'wb').close()
0.5.84 by John Arbash Meinel
(broken) problem with removes.
432
        open('b1/dir/nolastnewline.txt', 'wb').write('bloop')
0.5.94 by Aaron Bentley
Switched to native patch application, added tests for terminating newlines
433
        self.b1.add([
0.5.82 by John Arbash Meinel
Lots of changes, changing separators, updating tests, updated ChangesetTree to include text_ids
434
                'with space.txt'
0.5.84 by John Arbash Meinel
(broken) problem with removes.
435
                , 'dir'
436
                , 'dir/filein subdir.c'
437
                , 'dir/WithCaps.txt'
438
                , 'dir/trailing space '
0.5.87 by John Arbash Meinel
Handling international characters, added more test cases.
439
                , 'dir/nolastnewline.txt'
0.5.94 by Aaron Bentley
Switched to native patch application, added tests for terminating newlines
440
                , 'sub'
0.5.84 by John Arbash Meinel
(broken) problem with removes.
441
                , 'sub/sub'
442
                , 'sub/sub/nonempty.txt'
443
                , 'sub/sub/emptyfile.txt'
444
                ])
0.5.82 by John Arbash Meinel
Lots of changes, changing separators, updating tests, updated ChangesetTree to include text_ids
445
        self.b1.commit('add whitespace', rev_id='a@cset-0-2')
0.5.80 by John Arbash Meinel
Starting to write tests for changeset, discovering some errors as I go.
446
447
        cset = self.get_valid_cset('a@cset-0-1', 'a@cset-0-2')
448
        cset = self.get_valid_cset('a@cset-0-1', 'a@cset-0-2', auto_commit=True)
0.5.86 by John Arbash Meinel
Updated the auto-commit functionality, and adding to pending-merges, more testing.
449
        # Check a rollup changeset
0.5.80 by John Arbash Meinel
Starting to write tests for changeset, discovering some errors as I go.
450
        cset = self.get_valid_cset(None, 'a@cset-0-2')
451
        cset = self.get_valid_cset(None, 'a@cset-0-2', auto_commit=True)
0.5.86 by John Arbash Meinel
Updated the auto-commit functionality, and adding to pending-merges, more testing.
452
0.5.84 by John Arbash Meinel
(broken) problem with removes.
453
        # Now delete entries
454
        self.b1.remove(['sub/sub/nonempty.txt'
455
                , 'sub/sub/emptyfile.txt'
456
                , 'sub/sub'])
457
        self.b1.commit('removed', rev_id='a@cset-0-3')
458
        
0.5.80 by John Arbash Meinel
Starting to write tests for changeset, discovering some errors as I go.
459
        cset = self.get_valid_cset('a@cset-0-2', 'a@cset-0-3')
0.5.84 by John Arbash Meinel
(broken) problem with removes.
460
        cset = self.get_valid_cset('a@cset-0-2', 'a@cset-0-3', auto_commit=True)
0.5.86 by John Arbash Meinel
Updated the auto-commit functionality, and adding to pending-merges, more testing.
461
        # Check a rollup changeset
0.5.84 by John Arbash Meinel
(broken) problem with removes.
462
        cset = self.get_valid_cset(None, 'a@cset-0-3')
463
        cset = self.get_valid_cset(None, 'a@cset-0-3', auto_commit=True)
0.5.86 by John Arbash Meinel
Updated the auto-commit functionality, and adding to pending-merges, more testing.
464
0.5.84 by John Arbash Meinel
(broken) problem with removes.
465
466
        # Now move the directory
467
        self.b1.rename_one('dir', 'sub/dir')
468
        self.b1.commit('rename dir', rev_id='a@cset-0-4')
0.6.1 by Aaron Bentley
Fleshed out MockTree, fixed all test failures
469
0.5.84 by John Arbash Meinel
(broken) problem with removes.
470
        cset = self.get_valid_cset('a@cset-0-3', 'a@cset-0-4')
471
        # Check a rollup changeset
472
        cset = self.get_valid_cset(None, 'a@cset-0-4')
473
        cset = self.get_valid_cset(None, 'a@cset-0-4', auto_commit=True)
0.5.86 by John Arbash Meinel
Updated the auto-commit functionality, and adding to pending-merges, more testing.
474
        cset = self.get_valid_cset('a@cset-0-1', 'a@cset-0-4', auto_commit=True)
475
        cset = self.get_valid_cset('a@cset-0-2', 'a@cset-0-4', auto_commit=True)
476
        cset = self.get_valid_cset('a@cset-0-3', 'a@cset-0-4', auto_commit=True)
477
0.5.84 by John Arbash Meinel
(broken) problem with removes.
478
        # Modified files
0.5.87 by John Arbash Meinel
Handling international characters, added more test cases.
479
        open('b1/sub/dir/WithCaps.txt', 'ab').write('\nAdding some text\n')
480
        open('b1/sub/dir/trailing space ', 'ab').write('\nAdding some\nDOS format lines\n')
0.5.88 by John Arbash Meinel
Fixed a bug in the rename code, added more tests.
481
        open('b1/sub/dir/nolastnewline.txt', 'ab').write('\n')
0.5.94 by Aaron Bentley
Switched to native patch application, added tests for terminating newlines
482
        self.b1.rename_one('sub/dir/trailing space ', 'sub/ start and end space ')
0.5.88 by John Arbash Meinel
Fixed a bug in the rename code, added more tests.
483
        self.b1.commit('Modified files', rev_id='a@cset-0-5')
0.5.87 by John Arbash Meinel
Handling international characters, added more test cases.
484
        cset = self.get_valid_cset('a@cset-0-4', 'a@cset-0-5')
0.5.89 by John Arbash Meinel
Updating for explicitly defined directories.
485
        cset = self.get_valid_cset('a@cset-0-4', 'a@cset-0-5', auto_commit=True)
0.5.87 by John Arbash Meinel
Handling international characters, added more test cases.
486
        cset = self.get_valid_cset(None, 'a@cset-0-5', auto_commit=True)
487
488
        # Handle international characters
489
        f = open(u'b1/with Dod\xe9', 'wb')
490
        f.write((u'A file\n'
491
            u'With international man of mystery\n'
492
            u'William Dod\xe9\n').encode('utf-8'))
493
        self.b1.add([u'with Dod\xe9'])
494
        # BUG: (sort of) You must set verbose=False, so that python doesn't try
495
        #       and print the name of William Dode as part of the commit
496
        self.b1.commit(u'i18n commit from William Dod\xe9', rev_id='a@cset-0-6',
497
                committer=u'William Dod\xe9', verbose=False)
498
        cset = self.get_valid_cset('a@cset-0-5', 'a@cset-0-6')
499
        cset = self.get_valid_cset('a@cset-0-5', 'a@cset-0-6', auto_commit=True)
500
        cset = self.get_valid_cset(None, 'a@cset-0-6', auto_commit=True)
501
502
503
504
TEST_CLASSES = [
0.5.78 by John Arbash Meinel
Working on test cases, starting with the empty project issues.
505
    CTreeTester,
506
    CSetTester
507
]
508
0.5.66 by John Arbash Meinel
Refactoring, moving test code into test (switching back to assert is None)
509