ui.configpath() vs util.expandpath()

Greg Ward greg at gerg.ca
Sat Oct 15 11:45:13 CDT 2011


I was just looking at how largefiles finds its cache directory, and
found yet another place where you can't put "~/foo/bar" in
configuration. "Argh, how many places do I have to add a call to
util.expandpath()", I thought? Then I discovered ui.configpath():
perfect!

Well, almost perfect... ui.configpath() uses os.path.expanduser(), so
you get "~/" expanded but not "$HOME/". Argh. And it only calls
expanduser() under certain circumstances.

So the obvious thing here is to fix ui.configpath() to use
util.expandpath(), right? And possibly move the call out of the nested
"if" statements so it's more predictable. That seems like a low-risk
no-brainer. Then the long tedious part is auditing calls to
ui.config() to see which ones are getting a path and should really use
ui.configpath(). Seems to me like the only catch is the interpretation
of relative paths -- ui.configpath() interprets them relative to the
config file they came from, which makes sense but could conceivably
break some existing caller of ui.config().

Thoughts?

Greg


More information about the Mercurial-devel mailing list