Details
Details
- Reviewers
- None
- Group Reviewers
hg-reviewers - Commits
- rHG906c95073ff7: treemanifests: extract _loaddifflazy from _diff, use in _filesnotin
Diff Detail
Diff Detail
- Repository
- rHG Mercurial
- Lint
Lint Skipped - Unit
Unit Tests Skipped
hg-reviewers |
Lint Skipped |
Unit Tests Skipped |
Path | Packages | |||
---|---|---|---|---|
M | mercurial/manifest.py (38 lines) |
Commit | Parents | Author | Summary | Date |
---|---|---|---|---|
spectral | Oct 2 2018, 9:55 PM |
self._loadalllazy() | self._loadalllazy() | ||||
return None | return None | ||||
loadlazy = self._loadlazy | loadlazy = self._loadlazy | ||||
for k in visit: | for k in visit: | ||||
loadlazy(k + '/') | loadlazy(k + '/') | ||||
return visit | return visit | ||||
def _loaddifflazy(self, t1, t2): | |||||
"""load items in t1 and t2 if they're needed for diffing. | |||||
The criteria currently is: | |||||
- if it's not present in _lazydirs in either t1 or t2, load it in the | |||||
other (it may already be loaded or it may not exist, doesn't matter) | |||||
- if it's present in _lazydirs in both, compare the nodeid; if it | |||||
differs, load it in both | |||||
""" | |||||
toloadlazy = [] | |||||
for d, v1 in t1._lazydirs.iteritems(): | |||||
v2 = t2._lazydirs.get(d) | |||||
if not v2 or v2[1] != v1[1]: | |||||
toloadlazy.append(d) | |||||
for d, v1 in t2._lazydirs.iteritems(): | |||||
if d not in t1._lazydirs: | |||||
toloadlazy.append(d) | |||||
for d in toloadlazy: | |||||
t1._loadlazy(d) | |||||
t2._loadlazy(d) | |||||
def __len__(self): | def __len__(self): | ||||
self._load() | self._load() | ||||
size = len(self._files) | size = len(self._files) | ||||
self._loadalllazy() | self._loadalllazy() | ||||
for m in self._dirs.values(): | for m in self._dirs.values(): | ||||
size += m.__len__() | size += m.__len__() | ||||
return size | return size | ||||
return m1.filesnotin(m2) | return m1.filesnotin(m2) | ||||
files = set() | files = set() | ||||
def _filesnotin(t1, t2): | def _filesnotin(t1, t2): | ||||
if t1._node == t2._node and not t1._dirty and not t2._dirty: | if t1._node == t2._node and not t1._dirty and not t2._dirty: | ||||
return | return | ||||
t1._load() | t1._load() | ||||
t2._load() | t2._load() | ||||
t1._loadalllazy() | self._loaddifflazy(t1, t2) | ||||
t2._loadalllazy() | |||||
for d, m1 in t1._dirs.iteritems(): | for d, m1 in t1._dirs.iteritems(): | ||||
if d in t2._dirs: | if d in t2._dirs: | ||||
m2 = t2._dirs[d] | m2 = t2._dirs[d] | ||||
_filesnotin(m1, m2) | _filesnotin(m1, m2) | ||||
else: | else: | ||||
files.update(m1.iterkeys()) | files.update(m1.iterkeys()) | ||||
for fn in t1._files: | for fn in t1._files: | ||||
return m1.diff(m2, clean=clean) | return m1.diff(m2, clean=clean) | ||||
result = {} | result = {} | ||||
emptytree = treemanifest() | emptytree = treemanifest() | ||||
def _diff(t1, t2): | def _diff(t1, t2): | ||||
if t1._node == t2._node and not t1._dirty and not t2._dirty: | if t1._node == t2._node and not t1._dirty and not t2._dirty: | ||||
return | return | ||||
t1._load() | t1._load() | ||||
t2._load() | t2._load() | ||||
toloadlazy = [] | self._loaddifflazy(t1, t2) | ||||
for d, v1 in t1._lazydirs.iteritems(): | |||||
v2 = t2._lazydirs.get(d) | |||||
if not v2 or v2[1] != v1[1]: | |||||
toloadlazy.append(d) | |||||
for d, v1 in t2._lazydirs.iteritems(): | |||||
if d not in t1._lazydirs: | |||||
toloadlazy.append(d) | |||||
for d in toloadlazy: | |||||
t1._loadlazy(d) | |||||
t2._loadlazy(d) | |||||
for d, m1 in t1._dirs.iteritems(): | for d, m1 in t1._dirs.iteritems(): | ||||
m2 = t2._dirs.get(d, emptytree) | m2 = t2._dirs.get(d, emptytree) | ||||
_diff(m1, m2) | _diff(m1, m2) | ||||
for d, m2 in t2._dirs.iteritems(): | for d, m2 in t2._dirs.iteritems(): | ||||
if d not in t1._dirs: | if d not in t1._dirs: | ||||
_diff(emptytree, m2) | _diff(emptytree, m2) |