Bug 1393242 - Use hglib for get_files_in_working_directory(); r=mshal
☠☠ backed out by 299de9e2cdab ☠ ☠
authorGregory Szorc <gps@mozilla.com>
Wed, 23 Aug 2017 15:21:16 -0700
changeset 376730 18d89d8ab860835f3a380658d2606b68a19ce94c
parent 376729 ffe8bef74be0f16e129f00e13f62d4ae16b2aea7
child 376731 c36031a6431b3d3f7c7ff14ef4b385af2d9e47fb
push id32389
push userarchaeopteryx@coole-files.de
push dateFri, 25 Aug 2017 11:08:14 +0000
treeherdermozilla-central@3bbd8e25df3d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmshal
bugs1393242
milestone57.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1393242 - Use hglib for get_files_in_working_directory(); r=mshal And convert consumers to context managers because hglib requires that. MozReview-Commit-ID: Ckf1yBYeUlm
config/check_js_msg_encoding.py
config/check_macroassembler_style.py
config/check_spidermonkey_style.py
python/mozversioncontrol/mozversioncontrol/__init__.py
--- a/config/check_js_msg_encoding.py
+++ b/config/check_js_msg_encoding.py
@@ -42,24 +42,24 @@ def check_single_file(filename):
             log_fail(filename, 'not in {} encoding'.format(expected_encoding))
 
     log_pass(filename, 'ok')
     return True
 
 def check_files():
     result = True
 
-    repo = get_repository_from_env()
-    root = repo.path
+    with get_repository_from_env() as repo:
+        root = repo.path
 
-    for filename in repo.get_files_in_working_directory():
-        if filename.endswith('.msg'):
-            if filename not in ignore_files:
-                if not check_single_file(os.path.join(root, filename)):
-                    result = False
+        for filename in repo.get_files_in_working_directory():
+            if filename.endswith('.msg'):
+                if filename not in ignore_files:
+                    if not check_single_file(os.path.join(root, filename)):
+                        result = False
 
     return result
 
 def main():
     if not check_files():
         sys.exit(1)
 
     sys.exit(0)
--- a/config/check_macroassembler_style.py
+++ b/config/check_macroassembler_style.py
@@ -237,31 +237,30 @@ def generate_file_content(signatures):
 
 def check_style():
     # We read from the header file the signature of each function.
     decls = dict()      # type: dict(signature => ['x86', 'x64'])
 
     # We infer from each file the signature of each MacroAssembler function.
     defs = dict()       # type: dict(signature => ['x86', 'x64'])
 
-    repo = get_repository_from_env()
+    with get_repository_from_env() as repo:
+        # Select the appropriate files.
+        for filename in repo.get_files_in_working_directory():
+            if not filename.startswith('js/src/jit/'):
+                continue
+            if 'MacroAssembler' not in filename:
+                continue
 
-    # Select the appropriate files.
-    for filename in repo.get_files_in_working_directory():
-        if not filename.startswith('js/src/jit/'):
-            continue
-        if 'MacroAssembler' not in filename:
-            continue
+            filename = os.path.join(repo.path, filename)
 
-        filename = os.path.join(repo.path, filename)
-
-        if filename.endswith('MacroAssembler.h'):
-            decls = append_signatures(decls, get_macroassembler_declaration(filename))
-        else:
-            defs = append_signatures(defs, get_macroassembler_definitions(filename))
+            if filename.endswith('MacroAssembler.h'):
+                decls = append_signatures(decls, get_macroassembler_declaration(filename))
+            else:
+                defs = append_signatures(defs, get_macroassembler_definitions(filename))
 
     # Compare declarations and definitions output.
     difflines = difflib.unified_diff(generate_file_content(decls),
                                      generate_file_content(defs),
                                      fromfile='check_macroassembler_style.py declared syntax',
                                      tofile='check_macroassembler_style.py found definitions')
     ok = True
     for diffline in difflines:
