Mercurial > hg
comparison mercurial/httprepo.py @ 7211:25c0dee16ee0
Autodetect static-http
author | Matt Mackall <mpm@selenic.com> |
---|---|
date | Wed, 22 Oct 2008 15:41:32 -0500 |
parents | fe0a4ed4634f |
children | 95a53961d7a6 |
comparison
equal
deleted
inserted
replaced
7210:833d1250ce00 | 7211:25c0dee16ee0 |
---|---|
4 # Copyright 2006 Vadim Gelfer <vadim.gelfer@gmail.com> | 4 # Copyright 2006 Vadim Gelfer <vadim.gelfer@gmail.com> |
5 # | 5 # |
6 # This software may be used and distributed according to the terms | 6 # This software may be used and distributed according to the terms |
7 # of the GNU General Public License, incorporated herein by reference. | 7 # of the GNU General Public License, incorporated herein by reference. |
8 | 8 |
9 from node import bin, hex | 9 from node import bin, hex, nullid |
10 from i18n import _ | 10 from i18n import _ |
11 import repo, os, urllib, urllib2, urlparse, zlib, util, httplib | 11 import repo, os, urllib, urllib2, urlparse, zlib, util, httplib |
12 import errno, keepalive, socket, changegroup | 12 import errno, keepalive, socket, changegroup, statichttprepo |
13 | 13 |
14 class passwordmgr(urllib2.HTTPPasswordMgrWithDefaultRealm): | 14 class passwordmgr(urllib2.HTTPPasswordMgrWithDefaultRealm): |
15 def __init__(self, ui): | 15 def __init__(self, ui): |
16 urllib2.HTTPPasswordMgrWithDefaultRealm.__init__(self) | 16 urllib2.HTTPPasswordMgrWithDefaultRealm.__init__(self) |
17 self.ui = ui | 17 self.ui = ui |
453 httprepository.__init__(self, ui, path) | 453 httprepository.__init__(self, ui, path) |
454 | 454 |
455 def instance(ui, path, create): | 455 def instance(ui, path, create): |
456 if create: | 456 if create: |
457 raise util.Abort(_('cannot create new http repository')) | 457 raise util.Abort(_('cannot create new http repository')) |
458 if path.startswith('https:'): | 458 try: |
459 return httpsrepository(ui, path) | 459 if path.startswith('https:'): |
460 return httprepository(ui, path) | 460 inst = httpsrepository(ui, path) |
461 else: | |
462 inst = httprepository(ui, path) | |
463 inst.between([(nullid, nullid)]) | |
464 return inst | |
465 except repo.RepoError: | |
466 ui.note('(falling back to static-http)\n') | |
467 return statichttprepo.instance(ui, "static-" + path, create) |