Patchwork hghave: fix has_bzr() to not try to import RevisionSpec as module

login
register
mail settings
Submitter Yuya Nishihara
Date Sept. 6, 2016, 3:53 p.m.
Message ID <c68c8b3d8c371083eedc.1473177195@mimosa>
Download mbox | patch
Permalink /patch/16565/
State Accepted
Headers show

Comments

Yuya Nishihara - Sept. 6, 2016, 3:53 p.m.
# HG changeset patch
# User Yuya Nishihara <yuya@tcha.org>
# Date 1472977184 -32400
#      Sun Sep 04 17:19:44 2016 +0900
# Node ID c68c8b3d8c371083eedc2c0ea11e736540146421
# Parent  3f274098e9f4965920576842bffe57ce4e85ee32
hghave: fix has_bzr() to not try to import RevisionSpec as module

Since RevisionSpec isn't a module, "import bzrlib.revisionspec.RevisionSpec"
would always raise ImportError.
Augie Fackler - Sept. 7, 2016, 7:23 p.m.
On Wed, Sep 07, 2016 at 12:53:15AM +0900, Yuya Nishihara wrote:
> # HG changeset patch
> # User Yuya Nishihara <yuya@tcha.org>
> # Date 1472977184 -32400
> #      Sun Sep 04 17:19:44 2016 +0900
> # Node ID c68c8b3d8c371083eedc2c0ea11e736540146421
> # Parent  3f274098e9f4965920576842bffe57ce4e85ee32
> hghave: fix has_bzr() to not try to import RevisionSpec as module

Queued this, thanks

>
> Since RevisionSpec isn't a module, "import bzrlib.revisionspec.RevisionSpec"
> would always raise ImportError.
>
> diff --git a/tests/hghave.py b/tests/hghave.py
> --- a/tests/hghave.py
> +++ b/tests/hghave.py
> @@ -113,9 +113,10 @@ def has_bzr():
>          import bzrlib.bzrdir
>          import bzrlib.errors
>          import bzrlib.revision
> -        import bzrlib.revisionspec.RevisionSpec
> +        import bzrlib.revisionspec
> +        bzrlib.revisionspec.RevisionSpec
>          return bzrlib.__doc__ is not None
> -    except ImportError:
> +    except (AttributeError, ImportError):
>          return False
>
>  @checkvers("bzr", "Canonical's Bazaar client >= %s", (1.14,))
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@mercurial-scm.org
> https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel

Patch

diff --git a/tests/hghave.py b/tests/hghave.py
--- a/tests/hghave.py
+++ b/tests/hghave.py
@@ -113,9 +113,10 @@  def has_bzr():
         import bzrlib.bzrdir
         import bzrlib.errors
         import bzrlib.revision
-        import bzrlib.revisionspec.RevisionSpec
+        import bzrlib.revisionspec
+        bzrlib.revisionspec.RevisionSpec
         return bzrlib.__doc__ is not None
-    except ImportError:
+    except (AttributeError, ImportError):
         return False
 
 @checkvers("bzr", "Canonical's Bazaar client >= %s", (1.14,))