[PATCH 2 of 3] dirstate: add prefix and suffix arguments to backup

Durham Goode durham at fb.com
Tue May 10 00:26:50 EDT 2016



On 5/5/16 5:35 PM, 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 960056f578173d3da54cd0a3c1e05e06b39e64fe
> # Parent  7f8cd9ff187d776345d210611259491c67499fb9
> dirstate: add prefix and suffix arguments to backup
I'd mention why this is desirable in the commit message.
>
> 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='', prefix=''):
>           '''Save current dirstate into backup file with suffix'''
>           filename = self._actualfilename(tr)
>   
> @@ -1227,17 +1227,18 @@ class dirstate(object):
>               # end of this transaction
>               tr.registertmp(filename, location='plain')
>   
> -        self._opener.write(filename + suffix, self._opener.tryread(filename))
> +        self._opener.write(prefix + filename + suffix,
> +                           self._opener.tryread(filename))
>   
> -    def restorebackup(self, tr, suffix):
> +    def restorebackup(self, tr, suffix='', prefix=''):
>           '''Restore dirstate by backup file with suffix'''
>           # this "invalidate()" prevents "wlock.release()" from writing
>           # changes of dirstate out after restoring from backup file
>           self.invalidate()
>           filename = self._actualfilename(tr)
> -        self._opener.rename(filename + suffix, filename)
> +        self._opener.rename(prefix + filename + suffix, filename)
>   
> -    def clearbackup(self, tr, suffix):
> +    def clearbackup(self, tr, suffix='', prefix=''):
>           '''Clear backup file with suffix'''
>           filename = self._actualfilename(tr)
> -        self._opener.unlink(filename + suffix)
> +        self._opener.unlink(prefix + filename + suffix)
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel at mercurial-scm.org
> https://urldefense.proofpoint.com/v2/url?u=https-3A__www.mercurial-2Dscm.org_mailman_listinfo_mercurial-2Ddevel&d=CwIGaQ&c=5VD0RTtNlTh3ycd41b3MUw&r=nuarHzhP1wi1T9iURRCj1A&m=0ZkoA_-CX7H6XqrOBMGJJ5WVhtjhpr1rLbLPnJpcK9o&s=pcye0vJUM1KKdtar_nL94wGm5qi1Si2nORVDJrT-o74&e=



More information about the Mercurial-devel mailing list