/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,
0.5.103 by John Arbash Meinel
Updated to having a changeset specific message.
261
            auto_commit=False, checkout_dir=None,
262
            message=None):
263
        """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.
264
        Make sure that the text generated is valid, and that it
265
        can be applied against the base, and generate the same information.
266
        
267
        :return: The in-memory changeset
268
        """
269
        from cStringIO import StringIO
270
        from gen_changeset import show_changeset
0.5.78 by John Arbash Meinel
Working on test cases, starting with the empty project issues.
271
        from read_changeset import read_changeset
272
0.5.80 by John Arbash Meinel
Starting to write tests for changeset, discovering some errors as I go.
273
        cset_txt = StringIO()
274
        show_changeset(self.b1, base_rev_id, self.b1, rev_id, to_file=cset_txt,
0.5.103 by John Arbash Meinel
Updated to having a changeset specific message.
275
                message=message)
276
        cset_txt.seek(0)
0.5.80 by John Arbash Meinel
Starting to write tests for changeset, discovering some errors as I go.
277
        self.assertEqual(cset_txt.readline(), '# Bazaar-NG changeset v0.0.5\n')
278
        self.assertEqual(cset_txt.readline(), '# \n')
279
280
        rev = self.b1.get_revision(rev_id)
281
        self.assertEqual(cset_txt.readline().decode('utf-8'),
0.5.87 by John Arbash Meinel
Handling international characters, added more test cases.
282
                u'# committer: %s\n' % rev.committer)
283
0.5.80 by John Arbash Meinel
Starting to write tests for changeset, discovering some errors as I go.
284
        open(',,cset', 'wb').write(cset_txt.getvalue())
0.5.83 by John Arbash Meinel
Tests pass. Now ChangesetTree has it's own inventory.
285
        cset_txt.seek(0)
0.5.80 by John Arbash Meinel
Starting to write tests for changeset, discovering some errors as I go.
286
        # This should also validate the generate changeset
287
        cset = read_changeset(cset_txt, self.b1)
288
        info, tree = cset
0.5.83 by John Arbash Meinel
Tests pass. Now ChangesetTree has it's own inventory.
289
        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.
290
            # These really should have already been checked in read_changeset
291
            # since it computes the sha1 hash for the revision, which
292
            # only will match if everything is okay, but lets be
293
            # explicit about it
294
            branch_rev = self.b1.get_revision(cset_rev.revision_id)
295
            for a in ('inventory_id', 'inventory_sha1', 'revision_id',
296
                    'timestamp', 'timezone', 'message', 'committer'):
297
                self.assertEqual(getattr(branch_rev, a), getattr(cset_rev, a))
298
            self.assertEqual(len(branch_rev.parents), len(cset_rev.parents))
299
            for b_par, c_par in zip(branch_rev.parents, cset_rev.parents):
300
                self.assertEqual(b_par.revision_id, c_par.revision_id)
301
                # Foolishly, pending-merges generates parents which
302
                # may not have revision entries
303
                if b_par.revision_sha1 is None:
304
                    if b_par.revision_id in self.b1.revision_store:
305
                        sha1 = self.b1.get_revision_sha1(b_par.revision_id)
306
                    else:
307
                        sha1 = None
308
                else:
309
                    sha1 = b_par.revision_sha1
310
                if sha1 is not None:
311
                    self.assertEqual(sha1, c_par.revision_sha1)
312
313
        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.
314
                auto_commit=auto_commit, checkout_dir=checkout_dir)
315
0.5.80 by John Arbash Meinel
Starting to write tests for changeset, discovering some errors as I go.
316
        return cset
0.5.83 by John Arbash Meinel
Tests pass. Now ChangesetTree has it's own inventory.
317
0.5.80 by John Arbash Meinel
Starting to write tests for changeset, discovering some errors as I go.
318
    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.
319
        """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.
320
        """
321
        from bzrlib.branch import Branch
0.5.102 by John Arbash Meinel
Updated to latest bzr.dev changes (serialization, test cases, etc)
322
        import tempfile
0.5.80 by John Arbash Meinel
Starting to write tests for changeset, discovering some errors as I go.
323
        from bzrlib.merge import merge
324
325
        if checkout_dir is None:
0.5.88 by John Arbash Meinel
Fixed a bug in the rename code, added more tests.
326
            checkout_dir = tempfile.mkdtemp(prefix='test-branch-', dir='.')
327
        else:
0.5.89 by John Arbash Meinel
Updating for explicitly defined directories.
328
            import os
329
            if not os.path.exists(checkout_dir):
330
                os.mkdir(checkout_dir)
331
        to_branch = Branch.initialize(checkout_dir)
0.5.102 by John Arbash Meinel
Updated to latest bzr.dev changes (serialization, test cases, etc)
332
        # 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.
333
        if hasattr(self.b1, 'get_root_id'):
334
            to_branch.set_root_id(self.b1.get_root_id())
335
        if rev_id is not None:
336
            # TODO Worry about making the root id of the branch
337
            # the same
338
            rh = self.b1.revision_history()
