/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: 2019-05-29 03:22:34 UTC
  • mfrom: (7303 work)
  • mto: This revision was merged to the branch mainline in revision 7306.
  • Revision ID: jelmer@jelmer.uk-20190529032234-mt3fuws8gq03tapi
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,
66
65
 
67
66
    if not per_file_timestamps:
68
67
        force_mtime = time.time()
 
68
        if getattr(tree, '_repository', None):
 
69
            try:
 
70
                force_mtime = tree._repository.get_revision(
 
71
                    tree.get_revision_id()).timestamp
 
72
            except errors.NoSuchRevision:
 
73
                pass
69
74
    else:
70
75
        force_mtime = None
71
76
 
76
81
        # then we should stream a tar file and unpack that on the fly.
77
82
        with tree.lock_read():
78
83
            for unused in dir_exporter_generator(tree, dest, root, subdir,
79
 
                    force_mtime):
 
84
                                                 force_mtime):
80
85
                pass
81
86
        return
82
87
 
83
88
    with tree.lock_read():
84
 
        chunks = tree.archive(format, dest, root=root, subdir=subdir, force_mtime=force_mtime)
 
89
        chunks = tree.archive(format, dest, root=root,
 
90
                              subdir=subdir, force_mtime=force_mtime)
85
91
        if dest == '-':
86
92
            for chunk in chunks:
87
 
                 getattr(sys.stdout, 'buffer', sys.stdout).write(chunk)
 
93
                getattr(sys.stdout, 'buffer', sys.stdout).write(chunk)
88
94
        elif fileobj is not None:
89
95
            for chunk in chunks:
90
96
                fileobj.write(chunk)
197
203
            os.mkdir(fullpath)
198
204
        elif ie.kind == "symlink":
199
205
            try:
200
 
                symlink_target = tree.get_symlink_target(tp, file_id)
 
206
                symlink_target = tree.get_symlink_target(tp)
201
207
                os.symlink(symlink_target, fullpath)
202
208
            except OSError as e:
203
209
                raise errors.BzrError(
205
211
                    % (fullpath, symlink_target, e))
206
212
        else:
207
213
            raise errors.BzrError("don't know how to export {%s} of kind %r" %
208
 
               (tp, ie.kind))
 
214
                                  (tp, ie.kind))
209
215
 
210
216
        yield
211
217
    # The data returned here can be in any order, but we've already created all
215
221
        fullpath = osutils.pathjoin(dest, relpath)
216
222
        # We set the mode and let the umask sort out the file info
217
223
        mode = 0o666
218
 
        if tree.is_executable(treepath, file_id):
 
224
        if tree.is_executable(treepath):
219
225
            mode = 0o777
220
226
        with os.fdopen(os.open(fullpath, flags, mode), 'wb') as out:
221
227
            out.writelines(chunks)
222
228
        if force_mtime is not None:
223
229
            mtime = force_mtime
224
230
        else:
225
 
            mtime = tree.get_file_mtime(treepath, file_id)
 
231
            mtime = tree.get_file_mtime(treepath)
226
232
        os.utime(fullpath, (mtime, mtime))
227
233
 
228
234
        yield