[PATCH] httprepo: make sure we have auth before sending large bundles
durin42 at gmail.com
durin42 at gmail.com
Sat Sep 26 11:20:20 CDT 2009
# HG changeset patch
# User Augie Fackler <durin42 at gmail.com>
# Date 1253039420 18000
# Node ID a359878a686b571414b73ace46a58b66992a58c5
# Parent 32ec707991726bd58b9190862ab98f204797eea4
httprepo: make sure we have auth before sending large bundles
Send an empty bundle to the server to verify we are properly
authenticated before sending a large bundle. This prevents doing an
unbundle of many megabytes and then immediately do it again with auth.
diff --git a/mercurial/httprepo.py b/mercurial/httprepo.py
--- a/mercurial/httprepo.py
+++ b/mercurial/httprepo.py
@@ -211,12 +211,23 @@
tempname = changegroup.writebundle(cg, None, type)
fp = url.httpsendfile(tempname, "rb")
+
+ headsparam = ' '.join(map(hex, heads))
+ if len(fp) > 1024:
+ self.ui.debug('push empty bundle to check for auth\n')
+ # TODO check what comes back, we can fast-fail for certain non-push
+ # conditions (ssl required comes to mind).
+ resp = self.do_read('unbundle', data='',
+ headers={'Content-Type': 'application/octet-stream'},
+ heads=headsparam)
+ resp_code, output = resp.split('\n', 1)
+ self.ui.status(output)
try:
try:
resp = self.do_read(
'unbundle', data=fp,
headers={'Content-Type': 'application/octet-stream'},
- heads=' '.join(map(hex, heads)))
+ heads=headsparam)
resp_code, output = resp.split('\n', 1)
try:
ret = int(resp_code)
More information about the Mercurial-devel
mailing list