My personal feeling is that a sensible limit of wires would be either Gorebridge or Fushiebridge junction, as the stations between Edinburgh and Gorebridge are quite close together (4 stations in less than 6 miles) and there's reasonable construction access from the A7 without the terrain being too obstructive. Fushiebridge Jn, half a mile further south, would give the option of a train standing at the signal to Pan up, or for a train to clear the single line before panning down and switching to batteries.
Beyond Fushiebridge Jn the access gets much harder as the line follows the valley and the hills turn into actual mountains, while the stations get much further apart so the potential traffic thins out rather quickly. The just under 25 miles to Tweedback making a c.50 mile round trip comfortably suits a BEMU range. If needed, a trickle-charged fast-dump supply could be installed at Tweedbank.