[PATCH] localrepo: use set for tag_disallowed
Martin Geisler
mg at lazybytes.net
Mon May 4 02:32:29 CDT 2009
Simon Heimberg <simohe at besonet.ch> writes:
> # HG changeset patch
> # User Simon Heimberg <simohe at besonet.ch>
> # Date 1241402310 -7200
> # Node ID bafd1242ab8f8afe2e5ede2769c08feefbeca759
> # Parent 8b73db9fece2d936f9cc694c59a7206ff0829f2d
> localrepo: use set for tag_disallowed
>
> diff -r 8b73db9fece2 -r bafd1242ab8f mercurial/localrepo.py
> --- a/mercurial/localrepo.py Mon Mai 04 03:49:57 2009 +0200
> +++ b/mercurial/localrepo.py Mon Mai 04 03:58:30 2009 +0200
> @@ -127,7 +127,7 @@
> def hook(self, name, throw=False, **args):
> return hook.hook(self.ui, self, name, throw, **args)
>
> - tag_disallowed = ':\r\n'
> + tag_disallowed = set(':\r\n')
I have tried to convert as many pseudo-sets as possible into real sets
since they can help make the code clearer. But in this case I think
it's clear enough -- see also the comment below.
> def _tag(self, names, node, message, local, user, date, parent=None,
> extra={}):
> @@ -138,9 +138,10 @@
> names = (names,)
> else:
> allchars = ''.join(names)
> - for c in self.tag_disallowed:
> - if c in allchars:
> - raise util.Abort(_('%r cannot be used in a tag name') % c)
> + disallowed = self.tag_disallowed.intersection(allchars)
> + if disallowed:
> + c = list(disallowed)[0]
Since sets are unordered, this actually introduces a non-determinism
in case the tag contains several disallowed characters. We don't have
a test for this, though.
--
Martin Geisler
VIFF (Virtual Ideal Functionality Framework) brings easy and efficient
SMPC (Secure Multiparty Computation) to Python. See: http://viff.dk/.
More information about the Mercurial-devel
mailing list