bug 1388820 - remove repo manifest support from symbolstore.py. r=chmanchester draft
authorTed Mielczarek <ted@mielczarek.org>
Wed, 09 Aug 2017 13:36:07 -0400
changeset 646693 c692ae97cdc12c7f2c25aaf79a9b86fa2301872e
parent 618576 87824406b9feb420a3150720707b424d7cee5915
child 646694 2f199db33464e45de58959090944005bdf72e3a9
push id74221
push userbmo:ted@mielczarek.org
push dateTue, 15 Aug 2017 18:51:29 +0000
reviewerschmanchester
bugs1388820
milestone56.0a1
bug 1388820 - remove repo manifest support from symbolstore.py. r=chmanchester MozReview-Commit-ID: LbDc6YKGpqX
toolkit/crashreporter/tools/symbolstore.py
toolkit/crashreporter/tools/unit-symbolstore.py
--- a/toolkit/crashreporter/tools/symbolstore.py
+++ b/toolkit/crashreporter/tools/symbolstore.py
@@ -35,17 +35,16 @@ import fnmatch
 import subprocess
 import time
 import ctypes
 import urlparse
 import concurrent.futures
 import multiprocessing
 
 from optparse import OptionParser
-from xml.dom.minidom import parse
 
 from mozpack.copier import FileRegistry
 from mozpack.manifests import (
     InstallManifest,
     UnreadableInstallManifest,
 )
 
 # Utility classes
@@ -372,98 +371,45 @@ class Dumper:
     srcdirRepoInfo = {}
 
     def __init__(self, dump_syms, symbol_path,
                  archs=None,
                  srcdirs=[],
                  copy_debug=False,
                  vcsinfo=False,
                  srcsrv=False,
-                 repo_manifest=None,
                  file_mapping=None):
         # popen likes absolute paths, at least on windows
         self.dump_syms = os.path.abspath(dump_syms)
         self.symbol_path = symbol_path
         if archs is None:
             # makes the loop logic simpler
             self.archs = ['']
         else:
             self.archs = ['-a %s' % a for a in archs.split()]
         self.srcdirs = [os.path.normpath(self.FixFilenameCase(a)) for a in srcdirs]
         self.copy_debug = copy_debug
         self.vcsinfo = vcsinfo
         self.srcsrv = srcsrv
-        if repo_manifest:
-            self.parse_repo_manifest(repo_manifest)
         self.file_mapping = file_mapping or {}
         # Add a static mapping for Rust sources.
         target_os = buildconfig.substs['OS_ARCH']
         rust_srcdir = None
         if target_os == 'WINNT':
             rust_srcdir = 'C:/projects/rust/'
         elif target_os == 'Darwin':
             rust_srcdir = '/Users/travis/build/rust-lang/rust/'
         elif target_os == 'Linux':
             rust_srcdir = '/checkout/'
         if rust_srcdir is not None:
             self.srcdirs.append(rust_srcdir)
             Dumper.srcdirRepoInfo[rust_srcdir] = GitRepoInfo(rust_srcdir,
                                                              buildconfig.substs['RUSTC_COMMIT'],
                                                              'https://github.com/rust-lang/rust/')
 
-    def parse_repo_manifest(self, repo_manifest):
-        """
-        Parse an XML manifest of repository info as produced
-        by the `repo manifest -r` command.
-        """
-        doc = parse(repo_manifest)
-        if doc.firstChild.tagName != "manifest":
-            return
-        # First, get remotes.
-        def ensure_slash(u):
-            if not u.endswith("/"):
-                return u + "/"
-            return u
-        remotes = dict([(r.getAttribute("name"), ensure_slash(r.getAttribute("fetch"))) for r in doc.getElementsByTagName("remote")])
-        # And default remote.
-        default_remote = None
-        if doc.getElementsByTagName("default"):
-            default_remote = doc.getElementsByTagName("default")[0].getAttribute("remote")
-        # Now get projects. Assume they're relative to repo_manifest.
-        base_dir = os.path.abspath(os.path.dirname(repo_manifest))
-        for proj in doc.getElementsByTagName("project"):
-            # name is the repository URL relative to the remote path.
-            name = proj.getAttribute("name")
-            # path is the path on-disk, relative to the manifest file.
-            path = proj.getAttribute("path")
-            # revision is the changeset ID.
-            rev = proj.getAttribute("revision")
-            # remote is the base URL to use.
-            remote = proj.getAttribute("remote")
-            # remote defaults to the <default remote>.
-            if not remote:
-                remote = default_remote
-            # path defaults to name.
-            if not path:
-                path = name
-            if not (name and path and rev and remote):
-                print("Skipping project %s" % proj.toxml())
-                continue
-            remote = remotes[remote]
-            # Turn git URLs into http URLs so that urljoin works.
-            if remote.startswith("git:"):
-                remote = "http" + remote[3:]
-            # Add this project to srcdirs.
-            srcdir = os.path.join(base_dir, path)
-            self.srcdirs.append(srcdir)
-            # And cache its VCS file info. Currently all repos mentioned
-            # in a repo manifest are assumed to be git.
-            root = urlparse.urljoin(remote, name)
-            Dumper.srcdirRepoInfo[srcdir] = GitRepoInfo(srcdir, rev, root)
-
     # subclasses override this
     def ShouldProcess(self, file):
         return True
 
     def RunFileCommand(self, file):
         """Utility function, returns the output of file(1)"""
         try:
             # we use -L to read the targets of symlinks,
