This is an archive of the discontinued Mercurial Phabricator instance.

vfs: require use of .seek() or .write() before .tell() on append-mode files
AbandonedPublic

Authored by durin42 on Jun 20 2019, 2:29 PM.

Details

Reviewers
None
Group Reviewers
hg-reviewers
Summary

This prevents the bug in the previous change, but avoids an extraneous
seek() call in the common case when it's not required. My preference
was to ban .seek() and .tell() entirely on append-mode files since
they're potentially misleading, but our codebase doesn't make that
easy. This is better than nothing.

See the previous change for a detailed explanation of the bug we've
observed in the wild.

Diff Detail

Repository
rHG Mercurial
Lint
Lint Skipped
Unit
Unit Tests Skipped

Event Timeline

durin42 created this revision.Jun 20 2019, 2:29 PM

I worked around the same bug in Windows in platform.posixfile [1]. Should this be done in the posix layer (which is currently only an alias to open())? It looks like there are uses of posixfile outside of vfs.

[1] https://www.mercurial-scm.org/repo/hg/file/tip/mercurial/windows.py#l161

durin42 abandoned this revision.Jul 8 2019, 1:15 PM