question on ui.parentui
Alexis S. L. Carvalho
alexis at cecm.usp.br
Thu Jun 21 12:20:31 CDT 2007
Thus spake TK Soh:
> I'm rather confused why a ui object is getting it's parent ui from
> it's grandparent (parentui.parentui) instead of just the parentui
> # parentui may point to an ui object which is already a child
> self.parentui = parentui.parentui or parentui
> Appreciate if any can help explain it. Thanks.
"rootui" would actually be a better name for the field.
First of all: we need more than one ui object to avoid leaking
configuration items from one repo to the other - e.g. it'd be bad if
hg push ../other-repo ended up running hooks defined only for the
Commands that interact with another repo (pull, push, in, out) have to
create another repo instance, and for that they have to pass a ui
object. But the ui argument passed to command functions is actually the
same as repo.ui.
So, if ui.__init__ used the parentui argument directly, the parentui of
the ui object of a newly created remote repo would point to the ui
object of another repo, and we'd have some config leaking.
Having the caller pass the correct ui object to avoid this situation
would probably be more error-prone.
test-push-hook-lock tests that we don't have this config leaking.
More information about the Mercurial-devel