Mercurial > public > mercurial-scm > hg
comparison mercurial/revlogutils/rewrite.py @ 47818:5b046c2e3000 stable
issue6528: implement _is_revision_affected using callback
The delta comming from a bundle/stream does not exists in the revlog yet, so we
will need other way to retrieve the same information.
To prepare for this we split the function to use callbacks in the core logic.
Differential Revision: https://phab.mercurial-scm.org/D11267
author | Pierre-Yves David <pierre-yves.david@octobus.net> |
---|---|
date | Sat, 07 Aug 2021 12:38:48 +0200 |
parents | 855463b5fe49 |
children | c02ce6def30c |
comparison
equal
deleted
inserted
replaced
47817:855463b5fe49 | 47818:5b046c2e3000 |
---|---|
561 finally: | 561 finally: |
562 util.tryunlink(new_file_path) | 562 util.tryunlink(new_file_path) |
563 | 563 |
564 | 564 |
565 def _is_revision_affected(fl, filerev, metadata_cache=None): | 565 def _is_revision_affected(fl, filerev, metadata_cache=None): |
566 full_text = lambda: fl._revlog.rawdata(filerev) | |
567 parent_revs = lambda: fl._revlog.parentrevs(filerev) | |
568 return _is_revision_affected_inner( | |
569 full_text, parent_revs, filerev, metadata_cache | |
570 ) | |
571 | |
572 | |
573 def _is_revision_affected_inner( | |
574 full_text, | |
575 parents_revs, | |
576 filerev, | |
577 metadata_cache=None, | |
578 ): | |
566 """Mercurial currently (5.9rc0) uses `p1 == nullrev and p2 != nullrev` as a | 579 """Mercurial currently (5.9rc0) uses `p1 == nullrev and p2 != nullrev` as a |
567 special meaning compared to the reverse in the context of filelog-based | 580 special meaning compared to the reverse in the context of filelog-based |
568 copytracing. issue6528 exists because new code assumed that parent ordering | 581 copytracing. issue6528 exists because new code assumed that parent ordering |
569 didn't matter, so this detects if the revision contains metadata (since | 582 didn't matter, so this detects if the revision contains metadata (since |
570 it's only used for filelog-based copytracing) and its parents are in the | 583 it's only used for filelog-based copytracing) and its parents are in the |
571 "wrong" order.""" | 584 "wrong" order.""" |
572 try: | 585 try: |
573 raw_text = fl.rawdata(filerev) | 586 raw_text = full_text() |
574 except error.CensoredNodeError: | 587 except error.CensoredNodeError: |
575 # We don't care about censored nodes as they never carry metadata | 588 # We don't care about censored nodes as they never carry metadata |
576 return False | 589 return False |
577 has_meta = raw_text.startswith(b'\x01\n') | 590 has_meta = raw_text.startswith(b'\x01\n') |
578 if metadata_cache is not None: | 591 if metadata_cache is not None: |
579 metadata_cache[filerev] = has_meta | 592 metadata_cache[filerev] = has_meta |
580 if has_meta: | 593 if has_meta: |
581 (p1, p2) = fl.parentrevs(filerev) | 594 (p1, p2) = parents_revs() |
582 if p1 != nullrev and p2 == nullrev: | 595 if p1 != nullrev and p2 == nullrev: |
583 return True | 596 return True |
584 return False | 597 return False |
585 | 598 |
586 | 599 |