339
            self.assert_(rev_id in rh, 'Missing revision %s in base tree' % rev_id)
340
            revno = self.b1.revision_history().index(rev_id) + 1
341
            to_branch.update_revisions(self.b1, stop_revision=revno)
342
            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.
343
                    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.
344
        return to_branch
345
346
    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.
347
            auto_commit=False, checkout_dir=None):
348
        """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.
349
        sure everything matches the builtin branch.
350
        """
351
        from apply_changeset import _apply_cset
352
353
        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.
354
        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.
355
0.5.80 by John Arbash Meinel
Starting to write tests for changeset, discovering some errors as I go.
356
        info = cset[0]
357
        for rev in info.real_revisions:
358
            self.assert_(rev.revision_id in to_branch.revision_store,
359
                'Missing revision {%s} after applying changeset' 
360
                % rev.revision_id)
361
362
        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.
363
        for file_id, ie in to_branch.get_inventory(info.target).iter_entries():
364
            if hasattr(ie, 'text_id') and ie.text_id is not None:
365
                self.assert_(ie.text_id in to_branch.text_store)
366
367
368
        # Don't call get_valid_cset(auto_commit=True) unless you
369
        # expect the auto-commit to succeed.
370
        self.assertEqual(auto_commit, auto_committed)
371
372
        if auto_committed:
373
            # We might also check that all revisions are in the
374
            # history for some changeset applications which
375
            # merge multiple revisions.
376
            self.assertEqual(to_branch.last_patch(), info.target)
377
        else:
378
            self.assert_(info.target in to_branch.pending_merges())
379
380
381
        rev = info.real_revisions[-1]
0.5.80 by John Arbash Meinel
Starting to write tests for changeset, discovering some errors as I go.
382
        base_tree = self.b1.revision_tree(rev.revision_id)
383
        to_tree = to_branch.revision_tree(rev.revision_id)
384
        
385
        # TODO: make sure the target tree is identical to base tree
386
        #       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.
387
388
        base_files = list(base_tree.list_files())
389
        to_files = list(to_tree.list_files())
390
        self.assertEqual(len(base_files), len(to_files))
391
        self.assertEqual(base_files, to_files)
392
393
        for path, status, kind, fileid in base_files:
394
            # Check that the meta information is the same
395
            self.assertEqual(base_tree.get_file_size(fileid),
396
                    to_tree.get_file_size(fileid))
397
            self.assertEqual(base_tree.get_file_sha1(fileid),
398
                    to_tree.get_file_sha1(fileid))
399
            # Check that the contents are the same
400
            # This is pretty expensive
401
            # self.assertEqual(base_tree.get_file(fileid).read(),
402
            #         to_tree.get_file(fileid).read())
403
0.5.80 by John Arbash Meinel
Starting to write tests for changeset, discovering some errors as I go.
404
    def test_changeset(self):
0.5.102 by John Arbash Meinel
Updated to latest bzr.dev changes (serialization, test cases, etc)
405
        from bzrlib.branch import Branch
406
        import common
0.5.78 by John Arbash Meinel
Working on test cases, starting with the empty project issues.
407
408
        import os, sys
0.5.80 by John Arbash Meinel
Starting to write tests for changeset, discovering some errors as I go.
409
        pjoin = os.path.join
0.5.78 by John Arbash Meinel
Working on test cases, starting with the empty project issues.
410
411
        os.mkdir('b1')
412
        self.b1 = Branch.initialize('b1')
0.5.102 by John Arbash Meinel
Updated to latest bzr.dev changes (serialization, test cases, etc)
413
0.5.78 by John Arbash Meinel
Working on test cases, starting with the empty project issues.
414
        open(pjoin('b1/one'), 'wb').write('one\n')
415
        self.b1.add('one')
416
        self.b1.commit('add one', rev_id='a@cset-0-1')
417
418
        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.
419
        cset = self.get_valid_cset(None, 'a@cset-0-1',
0.5.103 by John Arbash Meinel
Updated to having a changeset specific message.
420
                message='With a specialized message')
421
0.5.80 by John Arbash Meinel
Starting to write tests for changeset, discovering some errors as I go.
422
        # Make sure we can handle files with spaces, tabs, other
423
        # bogus characters
424
        self.build_tree([
0.5.82 by John Arbash Meinel
Lots of changes, changing separators, updating tests, updated ChangesetTree to include text_ids
425
                'b1/with space.txt'
0.5.84 by John Arbash Meinel
(broken) problem with removes.
426
                , 'b1/dir/'
427
                , 'b1/dir/filein subdir.c'
428
                , 'b1/dir/WithCaps.txt'
429
                , 'b1/dir/trailing space '
0.5.87 by John Arbash Meinel
Handling international characters, added more test cases.
430
                , 'b1/sub/'
0.5.84 by John Arbash Meinel
(broken) problem with removes.
431
                , 'b1/sub/sub/'
432
                , 'b1/sub/sub/nonempty.txt'
433
                # 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
434
                #'b1/with\ttab.txt'
435
                ])
436
        open('b1/sub/sub/emptyfile.txt', 'wb').close()
