##// END OF EJS Templates
upgrade: move most of revlog.clone method into a _clone method...
marmoute -
r43266:4f2315cc default
parent child Browse files
Show More
@@ -2337,7 +2337,7 b' class revlog(object):'
2337 2337 DELTAREUSEALL = {'always', 'samerevs', 'never', 'fulladd'}
2338 2338
2339 2339 def clone(self, tr, destrevlog, addrevisioncb=None,
2340 deltareuse=DELTAREUSESAMEREVS, forcedeltabothparents=None):
2340 deltareuse=DELTAREUSESAMEREVS, forcedeltabothparents=None):
2341 2341 """Copy this revlog to another, possibly with format changes.
2342 2342
2343 2343 The destination revlog will contain the same revisions and nodes.
@@ -2405,60 +2405,66 b' class revlog(object):'
2405 2405
2406 2406 destrevlog._deltabothparents = forcedeltabothparents or oldamd
2407 2407
2408 deltacomputer = deltautil.deltacomputer(destrevlog)
2409 index = self.index
2410 for rev in self:
2411 entry = index[rev]
2412
2413 # Some classes override linkrev to take filtered revs into
2414 # account. Use raw entry from index.
2415 flags = entry[0] & 0xffff
2416 linkrev = entry[4]
2417 p1 = index[entry[5]][7]
2418 p2 = index[entry[6]][7]
2419 node = entry[7]
2420
2421 # (Possibly) reuse the delta from the revlog if allowed and
2422 # the revlog chunk is a delta.
2423 cachedelta = None
2424 rawtext = None
2425 if (deltareuse != self.DELTAREUSEFULLADD
2426 and destrevlog._lazydelta):
2427 dp = self.deltaparent(rev)
2428 if dp != nullrev:
2429 cachedelta = (dp, bytes(self._chunk(rev)))
2430
2431 if not cachedelta:
2432 rawtext = self.rawdata(rev)
2433
2434
2435 if deltareuse == self.DELTAREUSEFULLADD:
2436 destrevlog.addrevision(rawtext, tr, linkrev, p1, p2,
2437 cachedelta=cachedelta,
2438 node=node, flags=flags,
2439 deltacomputer=deltacomputer)
2440 else:
2441 ifh = destrevlog.opener(destrevlog.indexfile, 'a+',
2442 checkambig=False)
2443 dfh = None
2444 if not destrevlog._inline:
2445 dfh = destrevlog.opener(destrevlog.datafile, 'a+')
2446 try:
2447 destrevlog._addrevision(node, rawtext, tr, linkrev, p1,
2448 p2, flags, cachedelta, ifh, dfh,
2449 deltacomputer=deltacomputer)
2450 finally:
2451 if dfh:
2452 dfh.close()
2453 ifh.close()
2454
2455 if addrevisioncb:
2456 addrevisioncb(self, rev, node)
2408 self._clone(tr, destrevlog, addrevisioncb, deltareuse,
2409 forcedeltabothparents)
2410
2457 2411 finally:
2458 2412 destrevlog._lazydelta = oldlazydelta
2459 2413 destrevlog._lazydeltabase = oldlazydeltabase
2460 2414 destrevlog._deltabothparents = oldamd
2461 2415
2416 def _clone(self, tr, destrevlog, addrevisioncb, deltareuse,
2417 forcedeltabothparents):
2418 """perform the core duty of `revlog.clone` after parameter processing"""
2419 deltacomputer = deltautil.deltacomputer(destrevlog)
2420 index = self.index
2421 for rev in self:
2422 entry = index[rev]
2423
2424 # Some classes override linkrev to take filtered revs into
2425 # account. Use raw entry from index.
2426 flags = entry[0] & 0xffff
2427 linkrev = entry[4]
2428 p1 = index[entry[5]][7]
2429 p2 = index[entry[6]][7]
2430 node = entry[7]
2431
2432 # (Possibly) reuse the delta from the revlog if allowed and
2433 # the revlog chunk is a delta.
2434 cachedelta = None
2435 rawtext = None
2436 if (deltareuse != self.DELTAREUSEFULLADD and destrevlog._lazydelta):
2437 dp = self.deltaparent(rev)
2438 if dp != nullrev:
2439 cachedelta = (dp, bytes(self._chunk(rev)))
2440
2441 if not cachedelta:
2442 rawtext = self.rawdata(rev)
2443
2444
2445 if deltareuse == self.DELTAREUSEFULLADD:
2446 destrevlog.addrevision(rawtext, tr, linkrev, p1, p2,
2447 cachedelta=cachedelta,
2448 node=node, flags=flags,
2449 deltacomputer=deltacomputer)
2450 else:
2451 ifh = destrevlog.opener(destrevlog.indexfile, 'a+',
2452 checkambig=False)
2453 dfh = None
2454 if not destrevlog._inline:
2455 dfh = destrevlog.opener(destrevlog.datafile, 'a+')
2456 try:
2457 destrevlog._addrevision(node, rawtext, tr, linkrev, p1,
2458 p2, flags, cachedelta, ifh, dfh,
2459 deltacomputer=deltacomputer)
2460 finally:
2461 if dfh:
2462 dfh.close()
2463 ifh.close()
2464
2465 if addrevisioncb:
2466 addrevisioncb(self, rev, node)
2467
2462 2468 def censorrevision(self, tr, censornode, tombstone=b''):
2463 2469 if (self.version & 0xFFFF) == REVLOGV0:
2464 2470 raise error.RevlogError(_('cannot censor with version %d revlogs') %
General Comments 0
You need to be logged in to leave comments. Login now