Rev 3162: Misc cleanups for win32, especially tests (abentley) in file:///home/pqm/archives/thelove/bzr/%2Btrunk/

Canonical.com Patch Queue Manager pqm at pqm.ubuntu.com
Thu Jan 3 19:12:42 GMT 2008


At file:///home/pqm/archives/thelove/bzr/%2Btrunk/

------------------------------------------------------------
revno: 3162
revision-id:pqm at pqm.ubuntu.com-20080103191230-baidarqql3lct685
parent: pqm at pqm.ubuntu.com-20080103180901-w987y1ftqoh02qbm
parent: abentley at panoramicfeedback.com-20080103163108-iop8r47447ybdteo
committer: Canonical.com Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: +trunk
timestamp: Thu 2008-01-03 19:12:30 +0000
message:
  Misc cleanups for win32, especially tests (abentley)
modified:
  bzrlib/smart/vfs.py            vfs.py-20061108095550-gunadhxmzkdjfeek-2
  bzrlib/tests/test_bundle.py    test.py-20050630184834-092aa401ab9f039c
  bzrlib/tests/test_diff.py      testdiff.py-20050727164403-d1a3496ebb12e339
  bzrlib/tests/test_merge.py     testmerge.py-20050905070950-c1b5aa49ff911024
  bzrlib/tests/test_revert.py    test_revert.py-20060828180832-fqb1v6ecpyvnlitj-1
  bzrlib/tests/test_selftest.py  test_selftest.py-20051202044319-c110a115d8c0456a
  bzrlib/tests/test_transform.py test_transaction.py-20060105172520-b3ffb3946550e6c4
  bzrlib/tests/test_win32utils.py test_win32utils.py-20070713181630-8xsrjymd3e8mgw23-108
  bzrlib/transport/__init__.py   transport.py-20050711165921-4978aa7ce1285ad5
  bzrlib/transport/remote.py     ssh.py-20060608202016-c25gvf1ob7ypbus6-1
  bzrlib/workingtree_4.py        workingtree_4.py-20070208044105-5fgpc5j3ljlh5q6c-1
    ------------------------------------------------------------
    revno: 3146.4.12
    revision-id:abentley at panoramicfeedback.com-20080103163108-iop8r47447ybdteo
    parent: aaron.bentley at utoronto.ca-20071229224251-lasicaddozmcf3as
    committer: Aaron Bentley <abentley at panoramicfeedback.com>
    branch nick: win32fixes
    timestamp: Thu 2008-01-03 11:31:08 -0500
    message:
      Add needed write lock to test
    modified:
      bzrlib/tests/test_transform.py test_transaction.py-20060105172520-b3ffb3946550e6c4
    ------------------------------------------------------------
    revno: 3146.4.11
    revision-id:aaron.bentley at utoronto.ca-20071229224251-lasicaddozmcf3as
    parent: aaron.bentley at utoronto.ca-20071229223444-26tzfkl9vz5pnt79
    committer: Aaron Bentley <aaron.bentley at utoronto.ca>
    branch nick: win32fixes
    timestamp: Sat 2007-12-29 17:42:51 -0500
    message:
      Fix lock errors in bundle tests
    modified:
      bzrlib/tests/test_bundle.py    test.py-20050630184834-092aa401ab9f039c
    ------------------------------------------------------------
    revno: 3146.4.10
    revision-id:aaron.bentley at utoronto.ca-20071229223444-26tzfkl9vz5pnt79
    parent: aaron.bentley at utoronto.ca-20071229220547-fi8mxlg9fv9ivq68
    committer: Aaron Bentley <aaron.bentley at utoronto.ca>
    branch nick: win32fixes
    timestamp: Sat 2007-12-29 17:34:44 -0500
    message:
      Add handling of PermissionDenied errors to smart protocol VFS layer
    modified:
      bzrlib/smart/vfs.py            vfs.py-20061108095550-gunadhxmzkdjfeek-2
      bzrlib/transport/remote.py     ssh.py-20060608202016-c25gvf1ob7ypbus6-1
    ------------------------------------------------------------
    revno: 3146.4.9
    revision-id:aaron.bentley at utoronto.ca-20071229220547-fi8mxlg9fv9ivq68
    parent: aaron.bentley at utoronto.ca-20071229215903-hmlfjwdqg5mb93bn
    committer: Aaron Bentley <aaron.bentley at utoronto.ca>
    branch nick: win32fixes
    timestamp: Sat 2007-12-29 17:05:47 -0500
    message:
      do case-insensitive comparision of iexplore filename
    modified:
      bzrlib/tests/test_win32utils.py test_win32utils.py-20070713181630-8xsrjymd3e8mgw23-108
    ------------------------------------------------------------
    revno: 3146.4.8
    revision-id:aaron.bentley at utoronto.ca-20071229215903-hmlfjwdqg5mb93bn
    parent: aaron.bentley at utoronto.ca-20071229215120-a47jvvzj5zphj3x9
    committer: Aaron Bentley <aaron.bentley at utoronto.ca>
    branch nick: win32fixes
    timestamp: Sat 2007-12-29 16:59:03 -0500
    message:
      Add missing symlink requirement
    modified:
      bzrlib/tests/test_transform.py test_transaction.py-20060105172520-b3ffb3946550e6c4
    ------------------------------------------------------------
    revno: 3146.4.7
    revision-id:aaron.bentley at utoronto.ca-20071229215120-a47jvvzj5zphj3x9
    parent: aaron.bentley at utoronto.ca-20071229214344-f24le3b1p943rywx
    committer: Aaron Bentley <aaron.bentley at utoronto.ca>
    branch nick: win32fixes
    timestamp: Sat 2007-12-29 16:51:20 -0500
    message:
      Remove UNIX path assumption
    modified:
      bzrlib/tests/test_selftest.py  test_selftest.py-20051202044319-c110a115d8c0456a
    ------------------------------------------------------------
    revno: 3146.4.6
    revision-id:aaron.bentley at utoronto.ca-20071229214344-f24le3b1p943rywx
    parent: aaron.bentley at utoronto.ca-20071229212832-3cxifqmbz2yfy50g
    committer: Aaron Bentley <aaron.bentley at utoronto.ca>
    branch nick: win32fixes
    timestamp: Sat 2007-12-29 16:43:44 -0500
    message:
      Fix locking issues in revert tests
    modified:
      bzrlib/tests/test_revert.py    test_revert.py-20060828180832-fqb1v6ecpyvnlitj-1
    ------------------------------------------------------------
    revno: 3146.4.5
    revision-id:aaron.bentley at utoronto.ca-20071229212832-3cxifqmbz2yfy50g
    parent: aaron.bentley at utoronto.ca-20071229212526-d8xatqs93g0m6l6q
    committer: Aaron Bentley <aaron.bentley at utoronto.ca>
    branch nick: win32fixes
    timestamp: Sat 2007-12-29 16:28:32 -0500
    message:
      Require a read lock in POSIX is_exectuable implementations, matching win32
    modified:
      bzrlib/workingtree_4.py        workingtree_4.py-20070208044105-5fgpc5j3ljlh5q6c-1
    ------------------------------------------------------------
    revno: 3146.4.4
    revision-id:aaron.bentley at utoronto.ca-20071229212526-d8xatqs93g0m6l6q
    parent: aaron.bentley at utoronto.ca-20071229210815-12tkxjm6njj3xn8b
    committer: Aaron Bentley <aaron.bentley at utoronto.ca>
    branch nick: win32fixes
    timestamp: Sat 2007-12-29 16:25:26 -0500
    message:
      Add write lock, so merge_inner works properly
    modified:
      bzrlib/tests/test_merge.py     testmerge.py-20050905070950-c1b5aa49ff911024
    ------------------------------------------------------------
    revno: 3146.4.3
    revision-id:aaron.bentley at utoronto.ca-20071229210815-12tkxjm6njj3xn8b
    parent: aaron.bentley at utoronto.ca-20071229210402-nj1p3ho3xko9u56q
    committer: Aaron Bentley <aaron.bentley at utoronto.ca>
    branch nick: win32fixes
    timestamp: Sat 2007-12-29 16:08:15 -0500
    message:
      Add missing Symlink requirement
    modified:
      bzrlib/tests/test_diff.py      testdiff.py-20050727164403-d1a3496ebb12e339
    ------------------------------------------------------------
    revno: 3146.4.2
    revision-id:aaron.bentley at utoronto.ca-20071229210402-nj1p3ho3xko9u56q
    parent: aaron.bentley at utoronto.ca-20071229182350-f7wd95zied8e8vt7
    committer: Aaron Bentley <aaron.bentley at utoronto.ca>
    branch nick: win32fixes
    timestamp: Sat 2007-12-29 16:04:02 -0500
    message:
      Avoid assuming unix newline on output
    modified:
      bzrlib/tests/test_diff.py      testdiff.py-20050727164403-d1a3496ebb12e339
    ------------------------------------------------------------
    revno: 3146.4.1
    revision-id:aaron.bentley at utoronto.ca-20071229182350-f7wd95zied8e8vt7
    parent: pqm at pqm.ubuntu.com-20071228175832-9kboqtkemnuzzlab
    committer: Aaron Bentley <aaron.bentley at utoronto.ca>
    branch nick: win32fixes
    timestamp: Sat 2007-12-29 13:23:50 -0500
    message:
      Python 2.5 on win32 can emit errno.EINVAL when listing a non-directory
    modified:
      bzrlib/transport/__init__.py   transport.py-20050711165921-4978aa7ce1285ad5
