[MERGE][Bug #133548] bzr help does not recognise user configured aliases
Aaron Bentley
aaron.bentley at utoronto.ca
Wed Aug 22 22:41:48 BST 2007
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Daniel Watkins wrote:
> On Wed, 2007-08-22 at 20:47 +0100, James Westby wrote:
>> Can I ask what your code does if the user has an alias that is something
>> like:
>>
>> log='log --line'
>>
>> It shouldn't just print the alias, but I think it would be good to print
>> the information that the user has it aliased somewhere in the help.
> Attached is a bundle which appends the alias to the end of the help
> output in the above situation. It also has some tests.
bb:resubmit
> + alias = _mod_commands.get_alias(topic)
> + try:
> + topics = indices.search(topic)
> + shadowed_terms = []
> + for index, topic in topics[1:]:
> + shadowed_terms.append('%s%s' % (index.prefix, topic.get_help_topic()))
> + outfile.write(topics[0][1].get_help_text(shadowed_terms))
> + if alias:
Please don't use "if alias" when you really mean "if alias is not None".
Too many things evaluate False in Python: None, False, [] and ''.
> + outfile.write("'bzr %s' is an alias for 'bzr %s'.\n" % (topic, " ".join(alias)))
> + except errors.NoHelpTopic:
> + if alias:
> + outfile.write("'bzr %s' is an alias for 'bzr %s'.\n" % (topic, " ".join(alias)))
> + else:
> + raise errors.NoHelpTopic(topic)
When you want to re-raise the same exception, just do "raise", with no
arguments. This will preserve the original tracback.
Also, you can avoid duplicating the outfile.write() bit, like so:
try:
...
except errors.NoHelpTopic:
if not alias:
raise
if alias:
outfile.write(...)
> + self.assertEqual("'bzr c' is an alias for 'bzr cat'.\n",
> + self.run_bzr('help c')[0])
The indenting here doesn't match our style.
Aaron
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iD8DBQFGzK2b0F+nu1YWqI0RAlo1AJ9wxVAbUMdGZjo1sBt1wL32uSDi7gCcDiNn
mSLWcCGR6XTrB5CcHAQ6xyo=
=uJ/X
-----END PGP SIGNATURE-----
More information about the bazaar
mailing list