--- a/mercurial/repo.py Mon Aug 27 14:16:04 2007 -0700
+++ b/mercurial/repo.py Mon Aug 27 14:48:08 2007 -0700
@@ -9,16 +9,26 @@
class RepoError(Exception):
pass
+class NoCapability(RepoError):
+ pass
+
class repository(object):
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.'''
+ if name in self.capabilities:
+ return True
name_eq = name + '='
for cap in self.capabilities:
- if name == cap:
- return True
if cap.startswith(name_eq):
return cap[len(name_eq):]
return False
+
+ def requirecap(self, name, purpose):
+ '''raise an exception if the given capability is not present'''
+ if not self.capable(name):
+ raise NoCapability(_('cannot %s; remote repository does not '
+ 'support the %r capability') %
+ (purpose, name))