[PATCH 3 of 5 main-line-of-work] addbackup: add cache support

Matt Mackall mpm at selenic.com
Fri Nov 21 19:16:59 CST 2014


On Wed, 2014-11-19 at 19:30 -0800, Pierre-Yves David wrote:
> # HG changeset patch
> # User Pierre-Yves David <pierre-yves.david at fb.com>
> # Date 1415877482 0
> #      Thu Nov 13 11:18:02 2014 +0000
> # Node ID 2968a06bb0f4ba98e81dfd561444cab20a9af683
> # Parent  bb387f9638d0ee5321f2ea85f8cd2bd745ac5243
> addbackup: add cache support
> 
> One can now marks a backup as "cache" failure to back it up or to restore it
> will be ignored.
> 
> diff --git a/mercurial/transaction.py b/mercurial/transaction.py
> --- a/mercurial/transaction.py
> +++ b/mercurial/transaction.py
> @@ -186,11 +186,11 @@ class transaction(object):
>          # add enough data to the journal to do the truncate
>          self.file.write("%s\0%d\n" % (file, offset))
>          self.file.flush()
>  
>      @active
> -    def addbackup(self, file, hardlink=True, location=''):
> +    def addbackup(self, file, hardlink=True, location='', cache=False):
>          """Adds a backup of the file to the transaction
>  
>          Calling addbackup() creates a hardlink backup of the specified file
>          that is used to recover the file in the event of the transaction
>          aborting.

Probably needs a docstring addition.

> @@ -205,19 +205,23 @@ class transaction(object):
>          if file in self.map or file in self._backupmap:
>              return
>          dirname, filename = os.path.split(file)
>          backupfilename = "%s.backup.%s" % (self.journal, filename)
>          backupfile = os.path.join(dirname, backupfilename)
> +        if location not in self._vfsmap and cache:
> +            self.report("couldn't backup %s: unknown cache location %s\n"
> +                        % (file, location))
> +            return

This doesn't seem to agree with the summary?

-- 
Mathematics is the supreme nostalgia of our time.




More information about the Mercurial-devel mailing list