RFC: alias and unalias command

Tim Penhey tim at penhey.net
Mon Feb 4 02:53:48 GMT 2008


I'm the sort of person that has aliases for things that I perform
often.  I have a number of shell aliases, and several bzr aliases.

Every now and then I thought it would be good to have bzr tell
me what those aliases were without me having to go and read
~/.bazaar/bazaar.conf.  So I wrote an `alias` and `unalias` command
that operates in a similar way to the shell alias.

It produces output like: 

tim at slacko:~/src/bzr/alias-command$ ./bzr alias
bzr alias cbranch='cbranch --lightweight'
bzr alias col='checkout --lightweight'
bzr alias lastlog='log -r-2..-1'
bzr alias ll='log --line -r-10..-1'
tim at slacko:~/src/bzr/alias-command$ ./bzr alias ll
bzr alias ll='log --line -r-10..-1'
tim at slacko:~/src/bzr/alias-command$ ./bzr alias foo
bzr alias foo: not found
tim at slacko:~/src/bzr/alias-command$ ./bzr alias foo='log --line -r-5..-1'
tim at slacko:~/src/bzr/alias-command$ ./bzr foo
2903: Tim Penhey 2008-02-04 Wrong argument passed to unalias.
2902: Tim Penhey 2008-01-20 A working alias command.
2901: Tim Penhey 2008-01-20 Removed some annoying trailing whitespace.
2900: Canonical.com Pat... 2007-10-09 (Andrew Bennetts) Fix bug 146715: bzr+ssh:// and sftp:// should not assume port-not-specified...
2899: Canonical.com Pat... 2007-10-09 Fix incorrect comparison in Dirstate.set_state_from_inventory, and bug #146176
tim at slacko:~/src/bzr/alias-command$ ./bzr alias foo
bzr alias foo='log --line -r-5..-1'
tim at slacko:~/src/bzr/alias-command$ ./bzr unalias fubar
bzr unalias: fubar: not found
tim at slacko:~/src/bzr/alias-command$ ./bzr unalias foo
tim at slacko:~/src/bzr/alias-command$

The attached merge directive contains the changes so far,
but I'm not sure the best way to test it.

If I can get some concrete suggestions, I don't mind writing the tests,
or even better, feel free to write some for me :-)

Comments?

Tim
-------------- next part --------------
A non-text attachment was scrubbed...
Name: alias-command
Type: text/x-diff
Size: 13533 bytes
Desc: not available
Url : https://lists.ubuntu.com/archives/bazaar/attachments/20080204/5c0af944/attachment-0001.bin 


More information about the bazaar mailing list