Example #1
0
def httpsendfile(ui, filename):
    try:
        # Mercurial >= 1.9
        sendfile = httpconnection.httpsendfile(ui, filename, "rb")
        if getattr(sendfile, "__len__", None) is None:
            # Mercurial 1.9.3 removes httpsendfile's __len__. Hack it back in.
            setattr(sendfile.__class__, "__len__", lambda self: self.length)
        return sendfile
    except ImportError:
        if "ui" in inspect.getargspec(url_.httpsendfile.__init__)[0]:
            # Mercurial == 1.8
            return url_.httpsendfile(ui, filename, "rb")
        else:
            # Mercurial <= 1.7
            return url_.httpsendfile(filename, "rb")
Example #2
0
    def sendfile(self, filename, hash):
        if self._verify(hash):
            return

        self.ui.debug('httpstore.sendfile(%s, %s)\n' % (filename, hash))
        baseurl, authinfo = url_.getauthinfo(self.url)
        fd = None
        try:
            fd = url_.httpsendfile(filename, 'rb')
            request = urllib2.Request(bfutil.urljoin(baseurl, hash), fd)
            try:
                url = self.opener.open(request)
                self.ui.note(_('[OK] %s/%s\n') % (self.rawurl, url.geturl()))
            except urllib2.HTTPError, e:
                raise util.Abort(_('unable to POST: %s\n') % e.msg)
        except Exception, e:
            raise util.Abort(_('%s') % e)
Example #3
0
    def sendfile(self, filename, hash):
        if self._verify(hash):
            return

        self.ui.debug('httpstore.sendfile(%s, %s)\n' % (filename, hash))
        baseurl, authinfo = url_.getauthinfo(self.url)
        fd = None
        try:
            fd = url_.httpsendfile(filename, 'rb')
            request = urllib2.Request(bfutil.urljoin(baseurl, hash), fd)
            try:
                url = self.opener.open(request)
                self.ui.note(_('[OK] %s/%s\n') % (self.rawurl, url.geturl()))
            except urllib2.HTTPError, e:
                raise util.Abort(_('unable to POST: %s\n') % e.msg)
        except Exception, e:
            raise util.Abort(_('%s') % e)