Backed out changeset 101792a18a59 (bug 1676533) on request by Ricky for causing regressions

This commit is contained in:
Cristina Coroiu
2020-11-18 18:10:04 +02:00
parent f01412ade3
commit 08aa104e9c
4 changed files with 14 additions and 102 deletions

View File

@@ -109,7 +109,6 @@ class Repository(object):
pass
def _run(self, *args, **runargs):
universal_newlines = runargs.get("universal_newlines", True)
return_codes = runargs.get("return_codes", [])
cmd = (self._tool,) + args
@@ -118,7 +117,7 @@ class Repository(object):
cmd,
cwd=self.path,
env=ensure_subprocess_env(self._env),
universal_newlines=universal_newlines,
universal_newlines=True,
)
except subprocess.CalledProcessError as e:
if e.returncode in return_codes:
@@ -229,12 +228,6 @@ class Repository(object):
example, commits to the repo during the Finder's lifetime.
"""
@abc.abstractmethod
def get_file_content(self, path, revision=None):
"""Return as a bytestring the contents of the file as of the given
revision, or the current revision if none is provided.
"""
@abc.abstractmethod
def working_directory_clean(self, untracked=False, ignored=False):
"""Determine if the working directory is free of modifications.
@@ -339,16 +332,12 @@ class HgRepository(Repository):
self._client.close()
def _run(self, *args, **runargs):
universal_newlines = runargs.get("universal_newlines", True)
if not self._client.server:
return super(HgRepository, self)._run(*args, **runargs)
# hglib requires bytes on python 3
args = [a.encode("utf-8") if not isinstance(a, bytes) else a for a in args]
res = self._client.rawcommand(args)
if universal_newlines:
return res.decode("utf-8")
return res
return self._client.rawcommand(args).decode("utf-8")
def get_commit_time(self):
newest_public_revision_time = self._run(
@@ -467,12 +456,6 @@ class HgRepository(Repository):
)
return FileListFinder(files)
def get_file_content(self, path, revision=None):
args = ["cat", path]
if revision:
args += ["-r", revision]
return self._run(*args, universal_newlines=False)
def working_directory_clean(self, untracked=False, ignored=False):
args = ["status", "--modified", "--added", "--removed", "--deleted"]
if untracked:
@@ -612,10 +595,6 @@ class GitRepository(Repository):
files = [p for p in self._run("ls-files", "-z").split("\0") if p]
return FileListFinder(files)
def get_file_content(self, path, revision=None):
revision = revision or "HEAD"
return self._run("show", revision + ":" + path, universal_newlines=False)
def working_directory_clean(self, untracked=False, ignored=False):
args = ["status", "--porcelain"]

View File

@@ -2,7 +2,6 @@
subsuite=mozversioncontrol
[test_context_manager.py]
[test_file_content.py]
[test_push_to_try.py]
[test_workdir_outgoing.py]
[test_working_directory.py]

View File

@@ -1,42 +0,0 @@
from __future__ import absolute_import
import mozunit
from mozversioncontrol import get_repository_object
STEPS = {
"hg": [
"""
echo "foo" > bar
""",
"""
hg commit -m "Updated bar"
""",
],
"git": [
"""
echo "foo" > bar
""",
"""
git commit -am "Updated bar"
""",
],
}
def test_file_content(repo):
vcs = get_repository_object(repo.strpath)
head_ref = vcs.head_ref
assert vcs.get_file_content("foo") == b"foo\n"
assert vcs.get_file_content("bar") == b"bar\n"
next(repo.step)
assert vcs.get_file_content("foo") == b"foo\n"
assert vcs.get_file_content("bar") == b"bar\n"
next(repo.step)
assert vcs.get_file_content("foo") == b"foo\n"
assert vcs.get_file_content("bar") == b"foo\n"
assert vcs.get_file_content("bar", revision=head_ref) == b"bar\n"
if __name__ == "__main__":
mozunit.main()