Rev 4714: Fix bug #495023, _update_current_block should not supress exceptions. in http://bazaar.launchpad.net/~jameinel/bzr/2.0.4-update-exception-495023
John Arbash Meinel
john at arbash-meinel.com
Mon Jan 4 20:06:44 GMT 2010
At http://bazaar.launchpad.net/~jameinel/bzr/2.0.4-update-exception-495023
------------------------------------------------------------
revno: 4714
revision-id: john at arbash-meinel.com-20100104200630-p5qhylc0mr2qm5ws
parent: pqm at pqm.ubuntu.com-20091221020607-39aj3xnhja6hjfqe
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: 2.0.4-update-exception-495023
timestamp: Mon 2010-01-04 14:06:30 -0600
message:
Fix bug #495023, _update_current_block should not supress exceptions.
It was marked 'void' but called a pure-python function, so it could
not propogate the exception returned by python. Now we set an exept
clause so that it can.
-------------- next part --------------
=== modified file 'NEWS'
--- a/NEWS 2009-12-18 22:03:09 +0000
+++ b/NEWS 2010-01-04 20:06:30 +0000
@@ -31,6 +31,11 @@
This will likely have an impact on any other process that is serving for
an extended period of time. (John Arbash Meinel, #494406)
+* ``_update_current_block`` no longer suppresses exceptions, so ^C at just
+ the right time will get propagated, rather than silently failing to move
+ the block pointer. (John Arbash Meinel, #495023)
+
+
Improvements
************
=== modified file 'bzrlib/_dirstate_helpers_pyx.pyx'
--- a/bzrlib/_dirstate_helpers_pyx.pyx 2009-09-30 05:58:45 +0000
+++ b/bzrlib/_dirstate_helpers_pyx.pyx 2010-01-04 20:06:30 +0000
@@ -1392,7 +1392,7 @@
# provide.
self.search_specific_file_parents.add('')
- cdef void _update_current_block(self):
+ cdef int _update_current_block(self) except -1:
if (self.block_index < len(self.state._dirblocks) and
osutils.is_inside(self.current_root, self.state._dirblocks[self.block_index][0])):
self.current_block = self.state._dirblocks[self.block_index]
@@ -1401,6 +1401,7 @@
else:
self.current_block = None
self.current_block_list = None
+ return 0
def __next__(self):
# Simple thunk to allow tail recursion without pyrex confusion
=== modified file 'bzrlib/tests/test__dirstate_helpers.py'
--- a/bzrlib/tests/test__dirstate_helpers.py 2009-06-22 15:39:42 +0000
+++ b/bzrlib/tests/test__dirstate_helpers.py 2010-01-04 20:06:30 +0000
@@ -1,4 +1,4 @@
-# Copyright (C) 2007, 2008 Canonical Ltd
+# Copyright (C) 2007, 2008, 2009 Canonical Ltd
#
# 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
@@ -1295,6 +1295,25 @@
tree.unlock()
self.assertEqual(sorted(expected), sorted(file_ids))
+ def test_exceptions_raised(self):
+ # This is a direct test of bug #495023, it relies on osutils.is_inside
+ # getting called in an inner function. Which makes it a bit brittle,
+ # but at least it does reproduce the bug.
+ def is_inside_raises(*args, **kwargs):
+ raise RuntimeError('stop this')
+ tree = self.make_branch_and_tree('tree')
+ self.build_tree(['tree/file', 'tree/dir/', 'tree/dir/sub',
+ 'tree/dir2/', 'tree/dir2/sub2'])
+ tree.add(['file', 'dir', 'dir/sub', 'dir2', 'dir2/sub2'])
+ tree.commit('first commit')
+ tree.lock_read()
+ self.addCleanup(tree.unlock)
+ basis_tree = tree.basis_tree()
+ orig = osutils.is_inside
+ self.addCleanup(setattr, osutils, 'is_inside', orig)
+ osutils.is_inside = is_inside_raises
+ self.assertListRaises(RuntimeError, tree.iter_changes, basis_tree)
+
def test_simple_changes(self):
tree = self.make_branch_and_tree('tree')
self.build_tree(['tree/file'])
More information about the bazaar-commits
mailing list