[Bug 4353] New: dirstate can be corrupted by exceptions

mercurial-bugs at selenic.com mercurial-bugs at selenic.com
Wed Sep 3 17:50:23 CDT 2014


http://bz.selenic.com/show_bug.cgi?id=4353

          Priority: normal
            Bug ID: 4353
                CC: mercurial-devel at selenic.com
          Assignee: bugzilla at selenic.com
           Summary: dirstate can be corrupted by exceptions
          Severity: bug
    Classification: Unclassified
                OS: Mac OS
          Reporter: durham at fb.com
          Hardware: PC
            Status: UNCONFIRMED
           Version: 3.1.1
         Component: Mercurial
           Product: Mercurial

Our users have been experiencing increasingly frequent issues where the
dirstate is no longer in sync with the manifest of the working copy.  The
dirstate might contain files that the manifest doesn't, etc.

Currently, the dirstate is written by wlock.release(), which is called in a
try/finally, so the dirstate is written even during an exception.  In code like
the following, if you insert an exception it can result in a corrupt dirstate:

merge.py:update()

        if not partial:
            repo.setparents(fp1, fp2)
            raise Exception("THIS IS BAD")
            recordupdates(repo, actions, branchmerge)
            # update completed, clear state
            util.unlink(repo.join('updatestate'))

            if not branchmerge:
                repo.dirstate.setbranch(p2.branch())

        repo.dirstate.write()
    finally:
        wlock.release()

since the dirstate parents will be written to disk (as part of wlock.release())
but the dirstate entries won't have been changed.  For instance, hg
debugdirstate will show files as 'n' which may not even exist anymore.


This is a particular terrible state for a user to get into because there is no
real way for them to fix it without consulting a Mercurial expert.

-- 
You are receiving this mail because:
You are on the CC list for the bug.


More information about the Mercurial-devel mailing list