##// END OF EJS Templates
transactions: add version number to journal.backupfiles...
Durham Goode -
r23064:5dc888b7 stable
parent child Browse files
Show More
@@ -15,6 +15,8 b' from i18n import _'
15 15 import errno
16 16 import error, util
17 17
18 version = 1
19
18 20 def active(func):
19 21 def _active(self, *args, **kwds):
20 22 if self.count == 0:
@@ -92,6 +94,7 b' class transaction(object):'
92 94 self.backupjournal = "%s.backupfiles" % journal
93 95 self.file = opener.open(self.journal, "w")
94 96 self.backupsfile = opener.open(self.backupjournal, 'w')
97 self.backupsfile.write('%d\n' % version)
95 98 if createmode is not None:
96 99 opener.chmod(self.journal, createmode & 0666)
97 100 opener.chmod(self.backupjournal, createmode & 0666)
@@ -348,10 +351,20 b' def rollback(opener, file, report):'
348 351 fp = opener.open(backupjournal)
349 352 data = fp.read()
350 353 if len(data) > 0:
354 ver = version
355 versionend = data.find('\n')
356 if versionend != -1:
357 ver = data[:versionend]
358 data = data[versionend + 1:]
359
360 if ver == str(version):
351 361 parts = data.split('\0')
352 362 # Skip the final part, since it's just a trailing empty space
353 363 for i in xrange(0, len(parts) - 1, 2):
354 364 f, b = parts[i:i + 2]
355 365 backupentries.append((f, b, None))
366 else:
367 report(_("journal was created by a newer version of "
368 "Mercurial"))
356 369
357 370 _playback(file, report, opener, entries, backupentries)
General Comments 0
You need to be logged in to leave comments. Login now