Show More
@@ -210,6 +210,7 b' def strip(ui, repo, nodelist, backup=Tru' | |||
|
210 | 210 | # using append-only files. We'll need some kind of storage |
|
211 | 211 | # API to handle stripping for us. |
|
212 | 212 | oldfiles = set(tr._offsetmap.keys()) |
|
213 | oldfiles.update(tr._newfiles) | |
|
213 | 214 | |
|
214 | 215 | tr.startgroup() |
|
215 | 216 | cl.strip(striprev, tr) |
@@ -159,6 +159,7 b' class transaction(util.transactional):' | |||
|
159 | 159 | self._vfsmap = vfsmap |
|
160 | 160 | self._after = after |
|
161 | 161 | self._offsetmap = {} |
|
162 | self._newfiles = set() | |
|
162 | 163 | self._journal = journalname |
|
163 | 164 | self._undoname = undoname |
|
164 | 165 | self._queue = [] |
@@ -248,7 +249,11 b' class transaction(util.transactional):' | |||
|
248 | 249 | @active |
|
249 | 250 | def add(self, file, offset): |
|
250 | 251 | """record the state of an append-only file before update""" |
|
251 | if file in self._offsetmap or file in self._backupmap: | |
|
252 | if ( | |
|
253 | file in self._newfiles | |
|
254 | or file in self._offsetmap | |
|
255 | or file in self._backupmap | |
|
256 | ): | |
|
252 | 257 | return |
|
253 | 258 | if self._queue: |
|
254 | 259 | self._queue[-1].append((file, offset)) |
@@ -258,9 +263,16 b' class transaction(util.transactional):' | |||
|
258 | 263 | |
|
259 | 264 | def _addentry(self, file, offset): |
|
260 | 265 | """add a append-only entry to memory and on-disk state""" |
|
261 | if file in self._offsetmap or file in self._backupmap: | |
|
266 | if ( | |
|
267 | file in self._newfiles | |
|
268 | or file in self._offsetmap | |
|
269 | or file in self._backupmap | |
|
270 | ): | |
|
262 | 271 | return |
|
272 | if offset: | |
|
263 | 273 | self._offsetmap[file] = offset |
|
274 | else: | |
|
275 | self._newfiles.add(file) | |
|
264 | 276 | # add enough data to the journal to do the truncate |
|
265 | 277 | self._file.write(b"%s\0%d\n" % (file, offset)) |
|
266 | 278 | self._file.flush() |
@@ -280,7 +292,11 b' class transaction(util.transactional):' | |||
|
280 | 292 | msg = b'cannot use transaction.addbackup inside "group"' |
|
281 | 293 | raise error.ProgrammingError(msg) |
|
282 | 294 | |
|
283 | if file in self._offsetmap or file in self._backupmap: | |
|
295 | if ( | |
|
296 | file in self._newfiles | |
|
297 | or file in self._offsetmap | |
|
298 | or file in self._backupmap | |
|
299 | ): | |
|
284 | 300 | return |
|
285 | 301 | vfs = self._vfsmap[location] |
|
286 | 302 | dirname, filename = vfs.split(file) |
@@ -394,6 +410,8 b' class transaction(util.transactional):' | |||
|
394 | 410 | |
|
395 | 411 | @active |
|
396 | 412 | def findoffset(self, file): |
|
413 | if file in self._newfiles: | |
|
414 | return 0 | |
|
397 | 415 | return self._offsetmap.get(file) |
|
398 | 416 | |
|
399 | 417 | @active |
@@ -411,10 +429,19 b' class transaction(util.transactional):' | |||
|
411 | 429 | replace can only replace already committed entries |
|
412 | 430 | that are not pending in the queue |
|
413 | 431 | ''' |
|
414 | ||
|
415 |
if |
|
|
432 | if file in self._newfiles: | |
|
433 | if not offset: | |
|
434 | return | |
|
435 | self._newfiles.remove(file) | |
|
436 | self._offsetmap[file] = offset | |
|
437 | elif file in self._offsetmap: | |
|
438 | if not offset: | |
|
439 | del self._offsetmap[file] | |
|
440 | self._newfiles.add(file) | |
|
441 | else: | |
|
442 | self._offsetmap[file] = offset | |
|
443 | else: | |
|
416 | 444 | raise KeyError(file) |
|
417 | self._offsetmap[file] = offset | |
|
418 | 445 | self._file.write(b"%s\0%d\n" % (file, offset)) |
|
419 | 446 | self._file.flush() |
|
420 | 447 | |
@@ -555,6 +582,7 b' class transaction(util.transactional):' | |||
|
555 | 582 | b"couldn't remove %s: %s\n" % (vfs.join(b), inst) |
|
556 | 583 | ) |
|
557 | 584 | self._offsetmap = {} |
|
585 | self._newfiles = set() | |
|
558 | 586 | self._writeundo() |
|
559 | 587 | if self._after: |
|
560 | 588 | self._after() |
@@ -638,7 +666,7 b' class transaction(util.transactional):' | |||
|
638 | 666 | self._backupsfile.close() |
|
639 | 667 | |
|
640 | 668 | try: |
|
641 |
if not |
|
|
669 | if not entries and not self._backupentries: | |
|
642 | 670 | if self._backupjournal: |
|
643 | 671 | self._opener.unlink(self._backupjournal) |
|
644 | 672 | if self._journal: |
General Comments 0
You need to be logged in to leave comments.
Login now