0.5.84 by John Arbash Meinel
(broken) problem with removes.
437
        open('b1/dir/nolastnewline.txt', 'wb').write('bloop')
0.5.94 by Aaron Bentley
Switched to native patch application, added tests for terminating newlines
438
        self.b1.add([
0.5.82 by John Arbash Meinel
Lots of changes, changing separators, updating tests, updated ChangesetTree to include text_ids
439
                'with space.txt'
0.5.84 by John Arbash Meinel
(broken) problem with removes.
440
                , 'dir'
441
                , 'dir/filein subdir.c'
442
                , 'dir/WithCaps.txt'
443
                , 'dir/trailing space '
0.5.87 by John Arbash Meinel
Handling international characters, added more test cases.
444
                , 'dir/nolastnewline.txt'
0.5.94 by Aaron Bentley
Switched to native patch application, added tests for terminating newlines
445
                , 'sub'
0.5.84 by John Arbash Meinel
(broken) problem with removes.
446
                , 'sub/sub'
447
                , 'sub/sub/nonempty.txt'
448
                , 'sub/sub/emptyfile.txt'
449
                ])
0.5.82 by John Arbash Meinel
Lots of changes, changing separators, updating tests, updated ChangesetTree to include text_ids
450
        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.
451
452
        cset = self.get_valid_cset('a@cset-0-1', 'a@cset-0-2')
453
        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.
454
        # Check a rollup changeset
0.5.80 by John Arbash Meinel
Starting to write tests for changeset, discovering some errors as I go.
455
        cset = self.get_valid_cset(None, 'a@cset-0-2')
456
        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.
457
0.5.84 by John Arbash Meinel
(broken) problem with removes.
458
        # Now delete entries
459
        self.b1.remove(['sub/sub/nonempty.txt'
460
                , 'sub/sub/emptyfile.txt'
461
                , 'sub/sub'])
462
        self.b1.commit('removed', rev_id='a@cset-0-3')
463
        
0.5.80 by John Arbash Meinel
Starting to write tests for changeset, discovering some errors as I go.
464
        cset = self.get_valid_cset('a@cset-0-2', 'a@cset-0-3')
0.5.84 by John Arbash Meinel
(broken) problem with removes.
465
        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.
466
        # Check a rollup changeset
0.5.84 by John Arbash Meinel
(broken) problem with removes.
467
        cset = self.get_valid_cset(None, 'a@cset-0-3')
468
        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.
469
0.5.84 by John Arbash Meinel
(broken) problem with removes.
470
471
        # Now move the directory
472
        self.b1.rename_one('dir', 'sub/dir')
473
        self.b1.commit('rename dir', rev_id='a@cset-0-4')
0.6.1 by Aaron Bentley
Fleshed out MockTree, fixed all test failures
474
0.5.84 by John Arbash Meinel
(broken) problem with removes.
475
        cset = self.get_valid_cset('a@cset-0-3', 'a@cset-0-4')
476
        # Check a rollup changeset
477
        cset = self.get_valid_cset(None, 'a@cset-0-4')
478
        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.
479
        cset = self.get_valid_cset('a@cset-0-1', 'a@cset-0-4', auto_commit=True)
480
        cset = self.get_valid_cset('a@cset-0-2', 'a@cset-0-4', auto_commit=True)
481
        cset = self.get_valid_cset('a@cset-0-3', 'a@cset-0-4', auto_commit=True)
482
0.5.84 by John Arbash Meinel
(broken) problem with removes.
483
        # Modified files
0.5.87 by John Arbash Meinel
Handling international characters, added more test cases.
484
        open('b1/sub/dir/WithCaps.txt', 'ab').write('\nAdding some text\n')
485
        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.
486
        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
487
        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.
488
        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.
489
        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.
490
        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.
491
        cset = self.get_valid_cset(None, 'a@cset-0-5', auto_commit=True)
492
493
        # Handle international characters
494
        f = open(u'b1/with Dod\xe9', 'wb')
495
        f.write((u'A file\n'
496
            u'With international man of mystery\n'
497
            u'William Dod\xe9\n').encode('utf-8'))
498
        self.b1.add([u'with Dod\xe9'])
499
        # BUG: (sort of) You must set verbose=False, so that python doesn't try
500
        #       and print the name of William Dode as part of the commit
501
        self.b1.commit(u'i18n commit from William Dod\xe9', rev_id='a@cset-0-6',
502
                committer=u'William Dod\xe9', verbose=False)
503
        cset = self.get_valid_cset('a@cset-0-5', 'a@cset-0-6')
504
        cset = self.get_valid_cset('a@cset-0-5', 'a@cset-0-6', auto_commit=True)
505
        cset = self.get_valid_cset(None, 'a@cset-0-6', auto_commit=True)
506
507
508
509
TEST_CLASSES = [
0.5.78 by John Arbash Meinel
Working on test cases, starting with the empty project issues.
510
    CTreeTester,
511
    CSetTester
512
]
513
0.5.66 by John Arbash Meinel
Refactoring, moving test code into test (switching back to assert is None)
514