index parser: fix refcounting in case of errors, refactor
due to incorrect refcounting, on a bad revlog it was failing with:
*** glibc detected *** /usr/bin/python: corrupted double-linked list: 0x0816d318 ***
and a backtrace.
% change the id of the tree root
initializing destination source-hg repository
scanning source...
sorting...
converting...
1 Initial add
0 Changed root
% manifest of tip
644 file