mercurial/testing/storage.py
changeset 43077 687b865b95ad
parent 43076 2372284d9457
child 43089 c59eb1560c44
equal deleted inserted replaced
43076:2372284d9457 43077:687b865b95ad
    38     Use ``makeifileindextests()`` to create an instance of this type.
    38     Use ``makeifileindextests()`` to create an instance of this type.
    39     """
    39     """
    40 
    40 
    41     def testempty(self):
    41     def testempty(self):
    42         f = self._makefilefn()
    42         f = self._makefilefn()
    43         self.assertEqual(len(f), 0, 'new file store has 0 length by default')
    43         self.assertEqual(len(f), 0, b'new file store has 0 length by default')
    44         self.assertEqual(list(f), [], 'iter yields nothing by default')
    44         self.assertEqual(list(f), [], b'iter yields nothing by default')
    45 
    45 
    46         gen = iter(f)
    46         gen = iter(f)
    47         with self.assertRaises(StopIteration):
    47         with self.assertRaises(StopIteration):
    48             next(gen)
    48             next(gen)
    49 
    49 
   412         f = self._makefilefn()
   412         f = self._makefilefn()
   413 
   413 
   414         self.assertEqual(f.storageinfo(), {})
   414         self.assertEqual(f.storageinfo(), {})
   415         self.assertEqual(
   415         self.assertEqual(
   416             f.storageinfo(revisionscount=True, trackedsize=True),
   416             f.storageinfo(revisionscount=True, trackedsize=True),
   417             {'revisionscount': 0, 'trackedsize': 0},
   417             {b'revisionscount': 0, b'trackedsize': 0},
   418         )
   418         )
   419 
   419 
   420         self.assertEqual(f.size(nullrev), 0)
   420         self.assertEqual(f.size(nullrev), 0)
   421 
   421 
   422         for i in range(-5, 5):
   422         for i in range(-5, 5):
   470             node = f.add(fulltext, None, tr, 0, nullid, nullid)
   470             node = f.add(fulltext, None, tr, 0, nullid, nullid)
   471 
   471 
   472         self.assertEqual(f.storageinfo(), {})
   472         self.assertEqual(f.storageinfo(), {})
   473         self.assertEqual(
   473         self.assertEqual(
   474             f.storageinfo(revisionscount=True, trackedsize=True),
   474             f.storageinfo(revisionscount=True, trackedsize=True),
   475             {'revisionscount': 1, 'trackedsize': len(fulltext)},
   475             {b'revisionscount': 1, b'trackedsize': len(fulltext)},
   476         )
   476         )
   477 
   477 
   478         self.assertEqual(f.size(0), len(fulltext))
   478         self.assertEqual(f.size(0), len(fulltext))
   479 
   479 
   480         with self.assertRaises(IndexError):
   480         with self.assertRaises(IndexError):
   539 
   539 
   540         self.assertEqual(f.storageinfo(), {})
   540         self.assertEqual(f.storageinfo(), {})
   541         self.assertEqual(
   541         self.assertEqual(
   542             f.storageinfo(revisionscount=True, trackedsize=True),
   542             f.storageinfo(revisionscount=True, trackedsize=True),
   543             {
   543             {
   544                 'revisionscount': 3,
   544                 b'revisionscount': 3,
   545                 'trackedsize': len(fulltext0) + len(fulltext1) + len(fulltext2),
   545                 b'trackedsize': len(fulltext0)
       
   546                 + len(fulltext1)
       
   547                 + len(fulltext2),
   546             },
   548             },
   547         )
   549         )
   548 
   550 
   549         self.assertEqual(f.size(0), len(fulltext0))
   551         self.assertEqual(f.size(0), len(fulltext0))
   550         self.assertEqual(f.size(1), len(fulltext1))
   552         self.assertEqual(f.size(1), len(fulltext1))
   677         with self.assertRaises(StopIteration):
   679         with self.assertRaises(StopIteration):
   678             next(gen)
   680             next(gen)
   679 
   681 
   680         # Unrecognized nodesorder value raises ProgrammingError.
   682         # Unrecognized nodesorder value raises ProgrammingError.
   681         with self.assertRaises(error.ProgrammingError):
   683         with self.assertRaises(error.ProgrammingError):
   682             list(f.emitrevisions([], nodesorder='bad'))
   684             list(f.emitrevisions([], nodesorder=b'bad'))
   683 
   685 
   684         # nodesorder=storage is recognized. But we can't test it thoroughly
   686         # nodesorder=storage is recognized. But we can't test it thoroughly
   685         # because behavior is storage-dependent.
   687         # because behavior is storage-dependent.
   686         res = list(f.emitrevisions([node2, node1, node0], nodesorder='storage'))
   688         res = list(
       
   689             f.emitrevisions([node2, node1, node0], nodesorder=b'storage')
       
   690         )
   687         self.assertEqual(len(res), 3)
   691         self.assertEqual(len(res), 3)
   688         self.assertEqual({o.node for o in res}, {node0, node1, node2})
   692         self.assertEqual({o.node for o in res}, {node0, node1, node2})
   689 
   693 
   690         # nodesorder=nodes forces the order.
   694         # nodesorder=nodes forces the order.
   691         gen = f.emitrevisions(
   695         gen = f.emitrevisions(
   692             [node2, node0], nodesorder='nodes', revisiondata=True
   696             [node2, node0], nodesorder=b'nodes', revisiondata=True
   693         )
   697         )
   694 
   698 
   695         rev = next(gen)
   699         rev = next(gen)
   696         self.assertEqual(rev.node, node2)
   700         self.assertEqual(rev.node, node2)
   697         self.assertEqual(rev.p1node, node1)
   701         self.assertEqual(rev.p1node, node1)