~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/export/__init__.py

  • Committer: Danny van Heumen
  • Date: 2010-03-09 21:42:11 UTC
  • mto: (4634.139.5 2.0)
  • mto: This revision was merged to the branch mainline in revision 5160.
  • Revision ID: danny@dannyvanheumen.nl-20100309214211-iqh42x6qcikgd9p3
Reverted now-useless TODO list.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2005-2010 Canonical Ltd
 
1
# Copyright (C) 2005 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
19
19
Such as non-controlled directories, tarfiles, zipfiles, etc.
20
20
"""
21
21
 
 
22
from bzrlib.trace import mutter
22
23
import os
23
24
import bzrlib.errors as errors
24
25
 
54
55
 
55
56
    When requesting a specific type of export, load the respective path.
56
57
    """
57
 
    def _loader(tree, dest, root, subdir, filtered, per_file_timestamps):
 
58
    def _loader(tree, dest, root, subdir, filtered):
58
59
        mod = __import__(module, globals(), locals(), [funcname])
59
60
        func = getattr(mod, funcname)
60
 
        return func(tree, dest, root, subdir, filtered=filtered,
61
 
                    per_file_timestamps=per_file_timestamps)
 
61
        return func(tree, dest, root, subdir, filtered=filtered)
62
62
    register_exporter(scheme, extensions, _loader)
63
63
 
64
64
 
65
 
def export(tree, dest, format=None, root=None, subdir=None, filtered=False,
66
 
           per_file_timestamps=False):
 
65
def export(tree, dest, format=None, root=None, subdir=None, filtered=False):
67
66
    """Export the given Tree to the specific destination.
68
67
 
69
68
    :param tree: A Tree (such as RevisionTree) to export
82
81
        a directory to start exporting from.
83
82
    :param filtered: If True, content filtering is applied to the
84
83
                     files exported.
85
 
    :param per_file_timestamps: Whether to use the timestamp stored in the 
86
 
        tree rather than now(). This will do a revision lookup 
87
 
        for every file so will be significantly slower.
88
84
    """
89
85
    global _exporters, _exporter_extensions
90
86
 
103
99
        raise errors.NoSuchExportFormat(format)
104
100
    tree.lock_read()
105
101
    try:
106
 
        return _exporters[format](tree, dest, root, subdir, filtered=filtered,
107
 
                                  per_file_timestamps=per_file_timestamps)
 
102
        return _exporters[format](tree, dest, root, subdir, filtered=filtered)
108
103
    finally:
109
104
        tree.unlock()
110
105
 
143
138
    """Iter the entries for tree suitable for exporting.
144
139
 
145
140
    :param tree: A tree object.
146
 
    :param subdir: None or the path of an entry to start exporting from.
 
141
    :param subdir: None or the path of a directory to start exporting from.
147
142
    """
148
143
    inv = tree.inventory
149
144
    if subdir is None:
150
 
        subdir_object = None
 
145
        subdir_id = None
151
146
    else:
152
147
        subdir_id = inv.path2id(subdir)
153
 
        if subdir_id is not None:
154
 
            subdir_object = inv[subdir_id]
155
 
        # XXX: subdir is path not an id, so NoSuchId isn't proper error
156
 
        else:
157
 
            raise errors.NoSuchId(tree, subdir)
158
 
    if subdir_object is not None and subdir_object.kind != 'directory':
159
 
        yield subdir_object.name, subdir_object
160
 
        return
161
 
    else:
162
 
        entries = inv.iter_entries(subdir_object)
 
148
    entries = inv.iter_entries(subdir_id)
163
149
    if subdir is None:
164
150
        entries.next() # skip root
165
151
    for entry in entries: