Mercurial > hg
comparison mercurial/manifest.py @ 40038:906c95073ff7
treemanifests: extract _loaddifflazy from _diff, use in _filesnotin
Differential Revision: https://phab.mercurial-scm.org/D4873
author | spectral <spectral@google.com> |
---|---|
date | Tue, 02 Oct 2018 18:55:07 -0700 |
parents | e22016e83c1e |
children | a0c18b271ea1 |
comparison
equal
deleted
inserted
replaced
40037:fcad7fdc6474 | 40038:906c95073ff7 |
---|---|
722 loadlazy = self._loadlazy | 722 loadlazy = self._loadlazy |
723 for k in visit: | 723 for k in visit: |
724 loadlazy(k + '/') | 724 loadlazy(k + '/') |
725 return visit | 725 return visit |
726 | 726 |
727 def _loaddifflazy(self, t1, t2): | |
728 """load items in t1 and t2 if they're needed for diffing. | |
729 | |
730 The criteria currently is: | |
731 - if it's not present in _lazydirs in either t1 or t2, load it in the | |
732 other (it may already be loaded or it may not exist, doesn't matter) | |
733 - if it's present in _lazydirs in both, compare the nodeid; if it | |
734 differs, load it in both | |
735 """ | |
736 toloadlazy = [] | |
737 for d, v1 in t1._lazydirs.iteritems(): | |
738 v2 = t2._lazydirs.get(d) | |
739 if not v2 or v2[1] != v1[1]: | |
740 toloadlazy.append(d) | |
741 for d, v1 in t2._lazydirs.iteritems(): | |
742 if d not in t1._lazydirs: | |
743 toloadlazy.append(d) | |
744 | |
745 for d in toloadlazy: | |
746 t1._loadlazy(d) | |
747 t2._loadlazy(d) | |
748 | |
727 def __len__(self): | 749 def __len__(self): |
728 self._load() | 750 self._load() |
729 size = len(self._files) | 751 size = len(self._files) |
730 self._loadalllazy() | 752 self._loadalllazy() |
731 for m in self._dirs.values(): | 753 for m in self._dirs.values(): |
955 def _filesnotin(t1, t2): | 977 def _filesnotin(t1, t2): |
956 if t1._node == t2._node and not t1._dirty and not t2._dirty: | 978 if t1._node == t2._node and not t1._dirty and not t2._dirty: |
957 return | 979 return |
958 t1._load() | 980 t1._load() |
959 t2._load() | 981 t2._load() |
960 t1._loadalllazy() | 982 self._loaddifflazy(t1, t2) |
961 t2._loadalllazy() | |
962 for d, m1 in t1._dirs.iteritems(): | 983 for d, m1 in t1._dirs.iteritems(): |
963 if d in t2._dirs: | 984 if d in t2._dirs: |
964 m2 = t2._dirs[d] | 985 m2 = t2._dirs[d] |
965 _filesnotin(m1, m2) | 986 _filesnotin(m1, m2) |
966 else: | 987 else: |
1111 def _diff(t1, t2): | 1132 def _diff(t1, t2): |
1112 if t1._node == t2._node and not t1._dirty and not t2._dirty: | 1133 if t1._node == t2._node and not t1._dirty and not t2._dirty: |
1113 return | 1134 return |
1114 t1._load() | 1135 t1._load() |
1115 t2._load() | 1136 t2._load() |
1116 toloadlazy = [] | 1137 self._loaddifflazy(t1, t2) |
1117 for d, v1 in t1._lazydirs.iteritems(): | |
1118 v2 = t2._lazydirs.get(d) | |
1119 if not v2 or v2[1] != v1[1]: | |
1120 toloadlazy.append(d) | |
1121 for d, v1 in t2._lazydirs.iteritems(): | |
1122 if d not in t1._lazydirs: | |
1123 toloadlazy.append(d) | |
1124 | |
1125 for d in toloadlazy: | |
1126 t1._loadlazy(d) | |
1127 t2._loadlazy(d) | |
1128 | 1138 |
1129 for d, m1 in t1._dirs.iteritems(): | 1139 for d, m1 in t1._dirs.iteritems(): |
1130 m2 = t2._dirs.get(d, emptytree) | 1140 m2 = t2._dirs.get(d, emptytree) |
1131 _diff(m1, m2) | 1141 _diff(m1, m2) |
1132 | 1142 |