prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <issue>
  multiple mutable rev warnings issued on `autoupdate`
  when running `pre-commit autoupdate` I get 2 warnings per mutable rev, when I expected 0 see #974
  
  ```sh
  ~/projects/pytest-cov   pre-commit-autoupdate  pipx run pre-commit autoupdate    
  [WARNING] The 'rev' field of repo 'https://github.com/pre-commit/pre-commit-hooks' appears to be a mutable reference (moving tag / branch).  Mutable references are never updated after first install and are not supported.  See https://pre-commit.com/#using-the-latest-version-for-a-repository for more details.  Hint: `pre-commit autoupdate` often fixes this.
  [WARNING] The 'rev' field of repo 'https://github.com/timothycrosley/isort' appears to be a mutable reference (moving tag / branch).  Mutable references are never updated after first install and are not supported.  See https://pre-commit.com/#using-the-latest-version-for-a-repository for more details.  Hint: `pre-commit autoupdate` often fixes this.
  [WARNING] The 'rev' field of repo 'https://gitlab.com/pycqa/flake8' appears to be a mutable reference (moving tag / branch).  Mutable references are never updated after first install and are not supported.  See https://pre-commit.com/#using-the-latest-version-for-a-repository for more details.  Hint: `pre-commit autoupdate` often fixes this.
  [WARNING] The 'rev' field of repo 'https://github.com/pre-commit/pre-commit-hooks' appears to be a mutable reference (moving tag / branch).  Mutable references are never updated after first install and are not supported.  See https://pre-commit.com/#using-the-latest-version-for-a-repository for more details.  Hint: `pre-commit autoupdate` often fixes this.
  [WARNING] The 'rev' field of repo 'https://github.com/timothycrosley/isort' appears to be a mutable reference (moving tag / branch).  Mutable references are never updated after first install and are not supported.  See https://pre-commit.com/#using-the-latest-version-for-a-repository for more details.  Hint: `pre-commit autoupdate` often fixes this.
  [WARNING] The 'rev' field of repo 'https://gitlab.com/pycqa/flake8' appears to be a mutable reference (moving tag / branch).  Mutable references are never updated after first install and are not supported.  See https://pre-commit.com/#using-the-latest-version-for-a-repository for more details.  Hint: `pre-commit autoupdate` often fixes this.
  Updating https://github.com/pre-commit/pre-commit-hooks ... updating master -> v4.0.1.
  Updating https://github.com/timothycrosley/isort ... updating master -> 5.9.3.
  Updating https://gitlab.com/pycqa/flake8 ... updating master -> 3.9.2.
  ```
  
  </issue>
  <code>
  [start of pre_commit/commands/migrate_config.py]
  1 import re
  2 import textwrap
  3 
  4 import yaml
  5 
  6 from pre_commit.clientlib import load_config
  7 from pre_commit.util import yaml_load
  8 
  9 
  10 def _is_header_line(line: str) -> bool:
  11     return line.startswith(('#', '---')) or not line.strip()
  12 
  13 
  14 def _migrate_map(contents: str) -> str:
  15     if isinstance(yaml_load(contents), list):
  16         # Find the first non-header line
  17         lines = contents.splitlines(True)
  18         i = 0
  19         # Only loop on non empty configuration file
  20         while i < len(lines) and _is_header_line(lines[i]):
  21             i += 1
  22 
  23         header = ''.join(lines[:i])
  24         rest = ''.join(lines[i:])
  25 
  26         # If they are using the "default" flow style of yaml, this operation
  27         # will yield a valid configuration
  28         try:
  29             trial_contents = f'{header}repos:\n{rest}'
  30             yaml_load(trial_contents)
  31             contents = trial_contents
  32         except yaml.YAMLError:
  33             contents = f'{header}repos:\n{textwrap.indent(rest, " " * 4)}'
  34 
  35     return contents
  36 
  37 
  38 def _migrate_sha_to_rev(contents: str) -> str:
  39     return re.sub(r'(\n\s+)sha:', r'\1rev:', contents)
  40 
  41 
  42 def migrate_config(config_file: str, quiet: bool = False) -> int:
  43     # ensure that the configuration is a valid pre-commit configuration
  44     load_config(config_file)
  45 
  46     with open(config_file) as f:
  47         orig_contents = contents = f.read()
  48 
  49     contents = _migrate_map(contents)
  50     contents = _migrate_sha_to_rev(contents)
  51 
  52     if contents != orig_contents:
  53         with open(config_file, 'w') as f:
  54             f.write(contents)
  55 
  56         print('Configuration has been migrated.')
  57     elif not quiet:
  58         print('Configuration is already migrated.')
  59     return 0
  60
  [end of pre_commit/commands/migrate_config.py]
  </code>
  
  I need you to solve this issue by generating a single patch file that I can apply directly to this repository using git apply. Please respond with a single patch file in the following format.
  <patch>
  diff --git a/file.py b/file.py
  --- a/file.py
  +++ b/file.py
  @@ -1,27 +1,35 @@
   def euclidean(a, b):
  -    while b:
  -        a, b = b, a % b
  -    return a
  +    if b == 0:
  +        return a
  +    return euclidean(b, a % b)
   
   
   def bresenham(x0, y0, x1, y1):
       points = []
       dx = abs(x1 - x0)
       dy = abs(y1 - y0)
  -    sx = 1 if x0 < x1 else -1
  -    sy = 1 if y0 < y1 else -1
  -    err = dx - dy
  +    x, y = x0, y0
  +    sx = -1 if x0 > x1 else 1
  +    sy = -1 if y0 > y1 else 1
   
  -    while True:
  -        points.append((x0, y0))
  -        if x0 == x1 and y0 == y1:
  -            break
  -        e2 = 2 * err
  -        if e2 > -dy:
  -            err -= dy
  -            x0 += sx
  -        if e2 < dx:
  -            err += dx
  -            y0 += sy
  +    if dx > dy:
  +        err = dx / 2.0
  +        while x != x1:
  +            points.append((x, y))
  +            err -= dy
  +            if err < 0:
  +                y += sy
  +                err += dx
  +            x += sx
  +    else:
  +        err = dy / 2.0
  +        while y != y1:
  +            points.append((x, y))
  +            err -= dx
  +            if err < 0:
  +                x += sx
  +                err += dy
  +            y += sy
  +
  +    points.append((x, y))
       return points
  
  </patch>
