diff --git a/mercurial/revlogutils/deltas.py b/mercurial/revlogutils/deltas.py index 42f59d3f714dd283d6edcc4d72083ce38857f9cb_bWVyY3VyaWFsL3JldmxvZ3V0aWxzL2RlbHRhcy5weQ==..ba09db267cb68e54523e64f213d4f1eea50be9ac_bWVyY3VyaWFsL3JldmxvZ3V0aWxzL2RlbHRhcy5weQ== 100644 --- a/mercurial/revlogutils/deltas.py +++ b/mercurial/revlogutils/deltas.py @@ -655,6 +655,17 @@ # no delta for rawtext-changing revs (see "candelta" for why) if revlog.flags(rev) & REVIDX_RAWTEXT_CHANGING_FLAGS: continue + # If we reach here, we are about to build and test a delta. + # The delta building process will compute the chaininfo in all + # case, since that computation is cached, it is fine to access it + # here too. + chainlen, chainsize = revlog._chaininfo(rev) + # if chain will be too long, skip base + if revlog._maxchainlen and chainlen >= revlog._maxchainlen: + continue + # if chain already have too much data, skip base + if deltas_limit < chainsize: + continue group.append(rev) if group: # XXX: in the sparse revlog case, group can become large,