##// END OF EJS Templates
revlog: preindent some code in addgroup...
marmoute -
r47986:0cf537d8 default
parent child Browse files
Show More
@@ -2442,83 +2442,95 b' class revlog(object):'
2442 empty = True
2442 empty = True
2443
2443
2444 try:
2444 try:
2445 deltacomputer = deltautil.deltacomputer(self)
2445 if True:
2446 # loop through our set of deltas
2446 deltacomputer = deltautil.deltacomputer(self)
2447 for data in deltas:
2447 # loop through our set of deltas
2448 node, p1, p2, linknode, deltabase, delta, flags, sidedata = data
2448 for data in deltas:
2449 link = linkmapper(linknode)
2449 (
2450 flags = flags or REVIDX_DEFAULT_FLAGS
2450 node,
2451
2451 p1,
2452 rev = self.index.get_rev(node)
2452 p2,
2453 if rev is not None:
2453 linknode,
2454 # this can happen if two branches make the same change
2454 deltabase,
2455 self._nodeduplicatecallback(transaction, rev)
2455 delta,
2456 if duplicaterevisioncb:
2456 flags,
2457 duplicaterevisioncb(self, rev)
2457 sidedata,
2458 empty = False
2458 ) = data
2459 continue
2459 link = linkmapper(linknode)
2460
2460 flags = flags or REVIDX_DEFAULT_FLAGS
2461 for p in (p1, p2):
2461
2462 if not self.index.has_node(p):
2462 rev = self.index.get_rev(node)
2463 if rev is not None:
2464 # this can happen if two branches make the same change
2465 self._nodeduplicatecallback(transaction, rev)
2466 if duplicaterevisioncb:
2467 duplicaterevisioncb(self, rev)
2468 empty = False
2469 continue
2470
2471 for p in (p1, p2):
2472 if not self.index.has_node(p):
2473 raise error.LookupError(
2474 p, self.radix, _(b'unknown parent')
2475 )
2476
2477 if not self.index.has_node(deltabase):
2463 raise error.LookupError(
2478 raise error.LookupError(
2464 p, self.radix, _(b'unknown parent')
2479 deltabase, self.display_id, _(b'unknown delta base')
2465 )
2466
2467 if not self.index.has_node(deltabase):
2468 raise error.LookupError(
2469 deltabase, self.display_id, _(b'unknown delta base')
2470 )
2471
2472 baserev = self.rev(deltabase)
2473
2474 if baserev != nullrev and self.iscensored(baserev):
2475 # if base is censored, delta must be full replacement in a
2476 # single patch operation
2477 hlen = struct.calcsize(b">lll")
2478 oldlen = self.rawsize(baserev)
2479 newlen = len(delta) - hlen
2480 if delta[:hlen] != mdiff.replacediffheader(oldlen, newlen):
2481 raise error.CensoredBaseError(
2482 self.display_id, self.node(baserev)
2483 )
2480 )
2484
2481
2485 if not flags and self._peek_iscensored(baserev, delta):
2482 baserev = self.rev(deltabase)
2486 flags |= REVIDX_ISCENSORED
2483
2487
2484 if baserev != nullrev and self.iscensored(baserev):
2488 # We assume consumers of addrevisioncb will want to retrieve
2485 # if base is censored, delta must be full replacement in a
2489 # the added revision, which will require a call to
2486 # single patch operation
2490 # revision(). revision() will fast path if there is a cache
2487 hlen = struct.calcsize(b">lll")
2491 # hit. So, we tell _addrevision() to always cache in this case.
2488 oldlen = self.rawsize(baserev)
2492 # We're only using addgroup() in the context of changegroup
2489 newlen = len(delta) - hlen
2493 # generation so the revision data can always be handled as raw
2490 if delta[:hlen] != mdiff.replacediffheader(
2494 # by the flagprocessor.
2491 oldlen, newlen
2495 rev = self._addrevision(
2492 ):
2496 node,
2493 raise error.CensoredBaseError(
2497 None,
2494 self.display_id, self.node(baserev)
2498 transaction,
2495 )
2499 link,
2496
2500 p1,
2497 if not flags and self._peek_iscensored(baserev, delta):
2501 p2,
2498 flags |= REVIDX_ISCENSORED
2502 flags,
2499
2503 (baserev, delta),
2500 # We assume consumers of addrevisioncb will want to retrieve
2504 ifh,
2501 # the added revision, which will require a call to
2505 dfh,
2502 # revision(). revision() will fast path if there is a cache
2506 alwayscache=alwayscache,
2503 # hit. So, we tell _addrevision() to always cache in this case.
2507 deltacomputer=deltacomputer,
2504 # We're only using addgroup() in the context of changegroup
2508 sidedata=sidedata,
2505 # generation so the revision data can always be handled as raw
2509 )
2506 # by the flagprocessor.
2510
2507 rev = self._addrevision(
2511 if addrevisioncb:
2508 node,
2512 addrevisioncb(self, rev)
2509 None,
2513 empty = False
2510 transaction,
2514
2511 link,
2515 if not dfh and not self._inline:
2512 p1,
2516 # addrevision switched from inline to conventional
2513 p2,
2517 # reopen the index
2514 flags,
2518 ifh.close()
2515 (baserev, delta),
2519 dfh = self._datafp(b"a+")
2516 ifh,
2520 ifh = self._indexfp(b"a+")
2517 dfh,
2521 self._writinghandles = (ifh, dfh)
2518 alwayscache=alwayscache,
2519 deltacomputer=deltacomputer,
2520 sidedata=sidedata,
2521 )
2522
2523 if addrevisioncb:
2524 addrevisioncb(self, rev)
2525 empty = False
2526
2527 if not dfh and not self._inline:
2528 # addrevision switched from inline to conventional
2529 # reopen the index
2530 ifh.close()
2531 dfh = self._datafp(b"a+")
2532 ifh = self._indexfp(b"a+")
2533 self._writinghandles = (ifh, dfh)
2522 finally:
2534 finally:
2523 self._writinghandles = None
2535 self._writinghandles = None
2524
2536
General Comments 0
You need to be logged in to leave comments. Login now