Mercurial > public > mercurial-scm > hg
diff tests/test-remotefilelog-histpack.py @ 43076:2372284d9457
formatting: blacken the codebase
This is using my patch to black
(https://github.com/psf/black/pull/826) so we don't un-wrap collection
literals.
Done with:
hg files 'set:**.py - mercurial/thirdparty/** - "contrib/python-zstandard/**"' | xargs black -S
# skip-blame mass-reformatting only
# no-check-commit reformats foo_bar functions
Differential Revision: https://phab.mercurial-scm.org/D6971
author | Augie Fackler <augie@google.com> |
---|---|
date | Sun, 06 Oct 2019 09:45:02 -0400 |
parents | 876494fd967d |
children | 37458d8b0c1e |
line wrap: on
line diff
--- a/tests/test-remotefilelog-histpack.py Sat Oct 05 10:29:34 2019 -0400 +++ b/tests/test-remotefilelog-histpack.py Sun Oct 06 09:45:02 2019 -0400 @@ -18,6 +18,7 @@ pycompat, ui as uimod, ) + # Load the local remotefilelog, not the system one sys.path[0:0] = [os.path.join(os.path.dirname(__file__), '..')] from hgext.remotefilelog import ( @@ -25,6 +26,7 @@ historypack, ) + class histpacktests(unittest.TestCase): def setUp(self): self.tempdirs = [] @@ -42,8 +44,9 @@ return hashlib.sha1(content).digest() def getFakeHash(self): - return b''.join(pycompat.bytechr(random.randint(0, 255)) - for _ in range(20)) + return b''.join( + pycompat.bytechr(random.randint(0, 255)) for _ in range(20) + ) def createPack(self, revisions=None): """Creates and returns a historypack containing the specified revisions. @@ -52,12 +55,19 @@ node, p1node, p2node, and linknode. """ if revisions is None: - revisions = [(b"filename", self.getFakeHash(), nullid, nullid, - self.getFakeHash(), None)] + revisions = [ + ( + b"filename", + self.getFakeHash(), + nullid, + nullid, + self.getFakeHash(), + None, + ) + ] packdir = pycompat.fsencode(self.makeTempDir()) - packer = historypack.mutablehistorypack(uimod.ui(), packdir, - version=2) + packer = historypack.mutablehistorypack(uimod.ui(), packdir, version=2) for filename, node, p1, p2, linknode, copyfrom in revisions: packer.add(filename, node, p1, p2, linknode, copyfrom) @@ -163,8 +173,7 @@ # Verify the pack contents for (filename, node) in allentries: ancestors = pack.getancestors(filename, node) - self.assertEqual(ancestorcounts[(filename, node)], - len(ancestors)) + self.assertEqual(ancestorcounts[(filename, node)], len(ancestors)) for anode, (ap1, ap2, alinknode, copyfrom) in ancestors.items(): ep1, ep2, elinknode = allentries[(filename, anode)] self.assertEqual(ap1, ep1) @@ -208,13 +217,15 @@ missing = pack.getmissing([(filename, revisions[0][1])]) self.assertFalse(missing) - missing = pack.getmissing([(filename, revisions[0][1]), - (filename, revisions[1][1])]) + missing = pack.getmissing( + [(filename, revisions[0][1]), (filename, revisions[1][1])] + ) self.assertFalse(missing) fakenode = self.getFakeHash() - missing = pack.getmissing([(filename, revisions[0][1]), - (filename, fakenode)]) + missing = pack.getmissing( + [(filename, revisions[0][1]), (filename, fakenode)] + ) self.assertEqual(missing, [(filename, fakenode)]) # Test getmissing on a non-existant filename @@ -268,11 +279,13 @@ self.assertEqual(p2, actual[1]) self.assertEqual(linknode, actual[2]) self.assertEqual(copyfrom, actual[3]) + + # TODO: # histpack store: # - repack two packs into one if __name__ == '__main__': if pycompat.iswindows: - sys.exit(80) # Skip on Windows + sys.exit(80) # Skip on Windows silenttestrunner.main(__name__)