[PATCH 3 of 3 V2] distate: add assertions to backup functions
Augie Fackler
raf at durin42.com
Sun May 29 17:11:50 EDT 2016
On Thu, May 26, 2016 at 05:58:43PM -0700, Mateusz Kwapich wrote:
> # HG changeset patch
> # User Mateusz Kwapich <mitrandir at fb.com>
> # Date 1464309404 25200
> # Thu May 26 17:36:44 2016 -0700
> # Node ID e63eb84c5727e308dca8e39d4fe0dbc02d689d1c
> # Parent 6317f883ee530ae8525c68b5eef245a01c0e3e54
> distate: add assertions to backup functions
Queued these, thanks!
>
> Those assertions will prevent the backup functions from overwriting
> the dirstate file in case both: suffix and prefix are empty.
>
> (foozy suggested making that change and I agree with him)
>
> diff --git a/mercurial/dirstate.py b/mercurial/dirstate.py
> --- a/mercurial/dirstate.py
> +++ b/mercurial/dirstate.py
> @@ -1209,6 +1209,7 @@ class dirstate(object):
>
> def savebackup(self, tr, suffix='', prefix=''):
> '''Save current dirstate into backup file with suffix'''
> + assert len(suffix) > 0 or len(prefix) > 0
> filename = self._actualfilename(tr)
>
> # use '_writedirstate' instead of 'write' to write changes certainly,
> @@ -1233,6 +1234,7 @@ class dirstate(object):
>
> def restorebackup(self, tr, suffix='', prefix=''):
> '''Restore dirstate by backup file with suffix'''
> + assert len(suffix) > 0 or len(prefix) > 0
> # this "invalidate()" prevents "wlock.release()" from writing
> # changes of dirstate out after restoring from backup file
> self.invalidate()
> @@ -1242,5 +1244,6 @@ class dirstate(object):
>
> def clearbackup(self, tr, suffix='', prefix=''):
> '''Clear backup file with suffix'''
> + assert len(suffix) > 0 or len(prefix) > 0
> # using self._filename to avoid having "pending" in the backup filename
> self._opener.unlink(prefix + self._filename + suffix)
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel at mercurial-scm.org
> https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
More information about the Mercurial-devel
mailing list