##// END OF EJS Templates
context: extract _changesinrange() out of blockancestors()...
Denis Laxalde -
r30824:6e1d54be default
parent child Browse files
Show More
@@ -1156,21 +1156,21 b' class filectx(basefilectx):'
1156 return [filectx(self._repo, self._path, fileid=x,
1156 return [filectx(self._repo, self._path, fileid=x,
1157 filelog=self._filelog) for x in c]
1157 filelog=self._filelog) for x in c]
1158
1158
1159 def _changesrange(fctx1, fctx2, linerange2, diffopts):
1160 """Return `(diffinrange, linerange1)` where `diffinrange` is True
1161 if diff from fctx2 to fctx1 has changes in linerange2 and
1162 `linerange1` is the new line range for fctx1.
1163 """
1164 blocks = mdiff.allblocks(fctx1.data(), fctx2.data(), diffopts)
1165 filteredblocks, linerange1 = mdiff.blocksinrange(blocks, linerange2)
1166 diffinrange = any(stype == '!' for _, stype in filteredblocks)
1167 return diffinrange, linerange1
1168
1159 def blockancestors(fctx, fromline, toline):
1169 def blockancestors(fctx, fromline, toline):
1160 """Yield ancestors of `fctx` with respect to the block of lines within
1170 """Yield ancestors of `fctx` with respect to the block of lines within
1161 `fromline`-`toline` range.
1171 `fromline`-`toline` range.
1162 """
1172 """
1163 def changesrange(fctx1, fctx2, linerange2):
1173 diffopts = patch.diffopts(fctx._repo.ui)
1164 """Return `(diffinrange, linerange1)` where `diffinrange` is True
1165 if diff from fctx2 to fctx1 has changes in linerange2 and
1166 `linerange1` is the new line range for fctx1.
1167 """
1168 diffopts = patch.diffopts(fctx._repo.ui)
1169 blocks = mdiff.allblocks(fctx1.data(), fctx2.data(), diffopts)
1170 filteredblocks, linerange1 = mdiff.blocksinrange(blocks, linerange2)
1171 diffinrange = any(stype == '!' for _, stype in filteredblocks)
1172 return diffinrange, linerange1
1173
1174 visit = {(fctx.linkrev(), fctx.filenode()): (fctx, (fromline, toline))}
1174 visit = {(fctx.linkrev(), fctx.filenode()): (fctx, (fromline, toline))}
1175 while visit:
1175 while visit:
1176 c, linerange2 = visit.pop(max(visit))
1176 c, linerange2 = visit.pop(max(visit))
@@ -1181,7 +1181,7 b' def blockancestors(fctx, fromline, tolin'
1181 continue
1181 continue
1182 inrange = False
1182 inrange = False
1183 for p in pl:
1183 for p in pl:
1184 inrangep, linerange1 = changesrange(p, c, linerange2)
1184 inrangep, linerange1 = _changesrange(p, c, linerange2, diffopts)
1185 inrange = inrange or inrangep
1185 inrange = inrange or inrangep
1186 if linerange1[0] == linerange1[1]:
1186 if linerange1[0] == linerange1[1]:
1187 # Parent's linerange is empty, meaning that the block got
1187 # Parent's linerange is empty, meaning that the block got
General Comments 0
You need to be logged in to leave comments. Login now