[patch] exclude .bzrignore from export, this time with tests

John A Meinel john at arbash-meinel.com
Thu Dec 29 03:21:11 GMT 2005


Jamie Wilkinson wrote:
> I noticed yesterday that the exporters were split apart, and in doing so
> they no longer excluded '.bzrignore' from the export.
> 
> I've repatched it now, and added blackbox tests.
> 
> http://repo.spacepants.org/bzr.jaq/
> 
> revno 1524 and 1525
> 
> 

The tests are appreciated, but need some cleanup before they can be merged.

First, you have tab characters in your code. bzrlib code is expected to
only have space characters for indentation. There have been some threads
about how to configure vim so that it sets 'expandtab' based on the
working directory. I'm not sure how to do emacs. But I can repost if you
want.


> === added file 'bzrlib/tests/blackbox/test_export.py'
> --- /dev/null	
> +++ bzrlib/tests/blackbox/test_export.py	
> @@ -0,0 +1,59 @@
> +# -*- coding: utf-8 -*-
> +
> +# This program is free software; you can redistribute it and/or modify
> +# it under the terms of the GNU General Public License as published by
> +# the Free Software Foundation; either version 2 of the License, or
> +# (at your option) any later version.
> +
> +# This program is distributed in the hope that it will be useful,
> +# but WITHOUT ANY WARRANTY; without even the implied warranty of
> +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> +# GNU General Public License for more details.
> +
> +# You should have received a copy of the GNU General Public License
> +# along with this program; if not, write to the Free Software
> +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
> +
> +
> +"""Black-box tests for bzr export.
> +"""
> +
> +import os
> +
> +from bzrlib.branch import Branch
> +from bzrlib.tests.blackbox import ExternalBase
> +import tarfile, zipfile
> +
> +class TestExport(ExternalBase):
> +
> +    def test_tar_export(self):
> +
> +        os.mkdir('tar')
> +        os.chdir('tar')
> +
> +        self.runbzr('init')
> +        open('a', 'wb').write('foo\n')
> +        self.runbzr('add a')
> +        self.runbzr('ignore something')
> +        self.runbzr('commit -m 1')
> +        self.runbzr('export test.tar.gz')
> +        ball = tarfile.open('test.tar.gz')
> +        for m in ball.getnames():
> +            #print m
> +            self.failIf(os.path.basename(m) == '.bzrignore', 'tar export contains .bzrignore')
> +
> +    def test_zip_export(self):
> +
> +        os.mkdir('zip')
> +        os.chdir('zip')
> +
> +        self.runbzr('init')
> +        open('a', 'wb').write('foo\n')
> +        self.runbzr('add a')
> +        self.runbzr('ignore something')
> +        self.runbzr('commit -m 1')
> +        self.runbzr('export test.zip')
> +        ball = zipfile.ZipFile('test.zip')
> +        for m in ball.namelist():
> +            #print m
> +            self.failIf(os.path.basename(m) == '.bzrignore', 'zip export contains .bzrignore')
> 

Thanks for the tests here, but you forgot to test the 'dir exporter'.

> === modified file 'bzrlib/export/dir_exporter.py'
> --- bzrlib/export/dir_exporter.py	
> +++ bzrlib/export/dir_exporter.py	
> @@ -37,5 +37,10 @@
>      mutter('export version %r', tree)
>      inv = tree.inventory
>      for dp, ie in inv.iter_entries():
> +        # .bzrignore has no meaning outside of a working tree
> +        # so do not export it
> +        if dp == ".bzrignore":
> +			continue
> +		
>          ie.put_on_disk(dest, dp, tree)
>  
> 
> === modified file 'bzrlib/export/tar_exporter.py'
> --- bzrlib/export/tar_exporter.py	
> +++ bzrlib/export/tar_exporter.py	
> @@ -40,6 +40,11 @@
>      mutter('export version %r', tree)
>      inv = tree.inventory
>      for dp, ie in inv.iter_entries():
> +		# .bzrignore has no meaning outside of a working tree
> +		# so do not export it
> +        if dp == ".bzrignore":
> +			continue
> +		
>          mutter("  export {%s} kind %s to %s", ie.file_id, ie.kind, dest)
>          item, fileobj = ie.get_tar_item(root, dp, now, tree)
>          ball.addfile(item, fileobj)
> 
> === modified file 'bzrlib/export/zip_exporter.py'
> --- bzrlib/export/zip_exporter.py	
> +++ bzrlib/export/zip_exporter.py	
> @@ -39,6 +39,10 @@
>  
>      try:
>          for dp, ie in inv.iter_entries():
> +            # .bzrignore has no meaning outside of a working tree
> +            # so do not export it
> +            if dp == ".bzrignore":
> +                continue
>  
>              file_id = ie.file_id
>              mutter("  export {%s} kind %s to %s", file_id, ie.kind, dest)
> 
> === modified file 'bzrlib/tests/blackbox/__init__.py'
> --- bzrlib/tests/blackbox/__init__.py	
> +++ bzrlib/tests/blackbox/__init__.py	
> @@ -33,7 +33,8 @@
>                       'bzrlib.tests.blackbox.test_pull',
>                       'bzrlib.tests.blackbox.test_revno',
>                       'bzrlib.tests.blackbox.test_versioning',
> -                     'bzrlib.tests.blackbox.test_missing'
> +                     'bzrlib.tests.blackbox.test_missing',
> +					 'bzrlib.tests.blackbox.test_export',
>                       ]

It hasn't been obvious, and may have only happened recently, but all of
the tests are now sorted in alphabetical order. So this should go
between test_diff and test_fetch.
Also, the tab characters are obvious here.

>      return TestLoader().loadTestsFromNames(testmod_names)
>  
> 

John
=:->

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 249 bytes
Desc: OpenPGP digital signature
Url : https://lists.ubuntu.com/archives/bazaar/attachments/20051228/cd4c9d0a/attachment.pgp 


More information about the bazaar mailing list