Skip to content

Commit

Permalink
Bug 1393242 - Use hglib for get_files_in_working_directory(); r=mshal
Browse files Browse the repository at this point in the history
And convert consumers to context managers because hglib requires that.

MozReview-Commit-ID: Ckf1yBYeUlm

--HG--
extra : rebase_source : 985220032bced1a7077fd9b04ca8ad6de822c887
  • Loading branch information
indygreg committed Aug 23, 2017
1 parent 8634ccb commit 0b25d43
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 41 deletions.
16 changes: 8 additions & 8 deletions config/check_js_msg_encoding.py
Expand Up @@ -47,14 +47,14 @@ def check_single_file(filename):
def check_files():
result = True

repo = get_repository_from_env()
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
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

return result

Expand Down
25 changes: 12 additions & 13 deletions config/check_macroassembler_style.py
Expand Up @@ -242,21 +242,20 @@ def check_style():
# We infer from each file the signature of each MacroAssembler function.
defs = dict() # type: dict(signature => ['x86', 'x64'])

repo = get_repository_from_env()

# 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
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

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),
Expand Down
35 changes: 17 additions & 18 deletions config/check_spidermonkey_style.py
Expand Up @@ -249,24 +249,23 @@ def check_style():
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)

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
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/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())

Expand Down
5 changes: 3 additions & 2 deletions python/mozversioncontrol/mozversioncontrol/__init__.py
Expand Up @@ -204,7 +204,8 @@ def forget_add_remove_files(self, 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):
Expand Down Expand Up @@ -233,7 +234,7 @@ 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):
Expand Down

0 comments on commit 0b25d43

Please sign in to comment.