hg
author FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
Fri, 11 Mar 2016 21:55:44 +0900
changeset 28460 d6dbb0968c13
parent 21812 73e4a02e6d23
child 29172 2ea9c9aa6e60
permissions -rwxr-xr-x
convert: fix relative import of stdlib module in subversion Before this patch, import-checker reports "relative import of stdlib module" error for importing Pool and SubversionException from svn.core in subversion.py. To fix this relative import of stdlib module, this patch adds prefix 'svn.core.' to Pool and SubversionException in source. These 'svn.core.' relative accessing shouldn't cause performance impact, because there are much more code paths accessing to 'svn.core.' relative properties. BTW, in transport.py, this error is avoided by assignment below. SubversionException = svn.core.SubversionException But this can't be used in subversion.py case, because: - such assignment in indented code block causes "don't use camelcase in identifiers" error of check-code.py - but it should be placed in indented block, because svn is None at failure of importing subversion python binding libraries (= examination of 'svn' is needed)

#!/usr/bin/env python
#
# mercurial - scalable distributed SCM
#
# Copyright 2005-2007 Matt Mackall <mpm@selenic.com>
#
# This software may be used and distributed according to the terms of the
# GNU General Public License version 2 or any later version.

import os
import sys

if os.environ.get('HGUNICODEPEDANTRY', False):
    reload(sys)
    sys.setdefaultencoding("undefined")


libdir = '@LIBDIR@'

if libdir != '@' 'LIBDIR' '@':
    if not os.path.isabs(libdir):
        libdir = os.path.join(os.path.dirname(os.path.realpath(__file__)),
                              libdir)
        libdir = os.path.abspath(libdir)
    sys.path.insert(0, libdir)

# enable importing on demand to reduce startup time
try:
    from mercurial import demandimport; demandimport.enable()
except ImportError:
    import sys
    sys.stderr.write("abort: couldn't find mercurial libraries in [%s]\n" %
                     ' '.join(sys.path))
    sys.stderr.write("(check your install and PYTHONPATH)\n")
    sys.exit(-1)

import mercurial.util
import mercurial.dispatch

for fp in (sys.stdin, sys.stdout, sys.stderr):
    mercurial.util.setbinary(fp)

mercurial.dispatch.run()