Mercurial > hg
diff hgext/lfs/__init__.py @ 40131:535fc8a22365 stable
lfs: avoid a potential variable reference before assignment error in cmdserver
A coworker hit this once yesterday when pulling in thg (a retry worked), and
then I hit it with strip after a pull. I had a difficult time recreating a test
for this (at least one of the tricks was to not use '-R', which seems to cause
reposetup() to be called for each command), so I'm not sure how large of a
window there actually is for this. Calling reposetup() *after* the requirement
is added will skip the hook entirely.
The other issue I had was adding a couple `ui.status()` lines around the check
that installs the hook. On Windows, the cmdserver process ballooned to 1.6GB
and hung. Changing that to `ui.warn()` avoided the hang. It also hung on
macOS, but without the large memory usage.
author | Matt Harbison <matt_harbison@yahoo.com> |
---|---|
date | Wed, 10 Oct 2018 12:25:28 -0400 |
parents | ff5b6fca1082 |
children | ef0baff11aea |
line wrap: on
line diff
--- a/hgext/lfs/__init__.py Mon Oct 01 16:07:38 2018 -0400 +++ b/hgext/lfs/__init__.py Wed Oct 10 12:25:28 2018 -0400 @@ -229,13 +229,15 @@ if 'lfs' not in repo.requirements: def checkrequireslfs(ui, repo, **kwargs): - if 'lfs' not in repo.requirements: - last = kwargs.get(r'node_last') - _bin = node.bin - if last: - s = repo.set('%n:%n', _bin(kwargs[r'node']), _bin(last)) - else: - s = repo.set('%n', _bin(kwargs[r'node'])) + if 'lfs' in repo.requirements: + return 0 + + last = kwargs.get(r'node_last') + _bin = node.bin + if last: + s = repo.set('%n:%n', _bin(kwargs[r'node']), _bin(last)) + else: + s = repo.set('%n', _bin(kwargs[r'node'])) match = repo.narrowmatch() for ctx in s: # TODO: is there a way to just walk the files in the commit?