Skip to content

Commit d9318f6

Browse files
committed
Use robustcheckout for pulling
Fixes #5393
1 parent 57c7a46 commit d9318f6

File tree

2 files changed

+20
-28
lines changed

2 files changed

+20
-28
lines changed

bugbug/repository.py

Lines changed: 19 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
import lmdb
2727
import requests
2828
import rs_parsepatch
29-
import tenacity
3029
from tqdm import tqdm
3130

3231
from bugbug import db, rust_code_analysis_server, utils
@@ -1520,36 +1519,29 @@ def clone(
15201519

15211520
def pull(repo_dir: str, branch: str, revision: str) -> None:
15221521
"""Pull a revision from a branch of a remote repository into a local repository."""
1523-
1524-
@tenacity.retry(
1525-
stop=tenacity.stop_after_attempt(2),
1526-
reraise=True,
1527-
after=tenacity.after_log(logger, logging.DEBUG),
1528-
retry=tenacity.retry_if_exception_type(subprocess.TimeoutExpired),
1522+
cmd = _build_hg_cmd(
1523+
"robustcheckout",
1524+
f"https://hg.mozilla.org/{branch}/".encode("ascii"),
1525+
repo_dir,
1526+
purge=False,
1527+
sharebase=f"{repo_dir}-shared",
1528+
revision=revision.encode("ascii"),
1529+
noupdate=True,
15291530
)
1530-
def trigger_pull() -> None:
1531-
cmd = _build_hg_cmd(
1532-
"pull",
1533-
f"https://hg.mozilla.org/{branch}/".encode("ascii"),
1534-
r=revision.encode("ascii"),
1535-
debug=True,
1536-
)
1537-
1538-
p = subprocess.Popen(cmd, cwd=repo_dir)
15391531

1540-
try:
1541-
p.wait(timeout=180)
1542-
except subprocess.TimeoutExpired:
1543-
p.terminate()
1544-
p.wait()
1545-
raise
1532+
p = subprocess.Popen(cmd, cwd=repo_dir)
15461533

1547-
if p.returncode != 0:
1548-
raise RuntimeError(
1549-
f"Error {p.returncode} when pulling {revision} from {branch}"
1550-
)
1534+
try:
1535+
p.wait(timeout=180)
1536+
except subprocess.TimeoutExpired:
1537+
p.terminate()
1538+
p.wait()
1539+
raise
15511540

1552-
trigger_pull()
1541+
if p.returncode != 0:
1542+
raise RuntimeError(
1543+
f"Error {p.returncode} when pulling {revision} from {branch}"
1544+
)
15531545

15541546

15551547
if __name__ == "__main__":

http_service/tests/conftest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ def mock_repo(
247247
orig_hgutil_cmdbuilder = hglib.util.cmdbuilder
248248

249249
def hglib_cmdbuilder(name, *args, **kwargs):
250-
if name == "pull":
250+
if name == "robustcheckout":
251251
args = list(args)
252252
args[0] = str(remote_dir).encode("ascii")
253253

0 commit comments

Comments
 (0)