2012-07-13 23:47:06 +04:00
|
|
|
# peer.py - repository base classes for mercurial
|
2005-08-28 01:21:25 +04:00
|
|
|
#
|
2007-06-19 10:51:34 +04:00
|
|
|
# Copyright 2005, 2006 Matt Mackall <mpm@selenic.com>
|
2006-08-12 23:30:02 +04:00
|
|
|
# Copyright 2006 Vadim Gelfer <vadim.gelfer@gmail.com>
|
2005-08-28 01:21:25 +04:00
|
|
|
#
|
2009-04-26 03:08:54 +04:00
|
|
|
# This software may be used and distributed according to the terms of the
|
2010-01-20 07:20:08 +03:00
|
|
|
# GNU General Public License version 2 or any later version.
|
2005-08-28 01:21:25 +04:00
|
|
|
|
2007-10-11 18:26:14 +04:00
|
|
|
from i18n import _
|
2009-03-23 15:12:07 +03:00
|
|
|
import error
|
2007-10-11 18:26:14 +04:00
|
|
|
|
2012-07-13 23:47:06 +04:00
|
|
|
class peerrepository(object):
|
|
|
|
|
2006-07-14 22:17:22 +04:00
|
|
|
def capable(self, name):
|
|
|
|
'''tell whether repo supports named capability.
|
|
|
|
return False if not supported.
|
|
|
|
if boolean capability, return True.
|
|
|
|
if string capability, return string.'''
|
2012-07-13 23:47:06 +04:00
|
|
|
caps = self._capabilities()
|
|
|
|
if name in caps:
|
2007-08-28 01:48:08 +04:00
|
|
|
return True
|
2006-07-14 22:17:22 +04:00
|
|
|
name_eq = name + '='
|
2012-07-13 23:47:06 +04:00
|
|
|
for cap in caps:
|
2006-07-14 22:17:22 +04:00
|
|
|
if cap.startswith(name_eq):
|
|
|
|
return cap[len(name_eq):]
|
|
|
|
return False
|
2007-08-28 01:48:08 +04:00
|
|
|
|
|
|
|
def requirecap(self, name, purpose):
|
|
|
|
'''raise an exception if the given capability is not present'''
|
|
|
|
if not self.capable(name):
|
2009-01-12 19:42:31 +03:00
|
|
|
raise error.CapabilityError(
|
|
|
|
_('cannot %s; remote repository does not '
|
|
|
|
'support the %r capability') % (purpose, name))
|
2008-03-15 22:23:20 +03:00
|
|
|
|
|
|
|
def local(self):
|
2012-07-13 23:47:06 +04:00
|
|
|
'''return peer as a localrepo, or None'''
|
|
|
|
return None
|
|
|
|
|
|
|
|
def peer(self):
|
|
|
|
return self
|
2008-03-15 22:23:20 +03:00
|
|
|
|
2012-07-13 23:52:28 +04:00
|
|
|
def canpush(self):
|
|
|
|
return True
|
|
|
|
|
2011-02-12 12:58:11 +03:00
|
|
|
def close(self):
|
|
|
|
pass
|