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