For some reason I looked at /usr/bin/hg
and saw what seemed like a strange bit of code:
libdir = '@LIBDIR@'
if libdir != '@' 'LIBDIR' '@':
...
The if statement looks like a tautology/contradiction as '@LIBDIR@'
should always equal '@' 'LIBDIR' '@'
in Python, so the code will never run. Under what conditions does '@LIBDIR@'
change into something else?
I'm not familiar with Mercurial per se, but to me @LIBDIR@
is pretty clearly intended to be substituted with some other string by an automated search-and-replace, such as in a setup script. The if
statement checks to see whether this in fact has been done: a search won't find @LIBDIR@
in '@' 'LIBDIR' '@'
so this is a way of comparing the variable's value to its original placeholder value without triggering the substitution of the placeholder in the if
statement.
In other words, the if
statement is asking, "if a library path has been specified at installation time, then validate it and add it to the Python module search path."
I'd personally put this information in a configuration file, since that would be easier for the user to edit and would be less likely to be clobbered by an update, but it looks like Mercurial is using the source code munging approach to configuration.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With