( )⚙ D1201 dirstate: clean up when restoring identical backups

This is an archive of the discontinued Mercurial Phabricator instance.

dirstate: clean up when restoring identical backups
ClosedPublic

Authored by mbthomas on Oct 20 2017, 8:57 AM.

Details

Summary

When a dirstate backup is restored, it is possible that no actual changes to
the dirstate have been made. In this case, the backup is still a hardlink
to the original dirstate.

Unfortunately, os.rename silently fails (nothing happens, and no error
occurs) when src and dst are hardlinks to the same file. As a result,
the backup is left lying around. Over time, these files accumulate.

When restoring dirstate backups, check if the backup and the dirstate are
the same file, and if so, just delete the backup.

Diff Detail

Repository
rHG Mercurial
Lint
Lint Skipped
Unit
Unit Tests Skipped

Event Timeline

mbthomas created this revision.Oct 20 2017, 8:57 AM
krbullock accepted this revision as: krbullock.

LGTM but I'd like someone with more familiarity with dirstate to have a look too. Maybe @durham ?

durham accepted this revision.Oct 27 2017, 11:58 AM

lgtm. Is this a recent regression? Seems like this would be polluting lots of peoples repositories.

In D1201#20829, @durham wrote:

lgtm. Is this a recent regression? Seems like this would be polluting lots of peoples repositories.

I never noticed, but now that you ask, here's in my hg repo:

$ ls -1 .hg/dirstate.backup.import.*
.hg/dirstate.backup.import.139672779498704
.hg/dirstate.backup.import.139940118873296
.hg/dirstate.backup.import.140117795275984
.hg/dirstate.backup.import.140181671269584
.hg/dirstate.backup.import.140261652248144
.hg/dirstate.backup.import.140345443734736
.hg/dirstate.backup.import.140542706046160
.hg/dirstate.backup.import.140585297004112

based on behavior I've seen, this is a recent regression. Landing this series for stable.

durin42 accepted this revision.Oct 30 2017, 5:06 PM
This revision is now accepted and ready to land.Oct 30 2017, 5:06 PM
This revision was automatically updated to reflect the committed changes.