--- a/config/check_spidermonkey_style.py
+++ b/config/check_spidermonkey_style.py
@@ -244,34 +244,33 @@ def check_style():
     # - "js/src/vm/String.h"        -> "vm/String.h"
 
     non_js_dirnames = ('mfbt/',
                        'memory/mozalloc/',
                        'mozglue/')  # type: tuple(str)
     non_js_inclnames = set()        # type: set(inclname)
     js_names = dict()               # type: dict(filename, inclname)
 
-    repo = get_repository_from_env()
-
-    # Select the appropriate files.
-    for filename in repo.get_files_in_working_directory():
-        for non_js_dir in non_js_dirnames:
-            if filename.startswith(non_js_dir) and filename.endswith('.h'):
-                inclname = 'mozilla/' + filename.split('/')[-1]
-                non_js_inclnames.add(inclname)
+    with get_repository_from_env() as repo:
+        # Select the appropriate files.
+        for filename in repo.get_files_in_working_directory():
+            for non_js_dir in non_js_dirnames:
+                if filename.startswith(non_js_dir) and filename.endswith('.h'):
+                    inclname = 'mozilla/' + filename.split('/')[-1]
+                    non_js_inclnames.add(inclname)
 
-        if filename.startswith('js/public/') and filename.endswith('.h'):
-            inclname = 'js/' + filename[len('js/public/'):]
-            js_names[filename] = inclname
+            if filename.startswith('js/public/') and filename.endswith('.h'):
+                inclname = 'js/' + filename[len('js/public/'):]
+                js_names[filename] = inclname
 
-        if filename.startswith('js/src/') and \
-           not filename.startswith(tuple(ignored_js_src_dirs)) and \
-           filename.endswith(('.c', '.cpp', '.h', '.tbl', '.msg')):
-            inclname = filename[len('js/src/'):]
-            js_names[filename] = inclname
+            if filename.startswith('js/src/') and \
+               not filename.startswith(tuple(ignored_js_src_dirs)) and \
+               filename.endswith(('.c', '.cpp', '.h', '.tbl', '.msg')):
+                inclname = filename[len('js/src/'):]
+                js_names[filename] = inclname
 
     all_inclnames = non_js_inclnames | set(js_names.values())
 
     edges = dict()      # type: dict(inclname, set(inclname))
 
     # We don't care what's inside the MFBT and MOZALLOC files, but because they
     # are #included from JS files we have to add them to the inclusion graph.
     for inclname in non_js_inclnames:
--- a/python/mozversioncontrol/mozversioncontrol/__init__.py
+++ b/python/mozversioncontrol/mozversioncontrol/__init__.py
@@ -188,17 +188,18 @@ class HgRepository(Repository):
         self._run(*args)
 
     def forget_add_remove_files(self, path):
         self._run('forget', path)
 
     def get_files_in_working_directory(self):
         # Can return backslashes on Windows. Normalize to forward slashes.
         return list(p.replace('\\', '/') for p in
-                    self._run('files', '-0').split('\0'))
+                    self._run_in_client([b'files', b'-0']).split(b'\0')
+                    if p)
 
 
 class GitRepository(Repository):
     '''An implementation of `Repository` for Git repositories.'''
     def __init__(self, path, git='git'):
         super(GitRepository, self).__init__(path, tool=git)
 
     @property
@@ -217,17 +218,17 @@ class GitRepository(Repository):
 
     def add_remove_files(self, path):
         self._run('add', path)
 
     def forget_add_remove_files(self, path):
         self._run('reset', path)
 
     def get_files_in_working_directory(self):
-        return self._run('ls-files', '-z').split('\0')
+        return self._run('ls-files', '-z').split(b'\0')
 
 
 class InvalidRepoPath(Exception):
     """Represents a failure to find a VCS repo at a specified path."""
 
 
 def get_repository_object(path, hg='hg', git='git'):
     '''Get a repository object for the repository at `path`.