Don't update working copy of the repository

Unless necessary (in the commit classifier script, where we are currently
"manually" applying patches from Phabricator).

Fixes #1469
This commit is contained in:
Marco Castelluccio 2020-04-22 13:29:02 +02:00
Родитель 9c645e35b6
Коммит c5726cc5e5
3 изменённых файлов: 12 добавлений и 2 удалений

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

@ -1036,7 +1036,7 @@ def clean(hg, repo_dir, pull=True):
logger.info(f"{repo_dir} pulled and updated")
def clone(repo_dir, url="https://hg.mozilla.org/mozilla-central"):
def clone(repo_dir, url="https://hg.mozilla.org/mozilla-central", update=False):
try:
with hglib.open(repo_dir) as hg:
clean(hg, repo_dir)
@ -1054,6 +1054,7 @@ def clone(repo_dir, url="https://hg.mozilla.org/mozilla-central"):
sharebase=repo_dir + "-shared",
networkattempts=7,
branch=b"tip",
noupdate=not update,
)
cmd.insert(0, hglib.HGPATH)

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

@ -220,7 +220,7 @@ class CommitClassifier(object):
)()
def update_commit_db(self):
repository.clone(self.repo_dir)
repository.clone(self.repo_dir, update=True)
assert db.download(repository.COMMITS_DB, support_files_too=True)

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

@ -93,6 +93,10 @@ def test_clone(fake_hg_repo):
repository.clone(tmp_repo_dir, url=remote)
# Assert that we don't have the file from the remote repository, since we cloned
# without updating the working dir.
assert not os.path.exists(os.path.join(tmp_repo_dir, "file1"))
# Assert we have the commit from the remote repository.
remote_revs = repository.get_revs(hg)
with hglib.open(tmp_repo_dir) as tmp_hg:
@ -115,6 +119,11 @@ def test_clone(fake_hg_repo):
with hglib.open(tmp_repo_dir) as tmp_hg:
assert repository.get_revs(tmp_hg) == remote_revs
repository.clone(f"{tmp_repo_dir}2", url=remote, update=True)
# Assert that we do have the file from the remote repository, since we cloned
# and updated the working dir.
assert os.path.exists(os.path.join(tmp_repo_dir, "file1"))
def test_get_revs(fake_hg_repo):
hg, local, remote = fake_hg_repo