The sword almost has to be a prop. For a soldier going into town for a day, his next destination after the photographer would likely be the nearest bar and/or brothel. That being known, civil authorities would be derelict in their duties to allow soldiers on "shore leave" to bring muskets, revolvers, bowie knives and swords into their city. To guard against unwanted affrays, local military authorities probably had provost guards posted at different points.
Your explanation as to how military photographs are made probably hasn't changed in many years.