To pine-fin: Good piece of driving, you held your line, on the inside and very efficiently defended. The other driver could have overtaken you if he had gone wide, and did the normal line, but he insisted on trying for the inside and lost.
to kurent:
If you do that and the opponent is too close, what will happen is you shimmy left, he keeps his line, gets his nose side-by-side with your rear bumper, then when you return right, you slam into him. Zig-zagging is always a bad idea. What you CAN do is turn to the side he went to (trying to overtake), squeeze him hard. If hes got nothing on the side of you car, you can squeeze him all the way to the grass. THEN you can return to your line, for the next corner - but this is NOT turning back abruptly to your original line - its a more slow, predictable return. This is cause if you swerve left to block an overtaking manouvre, the opponent will, if he has time, turn back to the right side. If you then decide to return to the racing line quickly... bang.
As a general rule, if someone begins to overtake you on the beggining of a straight, dont bother to block - you wont be able to prevent it, and are risking a crash. Nearer a corner, though... you are preventing a side-by-side situation on the corner.
and never do that on the exit to a corner - most people will be coming of the corner as passengers, not drivers, so if you block the exit line, they cannot stop or swerve.