Show More
@@ -1,73 +1,73 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 ssh_(ui, path, create=0): |
|
36 | def ssh_(ui, path, create=0): | |
37 | return sshrepo.sshrepository(ui, path, create) |
|
37 | return sshrepo.sshrepository(ui, path, create) | |
38 |
|
38 | |||
39 | def old_http(ui, path): |
|
39 | def old_http(ui, path): | |
40 | ui.warn(_("old-http:// syntax is deprecated, " |
|
40 | ui.warn(_("old-http:// syntax is deprecated, " | |
41 | "please use static-http:// instead\n")) |
|
41 | "please use static-http:// instead\n")) | |
42 | return statichttprepo.statichttprepository( |
|
42 | return statichttprepo.statichttprepository( | |
43 | ui, path.replace("old-http://", "http://")) |
|
43 | ui, path.replace("old-http://", "http://")) | |
44 |
|
44 | |||
45 | def static_http(ui, path): |
|
45 | def static_http(ui, path): | |
46 | return statichttprepo.statichttprepository( |
|
46 | return statichttprepo.statichttprepository( | |
47 | ui, path.replace("static-http://", "http://")) |
|
47 | ui, path.replace("static-http://", "http://")) | |
48 |
|
48 | |||
49 | schemes = { |
|
49 | schemes = { | |
50 | 'bundle': bundle, |
|
50 | 'bundle': bundle, | |
51 | 'file': local_, |
|
51 | 'file': local_, | |
52 | 'hg': hg, |
|
52 | 'hg': hg, | |
53 | 'http': lambda ui, path: httprepo.httprepository(ui, path), |
|
53 | 'http': lambda ui, path: httprepo.httprepository(ui, path), | |
54 | 'https': lambda ui, path: httprepo.httpsrepository(ui, path), |
|
54 | 'https': lambda ui, path: httprepo.httpsrepository(ui, path), | |
55 | 'old-http': old_http, |
|
55 | 'old-http': old_http, | |
56 | 'ssh': ssh_, |
|
56 | 'ssh': ssh_, | |
57 | 'static-http': static_http, |
|
57 | 'static-http': static_http, | |
58 | } |
|
58 | } | |
59 |
|
59 | |||
60 | def repository(ui, path=None, create=0): |
|
60 | def repository(ui, path=None, create=0): | |
61 | if not path: path = '' |
|
61 | if not path: path = '' | |
62 | scheme = path |
|
62 | scheme = path | |
63 | if scheme: |
|
63 | if scheme: | |
64 | c = scheme.find(':') |
|
64 | c = scheme.find(':') | |
65 | scheme = c >= 0 and scheme[:c] |
|
65 | scheme = c >= 0 and scheme[:c] | |
66 | try: |
|
66 | ctor = schemes.get(scheme) or schemes['file'] | |
67 | ctor = schemes.get(scheme) or schemes['file'] |
|
67 | if create: | |
68 |
|
|
68 | try: | |
69 | return ctor(ui, path, create) |
|
69 | return ctor(ui, path, create) | |
70 | return ctor(ui, path) |
|
70 | except TypeError: | |
71 | except TypeError: |
|
71 | raise util.Abort(_('cannot create new repository over "%s" protocol') % | |
72 | raise util.Abort(_('cannot create new repository over "%s" protocol') % |
|
72 | scheme) | |
73 | scheme) |
|
73 | return ctor(ui, path) |
General Comments 0
You need to be logged in to leave comments.
Login now