[MERGE] no default ignores
John Arbash Meinel
john at arbash-meinel.com
Mon Jun 12 23:22:30 BST 2006
Denys Duchier wrote:
> Denys Duchier <duchier at ps.uni-sb.de> writes:
>
>> So, basically, I like the "bzr init --defaults <TYPE>" idea, but only if <TYPE>
>> denotes an arbitrary initialization procedure, not just a set of default
>> ignores.
>
> maybe using a plugin along these lines:
>
>
>
> ------------------------------------------------------------------------
>
> from bzrlib.option import Option
> from bzrlib.builtins import cmd_init as original_cmd_init
> from bzrlib.commands import register_command
>
> original_cmd_init.takes_options.append(
> Option('type',
> help='Specify the type of project which the branch will contain.'
> ' This will run additional hooks to set up an appropriate infrastructure'
> ' for this type of project. Default is none.',
> type=str))
>
> class cmd_init(original_cmd_init):
>
> __doc__ = original_cmd_init.__doc__
>
> def run(self, type=None, **keys):
> super(cmd_init, self).run(**keys)
> self.init_project_type(type, keys)
>
> def init_project_type(self, type, keys):
> if not type:
> return
> from bzrlib.config import config_dir
> from bzrlib.osutils import pathjoin
> import os, os.path, imp
> zdir = pathjoin(config_dir(),"init-project-type")
> try:
> zfile, zpath, zdesc = imp.find_module(type, [zdir])
> except:
> zfile = None
> if zfile:
> mod = imp.load_module(("bzrlib.project.%s" % type), zfile, zpath, zdesc)
> if hasattr(mod, 'ignore'):
> pdir = keys.get('location', None)
> if pdir:
> cwd = os.getcwd()
> os.chdir(pathjoin(cwd,pdir))
> try:
> from bzrlib.commands import get_cmd_object
> ign = get_cmd_object('ignore')
> for pat in mod.ignore:
> ign.run(pat)
> finally:
> if pdir:
> os.chdir(cwd)
>
> register_command(cmd_init)
>
>
> ------------------------------------------------------------------------
>
>
> notice the horrendous os.getcwd/os.chdir hack (blush), but I don't know how else
> to invoke bzr recursively on another directory.
>
> Cheers,
>
> --Denys
I think a better way would be to use an internal function. Though it
looks like 'bzr ignore' just writes the file itself. That really should
be factored out.
John
=:->
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 254 bytes
Desc: OpenPGP digital signature
Url : https://lists.ubuntu.com/archives/bazaar/attachments/20060612/bfb88237/attachment.pgp
More information about the bazaar
mailing list