##// END OF EJS Templates
transaction: change the on disk format for backupentries...
Pierre-Yves David -
r23309:7eb520f5 default
parent child Browse files
Show More
@@ -15,7 +15,7 b' from i18n import _'
15 15 import errno
16 16 import error, util
17 17
18 version = 1
18 version = 0
19 19
20 20 def active(func):
21 21 def _active(self, *args, **kwds):
@@ -43,7 +43,7 b' def _playback(journal, report, opener, e'
43 43 raise
44 44
45 45 backupfiles = []
46 for f, b in backupentries:
46 for l, f, b, c in backupentries:
47 47 if f and b:
48 48 filepath = opener.join(f)
49 49 backuppath = opener.join(b)
@@ -99,9 +99,10 b' class transaction(object):'
99 99 self.hookargs = {}
100 100 self.file = opener.open(self.journal, "w")
101 101
102 # a list of ('path', 'backuppath') entries.
102 # a list of ('location', 'path', 'backuppath', cache) entries.
103 103 # if 'backuppath' is empty, no file existed at backup time
104 104 # if 'path' is empty, this is a temporary transaction file
105 # (location, and cache are current unused)
105 106 self._backupentries = []
106 107 self._backupmap = {}
107 108 self._backupjournal = "%s.backupfiles" % journal
@@ -193,13 +194,13 b' class transaction(object):'
193 194 else:
194 195 backupfile = ''
195 196
196 self._addbackupentry((file, backupfile))
197 self._addbackupentry(('', file, backupfile, False))
197 198
198 199 def _addbackupentry(self, entry):
199 200 """register a new backup entry and write it to disk"""
200 201 self._backupentries.append(entry)
201 202 self._backupmap[file] = len(self._backupentries) - 1
202 self._backupsfile.write("%s\0%s\n" % entry)
203 self._backupsfile.write("%s\0%s\0%s\0%d\n" % entry)
203 204 self._backupsfile.flush()
204 205
205 206 @active
@@ -209,7 +210,7 b' class transaction(object):'
209 210 Such file will be delete when the transaction exit (on both failure and
210 211 success).
211 212 """
212 self._addbackupentry(('', tmpfile))
213 self._addbackupentry(('', '', tmpfile, False))
213 214
214 215 @active
215 216 def addfilegenerator(self, genid, filenames, genfunc, order=0, vfs=None):
@@ -355,7 +356,7 b' class transaction(object):'
355 356 self.file.close()
356 357 self._backupsfile.close()
357 358 # cleanup temporary files
358 for f, b in self._backupentries:
359 for _l, f, b, _c in self._backupentries:
359 360 if not f and b and self.opener.exists(b):
360 361 self.opener.unlink(b)
361 362 self.entries = []
@@ -365,7 +366,7 b' class transaction(object):'
365 366 self.opener.unlink(self.journal)
366 367 if self.opener.isfile(self._backupjournal):
367 368 self.opener.unlink(self._backupjournal)
368 for _f, b in self._backupentries:
369 for _l, _f, b, _c in self._backupentries:
369 370 if b and self.opener.exists(b):
370 371 self.opener.unlink(b)
371 372 self._backupentries = []
@@ -447,10 +448,10 b' def rollback(opener, file, report):'
447 448 if line:
448 449 # Shave off the trailing newline
449 450 line = line[:-1]
450 f, b = line.split('\0')
451 backupentries.append((f, b))
451 l, f, b, c = line.split('\0')
452 backupentries.append((l, f, b, bool(c)))
452 453 else:
453 report(_("journal was created by a newer version of "
454 report(_("journal was created by a different version of "
454 455 "Mercurial"))
455 456
456 457 _playback(file, report, opener, entries, backupentries)
General Comments 0
You need to be logged in to leave comments. Login now