Any mortgagee of, or person having a charge upon, immovable property, or any transferee from such mortgagee or charge-holder, may purchase or otherwise acquire the rights in the property of the mortgagor or owner, as the case may be, without thereby causing the mortgage or charge to be merged as between himself and any subsequent mortgagee of, or person having a subsequent charge upon, the same property; and no such subsequent mortgagee or charge-holder shall be entitled to foreclose or sell such property without redeeming the prior mortgage or charge, or otherwise than subject thereto.