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

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2007-11-23 18:44:13 UTC
  • mfrom: (3006.2.5 win32.symlink.workaround)
  • Revision ID: pqm@pqm.ubuntu.com-20071123184413-m5uanmtvxcllbjee
Return error instead of a traceback when bzr is unable to create
 symlink on some platforms (e.g. on Windows). (workaround for #81689)

Show diffs side-by-side

added added

removed removed

Lines of Context:
29
29
""")
30
30
from bzrlib.errors import (DuplicateKey, MalformedTransform, NoSuchFile,
31
31
                           ReusingTransform, NotVersionedError, CantMoveRoot,
32
 
                           ExistingLimbo, ImmortalLimbo, NoFinalPath)
 
32
                           ExistingLimbo, ImmortalLimbo, NoFinalPath,
 
33
                           UnableCreateSymlink)
33
34
from bzrlib.inventory import InventoryEntry
34
35
from bzrlib.osutils import (file_kind, supports_executable, pathjoin, lexists,
35
 
                            delete_any)
 
36
                            delete_any, has_symlinks)
36
37
from bzrlib.progress import DummyProgress, ProgressPhase
37
38
from bzrlib.symbol_versioning import (
38
39
        deprecated_function,
439
440
        target is a bytestring.
440
441
        See also new_symlink.
441
442
        """
442
 
        os.symlink(target, self._limbo_name(trans_id))
443
 
        unique_add(self._new_contents, trans_id, 'symlink')
 
443
        if has_symlinks():
 
444
            os.symlink(target, self._limbo_name(trans_id))
 
445
            unique_add(self._new_contents, trans_id, 'symlink')
 
446
        else:
 
447
            try:
 
448
                path = FinalPaths(self).get_path(trans_id)
 
449
            except KeyError:
 
450
                path = None
 
451
            raise UnableCreateSymlink(path=path)
444
452
 
445
453
    def cancel_creation(self, trans_id):
446
454
        """Cancel the creation of new file contents."""
1289
1297
            self._known_paths[trans_id] = self._determine_path(trans_id)
1290
1298
        return self._known_paths[trans_id]
1291
1299
 
 
1300
 
1292
1301
def topology_sorted_ids(tree):
1293
1302
    """Determine the topological order of the ids in a tree"""
1294
1303
    file_ids = list(tree)
1320
1329
    finally:
1321
1330
        wt.unlock()
1322
1331
 
 
1332
 
1323
1333
def _build_tree(tree, wt):
1324
1334
    """See build_tree."""
1325
1335
    if len(wt.inventory) > 1:  # more than just a root
1490
1500
    else:
1491
1501
        raise errors.BadFileKindError(name, kind)
1492
1502
 
 
1503
 
1493
1504
def create_by_entry(tt, entry, tree, trans_id, lines=None, mode_id=None):
1494
1505
    """Create new file contents according to an inventory entry."""
1495
1506
    if entry.kind == "file":
1501
1512
    elif entry.kind == "directory":
1502
1513
        tt.create_directory(trans_id)
1503
1514
 
 
1515
 
1504
1516
def create_entry_executability(tt, entry, trans_id):
1505
1517
    """Set the executability of a trans_id according to an inventory entry"""
1506
1518
    if entry.kind == "file":