diff options
author | W. Trevor King <wking@drexel.edu> | 2010-02-01 12:31:53 -0500 |
---|---|---|
committer | W. Trevor King <wking@drexel.edu> | 2010-02-01 12:31:53 -0500 |
commit | 3e16a0ab627a095605f14a5164c2d8e14a3bcaa9 (patch) | |
tree | d7f1be567115ccdca67940755eb2f8b97266251f /libbe | |
parent | cf930f941de308f5d46ce89aa7f6358ba3c453d6 (diff) | |
download | bugseverywhere-3e16a0ab627a095605f14a5164c2d8e14a3bcaa9.tar.gz |
Made Bzr/Darcs.version_cmp() more robust in response to Chris' email.
From: Chris Ball <cjb@laptop.org>
Subject: Test suite status
...
I ran the wking@drexel.edu-20100130162439-pmh5tg6kuq92x3l5 testsuite
on Fedora 13/Rawhide. Had to downgrade Mercurial (bzr-hg doesn't
support 1.4.2 yet) and bzr (my Fedora package contained a "b4" in the
version string, which breaks libbe/storage/vcs/bzr.py:version_cmp()).
...
Diffstat (limited to 'libbe')
-rw-r--r-- | libbe/storage/vcs/bzr.py | 24 | ||||
-rw-r--r-- | libbe/storage/vcs/darcs.py | 24 |
2 files changed, 30 insertions, 18 deletions
diff --git a/libbe/storage/vcs/bzr.py b/libbe/storage/vcs/bzr.py index ce140bc..01d9948 100644 --- a/libbe/storage/vcs/bzr.py +++ b/libbe/storage/vcs/bzr.py @@ -37,6 +37,7 @@ import re import shutil import StringIO import sys +import types import libbe import base @@ -82,22 +83,27 @@ class Bzr(base.VCS): >>> b._vcs_version = lambda : "2.0.0pre2" >>> b._parsed_version = None >>> b.version_cmp(3) + -1 + >>> b.version_cmp(2,0,1) Traceback (most recent call last): ... - NotImplementedError: Cannot parse "2.0.0pre2" portion of Bazaar version "2.0.0pre2" - invalid literal for int() with base 10: '0pre2' + NotImplementedError: Cannot parse non-integer portion "0pre2" of Bzr version "2.0.0pre2" """ if not hasattr(self, '_parsed_version') \ or self._parsed_version == None: num_part = self._vcs_version().split(' ')[0] - try: - self._parsed_version = [int(i) for i in num_part.split('.')] - except ValueError, e: + self._parsed_version = [] + for num in num_part.split('.'): + try: + self._parsed_version.append(int(num)) + except ValueError, e: + self._parsed_version.append(num) + for current,other in zip(self._parsed_version, args): + if type(current) != types.IntType: raise NotImplementedError( - 'Cannot parse "%s" portion of Bazaar version "%s"\n %s' - % (num_part, self._vcs_version(), str(e))) - cmps = [cmp(a,b) for a,b in zip(self._parsed_version, args)] - for c in cmps: + 'Cannot parse non-integer portion "%s" of Bzr version "%s"' + % (current, self._vcs_version())) + c = cmp(current,other) if c != 0: return c return 0 diff --git a/libbe/storage/vcs/darcs.py b/libbe/storage/vcs/darcs.py index 7c6f069..fd8b7d5 100644 --- a/libbe/storage/vcs/darcs.py +++ b/libbe/storage/vcs/darcs.py @@ -25,6 +25,7 @@ import re import shutil import sys import time # work around http://mercurial.selenic.com/bts/issue618 +import types try: # import core module, Python >= 2.5 from xml.etree import ElementTree except ImportError: # look for non-core module @@ -75,22 +76,27 @@ class Darcs(base.VCS): >>> d._vcs_version = lambda : "2.0.0pre2" >>> d._parsed_version = None >>> d.version_cmp(3) + -1 + >>> d.version_cmp(2,0,1) Traceback (most recent call last): ... - NotImplementedError: Cannot parse "2.0.0pre2" portion of Darcs version "2.0.0pre2" - invalid literal for int() with base 10: '0pre2' + NotImplementedError: Cannot parse non-integer portion "0pre2" of Darcs version "2.0.0pre2" """ if not hasattr(self, '_parsed_version') \ or self._parsed_version == None: num_part = self._vcs_version().split(' ')[0] - try: - self._parsed_version = [int(i) for i in num_part.split('.')] - except ValueError, e: + self._parsed_version = [] + for num in num_part.split('.'): + try: + self._parsed_version.append(int(num)) + except ValueError, e: + self._parsed_version.append(num) + for current,other in zip(self._parsed_version, args): + if type(current) != types.IntType: raise NotImplementedError( - 'Cannot parse "%s" portion of Darcs version "%s"\n %s' - % (num_part, self._vcs_version(), str(e))) - cmps = [cmp(a,b) for a,b in zip(self._parsed_version, args)] - for c in cmps: + 'Cannot parse non-integer portion "%s" of Darcs version "%s"' + % (current, self._vcs_version())) + c = cmp(current,other) if c != 0: return c return 0 |