|
1 | 1 | import os
|
2 | 2 |
|
3 |
| -if os.path.exists(".git"): |
4 |
| - flavor = "git" |
5 |
| - from ._git import * |
| 3 | +from typing import Container |
6 | 4 |
|
7 |
| -elif os.path.exists(".hg"): |
8 |
| - flavor = "hg" |
9 |
| - from ._hg import * |
10 | 5 |
|
11 |
| -else: |
12 |
| - flavor = "none" |
| 6 | +def _get_mod(base_directory: str): |
| 7 | + if os.path.exists(os.path.join(base_directory, ".git")): |
| 8 | + from . import _git |
13 | 9 |
|
14 |
| - def remove_files(fragment_filenames: list[str]) -> None: |
15 |
| - if not fragment_filenames: |
16 |
| - return |
| 10 | + return _git |
| 11 | + elif os.path.exists(os.path.join(base_directory, ".hg")): |
| 12 | + from . import _hg |
17 | 13 |
|
18 |
| - for fragment in fragment_filenames: |
19 |
| - os.remove(fragment) |
| 14 | + return _hg |
| 15 | + else: |
| 16 | + from . import _novcs |
20 | 17 |
|
21 |
| - def stage_newsfile(directory: str, filename: str) -> None: |
22 |
| - return |
| 18 | + return _novcs |
23 | 19 |
|
24 |
| - def get_remote_branches(base_directory: str) -> list[str]: |
25 |
| - return [] |
26 | 20 |
|
27 |
| - def list_changed_files_compared_to_branch( |
28 |
| - base_directory: str, compare_with: str, include_staged: bool |
29 |
| - ) -> list[str]: |
30 |
| - return [] |
| 21 | +def get_default_compare_branch( |
| 22 | + base_directory: str, branches: Container[str] |
| 23 | +) -> str | None: |
| 24 | + return _get_mod(base_directory).get_default_compare_branch(branches) |
| 25 | + |
| 26 | + |
| 27 | +def remove_files(base_directory: str, fragment_filenames: list[str]) -> None: |
| 28 | + return _get_mod(base_directory).remove_files(fragment_filenames) |
| 29 | + |
| 30 | + |
| 31 | +def stage_newsfile(directory: str, filename: str) -> None: |
| 32 | + return _get_mod(directory).stage_newsfile(directory, filename) |
| 33 | + |
| 34 | + |
| 35 | +def get_remote_branches(base_directory: str) -> list[str]: |
| 36 | + return _get_mod(base_directory).get_remote_branches(base_directory) |
| 37 | + |
| 38 | + |
| 39 | +def list_changed_files_compared_to_branch( |
| 40 | + base_directory: str, compare_with: str, include_staged: bool |
| 41 | +) -> list[str]: |
| 42 | + return _get_mod(base_directory).list_changed_files_compared_to_branch( |
| 43 | + base_directory, |
| 44 | + compare_with, |
| 45 | + include_staged, |
| 46 | + ) |
0 commit comments