# HG changeset patch # User Pierre-Yves David # Date 1415192784 0 # Node ID b04263c38a92c48847f0e6c195bbf09ab9c047d0 # Parent 6c1351352b6c7d90dcb280f03ed73af7186f080f transaction: extract backupentry registration in a dedicated function We are about to use the 'backupentry' mechanism to allow cleaning up transaction-related temporary files (such as 'changelog.i.a'). We start by extracting the entry registration into its own method 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 ideas. diff -r 6c1351352b6c -r b04263c38a92 mercurial/transaction.py --- a/mercurial/transaction.py Sat Nov 08 16:35:15 2014 +0000 +++ b/mercurial/transaction.py Wed Nov 05 13:06:24 2014 +0000 @@ -190,9 +190,13 @@ else: backupfile = '' - self._backupentries.append((file, backupfile)) + self._addbackupentry((file, backupfile)) + + def _addbackupentry(self, entry): + """register a new backup entry and 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