Fix history search to remove only past deleted records

review1481002
(transplanted from d3d7bfc0e0d674bd77add27f28bf0479ed005f0d)

--HG--
extra : transplant_source : %D3%D7%BF%C0%E0%D6t%BDw%AD%D2%7F%28%BF%04y%ED%00_%0D