##// END OF EJS Templates
hg.repository: many routines expect path to be a string even if empty.
Vadim Gelfer -
r2479:10ec8039 default
parent child Browse files
Show More
@@ -1,69 +1,70 b''
1 # hg.py - repository classes for mercurial
1 # hg.py - repository classes for mercurial
2 #
2 #
3 # Copyright 2005 Matt Mackall <mpm@selenic.com>
3 # Copyright 2005 Matt Mackall <mpm@selenic.com>
4 #
4 #
5 # This software may be used and distributed according to the terms
5 # This software may be used and distributed according to the terms
6 # of the GNU General Public License, incorporated herein by reference.
6 # of the GNU General Public License, incorporated herein by reference.
7
7
8 from node import *
8 from node import *
9 from repo import *
9 from repo import *
10 from demandload import *
10 from demandload import *
11 from i18n import gettext as _
11 from i18n import gettext as _
12 demandload(globals(), "localrepo bundlerepo httprepo sshrepo statichttprepo")
12 demandload(globals(), "localrepo bundlerepo httprepo sshrepo statichttprepo")
13 demandload(globals(), "os util")
13 demandload(globals(), "os util")
14
14
15 def bundle(ui, path):
15 def bundle(ui, path):
16 if path.startswith('bundle://'):
16 if path.startswith('bundle://'):
17 path = path[9:]
17 path = path[9:]
18 else:
18 else:
19 path = path[7:]
19 path = path[7:]
20 s = path.split("+", 1)
20 s = path.split("+", 1)
21 if len(s) == 1:
21 if len(s) == 1:
22 repopath, bundlename = "", s[0]
22 repopath, bundlename = "", s[0]
23 else:
23 else:
24 repopath, bundlename = s
24 repopath, bundlename = s
25 return bundlerepo.bundlerepository(ui, repopath, bundlename)
25 return bundlerepo.bundlerepository(ui, repopath, bundlename)
26
26
27 def hg(ui, path):
27 def hg(ui, path):
28 ui.warn(_("hg:// syntax is deprecated, please use http:// instead\n"))
28 ui.warn(_("hg:// syntax is deprecated, please use http:// instead\n"))
29 return httprepo.httprepository(ui, path.replace("hg://", "http://"))
29 return httprepo.httprepository(ui, path.replace("hg://", "http://"))
30
30
31 def local_(ui, path, create=0):
31 def local_(ui, path, create=0):
32 if path.startswith('file:'):
32 if path.startswith('file:'):
33 path = path[5:]
33 path = path[5:]
34 return localrepo.localrepository(ui, path, create)
34 return localrepo.localrepository(ui, path, create)
35
35
36 def old_http(ui, path):
36 def old_http(ui, path):
37 ui.warn(_("old-http:// syntax is deprecated, "
37 ui.warn(_("old-http:// syntax is deprecated, "
38 "please use static-http:// instead\n"))
38 "please use static-http:// instead\n"))
39 return statichttprepo.statichttprepository(
39 return statichttprepo.statichttprepository(
40 ui, path.replace("old-http://", "http://"))
40 ui, path.replace("old-http://", "http://"))
41
41
42 def static_http(ui, path):
42 def static_http(ui, path):
43 return statichttprepo.statichttprepository(
43 return statichttprepo.statichttprepository(
44 ui, path.replace("static-http://", "http://"))
44 ui, path.replace("static-http://", "http://"))
45
45
46 schemes = {
46 schemes = {
47 'bundle': bundle,
47 'bundle': bundle,
48 'file': local_,
48 'file': local_,
49 'hg': hg,
49 'hg': hg,
50 'http': lambda ui, path: httprepo.httprepository(ui, path),
50 'http': lambda ui, path: httprepo.httprepository(ui, path),
51 'https': lambda ui, path: httprepo.httpsrepository(ui, path),
51 'https': lambda ui, path: httprepo.httpsrepository(ui, path),
52 'old-http': old_http,
52 'old-http': old_http,
53 'ssh': lambda ui, path: sshrepo.sshrepository(ui, path),
53 'ssh': lambda ui, path: sshrepo.sshrepository(ui, path),
54 'static-http': static_http,
54 'static-http': static_http,
55 }
55 }
56
56
57 def repository(ui, path=None, create=0):
57 def repository(ui, path=None, create=0):
58 if not path: path = ''
58 scheme = path
59 scheme = path
59 if scheme:
60 if scheme:
60 c = scheme.find(':')
61 c = scheme.find(':')
61 scheme = c >= 0 and scheme[:c]
62 scheme = c >= 0 and scheme[:c]
62 try:
63 try:
63 ctor = schemes.get(scheme) or schemes['file']
64 ctor = schemes.get(scheme) or schemes['file']
64 if create:
65 if create:
65 return ctor(ui, path, create)
66 return ctor(ui, path, create)
66 return ctor(ui, path)
67 return ctor(ui, path)
67 except TypeError:
68 except TypeError:
68 raise util.Abort(_('cannot create new repository over "%s" protocol') %
69 raise util.Abort(_('cannot create new repository over "%s" protocol') %
69 scheme)
70 scheme)
General Comments 0
You need to be logged in to leave comments. Login now