2019-05-21 19:06:46 +03:00
|
|
|
from __future__ import absolute_import
|
|
|
|
|
2018-01-17 14:23:44 +03:00
|
|
|
import test_hgsubversion_util
|
2019-01-30 03:25:33 +03:00
|
|
|
from edenscm.hgext.hgsubversion import maps, svnmeta
|
2016-06-15 20:25:39 +03:00
|
|
|
|
|
|
|
|
2018-01-17 14:23:44 +03:00
|
|
|
class TestRevMapMigrate(test_hgsubversion_util.TestBase):
|
2016-07-26 13:38:23 +03:00
|
|
|
def tearDown(self):
|
|
|
|
# revert changes to defaultrevmapclass
|
|
|
|
svnmeta.SVNMeta._defaultrevmapclass = maps.RevMap
|
|
|
|
|
2016-06-15 20:25:39 +03:00
|
|
|
def _test_revmap_migrate(self, fromclass, toclass):
|
|
|
|
# revmap interfaces to test
|
|
|
|
getters = [
|
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
|
|
|
lambda x: x.branchedits("the_branch", 3),
|
|
|
|
lambda x: x.branchedits("the_branch", 4),
|
|
|
|
lambda x: x.branchedits("the_branch", 5),
|
|
|
|
lambda x: x.branchedits("the_branch", 6),
|
2016-06-15 20:25:39 +03:00
|
|
|
lambda x: x.branchedits(None, 5),
|
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
|
|
|
lambda x: x.branchedits("non_existed", 10),
|
|
|
|
lambda x: x.branchmaxrevnum("the_branch", 3),
|
|
|
|
lambda x: x.branchmaxrevnum("the_branch", 4),
|
|
|
|
lambda x: x.branchmaxrevnum("the_branch", 5),
|
|
|
|
lambda x: x.branchmaxrevnum("the_branch", 6),
|
2016-06-15 20:25:39 +03:00
|
|
|
lambda x: x.branchmaxrevnum(None, 5),
|
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
|
|
|
lambda x: x.branchmaxrevnum("non_existed", 10),
|
2016-06-15 20:25:39 +03:00
|
|
|
lambda x: list(x.revhashes(3)),
|
|
|
|
lambda x: list(x.revhashes(4)),
|
|
|
|
lambda x: list(x.revhashes(42)),
|
|
|
|
lambda x: list(x.revhashes(105)),
|
|
|
|
lambda x: x.firstpulled,
|
|
|
|
lambda x: x.lastpulled,
|
|
|
|
lambda x: x.lasthash,
|
|
|
|
]
|
|
|
|
|
|
|
|
svnmeta.SVNMeta._defaultrevmapclass = fromclass
|
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
|
|
|
repo = self._load_fixture_and_fetch("two_heads.svndump")
|
2016-06-15 20:25:39 +03:00
|
|
|
meta = svnmeta.SVNMeta(repo)
|
|
|
|
self.assertEqual(meta.revmap.__class__, fromclass)
|
|
|
|
origrevmap = meta.revmap
|
|
|
|
|
|
|
|
# insert fake special (duplicated, with '\0') data
|
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
|
|
|
origrevmap[103, None] = b"\0" * 20
|
|
|
|
origrevmap[104, None] = b"\0" * 18 + b"cd"
|
|
|
|
origrevmap[105, None] = b"ab\0cdefghijklmnopqrs"
|
|
|
|
origrevmap[104, None] = b"\0" * 18 + b"\xff\0"
|
|
|
|
origrevmap[105, "ab"] = origrevmap[105, None]
|
2016-06-15 20:25:39 +03:00
|
|
|
|
|
|
|
origvalues = [f(meta.revmap) for f in getters]
|
|
|
|
|
|
|
|
# migrate to another format (transparently)
|
|
|
|
svnmeta.SVNMeta._defaultrevmapclass = toclass
|
|
|
|
meta = svnmeta.SVNMeta(repo)
|
|
|
|
self.assertEqual(meta.revmap.__class__, toclass)
|
|
|
|
|
|
|
|
# enable iteration otherwise we cannot use iteritems
|
|
|
|
origrevmap._allowiter = True
|
|
|
|
for k, v in origrevmap.iteritems():
|
|
|
|
newv = meta.revmap[k]
|
|
|
|
self.assertEqual(newv, v)
|
|
|
|
self.assertEqual(len(newv), 20)
|
|
|
|
self.assertEqual(meta.revmap[meta.revmap.hashes()[v]], v)
|
|
|
|
|
|
|
|
newvalues = [f(meta.revmap) for f in getters]
|
|
|
|
self.assertEqual(origvalues, newvalues)
|
|
|
|
|
|
|
|
def test_revmap_migrate_up(self):
|
|
|
|
self._test_revmap_migrate(maps.RevMap, maps.SqliteRevMap)
|
|
|
|
|
|
|
|
def test_revmap_migrate_down(self):
|
|
|
|
self._test_revmap_migrate(maps.SqliteRevMap, maps.RevMap)
|
2018-01-17 14:23:44 +03:00
|
|
|
|
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__":
|
2018-01-17 14:23:44 +03:00
|
|
|
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
|
|
|
silenttestrunner.main(__name__)
|