This is an archive of the discontinued Mercurial Phabricator instance.

narrow: fix crash when restoring backup in legacy repo
ClosedPublic

Authored by martinvonz on Jan 19 2019, 2:51 AM.

Details

Summary

Using --addremove when committing in an old repo (before we started
keeping .hg/narrowspec.dirstate) results in a crash. The test
case modified in this patch would crash like this:

abort: $ENOENT$

The issue is that when the dirstateguard is aborted, it tries to
restore the backup of .hg/narrowspec.dirstate. However, since we were
in an old repo, that file did not get created when the dirstateguard
was created. Note that the dirstateguard is not used unless
--addremove is passed.

This patch fixes the bug by making restorewcbackup() not fail if the
backup doesn't exist. I also made clearwcbackup() safe, just in case.

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

martinvonz created this revision.Jan 19 2019, 2:51 AM

This is meant for the stable branch

This revision was automatically updated to reflect the committed changes.