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