~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/export/tar_exporter.py

  • Committer: Robert Collins
  • Date: 2008-08-08 06:59:48 UTC
  • mto: This revision was merged to the branch mainline in revision 3618.
  • Revision ID: robertc@robertcollins.net-20080808065948-io0c6pfo305ss5vj
Refactor exporters to remove obvious duplication to a helper function.

Show diffs side-by-side

added added

removed removed

Lines of Context:
23
23
import time
24
24
 
25
25
from bzrlib import errors, export, osutils
 
26
from bzrlib.export import _export_iter_entries
26
27
from bzrlib.trace import mutter
27
28
 
28
29
 
32
33
    `dest` will be created holding the contents of this tree; if it
33
34
    already exists, it will be clobbered, like with "tar -c".
34
35
    """
 
36
    mutter('export version %r', tree)
35
37
    now = time.time()
36
38
    compression = str(compression or '')
37
39
    if dest == '-':
42
44
        if root is None:
43
45
            root = export.get_root_name(dest)
44
46
        ball = tarfile.open(dest, 'w:' + compression)
45
 
    mutter('export version %r', tree)
46
 
    inv = tree.inventory
47
 
    if subdir is None:
48
 
        subdir_id = None
49
 
    else:
50
 
        subdir_id = inv.path2id(subdir)
51
 
    entries = inv.iter_entries(subdir_id)
52
 
    if subdir is None:
53
 
        entries.next() # skip root
54
 
    for dp, ie in entries:
55
 
        # The .bzr* namespace is reserved for "magic" files like
56
 
        # .bzrignore and .bzrrules - do not export these
57
 
        if dp.startswith(".bzr"):
58
 
            continue
59
 
 
 
47
    for dp, ie in _export_iter_entries(tree, subdir):
60
48
        filename = osutils.pathjoin(root, dp).encode('utf8')
61
49
        item = tarfile.TarInfo(filename)
62
50
        item.mtime = now