~amanica/bzr/320119-log_exclusive_lower_bound

« back to all changes in this revision

Viewing changes to bzrlib/export/dir_exporter.py

  • Committer: Marius Kruger
  • Date: 2009-08-01 23:31:52 UTC
  • mfrom: (4511.1.69 +trunk)
  • Revision ID: amanic@gmail.com-20090801233152-m2l31ll5qbcr4xz6
merge with bzr.dev

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
"""Export a Tree to a non-versioned directory.
18
18
"""
19
19
 
20
 
 
 
20
import errno
21
21
import os
22
22
import StringIO
23
23
 
43
43
           left in a half-assed state.
44
44
    """
45
45
    mutter('export version %r', tree)
46
 
    os.mkdir(dest)
 
46
    try:
 
47
        os.mkdir(dest)
 
48
    except OSError, e:
 
49
        if e.errno == errno.EEXIST:
 
50
            # check if directory empty
 
51
            if os.listdir(dest) != []:
 
52
                raise errors.BzrError("Can't export tree to non-empty directory.")
 
53
        else:
 
54
            raise
47
55
    for dp, ie in _export_iter_entries(tree, subdir):
48
56
        fullpath = osutils.pathjoin(dest, dp)
49
57
        if ie.kind == "file":
63
71
            os.mkdir(fullpath)
64
72
        elif ie.kind == "symlink":
65
73
            try:
66
 
                os.symlink(ie.symlink_target, fullpath)
 
74
                symlink_target = tree.get_symlink_target(ie.file_id)
 
75
                os.symlink(symlink_target, fullpath)
67
76
            except OSError,e:
68
77
                raise errors.BzrError(
69
78
                    "Failed to create symlink %r -> %r, error: %s"
70
 
                    % (fullpath, self.symlink_target, e))
 
79
                    % (fullpath, symlink_target, e))
71
80
        else:
72
81
            raise errors.BzrError("don't know how to export {%s} of kind %r" %
73
82
               (ie.file_id, ie.kind))