Rev 4341: Less lock thrashing in check.py. in http://people.ubuntu.com/~robertc/baz2.0/check
Robert Collins
robertc at robertcollins.net
Mon May 11 02:59:09 BST 2009
At http://people.ubuntu.com/~robertc/baz2.0/check
------------------------------------------------------------
revno: 4341
revision-id: robertc at robertcollins.net-20090511015906-6zi6a9b8tuuhipc8
parent: robertc at robertcollins.net-20090511014900-02c29bkf0vnjve4j
committer: Robert Collins <robertc at robertcollins.net>
branch nick: check
timestamp: Mon 2009-05-11 11:59:06 +1000
message:
Less lock thrashing in check.py.
=== modified file 'bzrlib/check.py'
--- a/bzrlib/check.py 2009-05-11 01:47:06 +0000
+++ b/bzrlib/check.py 2009-05-11 01:59:06 +0000
@@ -332,12 +332,14 @@
except errors.NotBranchError:
tree = branch = repo = None
- if do_tree:
- if tree is not None:
- note("Checking working tree at '%s'."
- % (tree.bzrdir.root_transport.base,))
- tree.lock_read()
- try:
+ to_unlock = []
+ try:
+ if do_tree:
+ if tree is not None:
+ note("Checking working tree at '%s'."
+ % (tree.bzrdir.root_transport.base,))
+ tree.lock_read()
+ to_unlock.append(tree)
needed_refs = tree._get_check_refs()
refs = {}
for ref in needed_refs:
@@ -348,23 +350,19 @@
raise AssertionError(
'unknown ref kind for ref %s' % ref)
tree._check(refs)
- finally:
- tree.unlock()
- else:
- log_error("No working tree found at specified location.")
-
- if branch is not None:
- # We have a branch
- if repo is None:
- # The branch is in a shared repository
- repo = branch.repository
- branches = [branch]
- elif repo is not None:
- branches = repo.find_branches(using=True)
-
- if repo is not None:
- repo.lock_read()
- try:
+ else:
+ log_error("No working tree found at specified location.")
+
+ if branch is not None:
+ # We have a branch
+ if repo is None:
+ # The branch is in a shared repository
+ repo = branch.repository
+
+ if repo is not None:
+ repo.lock_read()
+ to_unlock.append(repo)
+ branches = repo.find_branches(using=True)
if do_repo:
note("Checking repository at '%s'."
% (repo.bzrdir.root_transport.base,))
@@ -378,10 +376,11 @@
note("Checking branch at '%s'."
% (branch.bzrdir.root_transport.base,))
check_branch(branch, verbose)
- finally:
- repo.unlock()
- else:
- if do_branch:
- log_error("No branch found at specified location.")
- if do_repo:
- log_error("No repository found at specified location.")
+ else:
+ if do_branch:
+ log_error("No branch found at specified location.")
+ if do_repo:
+ log_error("No repository found at specified location.")
+ finally:
+ for thing in to_unlock:
+ thing.unlock()
More information about the bazaar-commits
mailing list