Show More
@@ -1098,7 +1098,8 b' class localrepository(object):' | |||
|
1098 | 1098 | aftertrans(renames), |
|
1099 | 1099 | self.store.createmode, |
|
1100 | 1100 | validator=validate, |
|
1101 |
releasefn=releasefn |
|
|
1101 | releasefn=releasefn, | |
|
1102 | checkambigfiles=_cachedfiles) | |
|
1102 | 1103 | tr.changes['revs'] = set() |
|
1103 | 1104 | tr.changes['obsmarkers'] = set() |
|
1104 | 1105 | |
@@ -1164,7 +1165,8 b' class localrepository(object):' | |||
|
1164 | 1165 | vfsmap = {'': self.svfs, |
|
1165 | 1166 | 'plain': self.vfs,} |
|
1166 | 1167 | transaction.rollback(self.svfs, vfsmap, "journal", |
|
1167 |
self.ui.warn |
|
|
1168 | self.ui.warn, | |
|
1169 | checkambigfiles=_cachedfiles) | |
|
1168 | 1170 | self.invalidate() |
|
1169 | 1171 | return True |
|
1170 | 1172 | else: |
@@ -1220,7 +1222,8 b' class localrepository(object):' | |||
|
1220 | 1222 | parents = self.dirstate.parents() |
|
1221 | 1223 | self.destroying() |
|
1222 | 1224 | vfsmap = {'plain': self.vfs, '': self.svfs} |
|
1223 |
transaction.rollback(self.svfs, vfsmap, 'undo', ui.warn |
|
|
1225 | transaction.rollback(self.svfs, vfsmap, 'undo', ui.warn, | |
|
1226 | checkambigfiles=_cachedfiles) | |
|
1224 | 1227 | if self.vfs.exists('undo.bookmarks'): |
|
1225 | 1228 | self.vfs.rename('undo.bookmarks', 'bookmarks', checkambig=True) |
|
1226 | 1229 | if self.svfs.exists('undo.phaseroots'): |
@@ -44,11 +44,12 b' def active(func):' | |||
|
44 | 44 | return _active |
|
45 | 45 | |
|
46 | 46 | def _playback(journal, report, opener, vfsmap, entries, backupentries, |
|
47 | unlink=True): | |
|
47 | unlink=True, checkambigfiles=None): | |
|
48 | 48 | for f, o, _ignore in entries: |
|
49 | 49 | if o or not unlink: |
|
50 | checkambig = checkambigfiles and (f, '') in checkambigfiles | |
|
50 | 51 | try: |
|
51 |
fp = opener(f, 'a', checkambig= |
|
|
52 | fp = opener(f, 'a', checkambig=checkambig) | |
|
52 | 53 | fp.truncate(o) |
|
53 | 54 | fp.close() |
|
54 | 55 | except IOError: |
@@ -101,7 +102,8 b' def _playback(journal, report, opener, v' | |||
|
101 | 102 | |
|
102 | 103 | class transaction(object): |
|
103 | 104 | def __init__(self, report, opener, vfsmap, journalname, undoname=None, |
|
104 |
after=None, createmode=None, validator=None, releasefn=None |
|
|
105 | after=None, createmode=None, validator=None, releasefn=None, | |
|
106 | checkambigfiles=None): | |
|
105 | 107 | """Begin a new transaction |
|
106 | 108 | |
|
107 | 109 | Begins a new transaction that allows rolling back writes in the event of |
@@ -110,6 +112,10 b' class transaction(object):' | |||
|
110 | 112 | * `after`: called after the transaction has been committed |
|
111 | 113 | * `createmode`: the mode of the journal file that will be created |
|
112 | 114 | * `releasefn`: called after releasing (with transaction and result) |
|
115 | ||
|
116 | `checkambigfiles` is a set of (path, vfs-location) tuples, | |
|
117 | which determine whether file stat ambiguity should be avoided | |
|
118 | for corresponded files. | |
|
113 | 119 | """ |
|
114 | 120 | self.count = 1 |
|
115 | 121 | self.usages = 1 |
@@ -137,6 +143,10 b' class transaction(object):' | |||
|
137 | 143 | releasefn = lambda tr, success: None |
|
138 | 144 | self.releasefn = releasefn |
|
139 | 145 | |
|
146 | self.checkambigfiles = set() | |
|
147 | if checkambigfiles: | |
|
148 | self.checkambigfiles.update(checkambigfiles) | |
|
149 | ||
|
140 | 150 | # A dict dedicated to precisely tracking the changes introduced in the |
|
141 | 151 | # transaction. |
|
142 | 152 | self.changes = {} |
@@ -564,7 +574,8 b' class transaction(object):' | |||
|
564 | 574 | # Prevent double usage and help clear cycles. |
|
565 | 575 | self._abortcallback = None |
|
566 | 576 | _playback(self.journal, self.report, self.opener, self._vfsmap, |
|
567 |
self.entries, self._backupentries, False |
|
|
577 | self.entries, self._backupentries, False, | |
|
578 | checkambigfiles=self.checkambigfiles) | |
|
568 | 579 | self.report(_("rollback completed\n")) |
|
569 | 580 | except BaseException: |
|
570 | 581 | self.report(_("rollback failed - please run hg recover\n")) |
@@ -573,7 +584,7 b' class transaction(object):' | |||
|
573 | 584 | self.releasefn(self, False) # notify failure of transaction |
|
574 | 585 | self.releasefn = None # Help prevent cycles. |
|
575 | 586 | |
|
576 | def rollback(opener, vfsmap, file, report): | |
|
587 | def rollback(opener, vfsmap, file, report, checkambigfiles=None): | |
|
577 | 588 | """Rolls back the transaction contained in the given file |
|
578 | 589 | |
|
579 | 590 | Reads the entries in the specified file, and the corresponding |
@@ -584,6 +595,10 b' def rollback(opener, vfsmap, file, repor' | |||
|
584 | 595 | file\0offset pairs, delimited by newlines. The corresponding |
|
585 | 596 | '*.backupfiles' file should contain a list of file\0backupfile |
|
586 | 597 | pairs, delimited by \0. |
|
598 | ||
|
599 | `checkambigfiles` is a set of (path, vfs-location) tuples, | |
|
600 | which determine whether file stat ambiguity should be avoided at | |
|
601 | restoring corresponded files. | |
|
587 | 602 | """ |
|
588 | 603 | entries = [] |
|
589 | 604 | backupentries = [] |
@@ -615,4 +630,5 b' def rollback(opener, vfsmap, file, repor' | |||
|
615 | 630 | report(_("journal was created by a different version of " |
|
616 | 631 | "Mercurial\n")) |
|
617 | 632 | |
|
618 |
_playback(file, report, opener, vfsmap, entries, backupentries |
|
|
633 | _playback(file, report, opener, vfsmap, entries, backupentries, | |
|
634 | checkambigfiles=checkambigfiles) |
@@ -39,8 +39,9 b' test qpush on empty series' | |||
|
39 | 39 | > from mercurial import extensions, transaction |
|
40 | 40 | > def wrapplayback(orig, |
|
41 | 41 | > journal, report, opener, vfsmap, entries, backupentries, |
|
42 | > unlink=True): | |
|
43 |
> orig(journal, report, opener, vfsmap, entries, backupentries, unlink |
|
|
42 | > unlink=True, checkambigfiles=None): | |
|
43 | > orig(journal, report, opener, vfsmap, entries, backupentries, unlink, | |
|
44 | > checkambigfiles) | |
|
44 | 45 | > # Touching files truncated at "transaction.abort" causes |
|
45 | 46 | > # forcible re-loading invalidated filecache properties |
|
46 | 47 | > # (including repo.changelog) |
General Comments 0
You need to be logged in to leave comments.
Login now