2017-02-24 01:03:02 +03:00
|
|
|
#!/usr/bin/env python
|
2017-11-16 21:56:44 +03:00
|
|
|
from __future__ import absolute_import
|
|
|
|
|
2016-06-16 01:48:16 +03:00
|
|
|
import hashlib
|
2017-01-13 20:42:25 +03:00
|
|
|
import os
|
2016-04-29 03:37:03 +03:00
|
|
|
import random
|
|
|
|
import shutil
|
2017-01-13 20:42:25 +03:00
|
|
|
import stat
|
2016-04-29 03:37:03 +03:00
|
|
|
import struct
|
|
|
|
import tempfile
|
|
|
|
import unittest
|
|
|
|
|
|
|
|
import silenttestrunner
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
from hgext.remotefilelog.basepack import LARGEFANOUTPREFIX, SMALLFANOUTCUTOFF
|
2018-01-10 02:23:52 +03:00
|
|
|
from hgext.remotefilelog.historypack import historypack, mutablehistorypack
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
from mercurial import error, ui as uimod
|
2016-11-25 03:23:21 +03:00
|
|
|
from mercurial.node import nullid
|
2016-04-29 03:37:03 +03:00
|
|
|
|
2016-05-24 12:15:58 +03:00
|
|
|
|
flake8: enable F821 check
Summary:
This check is useful and detects real errors (ex. fbconduit). Unfortunately
`arc lint` will run it with both py2 and py3 so a lot of py2 builtins will
still be warned.
I didn't find a clean way to disable py3 check. So this diff tries to fix them.
For `xrange`, the change was done by a script:
```
import sys
import redbaron
headertypes = {'comment', 'endl', 'from_import', 'import', 'string',
'assignment', 'atomtrailers'}
xrangefix = '''try:
xrange(0)
except NameError:
xrange = range
'''
def isxrange(x):
try:
return x[0].value == 'xrange'
except Exception:
return False
def main(argv):
for i, path in enumerate(argv):
print('(%d/%d) scanning %s' % (i + 1, len(argv), path))
content = open(path).read()
try:
red = redbaron.RedBaron(content)
except Exception:
print(' warning: failed to parse')
continue
hasxrange = red.find('atomtrailersnode', value=isxrange)
hasxrangefix = 'xrange = range' in content
if hasxrangefix or not hasxrange:
print(' no need to change')
continue
# find a place to insert the compatibility statement
changed = False
for node in red:
if node.type in headertypes:
continue
# node.insert_before is an easier API, but it has bugs changing
# other "finally" and "except" positions. So do the insert
# manually.
# # node.insert_before(xrangefix)
line = node.absolute_bounding_box.top_left.line - 1
lines = content.splitlines(1)
content = ''.join(lines[:line]) + xrangefix + ''.join(lines[line:])
changed = True
break
if changed:
# "content" is faster than "red.dumps()"
open(path, 'w').write(content)
print(' updated')
if __name__ == "__main__":
sys.exit(main(sys.argv[1:]))
```
For other py2 builtins that do not have a py3 equivalent, some `# noqa`
were added as a workaround for now.
Reviewed By: DurhamG
Differential Revision: D6934535
fbshipit-source-id: 546b62830af144bc8b46788d2e0fd00496838939
2018-02-10 04:31:44 +03:00
|
|
|
try:
|
|
|
|
xrange(0)
|
|
|
|
except NameError:
|
|
|
|
xrange = range
|
|
|
|
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
|
2016-04-29 03:37:03 +03:00
|
|
|
class histpacktests(unittest.TestCase):
|
|
|
|
def setUp(self):
|
|
|
|
self.tempdirs = []
|
|
|
|
|
|
|
|
def tearDown(self):
|
|
|
|
for d in self.tempdirs:
|
|
|
|
shutil.rmtree(d)
|
|
|
|
|
|
|
|
def makeTempDir(self):
|
|
|
|
tempdir = tempfile.mkdtemp()
|
|
|
|
self.tempdirs.append(tempdir)
|
|
|
|
return tempdir
|
|
|
|
|
|
|
|
def getHash(self, content):
|
2016-06-16 01:48:16 +03:00
|
|
|
return hashlib.sha1(content).digest()
|
2016-04-29 03:37:03 +03:00
|
|
|
|
|
|
|
def getFakeHash(self):
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
return "".join(chr(random.randint(0, 255)) for _ in range(20))
|
2016-04-29 03:37:03 +03:00
|
|
|
|
|
|
|
def createPack(self, revisions=None):
|
|
|
|
"""Creates and returns a historypack containing the specified revisions.
|
|
|
|
|
|
|
|
`revisions` is a list of tuples, where each tuple contains a filanem,
|
|
|
|
node, p1node, p2node, and linknode.
|
|
|
|
"""
|
|
|
|
if revisions is None:
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
revisions = [
|
|
|
|
(
|
|
|
|
"filename",
|
|
|
|
self.getFakeHash(),
|
|
|
|
nullid,
|
|
|
|
nullid,
|
|
|
|
self.getFakeHash(),
|
|
|
|
None,
|
|
|
|
)
|
|
|
|
]
|
2016-04-29 03:37:03 +03:00
|
|
|
|
|
|
|
packdir = self.makeTempDir()
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
packer = mutablehistorypack(uimod.ui(), packdir, version=1)
|
2016-04-29 03:37:03 +03:00
|
|
|
|
2016-05-16 20:59:09 +03:00
|
|
|
for filename, node, p1, p2, linknode, copyfrom in revisions:
|
|
|
|
packer.add(filename, node, p1, p2, linknode, copyfrom)
|
2016-04-29 03:37:03 +03:00
|
|
|
|
|
|
|
path = packer.close()
|
|
|
|
return historypack(path)
|
|
|
|
|
|
|
|
def testAddSingle(self):
|
|
|
|
"""Test putting a single entry into a pack and reading it out.
|
|
|
|
"""
|
|
|
|
filename = "foo"
|
|
|
|
node = self.getFakeHash()
|
|
|
|
p1 = self.getFakeHash()
|
|
|
|
p2 = self.getFakeHash()
|
|
|
|
linknode = self.getFakeHash()
|
|
|
|
|
2016-05-16 20:59:09 +03:00
|
|
|
revisions = [(filename, node, p1, p2, linknode, None)]
|
2016-04-29 03:37:03 +03:00
|
|
|
pack = self.createPack(revisions)
|
|
|
|
|
history: remove getparents and getlinknode apis
Summary:
These APIs weren't actually used, and the questions can be answered via
the existing getancestors() api anyway.
They were originally put in place because they are the type of question that
doesn't require the full ancestor tree, so we could answer them without doing in
traversal. In an upcoming patch we add the concept of copyfrom back into the
historypack, and getparents becomes confusing since it doesn't expose knowledge
of copy information. So I just decided to delete it all until we need it.
In the future we may want a 'gethistoryinfo(filename, node)' api that just
returns (p1, p2, linknode, copyfrom), to fulfill that original need of history
information without a full ancestor traversal.
Test Plan: Ran the tests
Reviewers: #mercurial, ttung, mitrandir
Reviewed By: mitrandir
Differential Revision: https://phabricator.intern.facebook.com/D3261734
Signature: t1:3261734:1462413665:987c4703e53468a75346aa323188107a5c070fde
2016-05-16 20:59:09 +03:00
|
|
|
actual = pack.getancestors(filename, node)[node]
|
|
|
|
self.assertEquals(p1, actual[0])
|
|
|
|
self.assertEquals(p2, actual[1])
|
|
|
|
self.assertEquals(linknode, actual[2])
|
2016-04-29 03:37:03 +03:00
|
|
|
|
|
|
|
def testAddMultiple(self):
|
|
|
|
"""Test putting multiple unrelated revisions into a pack and reading
|
|
|
|
them out.
|
|
|
|
"""
|
|
|
|
revisions = []
|
|
|
|
for i in range(10):
|
|
|
|
filename = "foo-%s" % i
|
|
|
|
node = self.getFakeHash()
|
|
|
|
p1 = self.getFakeHash()
|
|
|
|
p2 = self.getFakeHash()
|
|
|
|
linknode = self.getFakeHash()
|
2016-05-16 20:59:09 +03:00
|
|
|
revisions.append((filename, node, p1, p2, linknode, None))
|
2016-04-29 03:37:03 +03:00
|
|
|
|
|
|
|
pack = self.createPack(revisions)
|
|
|
|
|
2016-05-16 20:59:09 +03:00
|
|
|
for filename, node, p1, p2, linknode, copyfrom in revisions:
|
history: remove getparents and getlinknode apis
Summary:
These APIs weren't actually used, and the questions can be answered via
the existing getancestors() api anyway.
They were originally put in place because they are the type of question that
doesn't require the full ancestor tree, so we could answer them without doing in
traversal. In an upcoming patch we add the concept of copyfrom back into the
historypack, and getparents becomes confusing since it doesn't expose knowledge
of copy information. So I just decided to delete it all until we need it.
In the future we may want a 'gethistoryinfo(filename, node)' api that just
returns (p1, p2, linknode, copyfrom), to fulfill that original need of history
information without a full ancestor traversal.
Test Plan: Ran the tests
Reviewers: #mercurial, ttung, mitrandir
Reviewed By: mitrandir
Differential Revision: https://phabricator.intern.facebook.com/D3261734
Signature: t1:3261734:1462413665:987c4703e53468a75346aa323188107a5c070fde
2016-05-16 20:59:09 +03:00
|
|
|
actual = pack.getancestors(filename, node)[node]
|
|
|
|
self.assertEquals(p1, actual[0])
|
|
|
|
self.assertEquals(p2, actual[1])
|
|
|
|
self.assertEquals(linknode, actual[2])
|
2016-05-16 20:59:09 +03:00
|
|
|
self.assertEquals(copyfrom, actual[3])
|
2016-04-29 03:37:03 +03:00
|
|
|
|
|
|
|
def testAddAncestorChain(self):
|
|
|
|
"""Test putting multiple revisions in into a pack and read the ancestor
|
|
|
|
chain.
|
|
|
|
"""
|
|
|
|
revisions = []
|
|
|
|
filename = "foo"
|
|
|
|
lastnode = nullid
|
|
|
|
for i in range(10):
|
|
|
|
node = self.getFakeHash()
|
2016-05-16 20:59:09 +03:00
|
|
|
revisions.append((filename, node, lastnode, nullid, nullid, None))
|
2016-04-29 03:37:03 +03:00
|
|
|
lastnode = node
|
|
|
|
|
|
|
|
# revisions must be added in topological order, newest first
|
|
|
|
revisions = list(reversed(revisions))
|
|
|
|
pack = self.createPack(revisions)
|
|
|
|
|
|
|
|
# Test that the chain has all the entries
|
|
|
|
ancestors = pack.getancestors(revisions[0][0], revisions[0][1])
|
2016-05-16 20:59:09 +03:00
|
|
|
for filename, node, p1, p2, linknode, copyfrom in revisions:
|
|
|
|
ap1, ap2, alinknode, acopyfrom = ancestors[node]
|
2016-04-29 03:37:03 +03:00
|
|
|
self.assertEquals(ap1, p1)
|
|
|
|
self.assertEquals(ap2, p2)
|
|
|
|
self.assertEquals(alinknode, linknode)
|
2016-05-16 20:59:09 +03:00
|
|
|
self.assertEquals(acopyfrom, copyfrom)
|
2016-04-29 03:37:03 +03:00
|
|
|
|
|
|
|
def testPackMany(self):
|
|
|
|
"""Pack many related and unrelated ancestors.
|
|
|
|
"""
|
|
|
|
# Build a random pack file
|
|
|
|
allentries = {}
|
|
|
|
ancestorcounts = {}
|
|
|
|
revisions = []
|
|
|
|
random.seed(0)
|
|
|
|
for i in range(100):
|
|
|
|
filename = "filename-%s" % i
|
|
|
|
entries = []
|
|
|
|
p2 = nullid
|
|
|
|
linknode = nullid
|
|
|
|
for j in range(random.randint(1, 100)):
|
|
|
|
node = self.getFakeHash()
|
|
|
|
p1 = nullid
|
|
|
|
if len(entries) > 0:
|
|
|
|
p1 = entries[random.randint(0, len(entries) - 1)]
|
|
|
|
entries.append(node)
|
2016-05-16 20:59:09 +03:00
|
|
|
revisions.append((filename, node, p1, p2, linknode, None))
|
2016-04-29 03:37:03 +03:00
|
|
|
allentries[(filename, node)] = (p1, p2, linknode)
|
|
|
|
if p1 == nullid:
|
|
|
|
ancestorcounts[(filename, node)] = 1
|
|
|
|
else:
|
|
|
|
newcount = ancestorcounts[(filename, p1)] + 1
|
|
|
|
ancestorcounts[(filename, node)] = newcount
|
|
|
|
|
|
|
|
# Must add file entries in reverse topological order
|
|
|
|
revisions = list(reversed(revisions))
|
|
|
|
pack = self.createPack(revisions)
|
|
|
|
|
|
|
|
# Verify the pack contents
|
|
|
|
for (filename, node), (p1, p2, lastnode) in allentries.iteritems():
|
|
|
|
ancestors = pack.getancestors(filename, node)
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
self.assertEquals(ancestorcounts[(filename, node)], len(ancestors))
|
2016-04-29 03:37:03 +03:00
|
|
|
for anode, (ap1, ap2, alinknode, copyfrom) in ancestors.iteritems():
|
|
|
|
ep1, ep2, elinknode = allentries[(filename, anode)]
|
|
|
|
self.assertEquals(ap1, ep1)
|
|
|
|
self.assertEquals(ap2, ep2)
|
|
|
|
self.assertEquals(alinknode, elinknode)
|
|
|
|
self.assertEquals(copyfrom, None)
|
|
|
|
|
2017-04-27 20:44:34 +03:00
|
|
|
def testGetNodeInfo(self):
|
|
|
|
revisions = []
|
|
|
|
filename = "foo"
|
|
|
|
lastnode = nullid
|
|
|
|
for i in range(10):
|
|
|
|
node = self.getFakeHash()
|
|
|
|
revisions.append((filename, node, lastnode, nullid, nullid, None))
|
|
|
|
lastnode = node
|
|
|
|
|
|
|
|
pack = self.createPack(revisions)
|
|
|
|
|
|
|
|
# Test that getnodeinfo returns the expected results
|
|
|
|
for filename, node, p1, p2, linknode, copyfrom in revisions:
|
|
|
|
ap1, ap2, alinknode, acopyfrom = pack.getnodeinfo(filename, node)
|
|
|
|
self.assertEquals(ap1, p1)
|
|
|
|
self.assertEquals(ap2, p2)
|
|
|
|
self.assertEquals(alinknode, linknode)
|
|
|
|
self.assertEquals(acopyfrom, copyfrom)
|
|
|
|
|
2016-04-29 03:37:03 +03:00
|
|
|
def testGetMissing(self):
|
|
|
|
"""Test the getmissing() api.
|
|
|
|
"""
|
|
|
|
revisions = []
|
|
|
|
filename = "foo"
|
|
|
|
for i in range(10):
|
|
|
|
node = self.getFakeHash()
|
|
|
|
p1 = self.getFakeHash()
|
|
|
|
p2 = self.getFakeHash()
|
|
|
|
linknode = self.getFakeHash()
|
2016-05-16 20:59:09 +03:00
|
|
|
revisions.append((filename, node, p1, p2, linknode, None))
|
2016-04-29 03:37:03 +03:00
|
|
|
|
|
|
|
pack = self.createPack(revisions)
|
|
|
|
|
|
|
|
missing = pack.getmissing([(filename, revisions[0][1])])
|
|
|
|
self.assertFalse(missing)
|
|
|
|
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
missing = pack.getmissing(
|
|
|
|
[(filename, revisions[0][1]), (filename, revisions[1][1])]
|
|
|
|
)
|
2016-04-29 03:37:03 +03:00
|
|
|
self.assertFalse(missing)
|
|
|
|
|
|
|
|
fakenode = self.getFakeHash()
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
missing = pack.getmissing([(filename, revisions[0][1]), (filename, fakenode)])
|
2016-04-29 03:37:03 +03:00
|
|
|
self.assertEquals(missing, [(filename, fakenode)])
|
|
|
|
|
2016-05-16 20:59:09 +03:00
|
|
|
# Test getmissing on a non-existant filename
|
|
|
|
missing = pack.getmissing([("bar", fakenode)])
|
|
|
|
self.assertEquals(missing, [("bar", fakenode)])
|
|
|
|
|
2016-04-29 03:37:03 +03:00
|
|
|
def testAddThrows(self):
|
|
|
|
pack = self.createPack()
|
|
|
|
|
|
|
|
try:
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
pack.add("filename", nullid, nullid, nullid, nullid, None)
|
2016-04-29 03:37:03 +03:00
|
|
|
self.assertTrue(False, "historypack.add should throw")
|
|
|
|
except RuntimeError:
|
|
|
|
pass
|
|
|
|
|
|
|
|
def testBadVersionThrows(self):
|
|
|
|
pack = self.createPack()
|
2018-07-10 03:39:36 +03:00
|
|
|
path = pack.path() + ".histpack"
|
2016-04-29 03:37:03 +03:00
|
|
|
with open(path) as f:
|
|
|
|
raw = f.read()
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
raw = struct.pack("!B", 255) + raw[1:]
|
2017-01-13 20:42:25 +03:00
|
|
|
os.chmod(path, os.stat(path).st_mode | stat.S_IWRITE)
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
with open(path, "w+") as f:
|
2016-04-29 03:37:03 +03:00
|
|
|
f.write(raw)
|
|
|
|
|
|
|
|
try:
|
2018-07-10 03:39:36 +03:00
|
|
|
pack = historypack(pack.path())
|
2016-04-29 03:37:03 +03:00
|
|
|
self.assertTrue(False, "bad version number should have thrown")
|
|
|
|
except RuntimeError:
|
|
|
|
pass
|
|
|
|
|
2016-05-24 12:15:58 +03:00
|
|
|
def testLargePack(self):
|
|
|
|
"""Test creating and reading from a large pack with over X entries.
|
|
|
|
This causes it to use a 2^16 fanout table instead."""
|
|
|
|
total = SMALLFANOUTCUTOFF + 1
|
|
|
|
revisions = []
|
|
|
|
for i in xrange(total):
|
|
|
|
filename = "foo-%s" % i
|
|
|
|
node = self.getFakeHash()
|
|
|
|
p1 = self.getFakeHash()
|
|
|
|
p2 = self.getFakeHash()
|
|
|
|
linknode = self.getFakeHash()
|
|
|
|
revisions.append((filename, node, p1, p2, linknode, None))
|
|
|
|
|
|
|
|
pack = self.createPack(revisions)
|
|
|
|
self.assertEquals(pack.params.fanoutprefix, LARGEFANOUTPREFIX)
|
|
|
|
|
|
|
|
for filename, node, p1, p2, linknode, copyfrom in revisions:
|
|
|
|
actual = pack.getancestors(filename, node)[node]
|
|
|
|
self.assertEquals(p1, actual[0])
|
|
|
|
self.assertEquals(p2, actual[1])
|
|
|
|
self.assertEquals(linknode, actual[2])
|
|
|
|
self.assertEquals(copyfrom, actual[3])
|
2018-02-27 22:10:28 +03:00
|
|
|
|
|
|
|
def testReadingMutablePack(self):
|
|
|
|
"""Tests that the data written into a mutablehistorypack can be read out
|
|
|
|
before it has been finalized."""
|
|
|
|
packdir = self.makeTempDir()
|
2018-03-15 23:40:13 +03:00
|
|
|
packer = mutablehistorypack(uimod.ui(), packdir, version=1)
|
2018-02-27 22:10:28 +03:00
|
|
|
|
|
|
|
revisions = []
|
|
|
|
|
|
|
|
filename = "foo"
|
|
|
|
lastnode = nullid
|
|
|
|
for i in range(5):
|
|
|
|
node = self.getFakeHash()
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
revisions.append((filename, node, lastnode, nullid, nullid, ""))
|
2018-02-27 22:10:28 +03:00
|
|
|
lastnode = node
|
|
|
|
|
|
|
|
filename = "bar"
|
|
|
|
lastnode = nullid
|
|
|
|
for i in range(5):
|
|
|
|
node = self.getFakeHash()
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
revisions.append((filename, node, lastnode, nullid, nullid, ""))
|
2018-02-27 22:10:28 +03:00
|
|
|
lastnode = node
|
|
|
|
|
|
|
|
for filename, node, p1, p2, linknode, copyfrom in revisions:
|
|
|
|
packer.add(filename, node, p1, p2, linknode, copyfrom)
|
|
|
|
|
|
|
|
# Test getancestors()
|
|
|
|
for filename, node, p1, p2, linknode, copyfrom in revisions:
|
|
|
|
entry = packer.getancestors(filename, node)
|
|
|
|
self.assertEquals(entry, {node: (p1, p2, linknode, copyfrom)})
|
|
|
|
|
|
|
|
# Test getmissing()
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
missingcheck = [(revisions[0][0], revisions[0][1]), ("foo", self.getFakeHash())]
|
2018-02-27 22:10:28 +03:00
|
|
|
missing = packer.getmissing(missingcheck)
|
|
|
|
self.assertEquals(missing, missingcheck[1:])
|
|
|
|
|
2018-03-15 23:40:13 +03:00
|
|
|
def testWritingLinkRevs(self):
|
|
|
|
"""Tests that we can add linkrevs and have them written as linknodes.
|
|
|
|
"""
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
|
2018-03-22 08:33:29 +03:00
|
|
|
class fakerepo(object):
|
|
|
|
def __init__(self):
|
|
|
|
self.changelog = fakechangelog()
|
|
|
|
|
2018-03-15 23:40:13 +03:00
|
|
|
class fakechangelog(object):
|
|
|
|
def __init__(self):
|
|
|
|
self.commits = []
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
|
2018-03-15 23:40:13 +03:00
|
|
|
def __len__(self):
|
|
|
|
return len(self.commits)
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
|
2018-03-15 23:40:13 +03:00
|
|
|
def rev(self, node):
|
|
|
|
try:
|
|
|
|
return self.commits.index(node)
|
|
|
|
except Exception:
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
raise error.LookupError(hex(node), "x", "x")
|
|
|
|
|
2018-03-15 23:40:13 +03:00
|
|
|
def node(self, rev):
|
|
|
|
if rev >= len(self.commits):
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
raise error.LookupError(rev, "x", "x")
|
2018-03-15 23:40:13 +03:00
|
|
|
return self.commits[rev]
|
|
|
|
|
2018-03-22 08:33:29 +03:00
|
|
|
repo = fakerepo()
|
2018-03-15 23:40:13 +03:00
|
|
|
packdir = self.makeTempDir()
|
2018-03-22 08:33:29 +03:00
|
|
|
packer = mutablehistorypack(uimod.ui(), packdir, version=1, repo=repo)
|
2018-03-15 23:40:13 +03:00
|
|
|
|
|
|
|
revisions = []
|
|
|
|
commits = []
|
|
|
|
|
|
|
|
filename = "foo"
|
|
|
|
lastnode = nullid
|
|
|
|
for i in range(5):
|
|
|
|
node = self.getFakeHash()
|
|
|
|
linknode = self.getFakeHash()
|
|
|
|
commits.append(linknode)
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
revisions.append((filename, node, lastnode, nullid, linknode, ""))
|
2018-03-15 23:40:13 +03:00
|
|
|
lastnode = node
|
|
|
|
|
|
|
|
for filename, node, p1, p2, linknode, copyfrom in revisions:
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
packer.add(
|
|
|
|
filename, node, p1, p2, None, copyfrom, linkrev=commits.index(linknode)
|
|
|
|
)
|
2018-03-15 23:40:13 +03:00
|
|
|
|
|
|
|
# Test adding linknode and linkrev
|
|
|
|
try:
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
packer.add(
|
|
|
|
"",
|
|
|
|
self.getFakeHash(),
|
|
|
|
self.getFakeHash(),
|
|
|
|
nullid,
|
|
|
|
self.getFakeHash(),
|
|
|
|
"",
|
|
|
|
5,
|
|
|
|
)
|
|
|
|
self.assertFalse(True, "Adding linknode and linkrev should've " "thrown")
|
2018-03-15 23:40:13 +03:00
|
|
|
except error.ProgrammingError:
|
|
|
|
pass
|
|
|
|
|
|
|
|
# Test getancestors before finalizing
|
|
|
|
try:
|
|
|
|
filename, node = revisions[0][:2]
|
|
|
|
packer.getancestors(filename, node)
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
self.assertFalse(True, "Reading data before finalizing should've " "thrown")
|
2018-03-15 23:40:13 +03:00
|
|
|
except error.ProgrammingError:
|
|
|
|
pass
|
|
|
|
|
|
|
|
# "Commit" the commits to the changelog
|
2018-03-22 08:33:29 +03:00
|
|
|
repo.changelog.commits = commits
|
2018-03-15 23:40:13 +03:00
|
|
|
|
|
|
|
# Verify reading from the mutable store
|
|
|
|
for filename, node, p1, p2, linknode, copyfrom in revisions:
|
|
|
|
entry = packer.getnodeinfo(filename, node)
|
|
|
|
self.assertEquals(entry, (p1, p2, linknode, copyfrom))
|
|
|
|
|
|
|
|
path = packer.close()
|
|
|
|
pack = historypack(path)
|
|
|
|
|
|
|
|
# Verify reading from the on disk pack
|
|
|
|
for filename, node, p1, p2, linknode, copyfrom in revisions:
|
|
|
|
entry = pack.getnodeinfo(filename, node)
|
|
|
|
copyfrom = None if not copyfrom else copyfrom
|
|
|
|
self.assertEquals(entry, (p1, p2, linknode, copyfrom))
|
|
|
|
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
|
2016-04-29 03:37:03 +03:00
|
|
|
# TODO:
|
|
|
|
# histpack store:
|
|
|
|
# - repack two packs into one
|
|
|
|
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
if __name__ == "__main__":
|
2016-04-29 03:37:03 +03:00
|
|
|
silenttestrunner.main(__name__)
|