mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-19 00:05:36 +00:00
Bug 1662856 - Delete MercurialNativeRevisionFinder
and associated test r=dmajor
Bug 1659539 caused the unit tests of this class to suddenly start running on Linux; it failed with a type error that suggests this test has never really properly worked, at least not with the version of Mercurial we're using in CI (`unsupported changeid '0' of type <type 'unicode'>`). The class itself isn't used anywhere besides these tests, so just delete the entire class. Differential Revision: https://phabricator.services.mozilla.com/D89205
This commit is contained in:
parent
b8fb1213a4
commit
59ed932290
@ -1,97 +0,0 @@
|
||||
# Copyright (C) 2015 Mozilla Contributors
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
# as published by the Free Software Foundation; either version 2
|
||||
# of the License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
#
|
||||
# As a special exception, the copyright holders of this code give you
|
||||
# permission to combine this code with the software known as 'mozbuild',
|
||||
# and to distribute those combinations without any restriction
|
||||
# coming from the use of this file. (The General Public License
|
||||
# restrictions do apply in other respects; for example, they cover
|
||||
# modification of the file, and distribution when not combined with
|
||||
# mozbuild.)
|
||||
#
|
||||
# If you modify this code, you may extend this exception to your
|
||||
# version of the code, but you are not obliged to do so. If you
|
||||
# do not wish to do so, delete this exception statement from your
|
||||
# version.
|
||||
|
||||
from __future__ import absolute_import, print_function, unicode_literals
|
||||
|
||||
import mercurial.error as error
|
||||
import mercurial.hg as hg
|
||||
import mercurial.ui as hgui
|
||||
import six
|
||||
|
||||
from .files import (
|
||||
BaseFinder,
|
||||
MercurialFile,
|
||||
)
|
||||
import mozpack.path as mozpath
|
||||
|
||||
|
||||
# This isn't a complete implementation of BaseFile. But it is complete
|
||||
# enough for moz.build reading.
|
||||
class MercurialNativeFile(MercurialFile):
|
||||
def __init__(self, data):
|
||||
self.data = data
|
||||
|
||||
def read(self):
|
||||
return self.data
|
||||
|
||||
|
||||
class MercurialNativeRevisionFinder(BaseFinder):
|
||||
def __init__(self, repo, rev='.', recognize_repo_paths=False):
|
||||
"""Create a finder attached to a specific changeset.
|
||||
|
||||
Accepts a Mercurial localrepo and changectx instance.
|
||||
"""
|
||||
if isinstance(repo, six.string_types):
|
||||
path = repo
|
||||
repo = hg.repository(hgui.ui(), repo)
|
||||
else:
|
||||
path = repo.root
|
||||
|
||||
super(MercurialNativeRevisionFinder, self).__init__(base=repo.root)
|
||||
|
||||
self._repo = repo
|
||||
self._rev = rev
|
||||
self._root = mozpath.normpath(path).rstrip('/')
|
||||
self._recognize_repo_paths = recognize_repo_paths
|
||||
|
||||
def _find(self, pattern):
|
||||
if self._recognize_repo_paths:
|
||||
raise NotImplementedError('cannot use find with recognize_repo_path')
|
||||
|
||||
return self._find_helper(pattern, self._repo[self._rev], self._get)
|
||||
|
||||
def get(self, path):
|
||||
path = mozpath.normpath(path)
|
||||
if self._recognize_repo_paths:
|
||||
if not path.startswith(self._root):
|
||||
raise ValueError('lookups in recognize_repo_paths mode must be '
|
||||
'prefixed with repo path: %s' % path)
|
||||
path = path[len(self._root) + 1:]
|
||||
|
||||
return self._get(path)
|
||||
|
||||
def _get(self, path):
|
||||
if isinstance(path, six.text_type):
|
||||
path = path.encode('utf-8', 'replace')
|
||||
|
||||
try:
|
||||
fctx = self._repo.filectx(path, self._rev)
|
||||
return MercurialNativeFile(fctx.data())
|
||||
except error.LookupError:
|
||||
return None
|
@ -40,11 +40,6 @@ try:
|
||||
except ImportError:
|
||||
hglib = None
|
||||
|
||||
try:
|
||||
from mozpack.hg import MercurialNativeRevisionFinder
|
||||
except ImportError:
|
||||
MercurialNativeRevisionFinder = None
|
||||
|
||||
from mozpack.mozjar import (
|
||||
JarReader,
|
||||
JarWriter,
|
||||
@ -1289,11 +1284,5 @@ class TestMercurialRevisionFinder(MatchTestTemplate, TestWithTmpDir):
|
||||
f = None
|
||||
|
||||
|
||||
@unittest.skipUnless(MercurialNativeRevisionFinder, 'hgnative not available')
|
||||
class TestMercurialNativeRevisionFinder(TestMercurialRevisionFinder):
|
||||
def _get_finder(self, *args, **kwargs):
|
||||
return MercurialNativeRevisionFinder(*args, **kwargs)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
mozunit.main()
|
||||
|
Loading…
Reference in New Issue
Block a user