Rev 24: Use the builder in test_model as well to shave off a few more seconds. in http://bzr.arbash-meinel.com/plugins/git

John Arbash Meinel john at arbash-meinel.com
Fri Nov 9 15:56:26 GMT 2007


At http://bzr.arbash-meinel.com/plugins/git

------------------------------------------------------------
revno: 24
revision-id:john at arbash-meinel.com-20071109155623-drmfwv9j1nhaol64
parent: john at arbash-meinel.com-20071109155324-kg06nis3idelqva0
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: git
timestamp: Fri 2007-11-09 10:56:23 -0500
message:
  Use the builder in test_model as well to shave off a few more seconds.
modified:
  tests/test_model.py            test_model.py-20071109031625-vi84303d1n5gnha1-2
-------------- next part --------------
=== modified file 'tests/test_model.py'
--- a/tests/test_model.py	2007-11-09 04:40:42 +0000
+++ b/tests/test_model.py	2007-11-09 15:56:23 +0000
@@ -36,20 +36,30 @@
 
     def test_ancestors(self):
         tests.run_git('init')
-        self.build_tree(['a'])
-        tests.run_git('add', 'a')
-        tests.run_git('commit', '-m', 'a')
-        tests.run_git('branch', 'foo')
-        self.build_tree_contents([('a', 'new a\n')])
-        tests.run_git('commit', '-a', '-m', 'new a')
-        tests.run_git('checkout', 'foo')
-        self.build_tree(['b'])
-        tests.run_git('add', 'b')
-        tests.run_git('commit', '-m', 'b')
-        tests.run_git('merge', 'master')
-
-        revisions = tests.run_git('rev-list', '--topo-order', 'HEAD')
+        builder = tests.GitBranchBuilder()
+        file_handle = builder.set_file('a', 'text for a\n', False)
+        commit1_handle = builder.commit('Joe Foo <joe at foo.com>', u'message')
+        file2_handle = builder.set_file('a', 'new a\n', False)
+        commit2_handle = builder.commit('Joe Foo <joe at foo.com>', u'new a')
+        file3_handle = builder.set_file('b', 'text for b\n', False)
+        commit3_handle = builder.commit('Jerry Bar <jerry at foo.com>', u'b',
+                                        base=commit1_handle)
+        commit4_handle = builder.commit('Jerry Bar <jerry at foo.com>', u'merge',
+                                        base=commit3_handle,
+                                        merge=[commit2_handle],)
+
+        mapping = builder.finish()
+        commit1_id = mapping[commit1_handle]
+        commit2_id = mapping[commit2_handle]
+        commit3_id = mapping[commit3_handle]
+        commit4_id = mapping[commit4_handle]
+
+        revisions = tests.run_git('rev-list', '--topo-order',
+                                  commit4_id)
         revisions = revisions.splitlines()
+        self.assertEqual([commit4_id, commit2_id, commit3_id, commit1_id],
+                         revisions)
+
         graph = {revisions[0]:[revisions[2], revisions[1]],
                  revisions[1]:[revisions[3]],
                  revisions[2]:[revisions[3]],
@@ -57,5 +67,6 @@
                 }
 
         themodel = model.GitModel('.git')
+        tests.run_git('reset', '--hard', commit4_id)
         self.assertEqual(revisions[0], themodel.get_head())
         self.assertEqual(graph, themodel.ancestry([revisions[0]]))



More information about the bazaar-commits mailing list