/breezy/unstable

To get this branch, use:
bzr branch https://code.breezy-vcs.org/breezy/unstable

« back to all changes in this revision

Viewing changes to breezy/export/dir_exporter.py

  • Committer: Jelmer Vernooij
  • Date: 2017-05-24 01:39:33 UTC
  • mfrom: (3815.3776.6)
  • Revision ID: jelmer@jelmer.uk-20170524013933-ir4y4tqtrsiz2ka2
New upstream snapshot.

Show diffs side-by-side

added added

removed removed

Lines of Context:
14
14
# along with this program; if not, write to the Free Software
15
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16
16
 
17
 
"""Export a bzrlib.tree.Tree to a new or empty directory."""
 
17
"""Export a breezy.tree.Tree to a new or empty directory."""
18
18
 
19
19
from __future__ import absolute_import
20
20
 
21
21
import errno
22
22
import os
23
23
 
24
 
from bzrlib import errors, osutils
25
 
from bzrlib.export import _export_iter_entries
 
24
from .. import errors, osutils
 
25
from ..export import _export_iter_entries
26
26
 
27
27
 
28
28
def dir_exporter_generator(tree, dest, root, subdir=None,
39
39
    """
40
40
    try:
41
41
        os.mkdir(dest)
42
 
    except OSError, e:
 
42
    except OSError as e:
43
43
        if e.errno == errno.EEXIST:
44
44
            # check if directory empty
45
45
            if os.listdir(dest) != []:
64
64
            try:
65
65
                symlink_target = tree.get_symlink_target(ie.file_id, tp)
66
66
                os.symlink(symlink_target, fullpath)
67
 
            except OSError, e:
 
67
            except OSError as e:
68
68
                raise errors.BzrError(
69
69
                    "Failed to create symlink %r -> %r, error: %s"
70
70
                    % (fullpath, symlink_target, e))
79
79
    for (relpath, treepath, file_id), chunks in tree.iter_files_bytes(to_fetch):
80
80
        fullpath = osutils.pathjoin(dest, relpath)
81
81
        # We set the mode and let the umask sort out the file info
82
 
        mode = 0666
 
82
        mode = 0o666
83
83
        if tree.is_executable(file_id, treepath):
84
 
            mode = 0777
 
84
            mode = 0o777
85
85
        out = os.fdopen(os.open(fullpath, flags, mode), 'wb')
86
86
        try:
87
87
            out.writelines(chunks)