Mercurial > public > mercurial-scm > hg-stable
diff mercurial/dirstateguard.py @ 33440:ec306bc6915b
dirstate: update backup functions to take full backup filename
Update the dirstate functions so that the caller supplies the full backup
filename rather than just a prefix and suffix.
The localrepo code was already hard-coding the fact that the backup name must
be (exactly prefix + "dirstate" + suffix): it relied on this in _journalfiles()
and undofiles(). Making the caller responsible for specifying the full backup
name removes the need for the localrepo code to assume that dirstate._filename
is always "dirstate".
Differential Revision: https://phab.mercurial-scm.org/D68
author | Adam Simpkins <simpkins@fb.com> |
---|---|
date | Wed, 12 Jul 2017 15:24:07 -0700 |
parents | 751639bf6fc4 |
children | 609606d21765 |
line wrap: on
line diff
--- a/mercurial/dirstateguard.py Thu Jul 13 09:51:50 2017 -0700 +++ b/mercurial/dirstateguard.py Wed Jul 12 15:24:07 2017 -0700 @@ -31,8 +31,8 @@ self._repo = repo self._active = False self._closed = False - self._suffix = '.backup.%s.%d' % (name, id(self)) - repo.dirstate.savebackup(repo.currenttransaction(), self._suffix) + self._backupname = 'dirstate.backup.%s.%d' % (name, id(self)) + repo.dirstate.savebackup(repo.currenttransaction(), self._backupname) self._active = True def __del__(self): @@ -45,25 +45,24 @@ def close(self): if not self._active: # already inactivated - msg = (_("can't close already inactivated backup: dirstate%s") - % self._suffix) + msg = (_("can't close already inactivated backup: %s") + % self._backupname) raise error.Abort(msg) self._repo.dirstate.clearbackup(self._repo.currenttransaction(), - self._suffix) + self._backupname) self._active = False self._closed = True def _abort(self): self._repo.dirstate.restorebackup(self._repo.currenttransaction(), - self._suffix) + self._backupname) self._active = False def release(self): if not self._closed: if not self._active: # already inactivated - msg = (_("can't release already inactivated backup:" - " dirstate%s") - % self._suffix) + msg = (_("can't release already inactivated backup: %s") + % self._backupname) raise error.Abort(msg) self._abort()