diff --git a/bugbug/repository.py b/bugbug/repository.py index aaa62daf25..85508bfd7c 100644 --- a/bugbug/repository.py +++ b/bugbug/repository.py @@ -26,7 +26,6 @@ import lmdb import requests import rs_parsepatch -import tenacity from tqdm import tqdm from bugbug import db, rust_code_analysis_server, utils @@ -1520,36 +1519,29 @@ def clone( def pull(repo_dir: str, branch: str, revision: str) -> None: """Pull a revision from a branch of a remote repository into a local repository.""" - - @tenacity.retry( - stop=tenacity.stop_after_attempt(2), - reraise=True, - after=tenacity.after_log(logger, logging.DEBUG), - retry=tenacity.retry_if_exception_type(subprocess.TimeoutExpired), + cmd = _build_hg_cmd( + "robustcheckout", + f"https://hg.mozilla.org/{branch}/".encode("ascii"), + repo_dir, + purge=False, + sharebase=f"{repo_dir}-shared", + revision=revision.encode("ascii"), + noupdate=True, ) - def trigger_pull() -> None: - cmd = _build_hg_cmd( - "pull", - f"https://hg.mozilla.org/{branch}/".encode("ascii"), - r=revision.encode("ascii"), - debug=True, - ) - - p = subprocess.Popen(cmd, cwd=repo_dir) - try: - p.wait(timeout=180) - except subprocess.TimeoutExpired: - p.terminate() - p.wait() - raise + p = subprocess.Popen(cmd, cwd=repo_dir) - if p.returncode != 0: - raise RuntimeError( - f"Error {p.returncode} when pulling {revision} from {branch}" - ) + try: + p.wait(timeout=180) + except subprocess.TimeoutExpired: + p.terminate() + p.wait() + raise - trigger_pull() + if p.returncode != 0: + raise RuntimeError( + f"Error {p.returncode} when pulling {revision} from {branch}" + ) if __name__ == "__main__": diff --git a/http_service/tests/conftest.py b/http_service/tests/conftest.py index 86889eac83..c89bdce301 100644 --- a/http_service/tests/conftest.py +++ b/http_service/tests/conftest.py @@ -247,7 +247,8 @@ def mock_repo( orig_hgutil_cmdbuilder = hglib.util.cmdbuilder def hglib_cmdbuilder(name, *args, **kwargs): - if name == "pull": + if name == "robustcheckout": + name = "pull" args = list(args) args[0] = str(remote_dir).encode("ascii")