changeset 28411:098bb5660580

convert: bzr use absolute_import
author timeless <timeless@mozdev.org>
date Wed, 02 Mar 2016 16:32:52 +0000
parents 48b04018c897
children 1e03b74195d4
files hgext/convert/bzr.py tests/test-check-py3-compat.t
diffstat 2 files changed, 20 insertions(+), 14 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/convert/bzr.py	Wed Mar 02 16:26:35 2016 +0000
+++ b/hgext/convert/bzr.py	Wed Mar 02 16:32:52 2016 +0000
@@ -7,9 +7,16 @@
 
 # This module is for handling 'bzr', that was formerly known as Bazaar-NG;
 # it cannot access 'bar' repositories, but they were never used very much
+from __future__ import absolute_import
 
 import os
-from mercurial import demandimport, error
+from mercurial import (
+    demandimport,
+    error
+)
+from mercurial.i18n import _
+from . import common
+
 # these do not work with demandimport, blacklist
 demandimport.ignore.extend([
         'bzrlib.transactions',
@@ -17,42 +24,42 @@
         'ElementPath',
     ])
 
-from mercurial.i18n import _
-from mercurial import error
-from common import NoRepo, commit, converter_source
-
 try:
     # bazaar imports
-    from bzrlib import bzrdir, revision, errors
+    from bzrlib import (
+        bzrdir,
+        errors,
+        revision,
+    )
     from bzrlib.revisionspec import RevisionSpec
 except ImportError:
     pass
 
 supportedkinds = ('file', 'symlink')
 
-class bzr_source(converter_source):
+class bzr_source(common.converter_source):
     """Reads Bazaar repositories by using the Bazaar Python libraries"""
 
     def __init__(self, ui, path, revs=None):
         super(bzr_source, self).__init__(ui, path, revs=revs)
 
         if not os.path.exists(os.path.join(path, '.bzr')):
-            raise NoRepo(_('%s does not look like a Bazaar repository')
-                         % path)
+            raise common.NoRepo(_('%s does not look like a Bazaar repository')
+                              % path)
 
         try:
             # access bzrlib stuff
             bzrdir
         except NameError:
-            raise NoRepo(_('Bazaar modules could not be loaded'))
+            raise common.NoRepo(_('Bazaar modules could not be loaded'))
 
         path = os.path.abspath(path)
         self._checkrepotype(path)
         try:
             self.sourcerepo = bzrdir.BzrDir.open(path).open_repository()
         except errors.NoRepositoryPresent:
-            raise NoRepo(_('%s does not look like a Bazaar repository')
-                         % path)
+            raise common.NoRepo(_('%s does not look like a Bazaar repository')
+                              % path)
         self._parentids = {}
 
     def _checkrepotype(self, path):
@@ -160,7 +167,7 @@
         branch = self.recode(rev.properties.get('branch-nick', u'default'))
         if branch == 'trunk':
             branch = 'default'
-        return commit(parents=parents,
+        return common.commit(parents=parents,
                 date='%d %d' % (rev.timestamp, -rev.timezone),
                 author=self.recode(rev.committer),
                 desc=self.recode(rev.message),
--- a/tests/test-check-py3-compat.t	Wed Mar 02 16:26:35 2016 +0000
+++ b/tests/test-check-py3-compat.t	Wed Mar 02 16:32:52 2016 +0000
@@ -22,7 +22,6 @@
   hgext/__init__.py not using absolute_import
   hgext/color.py not using absolute_import
   hgext/convert/__init__.py not using absolute_import
-  hgext/convert/bzr.py not using absolute_import
   hgext/convert/cvs.py not using absolute_import
   hgext/convert/transport.py not using absolute_import
   hgext/eol.py not using absolute_import