mirror of
https://github.com/facebook/sapling.git
synced 2024-10-11 01:07:15 +03:00
97755349f5
Summary: This is probably not the proper fix but we're getting rid of svn too. Remove tests coupled with named branches. Modified some critical tests (ex. "push") so they can still pass. Reviewed By: DurhamG Differential Revision: D14210968 fbshipit-source-id: 62e02179b0e4745db8f90f718613afad42d7376a
194 lines
6.6 KiB
Python
194 lines
6.6 KiB
Python
# no-check-code -- see T24862348
|
|
|
|
import errno
|
|
|
|
import test_hgsubversion_util
|
|
from edenscm.hgext.hgsubversion import compathacks
|
|
from edenscm.mercurial import commands, context, hg, node
|
|
|
|
|
|
class TestSingleDirPush(test_hgsubversion_util.TestBase):
|
|
stupid_mode_tests = True
|
|
obsolete_mode_tests = True
|
|
|
|
def test_push_single_dir(self):
|
|
# Tests simple pushing from default branch to a single dir repo
|
|
repo, repo_path = self.load_and_fetch(
|
|
"branch_from_tag.svndump", layout="single", subdir=""
|
|
)
|
|
|
|
def file_callback(repo, memctx, path):
|
|
if path == "adding_file":
|
|
return compathacks.makememfilectx(
|
|
repo,
|
|
memctx=memctx,
|
|
path=path,
|
|
data="foo",
|
|
islink=False,
|
|
isexec=False,
|
|
copied=False,
|
|
)
|
|
elif path == "adding_binary":
|
|
return compathacks.makememfilectx(
|
|
repo,
|
|
memctx=memctx,
|
|
path=path,
|
|
data="\0binary",
|
|
islink=False,
|
|
isexec=False,
|
|
copied=False,
|
|
)
|
|
raise IOError(errno.EINVAL, "Invalid operation: " + path)
|
|
|
|
ctx = context.memctx(
|
|
repo,
|
|
(repo["tip"].node(), node.nullid),
|
|
"automated test",
|
|
["adding_file", "adding_binary"],
|
|
file_callback,
|
|
"an_author",
|
|
"2009-10-19 18:49:30 -0500",
|
|
{"branch": "default"},
|
|
)
|
|
repo.commitctx(ctx)
|
|
hg.update(repo, repo["tip"].node())
|
|
self.pushrevisions()
|
|
self.assertTrue("adding_file" in test_hgsubversion_util.svnls(repo_path, ""))
|
|
self.assertEqual(
|
|
"application/octet-stream",
|
|
test_hgsubversion_util.svnpropget(
|
|
repo_path, "adding_binary", "svn:mime-type"
|
|
),
|
|
)
|
|
# Now add another commit and test mime-type being reset
|
|
changes = [("adding_binary", "adding_binary", "no longer binary")]
|
|
self.commitchanges(changes)
|
|
self.pushrevisions()
|
|
self.assertEqual(
|
|
"",
|
|
test_hgsubversion_util.svnpropget(
|
|
repo_path, "adding_binary", "svn:mime-type"
|
|
),
|
|
)
|
|
|
|
def test_push_single_dir_at_subdir(self):
|
|
repo = self._load_fixture_and_fetch(
|
|
"branch_from_tag.svndump", layout="single", subdir="trunk"
|
|
)
|
|
|
|
def filectxfn(repo, memctx, path):
|
|
return compathacks.makememfilectx(
|
|
repo,
|
|
memctx=memctx,
|
|
path=path,
|
|
data="contents of %s" % path,
|
|
islink=False,
|
|
isexec=False,
|
|
copied=False,
|
|
)
|
|
|
|
ctx = context.memctx(
|
|
repo,
|
|
(repo["tip"].node(), node.nullid),
|
|
"automated test",
|
|
["bogus"],
|
|
filectxfn,
|
|
"an_author",
|
|
"2009-10-19 18:49:30 -0500",
|
|
{},
|
|
)
|
|
# Why is this here? Revisit! T24862348
|
|
repo.commitctx(ctx)
|
|
self.assertEqual(self.repo["tip"]["bogus"].data(), "contents of bogus")
|
|
before = repo["tip"].hex()
|
|
hg.update(repo, self.repo["tip"].hex())
|
|
self.pushrevisions()
|
|
self.assertNotEqual(before, self.repo["tip"].hex())
|
|
self.assertEqual(self.repo["tip"]["bogus"].data(), "contents of bogus")
|
|
|
|
def test_push_single_dir_one_incoming_and_two_outgoing(self):
|
|
# Tests simple pushing from default branch to a single dir repo
|
|
# Pushes two outgoing over one incoming svn rev
|
|
# (used to cause an "unknown revision")
|
|
# This can happen if someone committed to svn since our last pull (race).
|
|
repo, repo_path = self.load_and_fetch(
|
|
"branch_from_tag.svndump", layout="single", subdir="trunk"
|
|
)
|
|
self.add_svn_rev(repo_path, {"trunk/alpha": "Changed"})
|
|
|
|
def file_callback(repo, memctx, path):
|
|
return compathacks.makememfilectx(
|
|
repo,
|
|
memctx=memctx,
|
|
path=path,
|
|
data="data of %s" % path,
|
|
islink=False,
|
|
isexec=False,
|
|
copied=False,
|
|
)
|
|
|
|
for fn in ["one", "two"]:
|
|
ctx = context.memctx(
|
|
repo,
|
|
(repo["tip"].node(), node.nullid),
|
|
"automated test",
|
|
[fn],
|
|
file_callback,
|
|
"an_author",
|
|
"2009-10-19 18:49:30 -0500",
|
|
{"branch": "default"},
|
|
)
|
|
repo.commitctx(ctx)
|
|
hg.update(repo, repo["tip"].node())
|
|
self.pushrevisions(expected_extra_back=1)
|
|
self.assertTrue("trunk/one" in test_hgsubversion_util.svnls(repo_path, ""))
|
|
self.assertTrue("trunk/two" in test_hgsubversion_util.svnls(repo_path, ""))
|
|
|
|
@test_hgsubversion_util.requiresoption("branch")
|
|
def test_push_single_dir_renamed_branch(self):
|
|
# Tests pulling and pushing with a renamed branch
|
|
# Based on test_push_single_dir
|
|
repo_path = self.load_svndump("branch_from_tag.svndump")
|
|
cmd = ["clone", "--quiet", "--layout=single", "--branch=flaf"]
|
|
if self.stupid:
|
|
cmd.append("--stupid")
|
|
cmd += [test_hgsubversion_util.fileurl(repo_path), self.wc_path]
|
|
test_hgsubversion_util.dispatch(cmd)
|
|
|
|
def file_callback(repo, memctx, path):
|
|
if path == "adding_file":
|
|
return compathacks.makememfilectx(
|
|
repo,
|
|
memctx=memctx,
|
|
path=path,
|
|
data="foo",
|
|
islink=False,
|
|
isexec=False,
|
|
copied=False,
|
|
)
|
|
raise IOError(errno.EINVAL, "Invalid operation: " + path)
|
|
|
|
lr = self.repo
|
|
ctx = context.memctx(
|
|
lr,
|
|
(lr["tip"].node(), node.nullid),
|
|
"automated test",
|
|
["adding_file"],
|
|
file_callback,
|
|
"an_author",
|
|
"2009-10-19 18:49:30 -0500",
|
|
{"branch": "default"},
|
|
)
|
|
lr.commitctx(ctx)
|
|
hg.update(self.repo, self.repo["tip"].node())
|
|
self.pushrevisions()
|
|
self.assertTrue("adding_file" in test_hgsubversion_util.svnls(repo_path, ""))
|
|
|
|
self.assertEquals(set(["flaf"]), set(self.repo[i].branch() for i in self.repo))
|
|
|
|
|
|
if __name__ == "__main__":
|
|
import silenttestrunner
|
|
|
|
silenttestrunner.main(__name__)
|