Thank you for your patch, they have been accepted.
On Fri, 2017-09-15 at 00:31 +0900, FUJIWARA Katsunori wrote: > # HG changeset patch > # User FUJIWARA Katsunori <fo...@lares.dti.ne.jp> > # Date 1505050914 -32400 > # Sun Sep 10 22:41:54 2017 +0900 > # Node ID 3412cce8dbb22a937e72939a5d726c0949715983 > # Parent 23c9600607e7ea3c6d95cddc5ad134cab4f7d7fe > # Available At https://fo...@bitbucket.org/foozy/hgext-evolve > # hg pull https://fo...@bitbucket.org/foozy/hgext-evolve > -r 3412cce8dbb2 > # EXP-Topic topic-hg-version-portability > topic: centralize compatibility logic between hg versions into compat > module > > This patch can delay loading obsutil and obsolete modules until they > are actually used at "hg topics" or so, if demandimport of Mercurial > is enabled. > > diff --git a/hgext3rd/topic/__init__.py b/hgext3rd/topic/__init__.py > --- a/hgext3rd/topic/__init__.py > +++ b/hgext3rd/topic/__init__.py > @@ -79,6 +79,7 @@ from mercurial import ( > ) > > from . import ( > + compat, > constants, > revset as topicrevset, > destination, > @@ -727,16 +728,6 @@ def _showlasttouched(repo, fm, opts): > fm.plain('\n') > fm.end() > > -getmarkers = None > -try: > - from mercurial import obsutil > - getmarkers = getattr(obsutil, 'getmarkers', None) > -except ImportError: > - pass > - > -if getmarkers is None: > - getmarkers = obsolete.getmarkers > - > def _getlasttouched(repo, topics): > """ > Calculates the last time a topic was used. Returns a dictionary > of seconds > @@ -758,7 +749,7 @@ def _getlasttouched(repo, topics): > maxtime = rt > # looking on the markers also to get more information > and accurate > # last touch time. > - obsmarkers = getmarkers(repo, [repo[revs].node()]) > + obsmarkers = compat.getmarkers(repo, > [repo[revs].node()]) > for marker in obsmarkers: > rt = marker.date() > if rt[0] > maxtime[0]: > diff --git a/hgext3rd/topic/compat.py b/hgext3rd/topic/compat.py > new file mode 100644 > --- /dev/null > +++ b/hgext3rd/topic/compat.py > @@ -0,0 +1,24 @@ > +# Copyright 2017 FUJIWARA Katsunori <fo...@lares.dti.ne.jp> > +# > +# This software may be used and distributed according to the terms > of the > +# GNU General Public License version 2 or any later version. > +""" > +Compatibility module > +""" > +from __future__ import absolute_import > + > +from mercurial import obsolete > + > +getmarkers = None > +successorssets = None > +try: > + from mercurial import obsutil > + getmarkers = getattr(obsutil, 'getmarkers', None) > + successorssets = getattr(obsutil, 'successorssets', None) > +except ImportError: > + pass > + > +if getmarkers is None: > + getmarkers = obsolete.getmarkers > +if successorssets is None: > + successorssets = obsolete.successorssets > diff --git a/hgext3rd/topic/evolvebits.py > b/hgext3rd/topic/evolvebits.py > --- a/hgext3rd/topic/evolvebits.py > +++ b/hgext3rd/topic/evolvebits.py > @@ -1,15 +1,6 @@ > import collections > -from mercurial import obsolete > > -successorssets = None > -try: > - from mercurial import obsutil > - successorssets = getattr(obsutil, 'successorssets', None) > -except ImportError: > - pass > - > -if successorssets is None: > - successorssets = obsolete.successorssets > +from . import compat > > # Copied from evolve 081605c2e9b6 > > @@ -82,14 +73,14 @@ def _singlesuccessor(repo, p): > return p.rev() > obs = repo[p] > ui = repo.ui > - newer = successorssets(repo, obs.node()) > + newer = compat.successorssets(repo, obs.node()) > # search of a parent which is not killed > while not newer: > ui.debug("stabilize target %s is plain dead," > " trying to stabilize on its parent\n" % > obs) > obs = obs.parents()[0] > - newer = successorssets(repo, obs.node()) > + newer = compat.successorssets(repo, obs.node()) > if len(newer) > 1 or len(newer[0]) > 1: > raise MultipleSuccessorsError(newer) > > _______________________________________________ > Mercurial-devel mailing list > Mercurial-devel@mercurial-scm.org > https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel _______________________________________________ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel