[Commented On] D12047: test-http-bad-server: refactor the writing logic to avoid early return
baymax (Baymax, Your Personal Patch-care Companion)
phabricator at mercurial-scm.org
Mon Jan 24 18:17:18 UTC 2022
baymax added a comment.
baymax updated this revision to Diff 31871.
✅ refresh by Heptapod after a successful CI run (🐙 💚)
REPOSITORY
rHG Mercurial
CHANGES SINCE LAST UPDATE
https://phab.mercurial-scm.org/D12047?vs=31750&id=31871
BRANCH
default
CHANGES SINCE LAST ACTION
https://phab.mercurial-scm.org/D12047/new/
REVISION DETAIL
https://phab.mercurial-scm.org/D12047
AFFECTED FILES
tests/testlib/badserverext.py
CHANGE DETAILS
diff --git a/tests/testlib/badserverext.py b/tests/testlib/badserverext.py
--- a/tests/testlib/badserverext.py
+++ b/tests/testlib/badserverext.py
@@ -108,22 +108,25 @@
orig = object.__getattribute__(obj, '_orig')
bmethod = method.encode('ascii')
func = getattr(orig, method)
- # No byte limit on this operation. Call original function.
+
+ if remaining:
+ remaining = max(0, remaining)
+
if not remaining:
- result = func(data, *args, **kwargs)
- obj._writelog(b'%s(%d) -> %s' % (bmethod, len(data), data))
- return result
-
- remaining = max(0, remaining)
-
- if remaining > 0:
+ newdata = data
+ else:
if remaining < len(data):
newdata = data[0:remaining]
else:
newdata = data
+ remaining -= len(newdata)
+ self.remaining_send_bytes = remaining
- remaining -= len(newdata)
+ result = func(newdata, *args, **kwargs)
+ if remaining is None:
+ obj._writelog(b'%s(%d) -> %s' % (bmethod, len(data), data))
+ else:
obj._writelog(
b'%s(%d from %d) -> (%d) %s'
% (
@@ -135,11 +138,7 @@
)
)
- result = func(newdata, *args, **kwargs)
-
- self.remaining_send_bytes = remaining
-
- if remaining <= 0:
+ if remaining is not None and remaining <= 0:
obj._writelog(b'write limit reached; closing socket')
object.__getattribute__(obj, '_cond_close')()
raise Exception('connection closed after sending N bytes')
To: marmoute, #hg-reviewers, Alphare
Cc: mercurial-patches
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mercurial-scm.org/pipermail/mercurial-patches/attachments/20220124/5469e6d4/attachment-0002.html>
More information about the Mercurial-patches
mailing list