~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/export/tar_exporter.py

  • Committer: Robert Collins
  • Date: 2010-04-08 04:34:03 UTC
  • mfrom: (5138 +trunk)
  • mto: This revision was merged to the branch mainline in revision 5139.
  • Revision ID: robertc@robertcollins.net-20100408043403-56z0d07vdqrx7f3t
Update bugfix for 528114 to trunk.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2005, 2006, 2008 Canonical Ltd
 
1
# Copyright (C) 2005, 2006, 2008, 2009, 2010 Canonical Ltd
2
2
#
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
17
17
"""Export a Tree to a non-versioned directory.
18
18
"""
19
19
 
20
 
import os
21
20
import StringIO
22
21
import sys
23
22
import tarfile
24
23
import time
25
24
 
26
 
from bzrlib import errors, export, osutils
 
25
from bzrlib import export, osutils
27
26
from bzrlib.export import _export_iter_entries
28
27
from bzrlib.filters import (
29
28
    ContentFilterContext,
32
31
from bzrlib.trace import mutter
33
32
 
34
33
 
35
 
def tar_exporter(tree, dest, root, subdir, compression=None, filtered=False):
 
34
def tar_exporter(tree, dest, root, subdir, compression=None, filtered=False,
 
35
                 per_file_timestamps=False):
36
36
    """Export this tree to a new tar file.
37
37
 
38
38
    `dest` will be created holding the contents of this tree; if it
52
52
    for dp, ie in _export_iter_entries(tree, subdir):
53
53
        filename = osutils.pathjoin(root, dp).encode('utf8')
54
54
        item = tarfile.TarInfo(filename)
55
 
        item.mtime = now
 
55
        if per_file_timestamps:
 
56
            item.mtime = tree.get_file_mtime(ie.file_id, dp)
 
57
        else:
 
58
            item.mtime = now
56
59
        if ie.kind == "file":
57
60
            item.type = tarfile.REGTYPE
58
61
            if tree.is_executable(ie.file_id):
89
92
    ball.close()
90
93
 
91
94
 
92
 
def tgz_exporter(tree, dest, root, subdir, filtered=False):
93
 
    tar_exporter(tree, dest, root, subdir, compression='gz', filtered=filtered)
94
 
 
95
 
 
96
 
def tbz_exporter(tree, dest, root, subdir, filtered=False):
97
 
    tar_exporter(tree, dest, root, subdir, compression='bz2', filtered=filtered)
 
95
def tgz_exporter(tree, dest, root, subdir, filtered=False,
 
96
                 per_file_timestamps=False):
 
97
    tar_exporter(tree, dest, root, subdir, compression='gz',
 
98
                 filtered=filtered, per_file_timestamps=per_file_timestamps)
 
99
 
 
100
 
 
101
def tbz_exporter(tree, dest, root, subdir, filtered=False,
 
102
                 per_file_timestamps=False):
 
103
    tar_exporter(tree, dest, root, subdir, compression='bz2',
 
104
                 filtered=filtered, per_file_timestamps=per_file_timestamps)