remotefilelog: improve robustness of hg gc loop

Summary:
We've gotten reports of hg gc failing on some service machines because
`peer._repo.name` complains that repo has no attribute 'name'. I'm not sure how
this could happen, but it makes sense to make the hg gc loop more robust to the
possibility that the repos in the 'repos' file have changed their configuration
since they were added to the file.

Test Plan: Ran the tests

Reviewers: #mercurial, simonfar

Reviewed By: simonfar

Subscribers: mjpieters

Differential Revision: https://phabricator.intern.facebook.com/D4072719

Signature: t1:4072719:1477385020:24d532b9442292ce8234cc91bc7de503d3b0c88f
This commit is contained in:
Durham Goode 2016-10-25 12:30:59 -07:00
parent 857f31c0d7
commit 36ec03fd19

View File

@ -595,6 +595,16 @@ def gcclient(ui, cachepath):
validrepos.append(path)
# Protect against any repo or config changes that have happened since
# this repo was added to the repos file. We'd rather this loop succeed
# and too much be deleted, than the loop fail and nothing gets deleted.
if shallowrepo.requirement not in peer._repo.requirements:
continue
if not util.safehasattr(peer._repo, 'name'):
ui.warn(_("repo %s is a misconfigured remotefilelog repo\n") % path)
continue
reponame = peer._repo.name
if not sharedcache:
sharedcache = peer._repo.sharedstore