bzr branch
http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar
| 
768
by Martin Pool
 - start some tests for directory renames  | 
1  | 
import os  | 
2  | 
import unittest  | 
|
3  | 
||
| 
1185.31.25
by John Arbash Meinel
 Renamed all of the tests from selftest/foo.py to tests/test_foo.py  | 
4  | 
from bzrlib.tests import TestCaseInTempDir, TestCase  | 
| 
768
by Martin Pool
 - start some tests for directory renames  | 
5  | 
from bzrlib.branch import ScratchBranch, Branch  | 
| 
1185.31.42
by John Arbash Meinel
 Updated whitebox text for new PathNotChild exception  | 
6  | 
from bzrlib.errors import PathNotChild  | 
| 
1185.31.37
by John Arbash Meinel
 Switched os.path.abspath and os.path.realpath to osutils.* (still passes on cygwin)  | 
7  | 
from bzrlib.osutils import relpath, pathjoin, abspath, realpath  | 
| 
778
by Martin Pool
 - simple revert of text files  | 
8  | 
|
9  | 
||
| 
1141
by Martin Pool
 - rename FunctionalTest to TestCaseInTempDir  | 
10  | 
class TestBranch(TestCaseInTempDir):  | 
| 
1102
by Martin Pool
 - merge test refactoring from robertc  | 
11  | 
|
12  | 
def test_no_changes(self):  | 
|
| 
885
by Martin Pool
 - commit command refuses unless something is changed or --unchanged is given  | 
13  | 
from bzrlib.errors import PointlessCommit  | 
| 
882
by Martin Pool
 - Optionally raise EmptyCommit if there are no changes. Test for this.  | 
14  | 
|
| 
1185.33.66
by Martin Pool
 [patch] use unicode literals for all hardcoded paths (Alexander Belchenko)  | 
15  | 
b = Branch.initialize(u'.')  | 
| 
882
by Martin Pool
 - Optionally raise EmptyCommit if there are no changes. Test for this.  | 
16  | 
|
17  | 
self.build_tree(['hello.txt'])  | 
|
18  | 
||
| 
885
by Martin Pool
 - commit command refuses unless something is changed or --unchanged is given  | 
19  | 
self.assertRaises(PointlessCommit,  | 
| 
1457.1.17
by Robert Collins
 Branch.commit() has moved to WorkingTree.commit(). (Robert Collins)  | 
20  | 
b.working_tree().commit,  | 
| 
882
by Martin Pool
 - Optionally raise EmptyCommit if there are no changes. Test for this.  | 
21  | 
'commit without adding',  | 
| 
885
by Martin Pool
 - commit command refuses unless something is changed or --unchanged is given  | 
22  | 
allow_pointless=False)  | 
| 
882
by Martin Pool
 - Optionally raise EmptyCommit if there are no changes. Test for this.  | 
23  | 
|
| 
1457.1.17
by Robert Collins
 Branch.commit() has moved to WorkingTree.commit(). (Robert Collins)  | 
24  | 
b.working_tree().commit('commit pointless tree',  | 
| 
885
by Martin Pool
 - commit command refuses unless something is changed or --unchanged is given  | 
25  | 
allow_pointless=True)  | 
| 
883
by Martin Pool
 - more tests for detecting empty commits  | 
26  | 
|
| 
1508.1.5
by Robert Collins
 Move add from Branch to WorkingTree.  | 
27  | 
b.working_tree().add('hello.txt')  | 
| 
883
by Martin Pool
 - more tests for detecting empty commits  | 
28  | 
|
| 
1457.1.17
by Robert Collins
 Branch.commit() has moved to WorkingTree.commit(). (Robert Collins)  | 
29  | 
b.working_tree().commit('commit first added file',  | 
| 
885
by Martin Pool
 - commit command refuses unless something is changed or --unchanged is given  | 
30  | 
allow_pointless=False)  | 
| 
883
by Martin Pool
 - more tests for detecting empty commits  | 
31  | 
|
| 
885
by Martin Pool
 - commit command refuses unless something is changed or --unchanged is given  | 
32  | 
self.assertRaises(PointlessCommit,  | 
| 
1457.1.17
by Robert Collins
 Branch.commit() has moved to WorkingTree.commit(). (Robert Collins)  | 
33  | 
b.working_tree().commit,  | 
| 
883
by Martin Pool
 - more tests for detecting empty commits  | 
34  | 
'commit after adding file',  | 
| 
885
by Martin Pool
 - commit command refuses unless something is changed or --unchanged is given  | 
35  | 
allow_pointless=False)  | 
| 
883
by Martin Pool
 - more tests for detecting empty commits  | 
