I always thought that the ' devotion ' was just the urgency that Leia had impressed on R2 to get the information through or maybe a priority command code. What if it's a combination of ideas? He gets one memory wipe to forget Padme/Anakin but when Leia gets him, she stops getting the wipes done. there should be plenty of time for R2 to develop his loyal personality for Leia & want to do anything shes said would be important. Besides, R2 would know what the plans were that he was carrying which would give the little guy added incentive to get them through. Then later when he gets to hook up to the ballte stations computer, he has a chance to update the plans from what he already had stored so the Rebels had the most current information available to them.