diff --git a/hggit/compat.py b/hggit/compat.py index 0e22c438ec3cc8157ecc2d28d5cfcffbd4cbf8ec_aGdnaXQvY29tcGF0LnB5..f6548fb346909473110903d13f5141fd9735a48f_aGdnaXQvY29tcGF0LnB5 100644 --- a/hggit/compat.py +++ b/hggit/compat.py @@ -78,6 +78,13 @@ pathsuboption = ui.pathsuboption try: + from dulwich.client import HTTPUnauthorized +except ImportError: + # added in dulwich 0.20.3; just create a dummy class for catching + class HTTPUnauthorized(Exception): + pass + +try: from mercurial.cmdutil import check_at_most_one_arg except (ImportError, AttributeError): # added in 5.3 diff --git a/hggit/git_handler.py b/hggit/git_handler.py index 0e22c438ec3cc8157ecc2d28d5cfcffbd4cbf8ec_aGdnaXQvZ2l0X2hhbmRsZXIucHk=..f6548fb346909473110903d13f5141fd9735a48f_aGdnaXQvZ2l0X2hhbmRsZXIucHk= 100644 --- a/hggit/git_handler.py +++ b/hggit/git_handler.py @@ -1389,10 +1389,5 @@ func = getattr(clientobj, method) - # dulwich 0.19 does not offer a specific exception class - HTTPUnauthorized = getattr( - client, 'HTTPUnauthorized', type('<dummy>', (Exception,), {}), - ) - try: return func(path, *args, **kwargs) @@ -1397,5 +1392,5 @@ try: return func(path, *args, **kwargs) - except (HTTPUnauthorized, GitProtocolError) as e: + except (compat.HTTPUnauthorized, GitProtocolError) as e: self.ui.traceback() @@ -1400,6 +1395,6 @@ self.ui.traceback() - if isinstance(e, HTTPUnauthorized): + if isinstance(e, compat.HTTPUnauthorized): # this is a fallback just in case the header isn't # specified self._http_auth_realm = 'Git' @@ -1423,7 +1418,7 @@ try: return func(path, *args, **kwargs) - except HTTPUnauthorized: + except compat.HTTPUnauthorized: raise error.Abort(_(b'authorization failed')) except GitProtocolError as e: # dulwich 0.19