The Bitcoin developer guide states that
each output of a particular transaction can only be used as an input once in the block chain. Any subsequent reference is a forbidden double spend—an attempt to spend the same satoshis twice.
So how does a Bitcoin network node actually mark a transaction's output as spent? I imagine it would need to be irreversible, so that other nodes cannot revert the "spent" marker, but I cannot think of a way that Bitcoin could ensure that.
Where in the standard Bitcoin code does this marking occur, and how does it occur?