Mercurial > hg
diff hgext/convert/subversion.py @ 28460:d6dbb0968c13
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)
author | FUJIWARA Katsunori <foozy@lares.dti.ne.jp> |
---|---|
date | Fri, 11 Mar 2016 21:55:44 +0900 |
parents | 3ea62e748a18 |
children | f106913c6a4e |
line wrap: on
line diff
--- a/hgext/convert/subversion.py Fri Mar 11 21:55:44 2016 +0900 +++ b/hgext/convert/subversion.py Fri Mar 11 21:55:44 2016 +0900 @@ -43,10 +43,6 @@ # these bindings. try: - from svn.core import ( - Pool, - SubversionException, - ) import svn import svn.client import svn.core @@ -57,6 +53,7 @@ warnings.filterwarnings('ignore', module='svn.core', category=DeprecationWarning) + svn.core.SubversionException # trigger import to catch error except ImportError: svn = None @@ -103,7 +100,7 @@ def geturl(path): try: return svn.client.url_from_path(svn.core.svn_path_canonicalize(path)) - except SubversionException: + except svn.core.SubversionException: # svn.client.url_from_path() fails with local repositories pass if os.path.isdir(path): @@ -340,7 +337,7 @@ self.commits = {} self.paths = {} self.uuid = svn.ra.get_uuid(self.ra) - except SubversionException: + except svn.core.SubversionException: ui.traceback() svnversion = '%d.%d.%d' % (svn.core.SVN_VER_MAJOR, svn.core.SVN_VER_MINOR, @@ -401,7 +398,7 @@ svn.client.ls(self.url.rstrip('/') + '/' + quote(path), optrev, False, self.ctx) return True - except SubversionException: + except svn.core.SubversionException: return False def getheads(self): @@ -700,7 +697,7 @@ prevmodule = self.reparent('') dirent = svn.ra.stat(self.ra, path.strip('/'), stop) self.reparent(prevmodule) - except SubversionException: + except svn.core.SubversionException: dirent = None if not dirent: raise SvnPathNotFound(_('%s not found up to revision %d') @@ -972,7 +969,7 @@ firstcset.parents.append(latest) except SvnPathNotFound: pass - except SubversionException as xxx_todo_changeme: + except svn.core.SubversionException as xxx_todo_changeme: (inst, num) = xxx_todo_changeme.args if num == svn.core.SVN_ERR_FS_NO_SUCH_REVISION: raise error.Abort(_('svn: branch has no revision %s') @@ -999,7 +996,7 @@ info = info[-1] mode = ("svn:executable" in info) and 'x' or '' mode = ("svn:special" in info) and 'l' or mode - except SubversionException as e: + except svn.core.SubversionException as e: notfound = (svn.core.SVN_ERR_FS_NOT_FOUND, svn.core.SVN_ERR_RA_DAV_PATH_NOT_FOUND) if e.apr_err in notfound: # File not found @@ -1014,7 +1011,7 @@ def _iterfiles(self, path, revnum): """Enumerate all files in path at revnum, recursively.""" path = path.strip('/') - pool = Pool() + pool = svn.core.Pool() rpath = '/'.join([self.baseurl, quote(path)]).strip('/') entries = svn.client.ls(rpath, optrev(revnum), True, self.ctx, pool) if path: