# HG changeset patch # User FUJIWARA Katsunori # Date 1505049726 -32400 # Node ID 1341ff3ba4a9a8f47432feb23c65983d839cee25 # Parent 8874e65343a4564d025d02a6a1c70164b348e115 topic: check availability of obsutil.getmarkers() for portability Before this patch, topic extension causes unintentional failure with Mercurial earlier than 4.3, because obsutil.getmarkers() has been available since Mercurial 4.3 (tests for topic on mercurial-4.* branches fail, too). This breaks "minimumhgversion = '4.0'" declaration of topic extension. This patch fixes this issue in a straightforward way for simplicity on stable branch. I'm planning to centralize such portability logic in topic extension into topic/compat.py or so on default branch for efficiency at runtime, like as evolve/compat.py. diff -r 8874e65343a4 -r 1341ff3ba4a9 hgext3rd/topic/__init__.py --- a/hgext3rd/topic/__init__.py Thu Sep 07 16:45:53 2017 +0200 +++ b/hgext3rd/topic/__init__.py Sun Sep 10 22:22:06 2017 +0900 @@ -70,7 +70,6 @@ namespaces, node, obsolete, - obsutil, patch, phases, registrar, @@ -728,6 +727,16 @@ 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 @@ -749,7 +758,7 @@ maxtime = rt # looking on the markers also to get more information and accurate # last touch time. - obsmarkers = obsutil.getmarkers(repo, [repo[revs].node()]) + obsmarkers = getmarkers(repo, [repo[revs].node()]) for marker in obsmarkers: rt = marker.date() if rt[0] > maxtime[0]: