[PATCH 2 of 4] Provide a version independent way to use the set datatype

Thomas Arendsen Hein thomas at intevation.de
Sun Jun 17 07:19:05 CDT 2007


* Eric Hopper <hopper at omnifarious.org> [20070614 18:26]:
> # HG changeset patch
> # User Eric Hopper <hopper at omnifarious.org>
> # Date 1181836913 25200
> # Node ID f98ca5c0c43c4aacddbd147d7b854f280c827653
> # Parent  75a66022a47337f481799e25ec4933166ef8e5d0
> Provide a version independent way to use the set datatype.
> 
> diff --git a/mercurial/util.py b/mercurial/util.py
> --- a/mercurial/util.py
> +++ b/mercurial/util.py
> @@ -15,6 +15,13 @@ from i18n import _
>  from i18n import _
>  import cStringIO, errno, getpass, popen2, re, shutil, sys, tempfile
>  import os, threading, time, calendar, ConfigParser, locale, glob
> +
> +try:
> +    hgset = set
> +    hgfrozenset = frozenset
> +except NameError, e:

We don't need to waste a variable 'e' here (and if we would have
needed it, the name 'inst' or 'why' would have been better).

> +    from sets import Set as hgset
> +    from sets import ImmutableSet as hgfrozenset

I have only tried it with python2.3 and 2.4 and only in the
interactive interpreter, but what about this:

try:
    set, frozenset
except NameError:
    from sets import Set as set, ImmutableSet as frozenset

As there is nothing special about this sets, they should not be
called hgset.

Thomas

-- 
thomas at intevation.de - http://intevation.de/~thomas/ - OpenPGP key: 0x5816791A
Intevation GmbH, Osnabrueck - Register: Amtsgericht Osnabrueck, HR B 18998
Geschaeftsfuehrer: Frank Koormann, Bernhard Reiter, Dr. Jan-Oliver Wagner
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : http://selenic.com/pipermail/mercurial-devel/attachments/20070617/748e12d6/attachment.pgp 


More information about the Mercurial-devel mailing list