Ok, here's a better bundle, with tests and all.<br>Which lets you quote some arguments for aliased commands.<br><br>In order to get it tested, I had to add an optional parameter<br>to the get_alias function in commands.py , which 
<br>is hopefully not a problem.<br><br>I also renamed test_command.py to test_commands.py<br>which is the correct name as far as I can tel. I did ask about <br>it on this mailing list, but didn't get any responses, so I just did it. 
<br>(&quot;Its easier to say sorry, than ask permission.&quot; -- Gerard van Harmelen)<br><br>regards<br>marius<br><br><br><div><span class="gmail_quote">On 11/27/06, <b class="gmail_sendername">Aaron Bentley</b> &lt;<a href="mailto:aaron.bentley@utoronto.ca">
aaron.bentley@utoronto.ca</a>&gt; wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">-----BEGIN PGP SIGNED MESSAGE-----<br>Hash: SHA1
<br><br>Marius Kruger wrote:<br>&gt; My conclusion was thus that every time config.GlobalConfig ()<br>&gt; is called, that the config is read anew. I would like us to<br>&gt; store a instance of the GlobalConfig config somewhere,
<br>&gt; and just load it (lazily) and use the same instance everywhere,<br>&gt; so that we don't parse the file a million times.<br><br>I don't think we do parse the file a million times, though.&nbsp;&nbsp;Certainly,<br>if we did, that sort of thing would show up on benchmarks.
</blockquote><div><br>:) ok, ok, I don't know how often values will get read from the global config,<br>but it looks to me that the file will be parsed every time.<br>I just went ahead and found another way of solving my problem, 
<br>but I still think it might be a good idea to cache the config.<br></div><br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">&gt; I was thinking something like :
<br>&gt; (in bzrlib/config.py)<br>&gt;<br>&gt; _global_config=None<br>&gt;<br>&gt; def get_global_config():<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp; if _global_config is not None:<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; _global_config = config.GlobalConfig()<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp; return _global_config
<br><br>When converting a file-backed value into a memory-cached value, you must<br>be careful not to change its behavior.&nbsp;&nbsp;You would need to test that when<br>bzr sets a value in the global config:<br>1. that value is written to disk
<br>2. that value is immediately available to bzr</blockquote><div>I'm not saying store it in some other format, just that we should<br>re-use the already created and used config-reading object...<br>&nbsp;</div><br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
It's also worth considering whether we want the in-memory values to<br>change when the file is updated externally.&nbsp;&nbsp;The semantic thus far is<br>that they would.&nbsp;&nbsp;The config directory thus far doesn't support any<br>locking, so we can't use that as a hint.
<br><br>Also, if you're considering lazy-loading bazaar.conf, the same mechanism<br>ought to be used for locations.conf, which is usually queried before<br>bazaar.conf.&nbsp;&nbsp;This suggests that caching the GlobalConfig object is too
<br>high-level; LocationConfig has a parameterized constructor, so it can't<br>be cached effectively.&nbsp;&nbsp;Instead, it might be preferable to cache the<br>ConfigObj returned by IniBasedConfig._get_parser<br><br>&gt;&nbsp;&nbsp;&nbsp;&nbsp; &gt; I also think it should be possible to set branch specific aliases,
<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp; &gt; where the branch specific one over-rides the global one.<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp; &gt; I'll look into supporting this, If thats ok.<br>&gt;<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp; This seems error-prone and confusing to me, how do you intend to use it?
<br>&gt;<br>&gt;<br>&gt; Like you can set branch specific user-email (whoami),<br>&gt; I can imagine that you might want to do interesting aliases which<br>&gt; might only be appropriate for a specific&nbsp;&nbsp;branch,<br>&gt; for example you might want a&nbsp;&nbsp;particular branch to
<br>&gt; output its diff differently, with some funny diff options or something..<br><br>This doesn't sound convincing to me.&nbsp;&nbsp;My experience with similar systems<br>is that they aren't very helpful, because it's easy to forget precisely
<br>which behaviors are enabled for which locations.&nbsp;&nbsp;So you tend to specify<br>things that may-or-may-not be enabled for the current location, anyhow.<br><br>It's even problematic for the location values like 'pull/merge
<br>location', 'push location', 'bound location' and 'submit location',<br>which is why the dev version of bzrtools includes a 'show-paths' command<br>(by Alexander Belchenko) to remind you.<br><br>ConfigObj supports nesting, so per-location aliases are certainly
<br>possible, but I don't think they're useful.</blockquote><div><br>ok, lets leave it for now, once I&nbsp; have a use case, I might consider revisiting this. <br></div><br></div><br><br clear="all"><br>-- <br><br><br><br>coding in python is better than a holiday!
<br>