golden_diff: diff --git a/pre_commit/commands/migrate_config.py b/pre_commit/commands/migrate_config.py
  --- a/pre_commit/commands/migrate_config.py
  +++ b/pre_commit/commands/migrate_config.py
  @@ -3,7 +3,6 @@
   
   import yaml
   
  -from pre_commit.clientlib import load_config
   from pre_commit.util import yaml_load
   
   
  @@ -40,9 +39,6 @@
   
   
   def migrate_config(config_file: str, quiet: bool = False) -> int:
  -    # ensure that the configuration is a valid pre-commit configuration
  -    load_config(config_file)
  -
       with open(config_file) as f:
           orig_contents = contents = f.read()
  
verification_info: {"golden_diff": "diff --git a/pre_commit/commands/migrate_config.py b/pre_commit/commands/migrate_config.py\n--- a/pre_commit/commands/migrate_config.py\n+++ b/pre_commit/commands/migrate_config.py\n@@ -3,7 +3,6 @@\n \n import yaml\n \n-from pre_commit.clientlib import load_config\n from pre_commit.util import yaml_load\n \n \n@@ -40,9 +39,6 @@\n \n \n def migrate_config(config_file: str, quiet: bool = False) -> int:\n-    # ensure that the configuration is a valid pre-commit configuration\n-    load_config(config_file)\n-\n     with open(config_file) as f:\n         orig_contents = contents = f.read()\n", "issue": "multiple mutable rev warnings issued on `autoupdate`\nwhen running `pre-commit autoupdate` I get 2 warnings per mutable rev, when I expected 0 see #974\r\n\r\n```sh\r\n~/projects/pytest-cov \ue0b0 \ue0a0 pre-commit-autoupdate \ue0b0 pipx run pre-commit autoupdate    \r\n[WARNING] The 'rev' field of repo 'https://github.com/pre-commit/pre-commit-hooks' appears to be a mutable reference (moving tag / branch).  Mutable references are never updated after first install and are not supported.  See https://pre-commit.com/#using-the-latest-version-for-a-repository for more details.  Hint: `pre-commit autoupdate` often fixes this.\r\n[WARNING] The 'rev' field of repo 'https://github.com/timothycrosley/isort' appears to be a mutable reference (moving tag / branch).  Mutable references are never updated after first install and are not supported.  See https://pre-commit.com/#using-the-latest-version-for-a-repository for more details.  Hint: `pre-commit autoupdate` often fixes this.\r\n[WARNING] The 'rev' field of repo 'https://gitlab.com/pycqa/flake8' appears to be a mutable reference (moving tag / branch).  Mutable references are never updated after first install and are not supported.  See https://pre-commit.com/#using-the-latest-version-for-a-repository for more details.  Hint: `pre-commit autoupdate` often fixes this.\r\n[WARNING] The 'rev' field of repo 'https://github.com/pre-commit/pre-commit-hooks' appears to be a mutable reference (moving tag / branch).  Mutable references are never updated after first install and are not supported.  See https://pre-commit.com/#using-the-latest-version-for-a-repository for more details.  Hint: `pre-commit autoupdate` often fixes this.\r\n[WARNING] The 'rev' field of repo 'https://github.com/timothycrosley/isort' appears to be a mutable reference (moving tag / branch).  Mutable references are never updated after first install and are not supported.  See https://pre-commit.com/#using-the-latest-version-for-a-repository for more details.  Hint: `pre-commit autoupdate` often fixes this.\r\n[WARNING] The 'rev' field of repo 'https://gitlab.com/pycqa/flake8' appears to be a mutable reference (moving tag / branch).  Mutable references are never updated after first install and are not supported.  See https://pre-commit.com/#using-the-latest-version-for-a-repository for more details.  Hint: `pre-commit autoupdate` often fixes this.\r\nUpdating https://github.com/pre-commit/pre-commit-hooks ... updating master -> v4.0.1.\r\nUpdating https://github.com/timothycrosley/isort ... updating master -> 5.9.3.\r\nUpdating https://gitlab.com/pycqa/flake8 ... updating master -> 3.9.2.\r\n```\n", "before_files": [{"content": "import re\nimport textwrap\n\nimport yaml\n\nfrom pre_commit.clientlib import load_config\nfrom pre_commit.util import yaml_load\n\n\ndef _is_header_line(line: str) -> bool:\n    return line.startswith(('#', '---')) or not line.strip()\n\n\ndef _migrate_map(contents: str) -> str:\n    if isinstance(yaml_load(contents), list):\n        # Find the first non-header line\n        lines = contents.splitlines(True)\n        i = 0\n        # Only loop on non empty configuration file\n        while i < len(lines) and _is_header_line(lines[i]):\n            i += 1\n\n        header = ''.join(lines[:i])\n        rest = ''.join(lines[i:])\n\n        # If they are using the \"default\" flow style of yaml, this operation\n        # will yield a valid configuration\n        try:\n            trial_contents = f'{header}repos:\\n{rest}'\n            yaml_load(trial_contents)\n            contents = trial_contents\n        except yaml.YAMLError:\n            contents = f'{header}repos:\\n{textwrap.indent(rest, \" \" * 4)}'\n\n    return contents\n\n\ndef _migrate_sha_to_rev(contents: str) -> str:\n    return re.sub(r'(\\n\\s+)sha:', r'\\1rev:', contents)\n\n\ndef migrate_config(config_file: str, quiet: bool = False) -> int:\n    # ensure that the configuration is a valid pre-commit configuration\n    load_config(config_file)\n\n    with open(config_file) as f:\n        orig_contents = contents = f.read()\n\n    contents = _migrate_map(contents)\n    contents = _migrate_sha_to_rev(contents)\n\n    if contents != orig_contents:\n        with open(config_file, 'w') as f:\n            f.write(contents)\n\n        print('Configuration has been migrated.')\n    elif not quiet:\n        print('Configuration is already migrated.')\n    return 0\n", "path": "pre_commit/commands/migrate_config.py"}]}