Mercurial > public > mercurial-scm > hg
comparison mercurial/utils/storageutil.py @ 49668:383c79f8e5a7
emitrevision: also check the parents in the availability closure
One of the point of having a closure is to gather the logic in it. So we gather
the logic.
The `parents[:]` part is a bit ugly but will be replaced by better code soon
anyway.
author | Pierre-Yves David <pierre-yves.david@octobus.net> |
---|---|
date | Mon, 28 Nov 2022 15:59:52 +0100 |
parents | 191f5057ec45 |
children | f064b03d061a |
comparison
equal
deleted
inserted
replaced
49667:191f5057ec45 | 49668:383c79f8e5a7 |
---|---|
393 if deltamode == repository.CG_DELTAMODE_PREV or assumehaveparentrevisions: | 393 if deltamode == repository.CG_DELTAMODE_PREV or assumehaveparentrevisions: |
394 prevrev = store.parentrevs(revs[0])[0] | 394 prevrev = store.parentrevs(revs[0])[0] |
395 | 395 |
396 # Set of revs available to delta against. | 396 # Set of revs available to delta against. |
397 available = set() | 397 available = set() |
398 parents = [] | |
398 | 399 |
399 def is_usable_base(rev): | 400 def is_usable_base(rev): |
400 return rev != nullrev and rev in available | 401 """Is a delta against this revision usable over the wire""" |
402 if rev == nullrev: | |
403 return False | |
404 # Base revision was already emitted in this group. | |
405 if rev in available: | |
406 return True | |
407 # Base revision is a parent that hasn't been emitted already. | |
408 if assumehaveparentrevisions and rev in parents: | |
409 return True | |
410 return False | |
401 | 411 |
402 for rev in revs: | 412 for rev in revs: |
403 if rev == nullrev: | 413 if rev == nullrev: |
404 continue | 414 continue |
405 | 415 |
406 debug_delta_source = None | 416 debug_delta_source = None |
407 if debug_info is not None: | 417 if debug_info is not None: |
408 debug_info['revision-total'] += 1 | 418 debug_info['revision-total'] += 1 |
409 | 419 |
410 node = fnode(rev) | 420 node = fnode(rev) |
411 p1rev, p2rev = store.parentrevs(rev) | 421 parents[:] = p1rev, p2rev = store.parentrevs(rev) |
412 | 422 |
413 if debug_info is not None: | 423 if debug_info is not None: |
414 if p1rev != p2rev and p1rev != nullrev and p2rev != nullrev: | 424 if p1rev != p2rev and p1rev != nullrev and p2rev != nullrev: |
415 debug_info['merge-total'] += 1 | 425 debug_info['merge-total'] += 1 |
416 | 426 |
444 | 454 |
445 # There is a delta in storage. We try to use that because it | 455 # There is a delta in storage. We try to use that because it |
446 # amounts to effectively copying data from storage and is | 456 # amounts to effectively copying data from storage and is |
447 # therefore the fastest. | 457 # therefore the fastest. |
448 elif deltaparentrev != nullrev: | 458 elif deltaparentrev != nullrev: |
449 # Base revision was already emitted in this group. We can | 459 # If the stored delta works, let us use it ! |
450 # always safely use the delta. | |
451 if is_usable_base(deltaparentrev): | 460 if is_usable_base(deltaparentrev): |
452 if debug_info is not None: | |
453 debug_delta_source = "storage" | |
454 baserev = deltaparentrev | |
455 | |
456 # Base revision is a parent that hasn't been emitted already. | |
457 # Use it if we can assume the receiver has the parent revision. | |
458 elif assumehaveparentrevisions and deltaparentrev in (p1rev, p2rev): | |
459 if debug_info is not None: | 461 if debug_info is not None: |
460 debug_delta_source = "storage" | 462 debug_delta_source = "storage" |
461 baserev = deltaparentrev | 463 baserev = deltaparentrev |
462 # No guarantee the receiver has the delta parent. Send delta | 464 # No guarantee the receiver has the delta parent. Send delta |
463 # against last revision (if possible), which in the common case | 465 # against last revision (if possible), which in the common case |