@@ -41,6 +41,18 @@ def test_base(self):
4141 index_output .seek (0 )
4242 assert index_output .read () == fixture ("index_merge" )
4343
44+ def _cmp_tree_index (self , tree , index ):
45+ # fail unless both objects contain the same paths and blobs
46+ if isinstance (tree , str ):
47+ tree = self .repo .commit (tree ).tree
48+
49+ num_blobs = 0
50+ for blob in tree .traverse (predicate = lambda e : e .type == "blob" ):
51+ assert (blob .path ,0 ) in index .entries
52+ num_blobs += 1
53+ # END for each blob in tree
54+ assert num_blobs == len (index .entries )
55+
4456 def test_merge (self ):
4557 common_ancestor_sha = "5117c9c8a4d3af19a9958677e45cda9269de1541"
4658 cur_sha = "4b43ca7ff72d5f535134241e7c797ddc9c7a3573"
@@ -49,12 +61,12 @@ def test_merge(self):
4961 # simple index from tree
5062 base_index = Index .from_tree (self .repo , common_ancestor_sha )
5163 assert base_index .entries
64+ self ._cmp_tree_index (common_ancestor_sha , base_index )
5265
53- # merge two trees
66+ # merge two trees - its like a fast-forward
5467 two_way_index = Index .from_tree (self .repo , common_ancestor_sha , cur_sha )
5568 assert two_way_index .entries
56- for e in two_way_index .entries .values ():
57- print "%i | %s" % ( e .stage , e .path )
69+ self ._cmp_tree_index (cur_sha , two_way_index )
5870
5971 # merge three trees - here we have a merge conflict
6072 tree_way_index = Index .from_tree (self .repo , common_ancestor_sha , cur_sha , other_sha )
0 commit comments