Numbering Hierarchical Outlines
Python 2, 77



S={'0':0}
for w in input().split('\n'):S[w]+=1;S[' '+w]=0;print w[:-1]+`S[w]`


Like Sp3000's answer, but with a dictionary. The dict S stores the current number for each nesting level '0', ' 0', '  0' and so on. For each line in the input, increment the corresponding nesting level, and reset the nesting level one higher to 0.