~abentley/bzrtools/bzrtools.dev

« back to all changes in this revision

Viewing changes to upstream_import.py

  • Committer: Aaron Bentley
  • Date: 2007-01-08 17:08:42 UTC
  • Revision ID: abentley@panoramicfeedback.com-20070108170842-ei18carwxzr9709k
import now imports directories

Show diffs side-by-side

added added

removed removed

Lines of Context:
11
11
from bzrlib import generate_ids
12
12
from bzrlib.bzrdir import BzrDir
13
13
from bzrlib.errors import NoSuchFile, BzrCommandError, NotBranchError
14
 
from bzrlib.osutils import pathjoin, isdir, file_iterator, basename
 
14
from bzrlib.osutils import (pathjoin, isdir, file_iterator, basename,
 
15
                            file_kind)
15
16
from bzrlib.trace import warning
16
17
from bzrlib.transform import TreeTransform, resolve_conflicts, cook_conflicts
17
18
from bzrlib.workingtree import WorkingTree
87
88
    def __init__(self, root, filepath):
88
89
        self.fullpath = pathjoin(root, filepath)
89
90
        self.root = root
90
 
        self.name = filepath 
 
91
        if filepath != '':
 
92
            self.name = pathjoin(basename(root), filepath)
 
93
        else:
 
94
            print 'root %r' % root
 
95
            self.name = basename(root)
91
96
        self.type = None
92
97
        stat = os.lstat(self.fullpath)
93
98
        self.mode = stat.st_mode
268
273
                tar_input.close()
269
274
        elif source.endswith('.zip'):
270
275
            import_zip(tree, open(source, 'rb'))
 
276
        elif file_kind(source) == 'directory':
 
277
            s = StringIO(source)
 
278
            s.seek(0)
 
279
            import_dir(tree, s)
271
280
        else:
272
281
            raise BzrCommandError('Unhandled import source')
273
282
    finally: