Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/win32.py @ 38823:e7aa113b14f7
global: use pycompat.xrange()
On Python 3, our module importer automatically rewrites xrange()
to pycompat.xrange().
We want to move away from the custom importer on Python 3.
This commit converts all instances of xrange() to use
pycompat.xrange().
Differential Revision: https://phab.mercurial-scm.org/D4032
author | Gregory Szorc <gregory.szorc@gmail.com> |
---|---|
date | Wed, 01 Aug 2018 13:00:45 -0700 |
parents | 3a0f322af192 |
children | f3900f4c63d4 |
comparison
equal
deleted
inserted
replaced
38822:7eba8f83129b | 38823:e7aa113b14f7 |
---|---|
613 # A file that has been opened with posixfile can be renamed, so we rename | 613 # A file that has been opened with posixfile can be renamed, so we rename |
614 # f to a random temporary name before calling os.unlink on it. This allows | 614 # f to a random temporary name before calling os.unlink on it. This allows |
615 # callers to recreate f immediately while having other readers do their | 615 # callers to recreate f immediately while having other readers do their |
616 # implicit zombie filename blocking on a temporary name. | 616 # implicit zombie filename blocking on a temporary name. |
617 | 617 |
618 for tries in xrange(10): | 618 for tries in pycompat.xrange(10): |
619 temp = '%s-%08x' % (f, random.randint(0, 0xffffffff)) | 619 temp = '%s-%08x' % (f, random.randint(0, 0xffffffff)) |
620 try: | 620 try: |
621 os.rename(f, temp) # raises OSError EEXIST if temp exists | 621 os.rename(f, temp) # raises OSError EEXIST if temp exists |
622 break | 622 break |
623 except OSError as e: | 623 except OSError as e: |