=== modified file 'bzrlib/smart/vfs.py'
--- a/bzrlib/smart/vfs.py	2007-07-04 08:08:13 +0000
+++ b/bzrlib/smart/vfs.py	2007-12-29 22:34:44 +0000
@@ -75,6 +75,8 @@
         except errors.ReadError:
             # cannot read the file
             return request.FailedSmartServerResponse(('ReadError', ))
+        except errors.PermissionDenied:
+            return request.FailedSmartServerResponse(('PermissionDenied',))
         return request.SuccessfulSmartServerResponse(('ok',), backing_bytes)
 
 

=== modified file 'bzrlib/tests/test_bundle.py'
--- a/bzrlib/tests/test_bundle.py	2007-11-01 09:52:45 +0000
+++ b/bzrlib/tests/test_bundle.py	2007-12-29 22:42:51 +0000
@@ -498,6 +498,13 @@
         sure everything matches the builtin branch.
         """
         to_tree = self.get_checkout(base_rev_id, checkout_dir=checkout_dir)
+        to_tree.lock_write()
+        try:
+            self._valid_apply_bundle(base_rev_id, info, to_tree)
+        finally:
+            to_tree.unlock()
+
+    def _valid_apply_bundle(self, base_rev_id, info, to_tree):
         original_parents = to_tree.get_parent_ids()
         repository = to_tree.branch.repository
         original_parents = to_tree.get_parent_ids()

=== modified file 'bzrlib/tests/test_diff.py'
--- a/bzrlib/tests/test_diff.py	2008-01-03 16:01:06 +0000
+++ b/bzrlib/tests/test_diff.py	2008-01-03 19:12:30 +0000
@@ -21,6 +21,7 @@
 import subprocess
 from tempfile import TemporaryFile
 
+from bzrlib import tests
 from bzrlib.diff import (
     DiffFromTool,
     DiffPath,
@@ -664,6 +665,7 @@
              ' \@\@\n-old\n\+new\n\n')
 
     def test_diff_kind_change(self):
+        self.requireFeature(tests.SymlinkFeature)
         self.build_tree_contents([('old-tree/olddir/',),
                                   ('old-tree/olddir/oldfile', 'old\n')])
         self.old_tree.add('olddir')
@@ -1257,7 +1259,7 @@
                                 None, None, output)
         self.addCleanup(diff_obj.finish)
         diff_obj._execute('old', 'new')
-        self.assertEqual(output.getvalue(), 'old new\n')
+        self.assertEqual(output.getvalue().rstrip(), 'old new')
 
     def test_excute_missing(self):
         diff_obj = DiffFromTool(['a-tool-which-is-unlikely-to-exist'],

=== modified file 'bzrlib/tests/test_merge.py'
--- a/bzrlib/tests/test_merge.py	2007-12-28 21:45:18 +0000
+++ b/bzrlib/tests/test_merge.py	2008-01-03 19:12:30 +0000
@@ -138,6 +138,8 @@
         tree_a.commit(message="hello")
         dir_b = tree_a.bzrdir.sprout('b')
         tree_b = dir_b.open_workingtree()
+        tree_b.lock_write()
+        self.addCleanup(tree_b.unlock)
         tree_a.commit(message="hello again")
         log = StringIO()
         merge_inner(tree_b.branch, tree_a, tree_b.basis_tree(), 

=== modified file 'bzrlib/tests/test_revert.py'
--- a/bzrlib/tests/test_revert.py	2007-11-26 20:00:31 +0000
+++ b/bzrlib/tests/test_revert.py	2007-12-29 21:43:44 +0000
@@ -30,6 +30,8 @@
         self.build_tree(['source/dir/', 'source/dir/contents'])
         source_tree.add(['dir', 'dir/contents'], ['dir-id', 'contents-id'])
         source_tree.commit('added dir')
+        target_tree.lock_write()
+        self.addCleanup(target_tree.unlock)
         merge.merge_inner(target_tree.branch, source_tree.basis_tree(), 
                           target_tree.basis_tree(), this_tree=target_tree)
         self.failUnlessExists('target/dir')
@@ -84,8 +86,12 @@
         tt = transform.TreeTransform(tree)
         tt.new_file('newfile', tt.root, 'helooo!', 'newfile-id', True)
         tt.apply()
-        self.assertTrue(tree.is_executable('newfile-id'))
-        tree.commit('added newfile')
+        tree.lock_write()
+        try:
+            self.assertTrue(tree.is_executable('newfile-id'))
+            tree.commit('added newfile')
+        finally:
+            tree.unlock()
         return tree
 
     def test_preserve_execute(self):
@@ -96,6 +102,8 @@
         tt.create_file('Woooorld!', newfile)
         tt.apply()
         tree = workingtree.WorkingTree.open('tree')
+        tree.lock_write()
+        self.addCleanup(tree.unlock)
         self.assertTrue(tree.is_executable('newfile-id'))
         transform.revert(tree, tree.basis_tree(), None, backups=True)
         self.assertEqual('helooo!', tree.get_file('newfile-id').read())
@@ -107,6 +115,8 @@
         newfile = tt.trans_id_tree_file_id('newfile-id')
         tt.set_executability(False, newfile)
         tt.apply()
+        tree.lock_write()
+        self.addCleanup(tree.unlock)
         transform.revert(tree, tree.basis_tree(), None)
         self.assertTrue(tree.is_executable('newfile-id'))
 

=== modified file 'bzrlib/tests/test_selftest.py'
--- a/bzrlib/tests/test_selftest.py	2007-12-19 09:32:56 +0000
+++ b/bzrlib/tests/test_selftest.py	2008-01-03 19:12:30 +0000
@@ -1805,7 +1805,8 @@
         # code.
         out, err = self.run_bzr(["log", "/nonexistantpath"], retcode=3)
         self.assertEqual(out, '')
-        self.assertEqual(err, 'bzr: ERROR: Not a branch: "/nonexistantpath/".\n')
+        self.assertContainsRe(err,
+            'bzr: ERROR: Not a branch: ".*nonexistantpath/".\n')
 
 
 class TestTestLoader(TestCase):

=== modified file 'bzrlib/tests/test_transform.py'
--- a/bzrlib/tests/test_transform.py	2007-12-25 04:17:50 +0000
+++ b/bzrlib/tests/test_transform.py	2008-01-03 19:12:30 +0000
@@ -759,6 +759,8 @@
         transform, root = self.get_transform()
         transform.new_file('file1', root, 'contents', 'file1-id', True)
         transform.apply()
+        self.wt.lock_write()
+        self.addCleanup(self.wt.unlock)
         self.assertTrue(self.wt.is_executable('file1-id'))
         transform, root = self.get_transform()
         file1_id = transform.trans_id_tree_file_id('file1-id')
@@ -1598,6 +1600,7 @@
         self.assertEqual([], list(target._iter_changes(revision_tree)))
 
     def test_build_tree_accelerator_wrong_kind(self):
+        self.requireFeature(SymlinkFeature)
         source = self.make_branch_and_tree('source')
         self.build_tree_contents([('source/file1', '')])
         self.build_tree_contents([('source/file2', '')])

=== modified file 'bzrlib/tests/test_win32utils.py'
--- a/bzrlib/tests/test_win32utils.py	2007-08-11 05:59:59 +0000
+++ b/bzrlib/tests/test_win32utils.py	2007-12-29 22:05:47 +0000
@@ -154,7 +154,7 @@
         for a in ('iexplore', 'iexplore.exe'):
             p = get_app_path(a)
             d, b = os.path.split(p)
-            self.assertEquals('iexplore.exe', b)
+            self.assertEquals('iexplore.exe', b.lower())
             self.assertNotEquals('', d)
 
     def test_not_existing(self):

=== modified file 'bzrlib/transport/__init__.py'
--- a/bzrlib/transport/__init__.py	2007-12-08 23:15:18 +0000
+++ b/bzrlib/transport/__init__.py	2007-12-29 18:23:50 +0000
@@ -343,7 +343,7 @@
         This handles things like ENOENT, ENOTDIR, EEXIST, and EACCESS
         """
         if getattr(e, 'errno', None) is not None:
