Show More
@@ -1,49 +1,46 b'' | |||||
1 | # peer.py - repository base classes for mercurial |
|
1 | # peer.py - repository base classes for mercurial | |
2 | # |
|
2 | # | |
3 | # Copyright 2005, 2006 Matt Mackall <mpm@selenic.com> |
|
3 | # Copyright 2005, 2006 Matt Mackall <mpm@selenic.com> | |
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 of the |
|
6 | # This software may be used and distributed according to the terms of the | |
7 | # GNU General Public License version 2 or any later version. |
|
7 | # GNU General Public License version 2 or any later version. | |
8 |
|
8 | |||
9 | from i18n import _ |
|
9 | from i18n import _ | |
10 | import error |
|
10 | import error | |
11 |
|
11 | |||
12 | class peerrepository(object): |
|
12 | class peerrepository(object): | |
13 |
|
13 | |||
14 | def capable(self, name): |
|
14 | def capable(self, name): | |
15 | '''tell whether repo supports named capability. |
|
15 | '''tell whether repo supports named capability. | |
16 | return False if not supported. |
|
16 | return False if not supported. | |
17 | if boolean capability, return True. |
|
17 | if boolean capability, return True. | |
18 | if string capability, return string.''' |
|
18 | if string capability, return string.''' | |
19 | caps = self._capabilities() |
|
19 | caps = self._capabilities() | |
20 | if name in caps: |
|
20 | if name in caps: | |
21 | return True |
|
21 | return True | |
22 | name_eq = name + '=' |
|
22 | name_eq = name + '=' | |
23 | for cap in caps: |
|
23 | for cap in caps: | |
24 | if cap.startswith(name_eq): |
|
24 | if cap.startswith(name_eq): | |
25 | return cap[len(name_eq):] |
|
25 | return cap[len(name_eq):] | |
26 | return False |
|
26 | return False | |
27 |
|
27 | |||
28 | def requirecap(self, name, purpose): |
|
28 | def requirecap(self, name, purpose): | |
29 | '''raise an exception if the given capability is not present''' |
|
29 | '''raise an exception if the given capability is not present''' | |
30 | if not self.capable(name): |
|
30 | if not self.capable(name): | |
31 | raise error.CapabilityError( |
|
31 | raise error.CapabilityError( | |
32 | _('cannot %s; remote repository does not ' |
|
32 | _('cannot %s; remote repository does not ' | |
33 | 'support the %r capability') % (purpose, name)) |
|
33 | 'support the %r capability') % (purpose, name)) | |
34 |
|
34 | |||
35 | def local(self): |
|
35 | def local(self): | |
36 | '''return peer as a localrepo, or None''' |
|
36 | '''return peer as a localrepo, or None''' | |
37 | return None |
|
37 | return None | |
38 |
|
38 | |||
39 | def peer(self): |
|
39 | def peer(self): | |
40 | return self |
|
40 | return self | |
41 |
|
41 | |||
42 | def peer(self): |
|
|||
43 | return self |
|
|||
44 |
|
||||
45 | def canpush(self): |
|
42 | def canpush(self): | |
46 | return True |
|
43 | return True | |
47 |
|
44 | |||
48 | def close(self): |
|
45 | def close(self): | |
49 | pass |
|
46 | pass |
General Comments 0
You need to be logged in to leave comments.
Login now