diff -r 557454ce854a -r e38d85be978f mercurial/repair.py --- a/mercurial/repair.py Thu Sep 22 21:51:59 2016 +0900 +++ b/mercurial/repair.py Thu Sep 22 21:52:00 2016 +0900 @@ -181,7 +181,8 @@ for i in xrange(offset, len(tr.entries)): file, troffset, ignore = tr.entries[i] - repo.svfs(file, 'a').truncate(troffset) + with repo.svfs(file, 'a', checkambig=True) as fp: + fp.truncate(troffset) if troffset == 0: repo.store.markremoved(file)