##// END OF EJS Templates
transaction: include backup file in the "undo" transaction...
Pierre-Yves David -
r23904:d251da5e default
parent child Browse files
Show More
@@ -405,6 +405,7 b' class transaction(object):'
405 405 self.report("couldn't remote %s: %s\n"
406 406 % (vfs.join(b), inst))
407 407 self.entries = []
408 self._writeundo()
408 409 if self.after:
409 410 self.after()
410 411 if self.opener.isfile(self.journal):
@@ -440,6 +441,32 b' class transaction(object):'
440 441 scope)'''
441 442 self._abort()
442 443
444 def _writeundo(self):
445 """write transaction data for possible future undo call"""
446 if self.undoname is None:
447 return
448 undobackupfile = self.opener.open("%s.backupfiles" % self.undoname, 'w')
449 undobackupfile.write('%d\n' % version)
450 for l, f, b, c in self._backupentries:
451 if not f: # temporary file
452 continue
453 if not b:
454 u = ''
455 else:
456 if l not in self._vfsmap and c:
457 self.report("couldn't remote %s: unknown cache location"
458 "%s\n" % (b, l))
459 continue
460 vfs = self._vfsmap[l]
461 base, name = vfs.split(b)
462 assert name.startswith(self.journal), name
463 uname = name.replace(self.journal, self.undoname, 1)
464 u = vfs.reljoin(base, uname)
465 util.copyfile(vfs.join(b), vfs.join(u), hardlink=True)
466 undobackupfile.write("%s\0%s\0%s\0%d\n" % (l, f, u, c))
467 undobackupfile.close()
468
469
443 470 def _abort(self):
444 471 self.count = 0
445 472 self.usages = 0
@@ -81,6 +81,7 b' Non store repo:'
81 81 .hg/phaseroots
82 82 .hg/requires
83 83 .hg/undo
84 .hg/undo.backupfiles
84 85 .hg/undo.bookmarks
85 86 .hg/undo.branch
86 87 .hg/undo.desc
@@ -114,6 +115,7 b' Non fncache repo:'
114 115 .hg/store/data/tst.d.hg/_foo.i
115 116 .hg/store/phaseroots
116 117 .hg/store/undo
118 .hg/store/undo.backupfiles
117 119 .hg/store/undo.phaseroots
118 120 .hg/undo.bookmarks
119 121 .hg/undo.branch
@@ -50,6 +50,8 b' Prepare repo r1:'
50 50 1 r1/.hg/store/fncache
51 51 1 r1/.hg/store/phaseroots
52 52 1 r1/.hg/store/undo
53 1 r1/.hg/store/undo.backup.fncache
54 1 r1/.hg/store/undo.backupfiles
53 55 1 r1/.hg/store/undo.phaseroots
54 56
55 57
@@ -80,6 +82,8 b' Repos r1 and r2 should now contain hardl'
80 82 2 r1/.hg/store/fncache
81 83 1 r1/.hg/store/phaseroots
82 84 1 r1/.hg/store/undo
85 1 r1/.hg/store/undo.backup.fncache
86 1 r1/.hg/store/undo.backupfiles
83 87 1 r1/.hg/store/undo.phaseroots
84 88
85 89 $ nlinksdir r2/.hg/store
@@ -99,6 +103,7 b' Repo r3 should not be hardlinked:'
99 103 1 r3/.hg/store/fncache
100 104 1 r3/.hg/store/phaseroots
101 105 1 r3/.hg/store/undo
106 1 r3/.hg/store/undo.backupfiles
102 107 1 r3/.hg/store/undo.phaseroots
103 108
104 109
@@ -124,6 +129,9 b' Create a non-inlined filelog in r3:'
124 129 1 r3/.hg/store/fncache
125 130 1 r3/.hg/store/phaseroots
126 131 1 r3/.hg/store/undo
132 1 r3/.hg/store/undo.backup.fncache
133 1 r3/.hg/store/undo.backup.phaseroots
134 1 r3/.hg/store/undo.backupfiles
127 135 1 r3/.hg/store/undo.phaseroots
128 136
129 137 Push to repo r1 should break up most hardlinks in r2:
@@ -151,7 +159,7 b' Push to repo r1 should break up most har'
151 159 1 r2/.hg/store/00manifest.i
152 160 1 r2/.hg/store/data/d1/f2.i
153 161 2 r2/.hg/store/data/f1.i
154 1 r2/.hg/store/fncache
162 2 r2/.hg/store/fncache
155 163
156 164 $ hg -R r2 verify
157 165 checking changesets
@@ -176,7 +184,7 b' Committing a change to f1 in r1 must bre'
176 184 1 r2/.hg/store/00manifest.i
177 185 1 r2/.hg/store/data/d1/f2.i
178 186 1 r2/.hg/store/data/f1.i
179 1 r2/.hg/store/fncache
187 2 r2/.hg/store/fncache
180 188
181 189
182 190 $ cd r3
@@ -210,6 +218,9 b' r4 has hardlinks in the working dir (not'
210 218 2 r4/.hg/store/fncache
211 219 2 r4/.hg/store/phaseroots
212 220 2 r4/.hg/store/undo
221 2 r4/.hg/store/undo.backup.fncache
222 2 r4/.hg/store/undo.backup.phaseroots
223 2 r4/.hg/store/undo.backupfiles
213 224 2 r4/.hg/store/undo.phaseroots
214 225 2 r4/.hg/undo.bookmarks
215 226 2 r4/.hg/undo.branch
@@ -242,6 +253,9 b' Update back to revision 11 in r4 should '
242 253 2 r4/.hg/store/fncache
243 254 2 r4/.hg/store/phaseroots
244 255 2 r4/.hg/store/undo
256 2 r4/.hg/store/undo.backup.fncache
257 2 r4/.hg/store/undo.backup.phaseroots
258 2 r4/.hg/store/undo.backupfiles
245 259 2 r4/.hg/store/undo.phaseroots
246 260 2 r4/.hg/undo.bookmarks
247 261 2 r4/.hg/undo.branch
@@ -158,6 +158,8 b' more there after'
158 158 journal.phaseroots
159 159 phaseroots
160 160 undo
161 undo.backup.fncache
162 undo.backupfiles
161 163 undo.phaseroots
162 164
163 165
@@ -81,6 +81,7 b' new directories are setgid'
81 81 00660 ./.hg/store/fncache
82 82 00660 ./.hg/store/phaseroots
83 83 00660 ./.hg/store/undo
84 00660 ./.hg/store/undo.backupfiles
84 85 00660 ./.hg/store/undo.phaseroots
85 86 00660 ./.hg/undo.bookmarks
86 87 00660 ./.hg/undo.branch
@@ -125,6 +126,7 b' group can still write everything'
125 126 00660 ../push/.hg/store/data/foo.i
126 127 00660 ../push/.hg/store/fncache
127 128 00660 ../push/.hg/store/undo
129 00660 ../push/.hg/store/undo.backupfiles
128 130 00660 ../push/.hg/store/undo.phaseroots
129 131 00660 ../push/.hg/undo.bookmarks
130 132 00660 ../push/.hg/undo.branch
General Comments 0
You need to be logged in to leave comments. Login now