[PATCH 1 of 3] dirstate: make backup methods public

Augie Fackler raf at durin42.com
Wed May 11 02:13:26 UTC 2016


On Thu, May 05, 2016 at 05:35:10PM -0700, Mateusz Kwapich wrote:
> # HG changeset patch
> # User Mateusz Kwapich <mitrandir at fb.com>
> # Date 1462493214 25200
> #      Thu May 05 17:06:54 2016 -0700
> # Node ID 7f8cd9ff187d776345d210611259491c67499fb9
> # Parent  b473b7bd02b3bad724c0178ec08ae49019aed51c
> dirstate: make backup methods public

I've taken the first patch, and look forward to a resend of the other
two per durham's review. Thanks!

>
> They are called from outside of dirstate anyway and I want the localrepo to
> use them too.
>
> diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
> --- a/mercurial/cmdutil.py
> +++ b/mercurial/cmdutil.py
> @@ -3518,7 +3518,7 @@ class dirstateguard(object):
>      def __init__(self, repo, name):
>          self._repo = repo
>          self._suffix = '.backup.%s.%d' % (name, id(self))
> -        repo.dirstate._savebackup(repo.currenttransaction(), self._suffix)
> +        repo.dirstate.savebackup(repo.currenttransaction(), self._suffix)
>          self._active = True
>          self._closed = False
>
> @@ -3536,13 +3536,13 @@ class dirstateguard(object):
>                     % self._suffix)
>              raise error.Abort(msg)
>
> -        self._repo.dirstate._clearbackup(self._repo.currenttransaction(),
> +        self._repo.dirstate.clearbackup(self._repo.currenttransaction(),
>                                           self._suffix)
>          self._active = False
>          self._closed = True
>
>      def _abort(self):
> -        self._repo.dirstate._restorebackup(self._repo.currenttransaction(),
> +        self._repo.dirstate.restorebackup(self._repo.currenttransaction(),
>                                             self._suffix)
>          self._active = False
>
> diff --git a/mercurial/dirstate.py b/mercurial/dirstate.py
> --- a/mercurial/dirstate.py
> +++ b/mercurial/dirstate.py
> @@ -1206,7 +1206,7 @@ class dirstate(object):
>          else:
>              return self._filename
>
> -    def _savebackup(self, tr, suffix):
> +    def savebackup(self, tr, suffix):
>          '''Save current dirstate into backup file with suffix'''
>          filename = self._actualfilename(tr)
>
> @@ -1229,7 +1229,7 @@ class dirstate(object):
>
>          self._opener.write(filename + suffix, self._opener.tryread(filename))
>
> -    def _restorebackup(self, tr, suffix):
> +    def restorebackup(self, tr, suffix):
>          '''Restore dirstate by backup file with suffix'''
>          # this "invalidate()" prevents "wlock.release()" from writing
>          # changes of dirstate out after restoring from backup file
> @@ -1237,7 +1237,7 @@ class dirstate(object):
>          filename = self._actualfilename(tr)
>          self._opener.rename(filename + suffix, filename)
>
> -    def _clearbackup(self, tr, suffix):
> +    def clearbackup(self, tr, suffix):
>          '''Clear backup file with suffix'''
>          filename = self._actualfilename(tr)
>          self._opener.unlink(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