36  | 
|
| 
1457.1.17
by Robert Collins
 Branch.commit() has moved to WorkingTree.commit(). (Robert Collins)  | 
37  | 
b.working_tree().commit('commit pointless revision with one file',  | 
| 
885
by Martin Pool
 - commit command refuses unless something is changed or --unchanged is given  | 
38  | 
allow_pointless=True)  | 
| 
883
by Martin Pool
 - more tests for detecting empty commits  | 
39  | 
|
| 
811
by Martin Pool
 - Test case for validate_revision_id  | 
40  | 
|
| 
1278
by Martin Pool
 - remove test that tried to commit absent parents  | 
41  | 
class MoreTests(TestCaseInTempDir):  | 
| 
1390
by Robert Collins
 pair programming worx... merge integration and weave  | 
42  | 
|
| 
1102
by Martin Pool
 - merge test refactoring from robertc  | 
43  | 
def test_rename_dirs(self):  | 
44  | 
"""Test renaming directories and the files within them."""  | 
|
| 
1185.33.66
by Martin Pool
 [patch] use unicode literals for all hardcoded paths (Alexander Belchenko)  | 
45  | 
b = Branch.initialize(u'.')  | 
| 
768
by Martin Pool
 - start some tests for directory renames  | 
46  | 
self.build_tree(['dir/', 'dir/sub/', 'dir/sub/file'])  | 
| 
1508.1.5
by Robert Collins
 Move add from Branch to WorkingTree.  | 
47  | 
b.working_tree().add(['dir', 'dir/sub', 'dir/sub/file'])  | 
| 
768
by Martin Pool
 - start some tests for directory renames  | 
48  | 
|
| 
1457.1.17
by Robert Collins
 Branch.commit() has moved to WorkingTree.commit(). (Robert Collins)  | 
49  | 
b.working_tree().commit('create initial state')  | 
| 
768
by Martin Pool
 - start some tests for directory renames  | 
50  | 
|
51  | 
        # TODO: lift out to a test helper that checks the shape of
 | 
|
52  | 
        # an inventory
 | 
|
53  | 
||
54  | 
revid = b.revision_history()[0]  | 
|
55  | 
self.log('first revision_id is {%s}' % revid)  | 
|
56  | 
||
57  | 
inv = b.get_revision_inventory(revid)  | 
|
58  | 
self.log('contents of inventory: %r' % inv.entries())  | 
|
59  | 
||
60  | 
self.check_inventory_shape(inv,  | 
|
61  | 
['dir', 'dir/sub', 'dir/sub/file'])  | 
|
62  | 
||
| 
1508.1.7
by Robert Collins
 Move rename_one from Branch to WorkingTree. (Robert Collins).  | 
63  | 
b.working_tree().rename_one('dir', 'newdir')  | 
| 
771
by Martin Pool
 - more tests of directory renames  | 
64  | 
|
| 
1497
by Robert Collins
 Move Branch.read_working_inventory to WorkingTree.  | 
65  | 
self.check_inventory_shape(b.working_tree().read_working_inventory(),  | 
| 
771
by Martin Pool
 - more tests of directory renames  | 
66  | 
['newdir', 'newdir/sub', 'newdir/sub/file'])  | 
67  | 
||
| 
1508.1.7
by Robert Collins
 Move rename_one from Branch to WorkingTree. (Robert Collins).  | 
68  | 
b.working_tree().rename_one('newdir/sub', 'newdir/newsub')  | 
| 
1497
by Robert Collins
 Move Branch.read_working_inventory to WorkingTree.  | 
69  | 
self.check_inventory_shape(b.working_tree().read_working_inventory(),  | 
| 
771
by Martin Pool
 - more tests of directory renames  | 
70  | 
['newdir', 'newdir/newsub',  | 
71  | 
'newdir/newsub/file'])  | 
|
72  | 
||
| 
1102
by Martin Pool
 - merge test refactoring from robertc  | 
73  | 
def test_relpath(self):  | 
74  | 
"""test for branch path lookups  | 
|
75  | 
    
 | 
|
| 
1457.1.2
by Robert Collins
 move branch._relpath into osutils as relpath  | 
76  | 
        bzrlib.osutils._relpath do a simple but subtle
 | 
| 
1102
by Martin Pool
 - merge test refactoring from robertc  | 
77  | 
        job: given a path (either relative to cwd or absolute), work out
 | 
78  | 
        if it is inside a branch and return the path relative to the base.
 | 
|
79  | 
        """
 | 
