( )⚙ D611 checknlink: use a random temp file name for checking

This is an archive of the discontinued Mercurial Phabricator instance.

checknlink: use a random temp file name for checking
ClosedPublic

Authored by quark on Sep 1 2017, 8:29 PM.

Details

Summary

Previously, if .hg/store/00manifest.d.hgtmp1 exists, hg will copy the
entire 00manifest.d every time when appending new manifest revisions.
That could happen if Mercurial or the machine crashed when .hgtmp1 was
just created but not deleted yet.

This patch changes the fixed name to a random generated name. To be
consistent with D468, ~ suffix was used.

Diff Detail

Repository
rHG Mercurial
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

quark created this revision.Sep 1 2017, 8:29 PM
yuja requested changes to this revision.Sep 3 2017, 10:20 AM
yuja added a subscriber: yuja.
yuja added inline comments.
mercurial/util.py
1461–1462

mkstemp() may raise OSError, which should be caught as before.

This revision now requires changes to proceed.Sep 3 2017, 10:20 AM
quark edited edge metadata.Sep 5 2017, 4:07 PM
quark retitled this revision from nlink: use a random temp file name for checking to checknlink: use a random temp file name for checking.
quark updated this revision to Diff 1616.
yuja accepted this revision.Sep 6 2017, 10:41 AM

Queued, thanks.

mercurial/util.py
1465

Nit: here fd is a file descriptor, but later it's changed to a file
object. fd.close() would raise AttributeError if os.close(fd) failed.

Maybe we should rename the latter to fp or something. Can
you send a follow up?

This revision is now accepted and ready to land.Sep 6 2017, 10:41 AM
This revision was automatically updated to reflect the committed changes.
quark added inline comments.Sep 6 2017, 3:16 PM
mercurial/util.py
1465

Good catch!