Patchwork [7,of,7,main-line-of-work] transaction: extract backupentry registration in a dedicated function

login
register
mail settings
Submitter Pierre-Yves David
Date Nov. 11, 2014, 5:35 p.m.
Message ID <a196f9b8f58cf4a129c6.1415727314@marginatus.alto.octopoid.net>
Download mbox | patch
Permalink /patch/6680/
State Accepted
Commit b04263c38a92c48847f0e6c195bbf09ab9c047d0
Headers show

Comments

Pierre-Yves David - Nov. 11, 2014, 5:35 p.m.
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david@fb.com>
# Date 1415192784 0
#      Wed Nov 05 13:06:24 2014 +0000
# Node ID a196f9b8f58cf4a129c649fc2b498cb6c32904b0
# Parent  106e3ceedd34762e8355a8b85d250992e654bd55
transaction: extract backupentry registration in a dedicated function

We are about to use the 'backupentry' mechanism to allow cleaning up transaction
related temporary file (such as 'changelog.i.a') We start by extracting the
entry registration in its own logic for easy reuse.

At that point, I would like to rename the backup-file related variable to
something generic but I'm a bit short of idea.
Matt Mackall - Nov. 12, 2014, 11:10 p.m.
On Tue, 2014-11-11 at 17:35 +0000, Pierre-Yves David wrote:
> # HG changeset patch
> # User Pierre-Yves David <pierre-yves.david@fb.com>
> # Date 1415192784 0
> #      Wed Nov 05 13:06:24 2014 +0000
> # Node ID a196f9b8f58cf4a129c649fc2b498cb6c32904b0
> # Parent  106e3ceedd34762e8355a8b85d250992e654bd55
> transaction: extract backupentry registration in a dedicated function

These are queued for default, thanks.

Patch

diff --git a/mercurial/transaction.py b/mercurial/transaction.py
--- a/mercurial/transaction.py
+++ b/mercurial/transaction.py
@@ -188,13 +188,17 @@  class transaction(object):
             backuppath = self.opener.join(backupfile)
             util.copyfiles(filepath, backuppath, hardlink=hardlink)
         else:
             backupfile = ''
 
-        self._backupentries.append((file, backupfile))
+        self._addbackupentry((file, backupfile))
+
+    def _addbackupentry(self, entry):
+        """register a new backup entry an write it to disk"""
+        self._backupentries.append(entry)
         self._backupmap[file] = len(self._backupentries) - 1
-        self._backupsfile.write("%s\0%s\n" % (file, backupfile))
+        self._backupsfile.write("%s\0%s\n" % entry)
         self._backupsfile.flush()
 
     @active
     def addfilegenerator(self, genid, filenames, genfunc, order=0, vfs=None):
         """add a function to generates some files at transaction commit