~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/export/__init__.py

  • Committer: Martin Pool
  • Date: 2010-02-25 06:17:27 UTC
  • mfrom: (5055 +trunk)
  • mto: This revision was merged to the branch mainline in revision 5057.
  • Revision ID: mbp@sourcefrog.net-20100225061727-4sd9lt0qmdc6087t
merge news

Show diffs side-by-side

added added

removed removed

Lines of Context:
138
138
    """Iter the entries for tree suitable for exporting.
139
139
 
140
140
    :param tree: A tree object.
141
 
    :param subdir: None or the path of a directory to start exporting from.
 
141
    :param subdir: None or the path of an entry to start exporting from.
142
142
    """
143
143
    inv = tree.inventory
144
144
    if subdir is None:
145
 
        subdir_id = None
 
145
        subdir_object = None
146
146
    else:
147
147
        subdir_id = inv.path2id(subdir)
148
 
    entries = inv.iter_entries(subdir_id)
 
148
        if subdir_id is not None:
 
149
            subdir_object = inv[subdir_id]
 
150
        # XXX: subdir is path not an id, so NoSuchId isn't proper error
 
151
        else:
 
152
            raise errors.NoSuchId(tree, subdir)
 
153
    if subdir_object is not None and subdir_object.kind != 'directory':
 
154
        yield subdir_object.name, subdir_object
 
155
        return
 
156
    else:
 
157
        entries = inv.iter_entries(subdir_object)
149
158
    if subdir is None:
150
159
        entries.next() # skip root
151
160
    for entry in entries: