comparison mercurial/context.py @ 43146:0171483b082f

sidedatacopies: read rename information from sidedata Repository using the new format now use changeset centric algorithm and read the copies information from the changelog sidedata. Differential Revision: https://phab.mercurial-scm.org/D6953
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Wed, 09 Oct 2019 22:59:38 +0200
parents 8ff1ecfadcd1
children 54e943b28101
comparison
equal deleted inserted replaced
43145:4296cc3c4ae1 43146:0171483b082f
531 modified.difference_update(self.filesadded()) 531 modified.difference_update(self.filesadded())
532 modified.difference_update(self.filesremoved()) 532 modified.difference_update(self.filesremoved())
533 return sorted(modified) 533 return sorted(modified)
534 534
535 def filesadded(self): 535 def filesadded(self):
536 source = self._repo.ui.config(b'experimental', b'copies.read-from')
537 filesadded = self._changeset.filesadded 536 filesadded = self._changeset.filesadded
538 if source == b'changeset-only': 537 compute_on_none = True
539 if filesadded is None: 538 if self._repo.filecopiesmode == b'changeset-sidedata':
539 compute_on_none = False
540 else:
541 source = self._repo.ui.config(b'experimental', b'copies.read-from')
542 if source == b'changeset-only':
543 compute_on_none = False
544 elif source != b'compatibility':
545 # filelog mode, ignore any changelog content
546 filesadded = None
547 if filesadded is None:
548 if compute_on_none:
549 filesadded = scmutil.computechangesetfilesadded(self)
550 else:
540 filesadded = [] 551 filesadded = []
541 elif source == b'compatibility': 552 return filesadded
542 if filesadded is None: 553
543 filesadded = scmutil.computechangesetfilesadded(self) 554 def filesremoved(self):
555 filesremoved = self._changeset.filesremoved
556 compute_on_none = True
557 if self._repo.filecopiesmode == b'changeset-sidedata':
558 compute_on_none = False
544 else: 559 else:
545 filesadded = scmutil.computechangesetfilesadded(self) 560 source = self._repo.ui.config(b'experimental', b'copies.read-from')
546 return filesadded 561 if source == b'changeset-only':
547 562 compute_on_none = False
548 def filesremoved(self): 563 elif source != b'compatibility':
549 source = self._repo.ui.config(b'experimental', b'copies.read-from') 564 # filelog mode, ignore any changelog content
550 filesremoved = self._changeset.filesremoved 565 filesremoved = None
551 if source == b'changeset-only': 566 if filesremoved is None:
552 if filesremoved is None: 567 if compute_on_none:
568 filesremoved = scmutil.computechangesetfilesremoved(self)
569 else:
553 filesremoved = [] 570 filesremoved = []
554 elif source == b'compatibility':
555 if filesremoved is None:
556 filesremoved = scmutil.computechangesetfilesremoved(self)
557 else:
558 filesremoved = scmutil.computechangesetfilesremoved(self)
559 return filesremoved 571 return filesremoved
560 572
561 @propertycache 573 @propertycache
562 def _copies(self): 574 def _copies(self):
563 source = self._repo.ui.config(b'experimental', b'copies.read-from')
564 p1copies = self._changeset.p1copies 575 p1copies = self._changeset.p1copies
565 p2copies = self._changeset.p2copies 576 p2copies = self._changeset.p2copies
566 # If config says to get copy metadata only from changeset, then return 577 compute_on_none = True
567 # that, defaulting to {} if there was no copy metadata. 578 if self._repo.filecopiesmode == b'changeset-sidedata':
568 # In compatibility mode, we return copy data from the changeset if 579 compute_on_none = False
569 # it was recorded there, and otherwise we fall back to getting it from 580 else:
570 # the filelogs (below). 581 source = self._repo.ui.config(b'experimental', b'copies.read-from')
571 if source == b'changeset-only': 582 # If config says to get copy metadata only from changeset, then
572 if p1copies is None: 583 # return that, defaulting to {} if there was no copy metadata. In
573 p1copies = {} 584 # compatibility mode, we return copy data from the changeset if it
574 if p2copies is None: 585 # was recorded there, and otherwise we fall back to getting it from
575 p2copies = {} 586 # the filelogs (below).
576 elif source == b'compatibility': 587 #
577 if p1copies is None: 588 # If we are in compatiblity mode and there is not data in the
578 # we are in compatiblity mode and there is not data in the 589 # changeset), we get the copy metadata from the filelogs.
579 # changeset), we get the copy metadata from the filelogs. 590 #
591 # otherwise, when config said to read only from filelog, we get the
592 # copy metadata from the filelogs.
593 if source == b'changeset-only':
594 compute_on_none = False
595 elif source != b'compatibility':
596 # filelog mode, ignore any changelog content
597 p1copies = p2copies = None
598 if p1copies is None:
599 if compute_on_none:
580 p1copies, p2copies = super(changectx, self)._copies 600 p1copies, p2copies = super(changectx, self)._copies
581 else: 601 else:
582 # config said to read only from filelog, we get the copy metadata 602 if p1copies is None:
583 # from the filelogs. 603 p1copies = {}
584 p1copies, p2copies = super(changectx, self)._copies 604 if p2copies is None:
605 p2copies = {}
585 return p1copies, p2copies 606 return p1copies, p2copies
586 607
587 def description(self): 608 def description(self):
588 return self._changeset.description 609 return self._changeset.description
589 610