We report on a detailed investigation of history effects in the magnetic hysteresis of pure YBa 2 Cu 3 O y single crystals with various types and densities of pinning sites. A partial magnetization loop technique is employed that enables us to detect the point where topological disorder first invades the vortex system. Accordingly, studies of detwinned single crystals with very low densities of point defects reveal a transition in the mixed state of the superconductor that separates a dislocation-free Bragg glass from a highly disordered vortex phase. The transition line is identified in the field-temperature phase diagram and found to lie in the vicinity of the onset of the second magnetization peak. The effect of decreasing oxygen stoichiometry in the studied region (6.550рyр6.999) is the shift of this boundary to lower fields, and its final disappearance for high values of the oxygen deficiency in agreement with theoretical predictions. Above the transition metastable topological defects proliferate in the vortex lattice resulting in prominent history effects in the critical current. The last diminish at high enough fields for low oxygen concentrations near optimal doping, an effect not seen for samples close to the stoichiometric state. We also study the influence of extended defects and find that a low density of twin boundaries does not affect the Bragg glass significantly. However, a high concentration of twins as well as low densities of columnar defects are shown to suppress the transition and eliminate the memory effects.