Show More
@@ -919,7 +919,9 class localrepository(object): | |||
|
919 | 919 | try: |
|
920 | 920 | if self.svfs.exists("journal"): |
|
921 | 921 | self.ui.status(_("rolling back interrupted transaction\n")) |
|
922 | transaction.rollback(self.sopener, "journal", | |
|
922 | vfsmap = {'': self.sopener, | |
|
923 | 'plain': self.opener,} | |
|
924 | transaction.rollback(self.sopener, vfsmap, "journal", | |
|
923 | 925 | self.ui.warn) |
|
924 | 926 | self.invalidate() |
|
925 | 927 | return True |
@@ -975,7 +977,8 class localrepository(object): | |||
|
975 | 977 | |
|
976 | 978 | parents = self.dirstate.parents() |
|
977 | 979 | self.destroying() |
|
978 | transaction.rollback(self.sopener, 'undo', ui.warn) | |
|
980 | vfsmap = {'plain': self.opener} | |
|
981 | transaction.rollback(self.sopener, vfsmap, 'undo', ui.warn) | |
|
979 | 982 | if self.vfs.exists('undo.bookmarks'): |
|
980 | 983 | self.vfs.rename('undo.bookmarks', 'bookmarks') |
|
981 | 984 | if self.svfs.exists('undo.phaseroots'): |
@@ -25,7 +25,8 def active(func): | |||
|
25 | 25 | return func(self, *args, **kwds) |
|
26 | 26 | return _active |
|
27 | 27 | |
|
28 |
def _playback(journal, report, opener, entries, backupentries, |
|
|
28 | def _playback(journal, report, opener, vfsmap, entries, backupentries, | |
|
29 | unlink=True): | |
|
29 | 30 | for f, o, _ignore in entries: |
|
30 | 31 | if o or not unlink: |
|
31 | 32 | try: |
@@ -44,9 +45,10 def _playback(journal, report, opener, e | |||
|
44 | 45 | |
|
45 | 46 | backupfiles = [] |
|
46 | 47 | for l, f, b, c in backupentries: |
|
48 | vfs = vfsmap[l] | |
|
47 | 49 | if f and b: |
|
48 |
filepath = |
|
|
49 |
backuppath = |
|
|
50 | filepath = vfs.join(f) | |
|
51 | backuppath = vfs.join(b) | |
|
50 | 52 | try: |
|
51 | 53 | util.copyfile(backuppath, filepath) |
|
52 | 54 | backupfiles.append(b) |
@@ -56,7 +58,7 def _playback(journal, report, opener, e | |||
|
56 | 58 | else: |
|
57 | 59 | target = f or b |
|
58 | 60 | try: |
|
59 |
|
|
|
61 | vfs.unlink(target) | |
|
60 | 62 | except (IOError, OSError), inst: |
|
61 | 63 | if inst.errno != errno.ENOENT: |
|
62 | 64 | raise |
@@ -105,9 +107,11 class transaction(object): | |||
|
105 | 107 | self.file = opener.open(self.journal, "w") |
|
106 | 108 | |
|
107 | 109 | # a list of ('location', 'path', 'backuppath', cache) entries. |
|
108 | # if 'backuppath' is empty, no file existed at backup time | |
|
109 | # if 'path' is empty, this is a temporary transaction file | |
|
110 | # (location, and cache are current unused) | |
|
110 | # - if 'backuppath' is empty, no file existed at backup time | |
|
111 | # - if 'path' is empty, this is a temporary transaction file | |
|
112 | # - if 'location' is not empty, the path is outside main opener reach. | |
|
113 | # use 'location' value as a key in a vfsmap to find the right 'vfs' | |
|
114 | # (cache is currently unused) | |
|
111 | 115 | self._backupentries = [] |
|
112 | 116 | self._backupmap = {} |
|
113 | 117 | self._backupjournal = "%s.backupfiles" % journal |
@@ -361,9 +365,10 class transaction(object): | |||
|
361 | 365 | self.file.close() |
|
362 | 366 | self._backupsfile.close() |
|
363 | 367 | # cleanup temporary files |
|
364 |
for |
|
|
365 | if not f and b and self.opener.exists(b): | |
|
366 | self.opener.unlink(b) | |
|
368 | for l, f, b, _c in self._backupentries: | |
|
369 | vfs = self._vfsmap[l] | |
|
370 | if not f and b and vfs.exists(b): | |
|
371 | vfs.unlink(b) | |
|
367 | 372 | self.entries = [] |
|
368 | 373 | if self.after: |
|
369 | 374 | self.after() |
@@ -372,8 +377,9 class transaction(object): | |||
|
372 | 377 | if self.opener.isfile(self._backupjournal): |
|
373 | 378 | self.opener.unlink(self._backupjournal) |
|
374 | 379 | for _l, _f, b, _c in self._backupentries: |
|
375 | if b and self.opener.exists(b): | |
|
376 |
|
|
|
380 | vfs = self._vfsmap[l] | |
|
381 | if b and vfs.exists(b): | |
|
382 | vfs.unlink(b) | |
|
377 | 383 | self._backupentries = [] |
|
378 | 384 | self.journal = None |
|
379 | 385 | # run post close action |
@@ -408,7 +414,7 class transaction(object): | |||
|
408 | 414 | self.report(_("transaction abort!\n")) |
|
409 | 415 | |
|
410 | 416 | try: |
|
411 | _playback(self.journal, self.report, self.opener, | |
|
417 | _playback(self.journal, self.report, self.opener, self._vfsmap, | |
|
412 | 418 | self.entries, self._backupentries, False) |
|
413 | 419 | self.report(_("rollback completed\n")) |
|
414 | 420 | except Exception: |
@@ -417,7 +423,7 class transaction(object): | |||
|
417 | 423 | self.journal = None |
|
418 | 424 | |
|
419 | 425 | |
|
420 | def rollback(opener, file, report): | |
|
426 | def rollback(opener, vfsmap, file, report): | |
|
421 | 427 | """Rolls back the transaction contained in the given file |
|
422 | 428 | |
|
423 | 429 | Reads the entries in the specified file, and the corresponding |
@@ -459,4 +465,4 def rollback(opener, file, report): | |||
|
459 | 465 | report(_("journal was created by a different version of " |
|
460 | 466 | "Mercurial")) |
|
461 | 467 | |
|
462 | _playback(file, report, opener, entries, backupentries) | |
|
468 | _playback(file, report, opener, vfsmap, entries, backupentries) |
General Comments 0
You need to be logged in to leave comments.
Login now