|
| 
601
by Martin Pool
 - whitebox tests for branch path handling  | 
80  | 
import tempfile, shutil  | 
81  | 
||
82  | 
savedir = os.getcwdu()  | 
|
83  | 
dtmp = tempfile.mkdtemp()  | 
|
| 
907.1.7
by John Arbash Meinel
 Fixed test failure on Mac OSX.  | 
84  | 
        # On Mac OSX, /tmp actually expands to /private/tmp
 | 
| 
1185.31.37
by John Arbash Meinel
 Switched os.path.abspath and os.path.realpath to osutils.* (still passes on cygwin)  | 
85  | 
dtmp = realpath(dtmp)  | 
| 
601
by Martin Pool
 - whitebox tests for branch path handling  | 
86  | 
|
87  | 
def rp(p):  | 
|
| 
1457.1.2
by Robert Collins
 move branch._relpath into osutils as relpath  | 
88  | 
return relpath(dtmp, p)  | 
| 
601
by Martin Pool
 - whitebox tests for branch path handling  | 
89  | 
|
90  | 
try:  | 
|
91  | 
            # check paths inside dtmp while standing outside it
 | 
|
| 
1185.31.33
by John Arbash Meinel
 A couple more path.join statements needed changing.  | 
92  | 
self.assertEqual(rp(pathjoin(dtmp, 'foo')), 'foo')  | 
| 
601
by Martin Pool
 - whitebox tests for branch path handling  | 
93  | 
|
94  | 
            # root = nothing
 | 
|
95  | 
self.assertEqual(rp(dtmp), '')  | 
|
96  | 
||
| 
1185.31.42
by John Arbash Meinel
 Updated whitebox text for new PathNotChild exception  | 
97  | 
self.assertRaises(PathNotChild,  | 
| 
601
by Martin Pool
 - whitebox tests for branch path handling  | 
98  | 
rp,  | 
99  | 
'/etc')  | 
|
100  | 
||
101  | 
            # now some near-miss operations -- note that
 | 
|
102  | 
            # os.path.commonprefix gets these wrong!
 | 
|
| 
1185.31.42
by John Arbash Meinel
 Updated whitebox text for new PathNotChild exception  | 
103  | 
self.assertRaises(PathNotChild,  | 
| 
601
by Martin Pool
 - whitebox tests for branch path handling  | 
104  | 
rp,  | 
105  | 
dtmp.rstrip('\\/') + '2')  | 
|
106  | 
||
| 
1185.31.42
by John Arbash Meinel
 Updated whitebox text for new PathNotChild exception  | 
107  | 
self.assertRaises(PathNotChild,  | 
| 
601
by Martin Pool
 - whitebox tests for branch path handling  | 
108  | 
rp,  | 
109  | 
dtmp.rstrip('\\/') + '2/foo')  | 
|
110  | 
||
111  | 
            # now operations based on relpath of files in current
 | 
|
112  | 
            # directory, or nearby
 | 
|
113  | 
os.chdir(dtmp)  | 
|
114  | 
||
| 
1185.31.33
by John Arbash Meinel
 A couple more path.join statements needed changing.  | 
115  | 
self.assertEqual(rp('foo/bar/quux'), 'foo/bar/quux')  | 
| 
601
by Martin Pool
 - whitebox tests for branch path handling  | 
116  | 
|
117  | 
self.assertEqual(rp('foo'), 'foo')  | 
|
118  | 
||
119  | 
self.assertEqual(rp('./foo'), 'foo')  | 
|
120  | 
||
| 
1185.31.37
by John Arbash Meinel
 Switched os.path.abspath and os.path.realpath to osutils.* (still passes on cygwin)  | 
121  | 
self.assertEqual(rp(abspath('foo')), 'foo')  | 
| 
601
by Martin Pool
 - whitebox tests for branch path handling  | 
122  | 
|
| 
1185.31.42
by John Arbash Meinel
 Updated whitebox text for new PathNotChild exception  | 
123  | 
self.assertRaises(PathNotChild,  | 
| 
601
by Martin Pool
 - whitebox tests for branch path handling  | 
124  | 
rp, '../foo')  | 
125  | 
||
126  | 
finally:  | 
|
127  | 
os.chdir(savedir)  | 
|
128  | 
shutil.rmtree(dtmp)  |