Mercurial > hg
comparison mercurial/transaction.py @ 23283:b04263c38a92
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.
author | Pierre-Yves David <pierre-yves.david@fb.com> |
---|---|
date | Wed, 05 Nov 2014 13:06:24 +0000 |
parents | 6c1351352b6c |
children | 59513ec76748 |
comparison
equal
deleted
inserted
replaced
23282:6c1351352b6c | 23283:b04263c38a92 |
---|---|
188 backuppath = self.opener.join(backupfile) | 188 backuppath = self.opener.join(backupfile) |
189 util.copyfiles(filepath, backuppath, hardlink=hardlink) | 189 util.copyfiles(filepath, backuppath, hardlink=hardlink) |
190 else: | 190 else: |
191 backupfile = '' | 191 backupfile = '' |
192 | 192 |
193 self._backupentries.append((file, backupfile)) | 193 self._addbackupentry((file, backupfile)) |
194 | |
195 def _addbackupentry(self, entry): | |
196 """register a new backup entry and write it to disk""" | |
197 self._backupentries.append(entry) | |
194 self._backupmap[file] = len(self._backupentries) - 1 | 198 self._backupmap[file] = len(self._backupentries) - 1 |
195 self._backupsfile.write("%s\0%s\n" % (file, backupfile)) | 199 self._backupsfile.write("%s\0%s\n" % entry) |
196 self._backupsfile.flush() | 200 self._backupsfile.flush() |
197 | 201 |
198 @active | 202 @active |
199 def addfilegenerator(self, genid, filenames, genfunc, order=0, vfs=None): | 203 def addfilegenerator(self, genid, filenames, genfunc, order=0, vfs=None): |
200 """add a function to generates some files at transaction commit | 204 """add a function to generates some files at transaction commit |