author | Matt Harbison <matt_harbison@yahoo.com> |
Wed, 15 Jul 2020 14:06:12 -0400 | |
changeset 45137 | 3ad0855cc602 |
parent 44432 | dca4b5da417d |
child 45830 | c102b704edb5 |
permissions | -rwxr-xr-x |
40495
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
1 |
#!/usr/bin/env python |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
2 |
from __future__ import absolute_import, print_function |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
3 |
|
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
4 |
import hashlib |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
5 |
import os |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
6 |
import random |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
7 |
import shutil |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
8 |
import stat |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
9 |
import struct |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
10 |
import sys |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
11 |
import tempfile |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
12 |
import time |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
13 |
import unittest |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
14 |
|
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
15 |
import silenttestrunner |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
16 |
|
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
17 |
# Load the local remotefilelog, not the system one |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
18 |
sys.path[0:0] = [os.path.join(os.path.dirname(__file__), '..')] |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
19 |
from mercurial.node import nullid |
44432
dca4b5da417d
test: cleanly skip test-remotefilelog-datapack.py on policy that breaks it
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43990
diff
changeset
|
20 |
from mercurial import policy |
dca4b5da417d
test: cleanly skip test-remotefilelog-datapack.py on policy that breaks it
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43990
diff
changeset
|
21 |
|
dca4b5da417d
test: cleanly skip test-remotefilelog-datapack.py on policy that breaks it
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43990
diff
changeset
|
22 |
if not policy._packageprefs.get(policy.policy, (False, False))[1]: |
dca4b5da417d
test: cleanly skip test-remotefilelog-datapack.py on policy that breaks it
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43990
diff
changeset
|
23 |
if __name__ == '__main__': |
dca4b5da417d
test: cleanly skip test-remotefilelog-datapack.py on policy that breaks it
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43990
diff
changeset
|
24 |
msg = "skipped: pure module not available with module policy:" |
dca4b5da417d
test: cleanly skip test-remotefilelog-datapack.py on policy that breaks it
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43990
diff
changeset
|
25 |
print(msg, policy.policy, file=sys.stderr) |
dca4b5da417d
test: cleanly skip test-remotefilelog-datapack.py on policy that breaks it
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43990
diff
changeset
|
26 |
sys.exit(80) |
dca4b5da417d
test: cleanly skip test-remotefilelog-datapack.py on policy that breaks it
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43990
diff
changeset
|
27 |
|
40495
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
28 |
from mercurial import ( |
41254
2888d12b80a6
tests: fix up uses of xrange in remotefilelog tests for py3
Augie Fackler <augie@google.com>
parents:
40506
diff
changeset
|
29 |
pycompat, |
40495
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
30 |
ui as uimod, |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
31 |
) |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
32 |
from hgext.remotefilelog import ( |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
33 |
basepack, |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
34 |
constants, |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
35 |
datapack, |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
36 |
) |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
37 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41527
diff
changeset
|
38 |
|
40495
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
39 |
class datapacktestsbase(object): |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
40 |
def __init__(self, datapackreader, paramsavailable): |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
41 |
self.datapackreader = datapackreader |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
42 |
self.paramsavailable = paramsavailable |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
43 |
|
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
44 |
def setUp(self): |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
45 |
self.tempdirs = [] |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
46 |
|
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
47 |
def tearDown(self): |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
48 |
for d in self.tempdirs: |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
49 |
shutil.rmtree(d) |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
50 |
|
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
51 |
def makeTempDir(self): |
41473
90b3898cf0db
tests: various Python 3 ports for test-remotefilelog-datapack.py
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41472
diff
changeset
|
52 |
tempdir = pycompat.bytestr(tempfile.mkdtemp()) |
40495
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
53 |
self.tempdirs.append(tempdir) |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
54 |
return tempdir |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
55 |
|
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
56 |
def getHash(self, content): |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
57 |
return hashlib.sha1(content).digest() |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
58 |
|
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
59 |
def getFakeHash(self): |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41527
diff
changeset
|
60 |
return b''.join( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41527
diff
changeset
|
61 |
pycompat.bytechr(random.randint(0, 255)) for _ in range(20) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41527
diff
changeset
|
62 |
) |
40495
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
63 |
|
40506
10c10da14c5d
remotefilelog: bump pack file formats to version 2
Augie Fackler <augie@google.com>
parents:
40495
diff
changeset
|
64 |
def createPack(self, revisions=None, packdir=None): |
40495
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
65 |
if revisions is None: |
41471
268325697a47
tests: use bytes and %d formatting in test-remotefilelog-datapack.py
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41321
diff
changeset
|
66 |
revisions = [(b"filename", self.getFakeHash(), nullid, b"content")] |
40495
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
67 |
|
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
68 |
if packdir is None: |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
69 |
packdir = self.makeTempDir() |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
70 |
|
40506
10c10da14c5d
remotefilelog: bump pack file formats to version 2
Augie Fackler <augie@google.com>
parents:
40495
diff
changeset
|
71 |
packer = datapack.mutabledatapack(uimod.ui(), packdir, version=2) |
40495
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
72 |
|
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
73 |
for args in revisions: |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
74 |
filename, node, base, content = args[0:4] |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
75 |
# meta is optional |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
76 |
meta = None |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
77 |
if len(args) > 4: |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
78 |
meta = args[4] |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
79 |
packer.add(filename, node, base, content, metadata=meta) |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
80 |
|
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
81 |
path = packer.close() |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
82 |
return self.datapackreader(path) |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
83 |
|
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
84 |
def _testAddSingle(self, content): |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
85 |
"""Test putting a simple blob into a pack and reading it out. |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
86 |
""" |
41471
268325697a47
tests: use bytes and %d formatting in test-remotefilelog-datapack.py
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41321
diff
changeset
|
87 |
filename = b"foo" |
40495
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
88 |
node = self.getHash(content) |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
89 |
|
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
90 |
revisions = [(filename, node, nullid, content)] |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
91 |
pack = self.createPack(revisions) |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
92 |
if self.paramsavailable: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41527
diff
changeset
|
93 |
self.assertEqual( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41527
diff
changeset
|
94 |
pack.params.fanoutprefix, basepack.SMALLFANOUTPREFIX |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41527
diff
changeset
|
95 |
) |
40495
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
96 |
|
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
97 |
chain = pack.getdeltachain(filename, node) |
41321
724b4606528e
tests: use assertEqual()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41268
diff
changeset
|
98 |
self.assertEqual(content, chain[0][4]) |
40495
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
99 |
|
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
100 |
def testAddSingle(self): |
41471
268325697a47
tests: use bytes and %d formatting in test-remotefilelog-datapack.py
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41321
diff
changeset
|
101 |
self._testAddSingle(b'') |
40495
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
102 |
|
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
103 |
def testAddSingleEmpty(self): |
41471
268325697a47
tests: use bytes and %d formatting in test-remotefilelog-datapack.py
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41321
diff
changeset
|
104 |
self._testAddSingle(b'abcdef') |
40495
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
105 |
|
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
106 |
def testAddMultiple(self): |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
107 |
"""Test putting multiple unrelated blobs into a pack and reading them |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
108 |
out. |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
109 |
""" |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
110 |
revisions = [] |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
111 |
for i in range(10): |
41471
268325697a47
tests: use bytes and %d formatting in test-remotefilelog-datapack.py
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41321
diff
changeset
|
112 |
filename = b"foo%d" % i |
268325697a47
tests: use bytes and %d formatting in test-remotefilelog-datapack.py
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41321
diff
changeset
|
113 |
content = b"abcdef%d" % i |
40495
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
114 |
node = self.getHash(content) |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
115 |
revisions.append((filename, node, self.getFakeHash(), content)) |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
116 |
|
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
117 |
pack = self.createPack(revisions) |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
118 |
|
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
119 |
for filename, node, base, content in revisions: |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
120 |
entry = pack.getdelta(filename, node) |
41321
724b4606528e
tests: use assertEqual()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41268
diff
changeset
|
121 |
self.assertEqual((content, filename, base, {}), entry) |
40495
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
122 |
|
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
123 |
chain = pack.getdeltachain(filename, node) |
41321
724b4606528e
tests: use assertEqual()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41268
diff
changeset
|
124 |
self.assertEqual(content, chain[0][4]) |
40495
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
125 |
|
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
126 |
def testAddDeltas(self): |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
127 |
"""Test putting multiple delta blobs into a pack and read the chain. |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
128 |
""" |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
129 |
revisions = [] |
41471
268325697a47
tests: use bytes and %d formatting in test-remotefilelog-datapack.py
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41321
diff
changeset
|
130 |
filename = b"foo" |
40495
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
131 |
lastnode = nullid |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
132 |
for i in range(10): |
41471
268325697a47
tests: use bytes and %d formatting in test-remotefilelog-datapack.py
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41321
diff
changeset
|
133 |
content = b"abcdef%d" % i |
40495
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
134 |
node = self.getHash(content) |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
135 |
revisions.append((filename, node, lastnode, content)) |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
136 |
lastnode = node |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
137 |
|
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
138 |
pack = self.createPack(revisions) |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
139 |
|
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
140 |
entry = pack.getdelta(filename, revisions[0][1]) |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
141 |
realvalue = (revisions[0][3], filename, revisions[0][2], {}) |
41321
724b4606528e
tests: use assertEqual()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41268
diff
changeset
|
142 |
self.assertEqual(entry, realvalue) |
40495
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
143 |
|
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
144 |
# Test that the chain for the final entry has all the others |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
145 |
chain = pack.getdeltachain(filename, node) |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
146 |
for i in range(10): |
41471
268325697a47
tests: use bytes and %d formatting in test-remotefilelog-datapack.py
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41321
diff
changeset
|
147 |
content = b"abcdef%d" % i |
41321
724b4606528e
tests: use assertEqual()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41268
diff
changeset
|
148 |
self.assertEqual(content, chain[-i - 1][4]) |
40495
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
149 |
|
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
150 |
def testPackMany(self): |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
151 |
"""Pack many related and unrelated objects. |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
152 |
""" |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
153 |
# Build a random pack file |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
154 |
revisions = [] |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
155 |
blobs = {} |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
156 |
random.seed(0) |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
157 |
for i in range(100): |
41471
268325697a47
tests: use bytes and %d formatting in test-remotefilelog-datapack.py
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41321
diff
changeset
|
158 |
filename = b"filename-%d" % i |
40495
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
159 |
filerevs = [] |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
160 |
for j in range(random.randint(1, 100)): |
41471
268325697a47
tests: use bytes and %d formatting in test-remotefilelog-datapack.py
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41321
diff
changeset
|
161 |
content = b"content-%d" % j |
40495
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
162 |
node = self.getHash(content) |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
163 |
lastnode = nullid |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
164 |
if len(filerevs) > 0: |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
165 |
lastnode = filerevs[random.randint(0, len(filerevs) - 1)] |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
166 |
filerevs.append(node) |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
167 |
blobs[(filename, node, lastnode)] = content |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
168 |
revisions.append((filename, node, lastnode, content)) |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
169 |
|
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
170 |
pack = self.createPack(revisions) |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
171 |
|
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
172 |
# Verify the pack contents |
41472
6309ce86fa82
tests: use items() in test-remotefilelog-datapack.py
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41471
diff
changeset
|
173 |
for (filename, node, lastnode), content in sorted(blobs.items()): |
40495
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
174 |
chain = pack.getdeltachain(filename, node) |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
175 |
for entry in chain: |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
176 |
expectedcontent = blobs[(entry[0], entry[1], entry[3])] |
41321
724b4606528e
tests: use assertEqual()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41268
diff
changeset
|
177 |
self.assertEqual(entry[4], expectedcontent) |
40495
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
178 |
|
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
179 |
def testPackMetadata(self): |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
180 |
revisions = [] |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
181 |
for i in range(100): |
41471
268325697a47
tests: use bytes and %d formatting in test-remotefilelog-datapack.py
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41321
diff
changeset
|
182 |
filename = b'%d.txt' % i |
268325697a47
tests: use bytes and %d formatting in test-remotefilelog-datapack.py
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41321
diff
changeset
|
183 |
content = b'put-something-here \n' * i |
40495
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
184 |
node = self.getHash(content) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41527
diff
changeset
|
185 |
meta = { |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41527
diff
changeset
|
186 |
constants.METAKEYFLAG: i ** 4, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41527
diff
changeset
|
187 |
constants.METAKEYSIZE: len(content), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41527
diff
changeset
|
188 |
b'Z': b'random_string', |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41527
diff
changeset
|
189 |
b'_': b'\0' * i, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41527
diff
changeset
|
190 |
} |
40495
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
191 |
revisions.append((filename, node, nullid, content, meta)) |
40506
10c10da14c5d
remotefilelog: bump pack file formats to version 2
Augie Fackler <augie@google.com>
parents:
40495
diff
changeset
|
192 |
pack = self.createPack(revisions) |
40495
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
193 |
for name, node, x, content, origmeta in revisions: |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
194 |
parsedmeta = pack.getmeta(name, node) |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
195 |
# flag == 0 should be optimized out |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
196 |
if origmeta[constants.METAKEYFLAG] == 0: |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
197 |
del origmeta[constants.METAKEYFLAG] |
41321
724b4606528e
tests: use assertEqual()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41268
diff
changeset
|
198 |
self.assertEqual(parsedmeta, origmeta) |
40495
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
199 |
|
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
200 |
def testGetMissing(self): |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
201 |
"""Test the getmissing() api. |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
202 |
""" |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
203 |
revisions = [] |
41471
268325697a47
tests: use bytes and %d formatting in test-remotefilelog-datapack.py
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41321
diff
changeset
|
204 |
filename = b"foo" |
40495
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
205 |
lastnode = nullid |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
206 |
for i in range(10): |
41471
268325697a47
tests: use bytes and %d formatting in test-remotefilelog-datapack.py
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41321
diff
changeset
|
207 |
content = b"abcdef%d" % i |
40495
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
208 |
node = self.getHash(content) |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
209 |
revisions.append((filename, node, lastnode, content)) |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
210 |
lastnode = node |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
211 |
|
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
212 |
pack = self.createPack(revisions) |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
213 |
|
41471
268325697a47
tests: use bytes and %d formatting in test-remotefilelog-datapack.py
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41321
diff
changeset
|
214 |
missing = pack.getmissing([(b"foo", revisions[0][1])]) |
40495
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
215 |
self.assertFalse(missing) |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
216 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41527
diff
changeset
|
217 |
missing = pack.getmissing( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41527
diff
changeset
|
218 |
[(b"foo", revisions[0][1]), (b"foo", revisions[1][1])] |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41527
diff
changeset
|
219 |
) |
40495
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
220 |
self.assertFalse(missing) |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
221 |
|
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
222 |
fakenode = self.getFakeHash() |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41527
diff
changeset
|
223 |
missing = pack.getmissing( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41527
diff
changeset
|
224 |
[(b"foo", revisions[0][1]), (b"foo", fakenode)] |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41527
diff
changeset
|
225 |
) |
41471
268325697a47
tests: use bytes and %d formatting in test-remotefilelog-datapack.py
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41321
diff
changeset
|
226 |
self.assertEqual(missing, [(b"foo", fakenode)]) |
40495
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
227 |
|
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
228 |
def testAddThrows(self): |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
229 |
pack = self.createPack() |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
230 |
|
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
231 |
try: |
41471
268325697a47
tests: use bytes and %d formatting in test-remotefilelog-datapack.py
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41321
diff
changeset
|
232 |
pack.add(b'filename', nullid, b'contents') |
40495
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
233 |
self.assertTrue(False, "datapack.add should throw") |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
234 |
except RuntimeError: |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
235 |
pass |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
236 |
|
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
237 |
def testBadVersionThrows(self): |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
238 |
pack = self.createPack() |
41471
268325697a47
tests: use bytes and %d formatting in test-remotefilelog-datapack.py
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41321
diff
changeset
|
239 |
path = pack.path + b'.datapack' |
41473
90b3898cf0db
tests: various Python 3 ports for test-remotefilelog-datapack.py
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41472
diff
changeset
|
240 |
with open(path, 'rb') as f: |
40495
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
241 |
raw = f.read() |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
242 |
raw = struct.pack('!B', 255) + raw[1:] |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
243 |
os.chmod(path, os.stat(path).st_mode | stat.S_IWRITE) |
41473
90b3898cf0db
tests: various Python 3 ports for test-remotefilelog-datapack.py
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41472
diff
changeset
|
244 |
with open(path, 'wb+') as f: |
40495
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
245 |
f.write(raw) |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
246 |
|
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
247 |
try: |
43990
37458d8b0c1e
tests: drop unused local variable assignments in remotefilelog
Matt Harbison <matt_harbison@yahoo.com>
parents:
43076
diff
changeset
|
248 |
self.datapackreader(pack.path) |
40495
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
249 |
self.assertTrue(False, "bad version number should have thrown") |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
250 |
except RuntimeError: |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
251 |
pass |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
252 |
|
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
253 |
def testMissingDeltabase(self): |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
254 |
fakenode = self.getFakeHash() |
41471
268325697a47
tests: use bytes and %d formatting in test-remotefilelog-datapack.py
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41321
diff
changeset
|
255 |
revisions = [(b"filename", fakenode, self.getFakeHash(), b"content")] |
40495
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
256 |
pack = self.createPack(revisions) |
41471
268325697a47
tests: use bytes and %d formatting in test-remotefilelog-datapack.py
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41321
diff
changeset
|
257 |
chain = pack.getdeltachain(b"filename", fakenode) |
41321
724b4606528e
tests: use assertEqual()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41268
diff
changeset
|
258 |
self.assertEqual(len(chain), 1) |
40495
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
259 |
|
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
260 |
def testLargePack(self): |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
261 |
"""Test creating and reading from a large pack with over X entries. |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
262 |
This causes it to use a 2^16 fanout table instead.""" |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
263 |
revisions = [] |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
264 |
blobs = {} |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
265 |
total = basepack.SMALLFANOUTCUTOFF + 1 |
41254
2888d12b80a6
tests: fix up uses of xrange in remotefilelog tests for py3
Augie Fackler <augie@google.com>
parents:
40506
diff
changeset
|
266 |
for i in pycompat.xrange(total): |
41471
268325697a47
tests: use bytes and %d formatting in test-remotefilelog-datapack.py
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41321
diff
changeset
|
267 |
filename = b"filename-%d" % i |
40495
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
268 |
content = filename |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
269 |
node = self.getHash(content) |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
270 |
blobs[(filename, node)] = content |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
271 |
revisions.append((filename, node, nullid, content)) |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
272 |
|
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
273 |
pack = self.createPack(revisions) |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
274 |
if self.paramsavailable: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41527
diff
changeset
|
275 |
self.assertEqual( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41527
diff
changeset
|
276 |
pack.params.fanoutprefix, basepack.LARGEFANOUTPREFIX |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41527
diff
changeset
|
277 |
) |
40495
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
278 |
|
41472
6309ce86fa82
tests: use items() in test-remotefilelog-datapack.py
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41471
diff
changeset
|
279 |
for (filename, node), content in blobs.items(): |
40495
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
280 |
actualcontent = pack.getdeltachain(filename, node)[0][4] |
41321
724b4606528e
tests: use assertEqual()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41268
diff
changeset
|
281 |
self.assertEqual(actualcontent, content) |
40495
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
282 |
|
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
283 |
def testPacksCache(self): |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
284 |
"""Test that we remember the most recent packs while fetching the delta |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
285 |
chain.""" |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
286 |
|
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
287 |
packdir = self.makeTempDir() |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
288 |
deltachains = [] |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
289 |
|
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
290 |
numpacks = 10 |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
291 |
revisionsperpack = 100 |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
292 |
|
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
293 |
for i in range(numpacks): |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
294 |
chain = [] |
41471
268325697a47
tests: use bytes and %d formatting in test-remotefilelog-datapack.py
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41321
diff
changeset
|
295 |
revision = (b'%d' % i, self.getFakeHash(), nullid, b"content") |
40495
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
296 |
|
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
297 |
for _ in range(revisionsperpack): |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
298 |
chain.append(revision) |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
299 |
revision = ( |
41471
268325697a47
tests: use bytes and %d formatting in test-remotefilelog-datapack.py
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41321
diff
changeset
|
300 |
b'%d' % i, |
40495
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
301 |
self.getFakeHash(), |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
302 |
revision[1], |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41527
diff
changeset
|
303 |
self.getFakeHash(), |
40495
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
304 |
) |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
305 |
|
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
306 |
self.createPack(chain, packdir) |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
307 |
deltachains.append(chain) |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
308 |
|
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
309 |
class testdatapackstore(datapack.datapackstore): |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
310 |
# Ensures that we are not keeping everything in the cache. |
41527
eb37d95cc486
py3: use integer division instead of `int(...)` call
Boris Feld <boris.feld@octobus.net>
parents:
41474
diff
changeset
|
311 |
DEFAULTCACHESIZE = numpacks // 2 |
40495
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
312 |
|
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
313 |
store = testdatapackstore(uimod.ui(), packdir) |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
314 |
|
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
315 |
random.shuffle(deltachains) |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
316 |
for randomchain in deltachains: |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
317 |
revision = random.choice(randomchain) |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
318 |
chain = store.getdeltachain(revision[0], revision[1]) |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
319 |
|
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
320 |
mostrecentpack = next(iter(store.packs), None) |
41321
724b4606528e
tests: use assertEqual()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41268
diff
changeset
|
321 |
self.assertEqual( |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41527
diff
changeset
|
322 |
mostrecentpack.getdeltachain(revision[0], revision[1]), chain |
40495
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
323 |
) |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
324 |
|
41321
724b4606528e
tests: use assertEqual()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41268
diff
changeset
|
325 |
self.assertEqual(randomchain.index(revision) + 1, len(chain)) |
40495
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
326 |
|
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
327 |
# perf test off by default since it's slow |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
328 |
def _testIndexPerf(self): |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
329 |
random.seed(0) |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
330 |
print("Multi-get perf test") |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
331 |
packsizes = [ |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
332 |
100, |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
333 |
10000, |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
334 |
100000, |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
335 |
500000, |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
336 |
1000000, |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
337 |
3000000, |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
338 |
] |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
339 |
lookupsizes = [ |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
340 |
10, |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
341 |
100, |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
342 |
1000, |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
343 |
10000, |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
344 |
100000, |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
345 |
1000000, |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
346 |
] |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
347 |
for packsize in packsizes: |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
348 |
revisions = [] |
41254
2888d12b80a6
tests: fix up uses of xrange in remotefilelog tests for py3
Augie Fackler <augie@google.com>
parents:
40506
diff
changeset
|
349 |
for i in pycompat.xrange(packsize): |
41471
268325697a47
tests: use bytes and %d formatting in test-remotefilelog-datapack.py
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41321
diff
changeset
|
350 |
filename = b"filename-%d" % i |
268325697a47
tests: use bytes and %d formatting in test-remotefilelog-datapack.py
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41321
diff
changeset
|
351 |
content = b"content-%d" % i |
40495
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
352 |
node = self.getHash(content) |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
353 |
revisions.append((filename, node, nullid, content)) |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
354 |
|
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
355 |
path = self.createPack(revisions).path |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
356 |
|
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
357 |
# Perf of large multi-get |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
358 |
import gc |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41527
diff
changeset
|
359 |
|
40495
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
360 |
gc.disable() |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
361 |
pack = self.datapackreader(path) |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
362 |
for lookupsize in lookupsizes: |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
363 |
if lookupsize > packsize: |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
364 |
continue |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
365 |
random.shuffle(revisions) |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
366 |
findnodes = [(rev[0], rev[1]) for rev in revisions] |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
367 |
|
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
368 |
start = time.time() |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
369 |
pack.getmissing(findnodes[:lookupsize]) |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
370 |
elapsed = time.time() - start |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41527
diff
changeset
|
371 |
print( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41527
diff
changeset
|
372 |
"%s pack %d lookups = %0.04f" |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41527
diff
changeset
|
373 |
% ( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41527
diff
changeset
|
374 |
('%d' % packsize).rjust(7), |
41471
268325697a47
tests: use bytes and %d formatting in test-remotefilelog-datapack.py
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41321
diff
changeset
|
375 |
('%d' % lookupsize).rjust(7), |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41527
diff
changeset
|
376 |
elapsed, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41527
diff
changeset
|
377 |
) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41527
diff
changeset
|
378 |
) |
40495
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
379 |
|
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
380 |
print("") |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
381 |
gc.enable() |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
382 |
|
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
383 |
# The perf test is meant to produce output, so we always fail the test |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
384 |
# so the user sees the output. |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
385 |
raise RuntimeError("perf test always fails") |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
386 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41527
diff
changeset
|
387 |
|
40495
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
388 |
class datapacktests(datapacktestsbase, unittest.TestCase): |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
389 |
def __init__(self, *args, **kwargs): |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
390 |
datapacktestsbase.__init__(self, datapack.datapack, True) |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
391 |
unittest.TestCase.__init__(self, *args, **kwargs) |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
392 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41527
diff
changeset
|
393 |
|
40495
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
394 |
# TODO: |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
395 |
# datapack store: |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
396 |
# - getmissing |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
397 |
# - GC two packs into one |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
398 |
|
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
399 |
if __name__ == '__main__': |
41268
878084a495ef
tests: also skip remotefilelog *.py tests on Windows
Matt Harbison <matt_harbison@yahoo.com>
parents:
41254
diff
changeset
|
400 |
if pycompat.iswindows: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41527
diff
changeset
|
401 |
sys.exit(80) # Skip on Windows |
40495
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
402 |
silenttestrunner.main(__name__) |