[PATCH] graphlog: hide internal state of ascii() from users

Dennis Brakhane brakhane at googlemail.com
Tue Oct 13 16:11:11 CDT 2009


Sorry for the late reply, I missed your reply.

On Sun, Oct 4, 2009 at 9:23 PM, Peter Arrenbrecht
<peter.arrenbrecht at gmail.com> wrote:
> I do not understand. The list returned by asciictx() is used by
> ascii() to track internal state across invocations.

When I look at the code:

>>>  def generate(ui, dag, displayer, showparents, edgefn):
>>> -    seen, base = [], [0, 0]
>>> +    seen, ctx = [], asciictx()

Here you define ctx (which used to be called base) to be asciictx.

>>>     for rev, type, ctx, parents in dag:

But in the next line ctx is redefined to be the third element in each
iteration over dag (hence, dag[x][2])

>>> -        ascii(ui, base, type, char, lines, edgefn(seen, rev, parents))
>>> +        ascii(ui, ctx, type, char, lines, edgefn(seen, rev, parents))

And here ctx (which is dag[x][2] instead of asciictx) is used as the
second argument to ascii.

Therefore, if this code still works, the entire initialization of ctx
to asciictx would be unnecessary.

That's why I'm confused.



More information about the Mercurial-devel mailing list