D5160: keepalive: use getattr to avoid AttributeErrors when vcr is in use

durin42 (Augie Fackler) phabricator at mercurial-scm.org
Fri Oct 19 16:53:45 EDT 2018


This revision was automatically updated to reflect the committed changes.
Closed by commit rHG41506e3b04ee: keepalive: use getattr to avoid AttributeErrors when vcr is in use (authored by durin42, committed by ).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D5160?vs=12266&id=12284

REVISION DETAIL
  https://phab.mercurial-scm.org/D5160

AFFECTED FILES
  mercurial/keepalive.py

CHANGE DETAILS

diff --git a/mercurial/keepalive.py b/mercurial/keepalive.py
--- a/mercurial/keepalive.py
+++ b/mercurial/keepalive.py
@@ -315,7 +315,7 @@
         return r
 
     def _start_transaction(self, h, req):
-        oldbytescount = h.sentbytescount
+        oldbytescount = getattr(h, 'sentbytescount', 0)
 
         # What follows mostly reimplements HTTPConnection.request()
         # except it adds self.parent.addheaders in the mix and sends headers
@@ -353,11 +353,12 @@
 
         # This will fail to record events in case of I/O failure. That's OK.
         self.requestscount += 1
-        self.sentbytescount += h.sentbytescount - oldbytescount
+        self.sentbytescount += getattr(h, 'sentbytescount', 0) - oldbytescount
 
         try:
             self.parent.requestscount += 1
-            self.parent.sentbytescount += h.sentbytescount - oldbytescount
+            self.parent.sentbytescount += (
+                getattr(h, 'sentbytescount', 0) - oldbytescount)
         except AttributeError:
             pass
 



To: durin42, #hg-reviewers, pulkit
Cc: mercurial-devel


More information about the Mercurial-devel mailing list