This has been raised as a question a couple of times during our darkness ventures with some of us advocating selling lights after a year or two before the battery duration begins to reduce and others keeping a light until it dies and then buying a replacement.
As I use my lights regularly I should encounter end of battery life relatively quickly but I find the constant use over the winter keeps the batteries in good condition. That being said I usually end up with replacement batteries after a few seasons.
The popularity of Magicshine lights has mean that several riders have looked at replacements and size has been a factor. Older lights have a different connector size to the more recent ones and if the connector is bespoke then Maplins cannot help. I tried buying some new connectors but seemed too loose for rough trails.
As I had the new battery, I cut the connector off the old unit, cut the new connector off the replacement and soldered the old connector to the wires of the new battery. As the battery was charged I was careful but an easy job really. I did use a multimeter to check continuity, resistance and voltage but not absolutely necessary. I also changed over the rubber cover from the old unit and used super-glue and silicon to make it waterproof.
As there was a running conversation about battery packs and electronic controls this is the old unit with the outer cover removed and then cut open to show the inside. Connector tabs are spot welded to the battery cells rather than soldered so replacing individual battery cells can be tricky. It may be possible to substitute a spring type cell holder (Maplins) and attach the electronic control to that but the overall size of the complete pack increases and waterproofing has to be good.
You could opt for de-soldering the cables and changing old cables for new if the connector is a different size and this would be the better option. To avoid damage you need to use the correct size of soldering tip to avoid problems with heat transfer and you need to tin wires etc.