...to repent is to deplore something one has done. Now it has been stated above (III:84:9) that sorrow or sadness is twofold. First, it denotes a passion of the sensitive appetite, and in this sense penance is not a virtue, but a passion. Secondly, it denotes an act of the will, and in this way it implies choice, and if this be right, it must, of necessity, be an act of virtue. For it is stated in Ethic. ii, 6 that virtue is a habit of choosing according to right reason. Now it belongs to right reason that one should grieve for a proper object of grief as one ought to grieve, and for an end for which one ought to grieve. And this is observed in the penance of which we are speaking now; since the penitent assumes a moderated grief for his past sins, with the intention of removing them. Hence it is evident that the penance of which we are speaking now, is either a virtue or the act of a virtue.
Thomas Aquinas, Summa Theologiae 3.85.1