Rev 3011: Lock the tree's used to test annotate_file, and add a docstring for annotate_file explaining its needs. in http://people.ubuntu.com/~robertc/baz2.0/pack.read-locks

Robert Collins robertc at robertcollins.net
Wed Nov 21 21:57:24 GMT 2007


At http://people.ubuntu.com/~robertc/baz2.0/pack.read-locks

------------------------------------------------------------
revno: 3011
revision-id:robertc at robertcollins.net-20071121215711-meep8d5qazsufllc
parent: pqm at pqm.ubuntu.com-20071121045727-gqycrul94d0ssir1
committer: Robert Collins <robertc at robertcollins.net>
branch nick: pack.read-locks
timestamp: Thu 2007-11-22 08:57:11 +1100
message:
  Lock the tree's used to test annotate_file, and add a docstring for annotate_file explaining its needs.
modified:
  bzrlib/annotate.py             annotate.py-20050922133147-7c60541d2614f022
  bzrlib/tests/test_annotate.py  test_annotate.py-20061213215015-sttc9agsxomls7q0-1
=== modified file 'bzrlib/annotate.py'
--- a/bzrlib/annotate.py	2007-10-16 16:02:01 +0000
+++ b/bzrlib/annotate.py	2007-11-21 21:57:11 +0000
@@ -39,6 +39,20 @@
 
 def annotate_file(branch, rev_id, file_id, verbose=False, full=False,
                   to_file=None, show_ids=False):
+    """Annotate file_id at revision rev_id in branch.
+
+    The branch should already be read_locked() when annotate_file is called.
+
+    :param branch: The branch to look for revision numbers and history from.
+    :param rev_id: The revision id to annotate.
+    :param file_id: The file_id to annotate.
+    :param verbose: Show all details rather than truncating to ensure
+        reasonable text width.
+    :param full: XXXX Not sure what this does.
+    :param to_file: The file to output the annotation to; if None stdout is
+        used.
+    :param show_ids: Show revision ids in the annotation output.
+    """
     if to_file is None:
         to_file = sys.stdout
 

=== modified file 'bzrlib/tests/test_annotate.py'
--- a/bzrlib/tests/test_annotate.py	2007-08-31 19:38:52 +0000
+++ b/bzrlib/tests/test_annotate.py	2007-11-21 21:57:11 +0000
@@ -149,6 +149,8 @@
         tree1.commit('merge 2', rev_id='rev-3',
                      committer='sal at foo.com',
                      timestamp=1166046003.00, timezone=0)
+        tree1.lock_read()
+        self.addCleanup(tree1.unlock)
         return tree1, tree2
 
     def create_deeply_merged_trees(self):
@@ -175,6 +177,7 @@
         rev-6
         """
         tree1, tree2 = self.create_merged_trees()
+        tree1.unlock()
 
         tree3 = tree2.bzrdir.clone('tree3').open_workingtree()
 
@@ -202,6 +205,7 @@
                      timestamp=1166046005.00, timezone=0)
         self.assertEqual(0, tree1.merge_from_branch(tree4.branch))
         tree1.commit('merge five and six', rev_id='rev-6')
+        tree1.lock_read()
         return tree1
 
     def test_annotate_shows_dotted_revnos(self):
@@ -325,6 +329,8 @@
                      committer=u'p\xe9rez',
                      timestamp=1166046000.00, timezone=0)
 
+        tree1.lock_read()
+        self.addCleanup(tree1.unlock)
         # this passes if no exception is raised
         to_file = StringIO()
         annotate.annotate_file(tree1.branch, 'rev-1', 'a-id', to_file=to_file)
@@ -362,6 +368,8 @@
                      author='Author <author at example.com>',
                      timestamp=1166046000.00, timezone=0)
 
+        tree1.lock_read()
+        self.addCleanup(tree1.unlock)
         to_file = StringIO()
         annotate.annotate_file(tree1.branch, 'rev-1', 'a-id', to_file=to_file)
         self.assertEqual('1   committ | hello\n', to_file.getvalue())



More information about the bazaar-commits mailing list