@@ -863,21 +809,16 @@ def main():
                       action="append", dest="srcdir", default=[],
                       help="Use SRCDIR to determine relative paths to source files")
     parser.add_option("-v", "--vcs-info",
                       action="store_true", dest="vcsinfo",
                       help="Try to retrieve VCS info for each FILE listed in the output")
     parser.add_option("-i", "--source-index",
                       action="store_true", dest="srcsrv", default=False,
                       help="Add source index information to debug files, making them suitable for use in a source server.")
-    parser.add_option("--repo-manifest",
-                      action="store", dest="repo_manifest",
-                      help="""Get source information from this XML manifest
-produced by the `repo manifest -r` command.
-""")
     parser.add_option("--install-manifest",
                       action="append", dest="install_manifests",
                       default=[],
                       help="""Use this install manifest to map filenames back
 to canonical locations in the source repository. Specify
 <install manifest filename>,<install destination> as a comma-separated pair.
 """)
     (options, args) = parser.parse_args()
@@ -901,16 +842,15 @@ to canonical locations in the source rep
     file_mapping = make_file_mapping(manifests)
     dumper = GetPlatformSpecificDumper(dump_syms=args[0],
                                        symbol_path=args[1],
                                        copy_debug=options.copy_debug,
                                        archs=options.archs,
                                        srcdirs=options.srcdir,
                                        vcsinfo=options.vcsinfo,
                                        srcsrv=options.srcsrv,
-                                       repo_manifest=options.repo_manifest,
                                        file_mapping=file_mapping)
 
     dumper.Process(args[2])
 
 # run main if run directly
 if __name__ == "__main__":
     main()
--- a/toolkit/crashreporter/tools/unit-symbolstore.py
+++ b/toolkit/crashreporter/tools/unit-symbolstore.py
@@ -209,42 +209,16 @@ class TestGetVCSFilename(HelperMixin, un
         os.environ['MOZ_SOURCE_REPO'] = 'https://somewhere.com/repo'
         os.environ['MOZ_SOURCE_CHANGESET'] = 'abcdef0123456'
         os.mkdir(os.path.join(self.test_dir, '.hg'))
         filename = os.path.join(self.test_dir, 'foo.c')
         self.assertEqual('hg:somewhere.com/repo:foo.c:abcdef0123456',
                          symbolstore.GetVCSFilename(filename, [self.test_dir])[0])
 
 
-class TestRepoManifest(HelperMixin, unittest.TestCase):
-    def testRepoManifest(self):
-        manifest = os.path.join(self.test_dir, "sources.xml")
-        open(manifest, "w").write("""<?xml version="1.0" encoding="UTF-8"?>
-<manifest>
-<remote fetch="http://example.com/foo/" name="foo"/>
-<remote fetch="git://example.com/bar/" name="bar"/>
-<default remote="bar"/>
-<project name="projects/one" revision="abcd1234"/>
-<project name="projects/two" path="projects/another" revision="ffffffff" remote="foo"/>
-<project name="something_else" revision="00000000" remote="bar"/>
-</manifest>
-""")
-        # Use a source file from each of the three projects
-        file1 = os.path.join(self.test_dir, "projects", "one", "src1.c")
-        file2 = os.path.join(self.test_dir, "projects", "another", "src2.c")
-        file3 = os.path.join(self.test_dir, "something_else", "src3.c")
-        d = symbolstore.Dumper("dump_syms", "symbol_path",
-                               repo_manifest=manifest)
-        self.assertEqual("git:example.com/bar/projects/one:src1.c:abcd1234",
-                         symbolstore.GetVCSFilename(file1, d.srcdirs)[0])
-        self.assertEqual("git:example.com/foo/projects/two:src2.c:ffffffff",
-                         symbolstore.GetVCSFilename(file2, d.srcdirs)[0])
-        self.assertEqual("git:example.com/bar/something_else:src3.c:00000000",
-                         symbolstore.GetVCSFilename(file3, d.srcdirs)[0])
-
 if target_platform() == 'WINNT':
     class TestFixFilenameCase(HelperMixin, unittest.TestCase):
         def test_fix_filename_case(self):
             # self.test_dir is going to be 8.3 paths...
             junk = os.path.join(self.test_dir, 'x')
             with open(junk, 'wb') as o:
                 o.write('x')
             d = symbolstore.Dumper_Win32(dump_syms='dump_syms',