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