/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/bzrdir.py

  • Committer: John Arbash Meinel
  • Date: 2006-06-22 18:24:25 UTC
  • mfrom: (1803 +trunk)
  • mto: (1793.3.6 bundle-fixes)
  • mto: This revision was merged to the branch mainline in revision 1806.
  • Revision ID: john@arbash-meinel.com-20060622182425-6f45cb7acd587216
[merge] bzr.dev 1804 and fix conflicts.

Show diffs side-by-side

added added

removed removed

Lines of Context:
20
20
directories.
21
21
"""
22
22
 
 
23
# TODO: remove unittest dependency; put that stuff inside the test suite
 
24
 
23
25
from copy import deepcopy
 
26
from cStringIO import StringIO
24
27
import os
25
 
from cStringIO import StringIO
 
28
from stat import S_ISDIR
26
29
from unittest import TestSuite
27
30
 
28
31
import bzrlib
39
42
from bzrlib.store.revision.text import TextRevisionStore
40
43
from bzrlib.store.text import TextStore
41
44
from bzrlib.store.versioned import WeaveStore
42
 
from bzrlib.symbol_versioning import *
43
45
from bzrlib.trace import mutter
44
46
from bzrlib.transactions import WriteTransaction
45
47
from bzrlib.transport import get_transport
92
94
        """
93
95
        if not allow_unsupported and not format.is_supported():
94
96
            # see open_downlevel to open legacy branches.
95
 
            raise errors.UnsupportedFormatError(
96
 
                    'sorry, format %s not supported' % format,
97
 
                    ['use a different bzr version',
98
 
                     'or remove the .bzr directory'
99
 
                     ' and "bzr init" again'])
 
97
            raise errors.UnsupportedFormatError(format=format)
100
98
 
101
99
    def clone(self, url, revision_id=None, basis=None, force_new_repo=False):
102
100
        """Clone this bzrdir and its contents to url verbatim.
978
976
        try:
979
977
            return klass._formats[format_string]
980
978
        except KeyError:
981
 
            raise errors.UnknownFormatError(format_string)
 
979
            raise errors.UnknownFormatError(format=format_string)
982
980
 
983
981
    @classmethod
984
982
    def get_default_format(klass):
1378
1376
        return result
1379
1377
 
1380
1378
 
1381
 
class ScratchDir(BzrDir6):
1382
 
    """Special test class: a bzrdir that cleans up itself..
1383
 
 
1384
 
    >>> d = ScratchDir()
1385
 
    >>> base = d.transport.base
1386
 
    >>> isdir(base)
1387
 
    True
1388
 
    >>> b.transport.__del__()
1389
 
    >>> isdir(base)
1390
 
    False
1391
 
    """
1392
 
 
1393
 
    def __init__(self, files=[], dirs=[], transport=None):
1394
 
        """Make a test branch.
1395
 
 
1396
 
        This creates a temporary directory and runs init-tree in it.
1397
 
 
1398
 
        If any files are listed, they are created in the working copy.
1399
 
        """
1400
 
        if transport is None:
1401
 
            transport = bzrlib.transport.local.ScratchTransport()
1402
 
            # local import for scope restriction
1403
 
            BzrDirFormat6().initialize(transport.base)
1404
 
            super(ScratchDir, self).__init__(transport, BzrDirFormat6())
1405
 
            self.create_repository()
1406
 
            self.create_branch()
1407
 
            self.create_workingtree()
1408
 
        else:
1409
 
            super(ScratchDir, self).__init__(transport, BzrDirFormat6())
1410
 
 
1411
 
        # BzrBranch creates a clone to .bzr and then forgets about the
1412
 
        # original transport. A ScratchTransport() deletes itself and
1413
 
        # everything underneath it when it goes away, so we need to
1414
 
        # grab a local copy to prevent that from happening
1415
 
        self._transport = transport
1416
 
 
1417
 
        for d in dirs:
1418
 
            self._transport.mkdir(d)
1419
 
            
1420
 
        for f in files:
1421
 
            self._transport.put(f, 'content of %s' % f)
1422
 
 
1423
 
    def clone(self):
1424
 
        """
1425
 
        >>> orig = ScratchDir(files=["file1", "file2"])
1426
 
        >>> os.listdir(orig.base)
1427
 
        [u'.bzr', u'file1', u'file2']
1428
 
        >>> clone = orig.clone()
1429
 
        >>> if os.name != 'nt':
1430
 
        ...   os.path.samefile(orig.base, clone.base)
1431
 
        ... else:
1432
 
        ...   orig.base == clone.base
1433
 
        ...
1434
 
        False
1435
 
        >>> os.listdir(clone.base)
1436
 
        [u'.bzr', u'file1', u'file2']
1437
 
        """
1438
 
        from shutil import copytree
1439
 
        from bzrlib.osutils import mkdtemp
1440
 
        base = mkdtemp()
1441
 
        os.rmdir(base)
1442
 
        copytree(self.base, base, symlinks=True)
1443
 
        return ScratchDir(
1444
 
            transport=bzrlib.transport.local.ScratchTransport(base))
1445
 
 
1446
 
 
1447
1379
class Converter(object):
1448
1380
    """Converts a disk format object from one format to another."""
1449
1381