Merge lp:~jelmer/brz/git-unexpected-http-response into lp:brz/3.3

Proposed by Jelmer Vernooij
Status: Merged
Approved by: Jelmer Vernooij
Approved revision: 7728
Merged at revision: 7728
Proposed branch: lp:~jelmer/brz/git-unexpected-http-response
Merge into: lp:brz/3.3
Diff against target: 69 lines (+23/-0)
3 files modified
breezy/git/remote.py (+5/-0)
breezy/git/tests/test_remote.py (+13/-0)
breezy/repository.py (+5/-0)
To merge this branch: bzr merge lp:~jelmer/brz/git-unexpected-http-response
Reviewer Review Type Date Requested Status
Jelmer Vernooij Approve
Review via email: mp+433057@code.launchpad.net

Commit message

Handle http unexpected errors from git

Description of the change

Handle http unexpected errors from git

To post a comment you must log in.
Revision history for this message
Jelmer Vernooij (jelmer) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'breezy/git/remote.py'
--- breezy/git/remote.py 2022-10-28 18:05:19 +0000
+++ breezy/git/remote.py 2022-11-15 16:31:08 +0000
@@ -48,6 +48,7 @@
48 NotLocalUrl,48 NotLocalUrl,
49 PermissionDenied,49 PermissionDenied,
50 TransportError,50 TransportError,
51 UnexpectedHttpStatus,
51 UninitializableFormat,52 UninitializableFormat,
52 )53 )
53from ..revision import NULL_REVISION54from ..revision import NULL_REVISION
@@ -229,6 +230,10 @@
229 return ConnectionReset(message)230 return ConnectionReset(message)
230 if message == 'The remote server unexpectedly closed the connection.':231 if message == 'The remote server unexpectedly closed the connection.':
231 return TransportError(message)232 return TransportError(message)
233 m = re.match(r'unexpected http resp ([0-9]+) for (.*)', message)
234 if m:
235 # TODO(jelmer): Have dulwich raise an exception and look at that instead?
236 return UnexpectedHttpStatus(path=m.group(2), code=int(m.group(1)), extra=message)
232 if message == 'protected branch hook declined':237 if message == 'protected branch hook declined':
233 return ProtectedBranchHookDeclined(msg=message)238 return ProtectedBranchHookDeclined(msg=message)
234 # Don't know, just return it to the user as-is239 # Don't know, just return it to the user as-is
235240
=== modified file 'breezy/git/tests/test_remote.py'
--- breezy/git/tests/test_remote.py 2022-11-13 18:35:58 +0000
+++ breezy/git/tests/test_remote.py 2022-11-15 16:31:08 +0000
@@ -31,6 +31,7 @@
31 NoSuchTag,31 NoSuchTag,
32 PermissionDenied,32 PermissionDenied,
33 TransportError,33 TransportError,
34 UnexpectedHttpStatus,
34 )35 )
3536
36from ...tests import (37from ...tests import (
@@ -202,6 +203,18 @@
202 RemoteGitError(203 RemoteGitError(
203 '[Errno 104] Connection reset by peer')))204 '[Errno 104] Connection reset by peer')))
204205
206 def test_http_unexpected(self):
207 self.assertEqual(
208 UnexpectedHttpStatus(
209 'https://example.com/bigint.git/git-upload-pack',
210 403, extra=('unexpected http resp 403 for '
211 'https://example.com/bigint.git/git-upload-pack')),
212 parse_git_error(
213 'url',
214 RemoteGitError(
215 'unexpected http resp 403 for '
216 'https://example.com/bigint.git/git-upload-pack')))
217
205218
206class ParseHangupTests(TestCase):219class ParseHangupTests(TestCase):
207220
208221
=== modified file 'breezy/repository.py'
--- breezy/repository.py 2022-11-13 20:26:24 +0000
+++ breezy/repository.py 2022-11-15 16:31:08 +0000
@@ -1627,6 +1627,11 @@
1627 if source.supports_rich_root() != target.supports_rich_root():1627 if source.supports_rich_root() != target.supports_rich_root():
1628 raise errors.IncompatibleRepositories(source, target,1628 raise errors.IncompatibleRepositories(source, target,
1629 "different rich-root support")1629 "different rich-root support")
1630 if not hasattr(source, '_serializer') or not hasattr(target, '_serializer'):
1631 if source != target:
1632 raise errors.IncompatibleRepositories(source, target, "different formats")
1633 return
1634
1630 if source._serializer != target._serializer:1635 if source._serializer != target._serializer:
1631 raise errors.IncompatibleRepositories(source, target,1636 raise errors.IncompatibleRepositories(source, target,
1632 "different serializers")1637 "different serializers")

Subscribers

People subscribed via source and target branches