Rev 2430: Rework cmd_inventory so that it uses paths2ids and locks the trees for read. in http://bazaar.launchpad.net/%7Ebzr/bzr/dirstate
John Arbash Meinel
john at arbash-meinel.com
Wed Feb 28 15:45:19 GMT 2007
At http://bazaar.launchpad.net/%7Ebzr/bzr/dirstate
------------------------------------------------------------
revno: 2430
revision-id: john at arbash-meinel.com-20070228154412-3pwfza0d3839qpsg
parent: john at arbash-meinel.com-20070228154101-ht3tfhe0s7d5k3ds
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: dirstate
timestamp: Wed 2007-02-28 09:44:12 -0600
message:
Rework cmd_inventory so that it uses paths2ids and locks the trees for read.
modified:
bzrlib/builtins.py builtins.py-20050830033751-fc01482b9ca23183
bzrlib/workingtree_4.py workingtree_4.py-20070208044105-5fgpc5j3ljlh5q6c-1
-------------- next part --------------
=== modified file 'bzrlib/builtins.py'
--- a/bzrlib/builtins.py 2007-02-26 17:09:38 +0000
+++ b/bzrlib/builtins.py 2007-02-28 15:44:12 +0000
@@ -430,32 +430,35 @@
raise errors.BzrCommandError('invalid kind specified')
work_tree, file_list = tree_files(file_list)
-
- if revision is not None:
- if len(revision) > 1:
- raise errors.BzrCommandError('bzr inventory --revision takes'
- ' exactly one revision identifier')
- revision_id = revision[0].in_history(work_tree.branch).rev_id
- tree = work_tree.branch.repository.revision_tree(revision_id)
-
- # We include work_tree as well as 'tree' here
- # So that doing '-r 10 path/foo' will lookup whatever file
- # exists now at 'path/foo' even if it has been renamed, as
- # well as whatever files existed in revision 10 at path/foo
- trees = [tree, work_tree]
- else:
- tree = work_tree
- trees = [tree]
-
- if file_list is not None:
- file_ids = _mod_tree.find_ids_across_trees(file_list, trees,
- require_versioned=True)
- # find_ids_across_trees may include some paths that don't
- # exist in 'tree'.
- entries = sorted((tree.id2path(file_id), tree.inventory[file_id])
- for file_id in file_ids if file_id in tree)
- else:
- entries = tree.inventory.entries()
+ work_tree.lock_read()
+ try:
+ if revision is not None:
+ if len(revision) > 1:
+ raise errors.BzrCommandError(
+ 'bzr inventory --revision takes exactly one revision'
+ ' identifier')
+ revision_id = revision[0].in_history(work_tree.branch).rev_id
+ tree = work_tree.branch.repository.revision_tree(revision_id)
+
+ extra_trees = [work_tree]
+ tree.lock_read()
+ else:
+ tree = work_tree
+ extra_trees = []
+
+ if file_list is not None:
+ file_ids = tree.paths2ids(file_list, trees=extra_trees,
+ require_versioned=True)
+ # find_ids_across_trees may include some paths that don't
+ # exist in 'tree'.
+ entries = sorted((tree.id2path(file_id), tree.inventory[file_id])
+ for file_id in file_ids if file_id in tree)
+ else:
+ entries = tree.inventory.entries()
+ finally:
+ tree.unlock()
+ if tree is not work_tree:
+ work_tree.unlock()
for path, entry in entries:
if kind and kind != entry.kind:
=== modified file 'bzrlib/workingtree_4.py'
--- a/bzrlib/workingtree_4.py 2007-02-27 21:32:16 +0000
+++ b/bzrlib/workingtree_4.py 2007-02-28 15:44:12 +0000
@@ -671,7 +671,7 @@
def paths2ids(self, paths, trees=[], require_versioned=True):
"""See Tree.paths2ids().
-
+
This specialisation fast-paths the case where all the trees are in the
dirstate.
"""
More information about the bazaar-commits
mailing list