4. In the right triangle $ABC$, the hypotenuse $AB=5$, and the lengths of the two legs $BC$ and $AC$ are the roots of the quadratic equation
$$
x^{2}-(2 m-1) x+4(m-1)=0 \text {. }
$$

Then the value of $m$ is ( ).
(A) 4
(B) -1
(C) 4 or -1
(D) -4 or 1
4.A.

From the given, we have
$$
(2 m-1)^{2}-2 \times 4(m-1)=25 \text {. }
$$

Solving, we get $m_{1}=4, m_{2}=-1$ (discard).