# HG changeset patch # User Augie Fackler # Date 1334964799 18000 # Node ID b450448a9033ddd95b5b8e9dfc367ed2d682d3cb # Parent 9cc3ed1f474d4d491442d405cbaa758f38a6f766 wrappers: don't break on old hg versions that lack discovery diff --git a/hgsubversion/wrappers.py b/hgsubversion/wrappers.py --- a/hgsubversion/wrappers.py +++ b/hgsubversion/wrappers.py @@ -1,7 +1,11 @@ from hgext import rebase as hgrebase from mercurial import cmdutil -from mercurial import discovery +try: + from mercurial import discovery + discovery.nullid # force demandimport to import the module +except ImportError: + discovery = None from mercurial import patch from mercurial import hg from mercurial import util as hgutil @@ -92,10 +96,11 @@ def findcommonoutgoing(repo, other, only parent = repo.parents()[0].node() hashes = meta.revmap.hashes() common, heads = util.outgoing_common_and_heads(repo, hashes, parent) - outobj = getattr(discovery, 'outgoing', None) - if outobj is not None: - # Mercurial 2.1 and later - return outobj(repo.changelog, common, heads) + if discovery is not None: + outobj = getattr(discovery, 'outgoing', None) + if outobj is not None: + # Mercurial 2.1 and later + return outobj(repo.changelog, common, heads) # Mercurial 2.0 and earlier return common, heads