Merge lp:~bialix/bzr/bug-406174 into lp:~bzr/bzr/trunk-old

Proposed by Alexander Belchenko
Status: Merged
Approved by: John A Meinel
Approved revision: no longer in the source branch.
Merged at revision: not available
Proposed branch: lp:~bialix/bzr/bug-406174
Merge into: lp:~bzr/bzr/trunk-old
Diff against target: 79 lines
To merge this branch: bzr merge lp:~bialix/bzr/bug-406174
Reviewer Review Type Date Requested Status
John A Meinel Approve
Review via email: mp+9426@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Alexander Belchenko (bialix) wrote :

This branch fixed export to existing directory: if directory is empty then export will succeed, otherwise it fails with error. See bug #406174 for details.

Revision history for this message
John A Meinel (jameinel) wrote :

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Alexander Belchenko wrote:
> Alexander Belchenko has proposed merging lp:~bialix/bzr/bug-406174 into lp:bzr.
>
> Requested reviews:
> bzr-core (bzr-core)
>
> This branch fixed export to existing directory: if directory is empty then export will succeed, otherwise it fails with error. See bug #406174 for details.
>
>

 review approve
 merge approve

John
=:->

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (Cygwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAkpwcEAACgkQJdeBCYSNAAOfGgCeJ24K38h1RY1FVydmAdLukKWw
RzQAoItgQjHfiebrvVKISAHjkRj6E2Xo
=0PJ4
-----END PGP SIGNATURE-----

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'NEWS'
--- NEWS 2009-07-29 21:38:13 +0000
+++ NEWS 2009-07-30 02:35:21 +0000
@@ -70,6 +70,10 @@
70 causes a redirection loop when bzr tries to read a URL as a bundle.70 causes a redirection loop when bzr tries to read a URL as a bundle.
71 (Andrew Bennetts, #400847)71 (Andrew Bennetts, #400847)
72 72
73* Fixed export to existing directory: if directory is empty then export
74 will succeed, otherwise it fails with error.
75 (Alexander Belchenko, #406174)
76
73* Fixed spurious "Source branch does not support stacking" warning when77* Fixed spurious "Source branch does not support stacking" warning when
74 pushing. (Andrew Bennetts, #388908)78 pushing. (Andrew Bennetts, #388908)
7579
7680
=== modified file 'bzrlib/export/dir_exporter.py'
--- bzrlib/export/dir_exporter.py 2009-07-23 16:30:49 +0000
+++ bzrlib/export/dir_exporter.py 2009-07-30 02:35:21 +0000
@@ -17,7 +17,7 @@
17"""Export a Tree to a non-versioned directory.17"""Export a Tree to a non-versioned directory.
18"""18"""
1919
2020import errno
21import os21import os
22import StringIO22import StringIO
2323
@@ -43,7 +43,15 @@
43 left in a half-assed state.43 left in a half-assed state.
44 """44 """
45 mutter('export version %r', tree)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 for dp, ie in _export_iter_entries(tree, subdir):55 for dp, ie in _export_iter_entries(tree, subdir):
48 fullpath = osutils.pathjoin(dest, dp)56 fullpath = osutils.pathjoin(dest, dp)
49 if ie.kind == "file":57 if ie.kind == "file":
5058
=== modified file 'bzrlib/tests/test_export.py'
--- bzrlib/tests/test_export.py 2009-07-23 18:36:54 +0000
+++ bzrlib/tests/test_export.py 2009-07-30 02:35:21 +0000
@@ -18,6 +18,7 @@
1818
1919
20from bzrlib import (20from bzrlib import (
21 errors,
21 export,22 export,
22 osutils,23 osutils,
23 tests,24 tests,
@@ -42,3 +43,22 @@
42 wt.add(['link'])43 wt.add(['link'])
43 export.export(wt, 'target', format="dir")44 export.export(wt, 'target', format="dir")
44 self.failUnlessExists('target/link')45 self.failUnlessExists('target/link')
46
47 def test_dir_export_to_existing_empty_dir_success(self):
48 self.build_tree(['source/', 'source/a', 'source/b/', 'source/b/c'])
49 wt = self.make_branch_and_tree('source')
50 wt.add(['a', 'b', 'b/c'])
51 wt.commit('1')
52 self.build_tree(['target/'])
53 export.export(wt, 'target', format="dir")
54 self.failUnlessExists('target/a')
55 self.failUnlessExists('target/b')
56 self.failUnlessExists('target/b/c')
57
58 def test_dir_export_to_existing_nonempty_dir_fail(self):
59 self.build_tree(['source/', 'source/a', 'source/b/', 'source/b/c'])
60 wt = self.make_branch_and_tree('source')
61 wt.add(['a', 'b', 'b/c'])
62 wt.commit('1')
63 self.build_tree(['target/', 'target/foo'])
64 self.assertRaises(errors.BzrError, export.export, wt, 'target', format="dir")