> > Nope! Here, the loop is executed separately for the item we insert using
> > "insertBefore" function and it does not bother to iterate over a
> > childNodes collection whilst changing it. In current state, when we run
> > the script as below, it inserts only 9 items instead of 10 items.
> >
> > $ ./svn2feed.py -F atom -u .. -U .. -r1:10 /path/to/repos/ -m 10
> > # remove the feed and pickle files before you run the script.
> >
> > In this case, a temporary print statement for "total" variable explains
> > that the loop is iterated 10 times (while processing last revision) and
> > the "total" variable is set as 11, so, it removes an item
> > unnecessarily.
>
> Sorry, but *NO*, your analysis is wrong.
>
> The loop executes zero times for the inserted item, but *twice* for the
> item after the insert point. We ARE changing the childNodes collection
> whilst iterating over it. As a result, the iteration is responding in
> bizarre ways, because the iterator apparently was not designed to be
> capable of responding sensibly to changes in the collection it is
> iterating over.
Ok! I'll leave it here. It could be because i'm unable to express what i
found or i'm unable to understand your views!
> > My point is, we call this function for every revision. So, it's fine to
> > remove one item at a time. Moreover, i'm certain the condition is met
> > only when processing the last element, so, why we need to check the
> > condition for all child nodes.
>
> You need to also consider the case of a user decreasing the --max-items
> value in a subsequent invocation of the script..
Yep!
--
Regards,
Bhuvaneswaran
Received on Sun Aug 6 16:12:55 2006