/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 breezy/transform.py

  • Committer: Breezy landing bot
  • Author(s): Jelmer Vernooij
  • Date: 2019-06-04 00:08:59 UTC
  • mfrom: (7122.6.12 win-symlink-warning)
  • Revision ID: breezy.the.bot@gmail.com-20190604000859-2xwms4tkctrj83dm
Allow symbolic links to exist when checking out trees on Windows.

Merged from https://code.launchpad.net/~jelmer/brz/win-symlink-warning/+merge/363900

Show diffs side-by-side

added added

removed removed

Lines of Context:
52
52
""")
53
53
from .errors import (DuplicateKey, MalformedTransform,
54
54
                     ReusingTransform, CantMoveRoot,
55
 
                     ImmortalLimbo, NoFinalPath,
56
 
                     UnableCreateSymlink)
 
55
                     ImmortalLimbo, NoFinalPath)
57
56
from .filters import filtered_output_bytes, ContentFilterContext
58
57
from .mutabletree import MutableTree
59
58
from .osutils import (
60
59
    delete_any,
61
60
    file_kind,
62
 
    has_symlinks,
63
61
    pathjoin,
64
62
    sha_file,
65
63
    splitpath,
 
64
    supports_symlinks,
66
65
    )
67
66
from .progress import ProgressPhase
68
67
from .sixish import (
653
652
        conflicts = []
654
653
        for trans_id in self._new_id:
655
654
            kind = self.final_kind(trans_id)
 
655
            if kind == 'symlink' and not self._tree.supports_symlinks():
 
656
                # Ignore symlinks as they are not supported on this platform
 
657
                continue
656
658
            if kind is None:
657
659
                conflicts.append(('versioning no contents', trans_id))
658
660
                continue
1201
1203
class DiskTreeTransform(TreeTransformBase):
1202
1204
    """Tree transform storing its contents on disk."""
1203
1205
 
1204
 
    def __init__(self, tree, limbodir, pb=None,
1205
 
                 case_sensitive=True):
 
1206
    def __init__(self, tree, limbodir, pb=None, case_sensitive=True):
1206
1207
        """Constructor.
1207
1208
        :param tree: The tree that will be transformed, but not necessarily
1208
1209
            the output tree.
1226
1227
        # List of transform ids that need to be renamed from limbo into place
1227
1228
        self._needs_rename = set()
1228
1229
        self._creation_mtime = None
 
1230
        self._create_symlinks = osutils.supports_symlinks(self._limbodir)
1229
1231
 
1230
1232
    def finalize(self):
1231
1233
        """Release the working tree lock, if held, clean up limbo dir.
1263
1265
 
1264
1266
    def _limbo_supports_executable(self):
1265
1267
        """Check if the limbo path supports the executable bit."""
1266
 
        # FIXME: Check actual file system capabilities of limbodir
1267
 
        return osutils.supports_executable()
 
1268
        return osutils.supports_executable(self._limbodir)
1268
1269
 
1269
1270
    def _limbo_name(self, trans_id):
1270
1271
        """Generate the limbo name of a file"""
1396
1397
        target is a bytestring.
1397
1398
        See also new_symlink.
1398
1399
        """
1399
 
        if has_symlinks():
 
1400
        if self._create_symlinks:
1400
1401
            os.symlink(target, self._limbo_name(trans_id))
1401
 
            unique_add(self._new_contents, trans_id, 'symlink')
1402
1402
        else:
1403
1403
            try:
1404
1404
                path = FinalPaths(self).get_path(trans_id)
1405
1405
            except KeyError:
1406
1406
                path = None
1407
 
            raise UnableCreateSymlink(path=path)
 
1407
            trace.warning(
 
1408
                'Unable to create symlink "%s" on this filesystem.' % (path,))
 
1409
        # We add symlink to _new_contents even if they are unsupported
 
1410
        # and not created. These entries are subsequently used to avoid
 
1411
        # conflicts on platforms that don't support symlink
 
1412
        unique_add(self._new_contents, trans_id, 'symlink')
1408
1413
 
1409
1414
    def cancel_creation(self, trans_id):
1410
1415
        """Cancel the creation of new file contents."""