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

  • Committer: Robert Collins
  • Date: 2008-08-08 05:25:58 UTC
  • mto: This revision was merged to the branch mainline in revision 3618.
  • Revision ID: robertc@robertcollins.net-20080808052558-b3xkprmd19buq12s
Teach export how to export a subdirectory. (Robert Collins)

Show diffs side-by-side

added added

removed removed

Lines of Context:
26
26
from bzrlib.trace import mutter
27
27
 
28
28
 
29
 
def tar_exporter(tree, dest, root, compression=None):
 
29
def tar_exporter(tree, dest, root, subdir, compression=None):
30
30
    """Export this tree to a new tar file.
31
31
 
32
32
    `dest` will be created holding the contents of this tree; if it
44
44
        ball = tarfile.open(dest, 'w:' + compression)
45
45
    mutter('export version %r', tree)
46
46
    inv = tree.inventory
47
 
    entries = inv.iter_entries()
48
 
    entries.next() # skip root
 
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
49
54
    for dp, ie in entries:
50
55
        # The .bzr* namespace is reserved for "magic" files like
51
56
        # .bzrignore and .bzrrules - do not export these
82
87
    ball.close()
83
88
 
84
89
 
85
 
def tgz_exporter(tree, dest, root):
86
 
    tar_exporter(tree, dest, root, compression='gz')
87
 
 
88
 
 
89
 
def tbz_exporter(tree, dest, root):
90
 
    tar_exporter(tree, dest, root, compression='bz2')
 
90
def tgz_exporter(tree, dest, root, subdir):
 
91
    tar_exporter(tree, dest, root, subdir, compression='gz')
 
92
 
 
93
 
 
94
def tbz_exporter(tree, dest, root, subdir):
 
95
    tar_exporter(tree, dest, root, subdir, compression='bz2')