Mercurial > public > mercurial-scm > hg
annotate mercurial/pycompat.py @ 28866:02be5fc18c0c
import: document --exact behavior in more detail
author | Matt Mackall <mpm@selenic.com> |
---|---|
date | Wed, 09 Mar 2016 10:47:33 -0500 |
parents | 68a946e83188 |
children | 800ec7c048b0 |
rev | line source |
---|---|
28818
6041fb8f2da8
pycompat: add empty and queue to handle py3 divergence
timeless <timeless@mozdev.org>
parents:
diff
changeset
|
1 # pycompat.py - portability shim for python 3 |
6041fb8f2da8
pycompat: add empty and queue to handle py3 divergence
timeless <timeless@mozdev.org>
parents:
diff
changeset
|
2 # |
6041fb8f2da8
pycompat: add empty and queue to handle py3 divergence
timeless <timeless@mozdev.org>
parents:
diff
changeset
|
3 # This software may be used and distributed according to the terms of the |
6041fb8f2da8
pycompat: add empty and queue to handle py3 divergence
timeless <timeless@mozdev.org>
parents:
diff
changeset
|
4 # GNU General Public License version 2 or any later version. |
6041fb8f2da8
pycompat: add empty and queue to handle py3 divergence
timeless <timeless@mozdev.org>
parents:
diff
changeset
|
5 |
6041fb8f2da8
pycompat: add empty and queue to handle py3 divergence
timeless <timeless@mozdev.org>
parents:
diff
changeset
|
6 """Mercurial portability shim for python 3. |
6041fb8f2da8
pycompat: add empty and queue to handle py3 divergence
timeless <timeless@mozdev.org>
parents:
diff
changeset
|
7 |
6041fb8f2da8
pycompat: add empty and queue to handle py3 divergence
timeless <timeless@mozdev.org>
parents:
diff
changeset
|
8 This contains aliases to hide python version-specific details from the core. |
6041fb8f2da8
pycompat: add empty and queue to handle py3 divergence
timeless <timeless@mozdev.org>
parents:
diff
changeset
|
9 """ |
6041fb8f2da8
pycompat: add empty and queue to handle py3 divergence
timeless <timeless@mozdev.org>
parents:
diff
changeset
|
10 |
6041fb8f2da8
pycompat: add empty and queue to handle py3 divergence
timeless <timeless@mozdev.org>
parents:
diff
changeset
|
11 from __future__ import absolute_import |
6041fb8f2da8
pycompat: add empty and queue to handle py3 divergence
timeless <timeless@mozdev.org>
parents:
diff
changeset
|
12 |
6041fb8f2da8
pycompat: add empty and queue to handle py3 divergence
timeless <timeless@mozdev.org>
parents:
diff
changeset
|
13 try: |
28835
68a946e83188
pycompat: add util.stringio to handle py3 divergence
timeless <timeless@mozdev.org>
parents:
28834
diff
changeset
|
14 import cStringIO as io |
68a946e83188
pycompat: add util.stringio to handle py3 divergence
timeless <timeless@mozdev.org>
parents:
28834
diff
changeset
|
15 stringio = io.StringIO |
68a946e83188
pycompat: add util.stringio to handle py3 divergence
timeless <timeless@mozdev.org>
parents:
28834
diff
changeset
|
16 except ImportError: |
68a946e83188
pycompat: add util.stringio to handle py3 divergence
timeless <timeless@mozdev.org>
parents:
28834
diff
changeset
|
17 import io |
68a946e83188
pycompat: add util.stringio to handle py3 divergence
timeless <timeless@mozdev.org>
parents:
28834
diff
changeset
|
18 stringio = io.StringIO |
68a946e83188
pycompat: add util.stringio to handle py3 divergence
timeless <timeless@mozdev.org>
parents:
28834
diff
changeset
|
19 |
68a946e83188
pycompat: add util.stringio to handle py3 divergence
timeless <timeless@mozdev.org>
parents:
28834
diff
changeset
|
20 try: |
28818
6041fb8f2da8
pycompat: add empty and queue to handle py3 divergence
timeless <timeless@mozdev.org>
parents:
diff
changeset
|
21 import Queue as _queue |
28833
672fc23bf9cc
pycompat: fix demand import handling of Queue
timeless <timeless@mozdev.org>
parents:
28818
diff
changeset
|
22 _queue.Queue |
28818
6041fb8f2da8
pycompat: add empty and queue to handle py3 divergence
timeless <timeless@mozdev.org>
parents:
diff
changeset
|
23 except ImportError: |
6041fb8f2da8
pycompat: add empty and queue to handle py3 divergence
timeless <timeless@mozdev.org>
parents:
diff
changeset
|
24 import queue as _queue |
6041fb8f2da8
pycompat: add empty and queue to handle py3 divergence
timeless <timeless@mozdev.org>
parents:
diff
changeset
|
25 empty = _queue.Empty |
6041fb8f2da8
pycompat: add empty and queue to handle py3 divergence
timeless <timeless@mozdev.org>
parents:
diff
changeset
|
26 queue = _queue.Queue |
28834
2fac032c1269
pycompat: alias xrange to range in py3
timeless <timeless@mozdev.org>
parents:
28833
diff
changeset
|
27 |
2fac032c1269
pycompat: alias xrange to range in py3
timeless <timeless@mozdev.org>
parents:
28833
diff
changeset
|
28 try: |
2fac032c1269
pycompat: alias xrange to range in py3
timeless <timeless@mozdev.org>
parents:
28833
diff
changeset
|
29 xrange |
2fac032c1269
pycompat: alias xrange to range in py3
timeless <timeless@mozdev.org>
parents:
28833
diff
changeset
|
30 except NameError: |
2fac032c1269
pycompat: alias xrange to range in py3
timeless <timeless@mozdev.org>
parents:
28833
diff
changeset
|
31 import builtins |
2fac032c1269
pycompat: alias xrange to range in py3
timeless <timeless@mozdev.org>
parents:
28833
diff
changeset
|
32 builtins.xrange = range |