-            if e.errno in (errno.ENOENT, errno.ENOTDIR):
+            if e.errno in (errno.ENOENT, errno.ENOTDIR, errno.EINVAL):
                 raise errors.NoSuchFile(path, extra=e)
             # I would rather use errno.EFOO, but there doesn't seem to be
             # any matching for 267

=== modified file 'bzrlib/transport/remote.py'
--- a/bzrlib/transport/remote.py	2007-11-19 13:44:25 +0000
+++ b/bzrlib/transport/remote.py	2007-12-29 22:34:44 +0000
@@ -386,6 +386,12 @@
             else:
                 error_path = resp[1]
             raise errors.ReadError(error_path)
+        elif what == "PermissionDenied":
+            if orig_path is not None:
+                error_path = orig_path
+            else:
+                error_path = resp[1]
+            raise errors.PermissionDenied(error_path)
         else:
             raise errors.SmartProtocolError('unexpected smart server error: %r' % (resp,))
 

=== modified file 'bzrlib/workingtree_4.py'
--- a/bzrlib/workingtree_4.py	2007-12-20 15:21:48 +0000
+++ b/bzrlib/workingtree_4.py	2007-12-29 21:28:32 +0000
@@ -494,6 +494,7 @@
 
             Note: The caller is expected to take a read-lock before calling this.
             """
+            self._must_be_locked()
             if not path:
                 path = self.id2path(file_id)
             mode = os.lstat(self.abspath(path)).st_mode




More information about the bazaar-commits mailing list