Bug 1630047 - Allow mozversioncontrol to add or remove multiple files at once; r=ahal

Differential Revision: https://phabricator.services.mozilla.com/D70938

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Tom Prince 2020-04-15 22:16:49 +00:00
Родитель 7c32464a6c
Коммит 01409a49a6
6 изменённых файлов: 17 добавлений и 26 удалений

Просмотреть файл

@ -199,10 +199,9 @@ Please commit or stash these changes before vendoring, or re-run with `--ignore-
self.log(logging.INFO, 'update_readme', {},
'''Updating README_MOZILLA.''')
self.update_readme(commit, timestamp, glue_dir)
self.repository.add_remove_files(vendor_dir)
self.log(logging.INFO, 'add_remove_files', {},
'''Registering changes with version control.''')
self.repository.add_remove_files(vendor_dir)
self.repository.add_remove_files(vendor_dir, glue_dir)
self.repository.add_remove_files(glue_dir)
self.log(logging.INFO, 'done', {'revision': revision},
'''Update to aom version '{revision}' ready to commit.''')

Просмотреть файл

@ -167,7 +167,6 @@ Please commit or stash these changes before vendoring, or re-run with `--ignore-
self.update_vcs_version(commit, vendor_dir, glue_dir)
self.log(logging.INFO, 'add_remove_files', {},
'''Registering changes with version control.''')
self.repository.add_remove_files(vendor_dir)
self.repository.add_remove_files(glue_dir)
self.repository.add_remove_files(vendor_dir, glue_dir)
self.log(logging.INFO, 'done', {'revision': revision},
'''Update to dav1d version '{revision}' ready to commit.''')

Просмотреть файл

@ -194,13 +194,13 @@ class Repository(object):
"""
@abc.abstractmethod
def add_remove_files(self, path):
'''Add and remove files under `path` in this repository's working copy.
def add_remove_files(self, *paths):
'''Add and remove files under `paths` in this repository's working copy.
'''
@abc.abstractmethod
def forget_add_remove_files(self, path):
'''Undo the effects of a previous add_remove_files call for `path`.
def forget_add_remove_files(self, *paths):
'''Undo the effects of a previous add_remove_files call for `paths`.
'''
@abc.abstractmethod
@ -370,16 +370,16 @@ class HgRepository(Repository):
return self._run('outgoing', '-r', '.', '--quiet',
'--template', template, upstream, return_codes=(1,)).split()
def add_remove_files(self, path):
args = ['addremove', path]
def add_remove_files(self, *paths):
args = ['addremove'] + list(paths)
m = re.search(r'\d+\.\d+', self.tool_version)
simplified_version = float(m.group(0)) if m else 0
if simplified_version >= 3.9:
args = ['--config', 'extensions.automv='] + args
self._run(*args)
def forget_add_remove_files(self, path):
self._run('forget', path)
def forget_add_remove_files(self, paths):
self._run('forget', *paths)
def get_files_in_working_directory(self):
# Can return backslashes on Windows. Normalize to forward slashes.
@ -493,11 +493,11 @@ class GitRepository(Repository):
'--oneline', '--pretty=format:', compare).splitlines()
return [f for f in files if f]
def add_remove_files(self, path):
self._run('add', path)
def add_remove_files(self, paths):
self._run('add', *paths)
def forget_add_remove_files(self, path):
self._run('reset', path)
def forget_add_remove_files(self, paths):
self._run('reset', *paths)
def get_files_in_working_directory(self):
return self._run('ls-files', '-z').split(b'\0')

Просмотреть файл

@ -53,10 +53,7 @@ def run_clang_format(hooktype, changedFiles):
# don't prevent commits, just display the clang-format results
subprocess.call(clang_format_cmd)
# Add the modified files back to the repo (expect a string)
# one by one (fails otherwise, see bug #1541409)
for f in path_list:
vcs.add_remove_files(f)
vcs.add_remove_files(*path_list)
return False
print("warning: '{}' is not a valid clang-format hooktype".format(hooktype))

Просмотреть файл

@ -48,10 +48,7 @@ def run_js_format(hooktype, changedFiles):
# don't prevent commits, just display the eslint and prettier results
subprocess.call(js_format_cmd)
# Add the modified files back to the repo (expect a string)
# one by one (fails otherwise, see bug #1541409)
for f in path_list:
vcs.add_remove_files(f)
vcs.add_remove_files(*path_list)
return False
print("warning: '{}' is not a valid js-format hooktype".format(hooktype))

Просмотреть файл

@ -175,8 +175,7 @@ def push_to_try(method, msg, try_task_config=None,
print(fh.read())
return
for path in changed_files:
vcs.add_remove_files(path)
vcs.add_remove_files(*changed_files)
try:
vcs.push_to_try(commit_message)