Submitter | timeless@mozdev.org |
---|---|
Date | March 11, 2016, 4:25 a.m. |
Message ID | <223c17adb96a2ff2c2b3.1457670358@waste.org> |
Download | mbox | patch |
Permalink | /patch/13753/ |
State | Superseded |
Headers | show |
Comments
nevermind this. i'm still working on getting the test environment correct. sorry On Thu, Mar 10, 2016 at 11:25 PM, timeless <timeless@mozdev.org> wrote: > # HG changeset patch > # User timeless <timeless@mozdev.org> > # Date 1456936372 0 > # Wed Mar 02 16:32:52 2016 +0000 > # Node ID 223c17adb96a2ff2c2b394c976a15748c3afe044 > # Parent 1c658391b22fb4d98ccfb60c0e57315b55634117 > convert: bzr use absolute_import > > diff --git a/hgext/convert/bzr.py b/hgext/convert/bzr.py > --- a/hgext/convert/bzr.py > +++ b/hgext/convert/bzr.py > @@ -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,49 +24,47 @@ > '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.revisionspec import RevisionSpec > + import bzrlib.bzrdir > + import bzrlib.errors > + import bzrlib.revision > + import bzrlib.revisionspec.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): > # Lightweight checkouts detection is informational but probably > # fragile at API level. It should not terminate the conversion. > try: > - from bzrlib import bzrdir > + import bzrlib.bzrdir > dir = bzrdir.BzrDir.open_containing(path)[0] > try: > tree = dir.open_workingtree(recommend_upgrade=False) > @@ -160,7 +165,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), > diff --git a/tests/test-check-py3-compat.t b/tests/test-check-py3-compat.t > --- a/tests/test-check-py3-compat.t > +++ b/tests/test-check-py3-compat.t > @@ -25,7 +25,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/common.py not using absolute_import > hgext/convert/convcmd.py not using absolute_import > hgext/convert/cvs.py not using absolute_import > _______________________________________________ > Mercurial-devel mailing list > Mercurial-devel@mercurial-scm.org > https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
Patch
diff --git a/hgext/convert/bzr.py b/hgext/convert/bzr.py --- a/hgext/convert/bzr.py +++ b/hgext/convert/bzr.py @@ -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,49 +24,47 @@ '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.revisionspec import RevisionSpec + import bzrlib.bzrdir + import bzrlib.errors + import bzrlib.revision + import bzrlib.revisionspec.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): # Lightweight checkouts detection is informational but probably # fragile at API level. It should not terminate the conversion. try: - from bzrlib import bzrdir + import bzrlib.bzrdir dir = bzrdir.BzrDir.open_containing(path)[0] try: tree = dir.open_workingtree(recommend_upgrade=False) @@ -160,7 +165,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), diff --git a/tests/test-check-py3-compat.t b/tests/test-check-py3-compat.t --- a/tests/test-check-py3-compat.t +++ b/tests/test-check-py3-compat.t @@ -25,7 +25,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/common.py not using absolute_import hgext/convert/convcmd.py not using absolute_import hgext/convert/cvs.py not using absolute_import