[patch] make 'bzr ignore' take multiple arguments (bug 29488)
Michele Cella
michele.cella at gmail.com
Fri Oct 13 12:55:51 BST 2006
Cheuksan Edward Wang wrote:
> - def run(self, name_pattern=None, old_default_rules=None):
> + def run(self, name_pattern_list=None, old_default_rules=None):
> from bzrlib.atomicfile import AtomicFile
> if old_default_rules is not None:
> # dump the rules and exit
> for pattern in ignores.OLD_DEFAULTS:
> print pattern
> return
> - if name_pattern is None:
> - raise errors.BzrCommandError("ignore requires a NAME_PATTERN")
> + if name_pattern_list is None or name_pattern_list == []:
> + raise errors.BzrCommandError("ignore requires at least one "
> + "NAME_PATTERN or --old-default-rules")
Hi Edward,
It seems you're just trying to check for an empty list here.
Since in python every empty sequence (a list, a dictionary and a tuple)
evaluates to False (as does None BTW) you don't need this long check but
just:
if not name_pattern_list:
raise errors.BzrCommandError("ignore requires at least one "
"NAME_PATTERN or --old-default-rules")
in fact:
>>> def run(pattern=None):
... if not pattern:
... print "Error"
... else:
... print "Ok"
...
>>> run()
Error
>>> run(None)
Error
>>> run([])
Error
>>> run([1, 2, 3])
Ok
>>>
This also saves instantiating an empty list just for making the
comparison (not a big save of course).
Ciao
Michele
More information about the bazaar
mailing list