~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/export/dir_exporter.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2009-07-30 14:24:06 UTC
  • mfrom: (4576.1.1 export-to-dir)
  • Revision ID: pqm@pqm.ubuntu.com-20090730142406-wg8gmxpcjz4c1z00
(bialix) Allow 'bzr export' to export into an existing (but empty)
        directory

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
"""Export a Tree to a non-versioned directory.
18
18
"""
19
19
 
20
 
 
 
20
import errno
21
21
import os
22
22
import StringIO
23
23
 
43
43
           left in a half-assed state.
44
44
    """
45
45
    mutter('export version %r', tree)
46
 
    os.mkdir(dest)
 
46
    try:
 
47
        os.mkdir(dest)
 
48
    except OSError, e:
 
49
        if e.errno == errno.EEXIST:
 
50
            # check if directory empty
 
51
            if os.listdir(dest) != []:
 
52
                raise errors.BzrError("Can't export tree to non-empty directory.")
 
53
        else:
 
54
            raise
47
55
    for dp, ie in _export_iter_entries(tree, subdir):
48
56
        fullpath = osutils.pathjoin(dest, dp)
49
57
        if ie.kind == "file":