Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/utils/storageutil.py @ 49607:0bda07f34c01 stable
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 | fa955e3f6aee |
children | bb2c663c840f |
comparison
equal
deleted
inserted
replaced
49606:fa955e3f6aee | 49607:0bda07f34c01 |
---|---|
388 if deltamode == repository.CG_DELTAMODE_PREV or assumehaveparentrevisions: | 388 if deltamode == repository.CG_DELTAMODE_PREV or assumehaveparentrevisions: |
389 prevrev = store.parentrevs(revs[0])[0] | 389 prevrev = store.parentrevs(revs[0])[0] |
390 | 390 |
391 # Set of revs available to delta against. | 391 # Set of revs available to delta against. |
392 available = set() | 392 available = set() |
393 parents = [] | |
393 | 394 |
394 def is_usable_base(rev): | 395 def is_usable_base(rev): |
395 return rev != nullrev and rev in available | 396 """Is a delta against this revision usable over the wire""" |
397 if rev == nullrev: | |
398 return False | |
399 # Base revision was already emitted in this group. | |
400 if rev in available: | |
401 return True | |
402 # Base revision is a parent that hasn't been emitted already. | |
403 if assumehaveparentrevisions and rev in parents: | |
404 return True | |
405 return False | |
396 | 406 |
397 for rev in revs: | 407 for rev in revs: |
398 if rev == nullrev: | 408 if rev == nullrev: |
399 continue | 409 continue |
400 | 410 |
401 node = fnode(rev) | 411 node = fnode(rev) |
402 p1rev, p2rev = store.parentrevs(rev) | 412 parents[:] = p1rev, p2rev = store.parentrevs(rev) |
403 | 413 |
404 if deltaparentfn: | 414 if deltaparentfn: |
405 deltaparentrev = deltaparentfn(rev) | 415 deltaparentrev = deltaparentfn(rev) |
406 else: | 416 else: |
407 deltaparentrev = nullrev | 417 deltaparentrev = nullrev |
419 | 429 |
420 # There is a delta in storage. We try to use that because it | 430 # There is a delta in storage. We try to use that because it |
421 # amounts to effectively copying data from storage and is | 431 # amounts to effectively copying data from storage and is |
422 # therefore the fastest. | 432 # therefore the fastest. |
423 elif deltaparentrev != nullrev: | 433 elif deltaparentrev != nullrev: |
424 # Base revision was already emitted in this group. We can | 434 # If the stored delta works, let us use it ! |
425 # always safely use the delta. | |
426 if is_usable_base(deltaparentrev): | 435 if is_usable_base(deltaparentrev): |
427 baserev = deltaparentrev | 436 baserev = deltaparentrev |
428 | |
429 # Base revision is a parent that hasn't been emitted already. | |
430 # Use it if we can assume the receiver has the parent revision. | |
431 elif assumehaveparentrevisions and deltaparentrev in (p1rev, p2rev): | |
432 baserev = deltaparentrev | |
433 | |
434 # No guarantee the receiver has the delta parent. Send delta | 437 # No guarantee the receiver has the delta parent. Send delta |
435 # against last revision (if possible), which in the common case | 438 # against last revision (if possible), which in the common case |
436 # should be similar enough to this revision that the delta is | 439 # should be similar enough to this revision that the delta is |
437 # reasonable. | 440 # reasonable. |
438 elif prevrev is not None: | 441 elif prevrev is not None: |