Merge lp://qastaging/~maxb/bzrtools/skip-import-.bzr into lp://qastaging/bzrtools

Proposed by Max Bowsher
Status: Merged
Merged at revision: not available
Proposed branch: lp://qastaging/~maxb/bzrtools/skip-import-.bzr
Merge into: lp://qastaging/bzrtools
Diff against target: 58 lines (+24/-0)
2 files modified
tests/upstream_import.py (+18/-0)
upstream_import.py (+6/-0)
To merge this branch: bzr merge lp://qastaging/~maxb/bzrtools/skip-import-.bzr
Reviewer Review Type Date Requested Status
Aaron Bentley Approve
Review via email: mp+14593@code.qastaging.launchpad.net
To post a comment you must log in.
Revision history for this message
Aaron Bentley (abentley) wrote :

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

Max Bowsher wrote:
> Max Bowsher has proposed merging lp:~maxb/bzrtools/skip-import-.bzr into lp:bzrtools.
>
> Requested reviews:
> Aaron Bentley (abentley)
> Related bugs:
> #237933 attempting to import a directory/archive containing a .bzr directory gives a fatal "tree transform is malformed" error
> https://bugs.launchpad.net/bugs/237933

 review resubmit

This looks like a reasonable change, but needs tests. Existing tests
are in bzrtools/tests/upstream_import.

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

iEYEARECAAYFAkr4+ZsACgkQ0F+nu1YWqI3GLACfc0cUm+2HNViCsm/zHdI4XhTz
35QAnRExkzUppFYLWE7triL7hkA99Nb3
=pff6
-----END PGP SIGNATURE-----

review: Needs Resubmitting
732. By Max Bowsher

Having discovered that bzr-builddeb import_dsc.py is a horrid copy-paste job of bzrtools upstream_import.py, restructure the change to minimize divergence from it.

733. By Max Bowsher

Add a very simple test.

Revision history for this message
Max Bowsher (maxb) wrote :

Is this very simple test acceptable?

If not, can you guide me to what needs to be checked in more depth?

Revision history for this message
Aaron Bentley (abentley) wrote :

This looks good. Sorry for the delay merging it.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'tests/upstream_import.py'
2--- tests/upstream_import.py 2009-04-10 21:09:41 +0000
3+++ tests/upstream_import.py 2010-02-09 09:13:11 +0000
4@@ -154,6 +154,18 @@
5 return ZipFileWrapper(fileobj, 'w')
6 return self.make_archive(maker)
7
8+ def make_tar_with_bzrdir(self):
9+ result = StringIO()
10+ tar_file = tarfile.open('tar-with-bzrdir.tar', 'w', result)
11+ os.mkdir('toplevel-dir')
12+ tar_file.add('toplevel-dir')
13+ os.mkdir('toplevel-dir/.bzr')
14+ tar_file.add('toplevel-dir/.bzr')
15+ tar_file.close()
16+ rmtree('toplevel-dir')
17+ result.seek(0)
18+ return result
19+
20 def test_top_path(self):
21 self.assertEqual(top_path('ab/b/c'), 'ab')
22 self.assertEqual(top_path('etc'), 'etc')
23@@ -223,5 +235,11 @@
24 import_tar(tree, tar_file)
25 self.assertTrue(tree.path2id('README') is not None)
26
27+ def test_no_crash_with_bzrdir(self):
28+ tar_file = self.make_tar_with_bzrdir()
29+ tree = BzrDir.create_standalone_workingtree('tree')
30+ import_tar(tree, tar_file)
31+ # So long as it did not crash, that should be ok
32+
33 def test_suite():
34 return makeSuite(TestImport)
35
36=== modified file 'upstream_import.py'
37--- upstream_import.py 2009-04-10 21:09:41 +0000
38+++ upstream_import.py 2010-02-09 09:13:11 +0000
39@@ -163,6 +163,10 @@
40 yield member.name
41
42
43+def should_ignore(relative_path):
44+ return top_path(relative_path) == '.bzr'
45+
46+
47 def import_tar(tree, tar_input):
48 """Replace the contents of a working directory with tarfile contents.
49 The tarfile may be a gzipped stream. File ids will be updated.
50@@ -203,6 +207,8 @@
51 relative_path = relative_path.rstrip('/')
52 if relative_path == '':
53 continue
54+ if should_ignore(relative_path):
55+ continue
56 add_implied_parents(implied_parents, relative_path)
57 trans_id = tt.trans_id_tree_path(relative_path)
58 added.add(relative_path.rstrip('/'))

Subscribers

People subscribed via source and target branches