[MERGE] Adds a new builtin command 'alias' to list, set and remove bzr aliases.

Tim Penhey tim at penhey.net
Fri May 30 12:02:06 BST 2008


On Wednesday 21 May 2008 17:27:43 Ian Clatworthy wrote:
> Tim Penhey wrote:
> > Here's another patch, from our sit down fix-it session.
> 
> Some tweaks needed, particularly for better Windows compatibility.
> 
> bb:tweak

Hi Ian,

I'm pretty sure I've addressed all of these, and some of Daniel's other
review comments on tidying the tests.
 
> Firstly, this needs a NEWS item added under IMPROVEMENTS.
> 
> > +        Show the alias specified for 'll'::
> > +
> > +            bzr alias ll
> > +
> > +        Set an alias for 'll'::
> > +
> > +            bzr alias ll='log --line -r-10..-1'
> > +
> > +        To remove an alias for 'll'::
> 
> See bug #59302. Daniel mentioned this in an earlier review btw.
> 
> > +    @display_command
> > +    def print_aliases(self):
> > +        """Print out the defined aliases in a similar format to bash."""
> > +        aliases = config.GlobalConfig().get_aliases()
> > +        for key, value in sorted(aliases.iteritems()):
> > +            self.outf.write("bzr alias %s='%s'\n" % (key, value))
> > +
> > +    @display_command
> > +    def print_alias(self, alias_name):
> > +        from bzrlib.commands import get_alias
> > +        alias = get_alias(alias_name)
> > +        if alias is None:
> > +            self.outf.write("bzr alias: %s: not found\n" % alias_name)
> > +        else:
> > +            self.outf.write(
> > +                "bzr alias %s='%s'" % (alias_name, ' '.join(alias)))
> 
> I think the output should reflect the preferred input - use " again
> here instead of '.
> 
> > +    def set_alias(self, alias_name, alias_commands):
> > +        """Save the alias in the global config."""
> > +        c = config.GlobalConfig()
> > +        c.set_alias(alias_name, alias_commands)
> 
> The last parameter is actually a string, not a list, so I'd like it
> renamed to alias_command to make this clearer.
> 
> > +        self._writeConfigFile()
> > +
> > +    def _set_option(self, option, value, section):
> >          # FIXME: RBC 20051029 This should refresh the parser and also take a
> >          # file lock on bazaar.conf.
> >          conf_dir = os.path.dirname(self._get_filename())
> >          ensure_config_dir_exists(conf_dir)
> > -        if 'DEFAULT' not in self._get_parser():
> > -            self._get_parser()['DEFAULT'] = {}
> > -        self._get_parser()['DEFAULT'][option] = value
> > +        self._get_parser().setdefault(section, {})[option] = value
> > +        self._writeConfigFile()
> > +
> > +    def _writeConfigFile(self):
> 
> Our method naming convention is xx_yy_zz, not xxYyZz. Fix _writeConfigFile
> accordingly please.
> 
> > +    def test_add_alias_visible(self):
> > +        """Adding an alias makes it ..."""
> > +        self.run_bzr('alias commit="commit --strict"')
> > +        out = self.run_bzr('alias commit')[0].rstrip('\n')
> > +        self.assertEquals("bzr alias commit='commit --strict'", out)
> 
> Be sure to update the tests after s/"/'/ in the print methods.
> 
> If you make the above changes and send the new bundle to the list,
> I'll merge it. It doesn't require another round of reviews.
> 
> Ian C.
> 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: alias.patch
Type: text/x-diff
Size: 25009 bytes
Desc: not available
Url : https://lists.ubuntu.com/archives/bazaar/attachments/20080530/ba2ae09f/attachment.bin 


More information about the bazaar mailing list