mirror of
https://github.com/facebook/sapling.git
synced 2024-10-10 08:47:12 +03:00
584656dff3
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
106 lines
3.8 KiB
Python
106 lines
3.8 KiB
Python
import sys
|
|
|
|
import test_hgsubversion_util
|
|
|
|
|
|
class TestFetchRenames(test_hgsubversion_util.TestBase):
|
|
stupid_mode_tests = True
|
|
|
|
def _debug_print_copies(self, repo):
|
|
w = sys.stderr.write
|
|
for rev in repo:
|
|
ctx = repo[rev]
|
|
w("%d - %s\n" % (ctx.rev(), ctx.branch()))
|
|
for f in ctx:
|
|
fctx = ctx[f]
|
|
w("%s: %r %r\n" % (f, fctx.data(), fctx.renamed()))
|
|
|
|
def test_rename(self):
|
|
config = {
|
|
"hgsubversion.filestoresize": "0",
|
|
# we set this because we expect all of the copies to be
|
|
# handled via replay, and we want to notice if that
|
|
# changes.
|
|
"hgsubversion.failonmissing": "yes",
|
|
}
|
|
repo = self._load_fixture_and_fetch("renames.svndump", config=config)
|
|
self._run_assertions(repo)
|
|
|
|
def test_rename_with_prefix(self):
|
|
config = {
|
|
"hgsubversion.filestoresize": "0",
|
|
"hgsubversion.failonmissing": "yes",
|
|
}
|
|
repo = self._load_fixture_and_fetch(
|
|
"renames_with_prefix.svndump", subdir="prefix", config=config
|
|
)
|
|
self._run_assertions(repo, prefix=True)
|
|
|
|
def _run_assertions(self, repo, prefix=False):
|
|
# Map revnum to mappings of dest name to (source name, dest content)
|
|
if prefix:
|
|
prefixlen = len("svn:ae30a990-0fd3-493e-b5d7-883bdd606745/prefix")
|
|
else:
|
|
prefixlen = len("svn:ae30a990-0fd3-493e-b5d7-883bdd606745")
|
|
copies = {
|
|
"/trunk@6": {
|
|
"a1": ("a", "a\n"),
|
|
"linka1": ("linka", "a"),
|
|
"a2": ("a", "a\n"),
|
|
"linka2": ("linka", "a"),
|
|
"b1": ("b", "b\nc\n"),
|
|
"linkb1": ("linkb", "bc"),
|
|
"da1/daf": ("da/daf", "c\n"),
|
|
"da1/dalink": ("da/dalink", "daf"),
|
|
"da1/db/dbf": ("da/db/dbf", "d\n"),
|
|
"da1/db/dblink": ("da/db/dblink", "../daf"),
|
|
"da2/daf": ("da/daf", "c\n"),
|
|
"da2/dalink": ("da/dalink", "daf"),
|
|
"da2/db/dbf": ("da/db/dbf", "d\n"),
|
|
"da2/db/dblink": ("da/db/dblink", "../daf"),
|
|
},
|
|
"/branches/branch1@6": {"c1": ("c", "c\nc\n"), "linkc1": ("linkc", "cc")},
|
|
"/trunk@10": {
|
|
"unchanged2": ("unchanged", "unchanged\n"),
|
|
"unchangedlink2": ("unchangedlink", "unchanged"),
|
|
"unchangeddir2/f": ("unchangeddir/f", "unchanged2\n"),
|
|
"unchangeddir2/link": ("unchangeddir/link", "f"),
|
|
},
|
|
"/trunk@11": {
|
|
"groupdir2/b": ("groupdir/b", "b\n"),
|
|
"groupdir2/linkb": ("groupdir/linkb", "b"),
|
|
},
|
|
}
|
|
for rev in repo:
|
|
ctx = repo[rev]
|
|
copymap = copies.get(ctx.extra()["convert_revision"][prefixlen:], {})
|
|
for f in ctx.manifest():
|
|
cp = ctx[f].renamed()
|
|
want = copymap.get(f)
|
|
self.assertEqual(
|
|
bool(cp),
|
|
bool(want),
|
|
"copy records differ for %s in %d (want %r, got %r)"
|
|
% (f, rev, want, cp),
|
|
)
|
|
if cp:
|
|
self.assertEqual(cp[0], want[0])
|
|
self.assertEqual(ctx[f].data(), want[1])
|
|
|
|
self.assertEqual(repo["tip"]["changed3"].data(), "changed\nchanged3\n")
|
|
|
|
def test_case(self):
|
|
repo = self._load_fixture_and_fetch("filecase.svndump")
|
|
files = {
|
|
0: ["A", "a", "e/a", "b", "d/a", "D/a", "f/a", "F"],
|
|
1: ["A", "a", "E/a", "B", "d/A", "D/a", "f/a", "F"],
|
|
}
|
|
for rev in repo:
|
|
self.assertEqual(sorted(files[rev]), sorted(repo[rev].manifest()))
|
|
|
|
|
|
if __name__ == "__main__":
|
|
import silenttestrunner
|
|
|
|
silenttestrunner.main(__name__)
|