Rev 16: Lock trees at the appropriate time in http://bazaar.launchpad.net/%7Ebzr/bzr-vimdiff/vimdiff
John Arbash Meinel
john at arbash-meinel.com
Fri Mar 2 00:40:05 GMT 2007
At http://bazaar.launchpad.net/%7Ebzr/bzr-vimdiff/vimdiff
------------------------------------------------------------
revno: 16
revision-id: john at arbash-meinel.com-20070302003954-8ztdsswe1g3plgbu
parent: john at arbash-meinel.com-20070302003544-zq4q5v30kk215rsz
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: vimdiff
timestamp: Thu 2007-03-01 18:39:54 -0600
message:
Lock trees at the appropriate time
modified:
__init__.py __init__.py-20051124001049-15a328174b534d0a
-------------- next part --------------
=== modified file '__init__.py'
--- a/__init__.py 2007-03-02 00:35:44 +0000
+++ b/__init__.py 2007-03-02 00:39:54 +0000
@@ -59,6 +59,16 @@
def vimdiff_to_file(vimdiff_args, file_to_diff, revision=None):
from bzrlib.workingtree import WorkingTree
work_tree, rel_path = WorkingTree.open_containing(file_to_diff)
+ work_tree.lock_read()
+ try:
+ _vimdiff_to_file(work_tree, rel_path, vimdiff_args, file_to_diff,
+ revision=revision)
+ finally:
+ work_tree.unlock()
+
+
+def _vimdiff_to_file(work_tree, rel_path, vimdiff_args, file_to_diff,
+ revision=None):
branch = work_tree.branch
file_id = work_tree.path2id(rel_path)
@@ -85,7 +95,11 @@
from_rev_no, rev_id = revision[0].in_history(branch)
from_tree = branch.repository.revision_tree(rev_id)
- tmp_from = write_old_to_temp(from_tree, file_id, from_rev_no)
+ from_tree.lock_read()
+ try:
+ tmp_from = write_old_to_temp(from_tree, file_id, from_rev_no)
+ finally:
+ from_tree.unlock()
from_file = tmp_from.name
# must call with -f to wait around, so we can delete the temp file
More information about the bazaar-commits
mailing list