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

  • Committer: Jelmer Vernooij
  • Date: 2018-11-16 23:15:15 UTC
  • mfrom: (7180 work)
  • mto: This revision was merged to the branch mainline in revision 7183.
  • Revision ID: jelmer@jelmer.uk-20181116231515-zqd2yn6kj8lfydyp
Merge trunk.

Show diffs side-by-side

added added

removed removed

Lines of Context:
23
23
import os
24
24
import sys
25
25
import time
26
 
import warnings
27
26
 
28
27
from . import (
29
28
    archive,
76
75
        # then we should stream a tar file and unpack that on the fly.
77
76
        with tree.lock_read():
78
77
            for unused in dir_exporter_generator(tree, dest, root, subdir,
79
 
                    force_mtime):
 
78
                                                 force_mtime):
80
79
                pass
81
80
        return
82
81
 
83
82
    with tree.lock_read():
84
 
        chunks = tree.archive(format, dest, root=root, subdir=subdir, force_mtime=force_mtime)
 
83
        chunks = tree.archive(format, dest, root=root,
 
84
                              subdir=subdir, force_mtime=force_mtime)
85
85
        if dest == '-':
86
86
            for chunk in chunks:
87
 
                 getattr(sys.stdout, 'buffer', sys.stdout).write(chunk)
 
87
                getattr(sys.stdout, 'buffer', sys.stdout).write(chunk)
88
88
        elif fileobj is not None:
89
89
            for chunk in chunks:
90
90
                fileobj.write(chunk)
197
197
            os.mkdir(fullpath)
198
198
        elif ie.kind == "symlink":
199
199
            try:
200
 
                symlink_target = tree.get_symlink_target(tp, file_id)
 
200
                symlink_target = tree.get_symlink_target(tp)
201
201
                os.symlink(symlink_target, fullpath)
202
202
            except OSError as e:
203
203
                raise errors.BzrError(
205
205
                    % (fullpath, symlink_target, e))
206
206
        else:
207
207
            raise errors.BzrError("don't know how to export {%s} of kind %r" %
208
 
               (tp, ie.kind))
 
208
                                  (tp, ie.kind))
209
209
 
210
210
        yield
211
211
    # The data returned here can be in any order, but we've already created all
215
215
        fullpath = osutils.pathjoin(dest, relpath)
216
216
        # We set the mode and let the umask sort out the file info
217
217
        mode = 0o666
218
 
        if tree.is_executable(treepath, file_id):
 
218
        if tree.is_executable(treepath):
219
219
            mode = 0o777
220
220
        with os.fdopen(os.open(fullpath, flags, mode), 'wb') as out:
221
221
            out.writelines(chunks)
222
222
        if force_mtime is not None:
223
223
            mtime = force_mtime
224
224
        else:
225
 
            mtime = tree.get_file_mtime(treepath, file_id)
 
225
            mtime = tree.get_file_mtime(treepath)
226
226
        os.utime(fullpath, (mtime, mtime))
227
227
 
228
228
        yield