5557.1.15
by John Arbash Meinel
Merge bzr.dev 5597 to resolve NEWS, aka bzr-2.3.txt |
1 |
# Copyright (C) 2005, 2006, 2008, 2009, 2011 Canonical Ltd
|
1773.4.1
by Martin Pool
Add pyflakes makefile target; fix many warnings |
2 |
#
|
1740.6.1
by Martin Pool
Remove Scratch objects used by doctests |
3 |
# This program is free software; you can redistribute it and/or modify
|
4 |
# it under the terms of the GNU General Public License as published by
|
|
5 |
# the Free Software Foundation; either version 2 of the License, or
|
|
6 |
# (at your option) any later version.
|
|
1773.4.1
by Martin Pool
Add pyflakes makefile target; fix many warnings |
7 |
#
|
1740.6.1
by Martin Pool
Remove Scratch objects used by doctests |
8 |
# This program is distributed in the hope that it will be useful,
|
9 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
10 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
11 |
# GNU General Public License for more details.
|
|
1773.4.1
by Martin Pool
Add pyflakes makefile target; fix many warnings |
12 |
#
|
1740.6.1
by Martin Pool
Remove Scratch objects used by doctests |
13 |
# You should have received a copy of the GNU General Public License
|
14 |
# along with this program; if not, write to the Free Software
|
|
4183.7.1
by Sabin Iacob
update FSF mailing address |
15 |
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
1740.6.1
by Martin Pool
Remove Scratch objects used by doctests |
16 |
|
768
by Martin Pool
- start some tests for directory renames |
17 |
import os |
18 |
||
1996.3.18
by John Arbash Meinel
Now that mkdtemp and rmtree are lazy, they should not be directly improted. |
19 |
from bzrlib import ( |
20 |
osutils, |
|
21 |
)
|
|
5579.3.1
by Jelmer Vernooij
Remove unused imports. |
22 |
from bzrlib.tests import TestCaseWithTransport |
1185.31.42
by John Arbash Meinel
Updated whitebox text for new PathNotChild exception |
23 |
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) |
24 |
from bzrlib.osutils import relpath, pathjoin, abspath, realpath |
778
by Martin Pool
- simple revert of text files |
25 |
|
26 |
||
1534.4.26
by Robert Collins
Move working tree initialisation out from Branch.initialize, deprecated Branch.initialize to Branch.create. |
27 |
class MoreTests(TestCaseWithTransport): |
771
by Martin Pool
- more tests of directory renames |
28 |
|
1102
by Martin Pool
- merge test refactoring from robertc |
29 |
def test_relpath(self): |
30 |
"""test for branch path lookups
|
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
31 |
|
1457.1.2
by Robert Collins
move branch._relpath into osutils as relpath |
32 |
bzrlib.osutils._relpath do a simple but subtle
|
1102
by Martin Pool
- merge test refactoring from robertc |
33 |
job: given a path (either relative to cwd or absolute), work out
|
34 |
if it is inside a branch and return the path relative to the base.
|
|
35 |
"""
|
|
1692.7.6
by Martin Pool
[patch] force deletion of trees containing readonly files (alexander) |
36 |
import tempfile |
3638.3.2
by Vincent Ladeuil
Fix all calls to tempfile.mkdtemp to osutils.mkdtemp. |
37 |
|
601
by Martin Pool
- whitebox tests for branch path handling |
38 |
savedir = os.getcwdu() |
3638.3.2
by Vincent Ladeuil
Fix all calls to tempfile.mkdtemp to osutils.mkdtemp. |
39 |
dtmp = osutils.mkdtemp() |
907.1.7
by John Arbash Meinel
Fixed test failure on Mac OSX. |
40 |
# 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) |
41 |
dtmp = realpath(dtmp) |
601
by Martin Pool
- whitebox tests for branch path handling |
42 |
|
43 |
def rp(p): |
|
1457.1.2
by Robert Collins
move branch._relpath into osutils as relpath |
44 |
return relpath(dtmp, p) |
3638.3.2
by Vincent Ladeuil
Fix all calls to tempfile.mkdtemp to osutils.mkdtemp. |
45 |
|
601
by Martin Pool
- whitebox tests for branch path handling |
46 |
try: |
47 |
# check paths inside dtmp while standing outside it
|
|
1185.31.33
by John Arbash Meinel
A couple more path.join statements needed changing. |
48 |
self.assertEqual(rp(pathjoin(dtmp, 'foo')), 'foo') |
601
by Martin Pool
- whitebox tests for branch path handling |
49 |
|
50 |
# root = nothing
|
|
51 |
self.assertEqual(rp(dtmp), '') |
|
52 |
||
1185.31.42
by John Arbash Meinel
Updated whitebox text for new PathNotChild exception |
53 |
self.assertRaises(PathNotChild, |
601
by Martin Pool
- whitebox tests for branch path handling |
54 |
rp, |
55 |
'/etc') |
|
56 |
||
57 |
# now some near-miss operations -- note that
|
|
58 |
# os.path.commonprefix gets these wrong!
|
|
1185.31.42
by John Arbash Meinel
Updated whitebox text for new PathNotChild exception |
59 |
self.assertRaises(PathNotChild, |
601
by Martin Pool
- whitebox tests for branch path handling |
60 |
rp, |
61 |
dtmp.rstrip('\\/') + '2') |
|
62 |
||
1185.31.42
by John Arbash Meinel
Updated whitebox text for new PathNotChild exception |
63 |
self.assertRaises(PathNotChild, |
601
by Martin Pool
- whitebox tests for branch path handling |
64 |
rp, |
65 |
dtmp.rstrip('\\/') + '2/foo') |
|
66 |
||
67 |
# now operations based on relpath of files in current
|
|
68 |
# directory, or nearby
|
|
69 |
os.chdir(dtmp) |
|
70 |
||
1185.31.33
by John Arbash Meinel
A couple more path.join statements needed changing. |
71 |
self.assertEqual(rp('foo/bar/quux'), 'foo/bar/quux') |
601
by Martin Pool
- whitebox tests for branch path handling |
72 |
|
73 |
self.assertEqual(rp('foo'), 'foo') |
|
74 |
||
75 |
self.assertEqual(rp('./foo'), 'foo') |
|
76 |
||
1185.31.37
by John Arbash Meinel
Switched os.path.abspath and os.path.realpath to osutils.* (still passes on cygwin) |
77 |
self.assertEqual(rp(abspath('foo')), 'foo') |
601
by Martin Pool
- whitebox tests for branch path handling |
78 |
|
1185.31.42
by John Arbash Meinel
Updated whitebox text for new PathNotChild exception |
79 |
self.assertRaises(PathNotChild, |
601
by Martin Pool
- whitebox tests for branch path handling |
80 |
rp, '../foo') |
81 |
||
82 |
finally: |
|
83 |
os.chdir(savedir) |
|
1996.3.18
by John Arbash Meinel
Now that mkdtemp and rmtree are lazy, they should not be directly improted. |
84 |
osutils.rmtree(dtmp) |