/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 bzrlib/tests/test_whitebox.py

  • Committer: Michael Ellerman
  • Date: 2006-05-31 08:44:29 UTC
  • mto: (1711.2.63 jam-integration)
  • mto: This revision was merged to the branch mainline in revision 1792.
  • Revision ID: michael@ellerman.id.au-20060531084429-35e5429abda9f560
Add optional location to ancestry and fix behaviour for checkouts.

This adds an optional location parameter to the ancestry command. It also
changes the behaviour of ancestry on checkouts such that if they have
been created with a subset of the branch history, only the subset is
shown by 'bzr ancestry'. Tests for all of that as well.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2005, 2006 Canonical Ltd
2
 
#
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.
7
 
#
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.
12
 
#
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
15
 
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16
 
 
17
1
import os
18
2
import unittest
19
3
 
20
 
from bzrlib import (
21
 
    osutils,
22
 
    )
23
4
from bzrlib.tests import TestCaseWithTransport, TestCase
24
 
from bzrlib.branch import Branch
 
5
from bzrlib.branch import ScratchBranch, Branch
25
6
from bzrlib.errors import PathNotChild
26
7
from bzrlib.osutils import relpath, pathjoin, abspath, realpath
27
8
 
30
11
 
31
12
    def test_relpath(self):
32
13
        """test for branch path lookups
33
 
 
 
14
    
34
15
        bzrlib.osutils._relpath do a simple but subtle
35
16
        job: given a path (either relative to cwd or absolute), work out
36
17
        if it is inside a branch and return the path relative to the base.
37
18
        """
38
19
        import tempfile
39
 
 
 
20
        from bzrlib.osutils import rmtree
 
21
        
40
22
        savedir = os.getcwdu()
41
 
        dtmp = osutils.mkdtemp()
 
23
        dtmp = tempfile.mkdtemp()
42
24
        # On Mac OSX, /tmp actually expands to /private/tmp
43
25
        dtmp = realpath(dtmp)
44
26
 
45
27
        def rp(p):
46
28
            return relpath(dtmp, p)
47
 
 
 
29
        
48
30
        try:
49
31
            # check paths inside dtmp while standing outside it
50
32
            self.assertEqual(rp(pathjoin(dtmp, 'foo')), 'foo')
83
65
 
84
66
        finally:
85
67
            os.chdir(savedir)
86
 
            osutils.rmtree(dtmp)
 
68
            rmtree(dtmp)