def version(self):
# Cache version string for efficiency.
if not hasattr(self, '_version'):
- self._version = self._get_version()
+ self._version = self._vcs_version()
return self._version
- def _get_version(self):
- try:
- ret = self._vcs_version()
- return ret
- except OSError, e:
- if e.errno == errno.ENOENT:
- return None
- else:
- raise OSError, e
- except CommandError:
- return None
-
def installed(self):
if self.version() != None:
return True
"""
if not hasattr(self, 'user_id'):
self.user_id = self._vcs_get_user_id()
+ if self.user_id == None:
+ # guess missing info
+ name = libbe.ui.util.user.get_fallback_username()
+ email = libbe.ui.util.user.get_fallback_email()
+ self.user_id = libbe.ui.util.user.create_user_id(name, email)
return self.user_id
def _detect(self, path='.'):
--------
>>> b = Bzr(repo='.')
- >>> b._vcs_version = lambda : "2.3.1 (release)"
+ >>> b._version = '2.3.1 (release)'
>>> b.version_cmp(2,3,1)
0
>>> b.version_cmp(2,3,2)
1
>>> b.version_cmp(3)
-1
- >>> b._vcs_version = lambda : "2.0.0pre2"
+ >>> b._version = '2.0.0pre2'
>>> b._parsed_version = None
>>> b.version_cmp(3)
-1
"""
if not hasattr(self, '_parsed_version') \
or self._parsed_version == None:
- num_part = self._vcs_version().split(' ')[0]
+ num_part = self.version().split(' ')[0]
self._parsed_version = []
for num in num_part.split('.'):
try:
if type(current) != types.IntType:
raise NotImplementedError(
'Cannot parse non-integer portion "%s" of Bzr version "%s"'
- % (current, self._vcs_version()))
+ % (current, self.version()))
c = cmp(current,other)
if c != 0:
return c
--------
>>> d = Darcs(repo='.')
- >>> d._vcs_version = lambda : "2.3.1 (release)"
+ >>> d._version = '2.3.1 (release)'
>>> d.version_cmp(2,3,1)
0
>>> d.version_cmp(2,3,2)
1
>>> d.version_cmp(3)
-1
- >>> d._vcs_version = lambda : "2.0.0pre2"
+ >>> d._version = '2.0.0pre2'
>>> d._parsed_version = None
>>> d.version_cmp(3)
-1
"""
if not hasattr(self, '_parsed_version') \
or self._parsed_version == None:
- num_part = self._vcs_version().split(' ')[0]
+ num_part = self.version().split(' ')[0]
self._parsed_version = []
for num in num_part.split('.'):
try:
if type(current) != types.IntType:
raise NotImplementedError(
'Cannot parse non-integer portion "%s" of Darcs version "%s"'
- % (current, self._vcs_version()))
+ % (current, self.version()))
c = cmp(current,other)
if c != 0:
return c