~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/__init__.py

merge cicp patch, correct rest syntax and news typo

Show diffs side-by-side

added added

removed removed

Lines of Context:
3348
3348
UTF8Filesystem = _UTF8Filesystem()
3349
3349
 
3350
3350
 
 
3351
class _CaseInsCasePresFilenameFeature(Feature):
 
3352
    """Is the file-system case insensitive, but case-preserving?"""
 
3353
 
 
3354
    def _probe(self):
 
3355
        fileno, name = tempfile.mkstemp(prefix='MixedCase')
 
3356
        try:
 
3357
            # first check truly case-preserving for created files, then check
 
3358
            # case insensitive when opening existing files.
 
3359
            name = osutils.normpath(name)
 
3360
            base, rel = osutils.split(name)
 
3361
            found_rel = osutils.canonical_relpath(base, name)
 
3362
            return (found_rel == rel
 
3363
                    and os.path.isfile(name.upper())
 
3364
                    and os.path.isfile(name.lower()))
 
3365
        finally:
 
3366
            os.close(fileno)
 
3367
            os.remove(name)
 
3368
 
 
3369
    def feature_name(self):
 
3370
        return "case-insensitive case-preserving filesystem"
 
3371
 
 
3372
CaseInsCasePresFilenameFeature = _CaseInsCasePresFilenameFeature()
 
3373
 
 
3374
 
3351
3375
class _CaseInsensitiveFilesystemFeature(Feature):
3352
 
    """Check if underlying filesystem is case-insensitive
3353
 
    (e.g. on Windows, Cygwin, MacOS)
 
3376
    """Check if underlying filesystem is case-insensitive but *not* case
 
3377
    preserving.
3354
3378
    """
 
3379
    # Note that on Windows, Cygwin, MacOS etc, the file-systems are far
 
3380
    # more likely to be case preserving, so this case is rare.
3355
3381
 
3356
3382
    def _probe(self):
 
3383
        if CaseInsCasePresFilenameFeature.available():
 
3384
            return False
 
3385
 
3357
3386
        if TestCaseWithMemoryTransport.TEST_ROOT is None:
3358
3387
            root = osutils.mkdtemp(prefix='testbzr-', suffix='.tmp')
3359
3388
            TestCaseWithMemoryTransport.TEST_ROOT = root