[be] Remove currently broken support for arch, hg and monotone Improve bzr module's version comparison Fi

Michel Alexandre Salim salimma at fedoraproject.org
Thu Aug 4 16:59:11 UTC 2011


commit db830aa850a610c29f213190d19a56a4cea321db
Author: Michel Alexandre Salim <salimma at fedoraproject.org>
Date:   Thu Aug 4 18:58:50 2011 +0200

    Remove currently broken support for arch, hg and monotone
    Improve bzr module's version comparison
    Fix version string
    Partially enable tests

 be-1.0.1-bzr_verparse.patch      |  111 ++++++++++++++++++++++++++++++++++++++
 be-1.0.1-remove_broken_vcs.patch |   11 ++++
 be-1.0.1-version.patch           |   29 ++++++++++
 be.spec                          |   36 ++++++++++++-
 4 files changed, 186 insertions(+), 1 deletions(-)
---
diff --git a/be-1.0.1-bzr_verparse.patch b/be-1.0.1-bzr_verparse.patch
new file mode 100644
index 0000000..3459409
--- /dev/null
+++ b/be-1.0.1-bzr_verparse.patch
@@ -0,0 +1,111 @@
+From dc08d2a73b02339a9d1952223b6d87f1f36303bc Mon Sep 17 00:00:00 2001
+From: Michel Alexandre Salim <salimma at fedoraproject.org>
+Date: Thu, 4 Aug 2011 17:50:32 +0200
+Subject: [PATCH] Enhance Bzr.version_cmp to handle non-numeric versions
+
+bzr uses non-numeric tags to indicate prereleases; previously, this
+triggers an exception in be's Bzr module as version comparison is only
+supported between version strings that only contain numbers and dots.
+
+This patch extends version_cmp to support a single non-numeric
+pre-release string of arbitrary length (e.g. 'a', 'b', 'pre', 'rc'), and
+extends the docstring tests to cover this extension.
+
+Signed-off-by: Michel Alexandre Salim <salimma at fedoraproject.org>
+---
+ libbe/storage/vcs/bzr.py |   59 +++++++++++++++++++++++++++++++++++++++-------
+ 1 files changed, 50 insertions(+), 9 deletions(-)
+
+diff --git a/libbe/storage/vcs/bzr.py b/libbe/storage/vcs/bzr.py
+index a3f623e..302e025 100644
+--- a/libbe/storage/vcs/bzr.py
++++ b/libbe/storage/vcs/bzr.py
+@@ -87,8 +87,14 @@ class Bzr(base.VCS):
+         0
+         >>> b.version_cmp(2,3,2)
+         -1
++        >>> b.version_cmp(2,3,'a',5)
++        1
+         >>> b.version_cmp(2,3,0)
+         1
++        >>> b.version_cmp(2,3,1,'a',5)
++        1
++        >>> b.version_cmp(2,3,1,1)
++        -1
+         >>> b.version_cmp(3)
+         -1
+         >>> b._version = '2.0.0pre2'
+@@ -96,9 +102,17 @@ class Bzr(base.VCS):
+         >>> b.version_cmp(3)
+         -1
+         >>> b.version_cmp(2,0,1)
+-        Traceback (most recent call last):
+-          ...
+-        NotImplementedError: Cannot parse non-integer portion "0pre2" of Bzr version "2.0.0pre2"
++        -1
++        >>> b.version_cmp(2,0,0,'pre',1)
++        1
++        >>> b.version_cmp(2,0,0,'pre',2)
++        0
++        >>> b.version_cmp(2,0,0,'pre',3)
++        -1
++        >>> b.version_cmp(2,0,0,'a',3)
++        1
++        >>> b.version_cmp(2,0,0,'rc',1)
++        -1
+         """
+         if not hasattr(self, '_parsed_version') \
+                 or self._parsed_version == None:
+@@ -108,16 +122,43 @@ class Bzr(base.VCS):
+                 try:
+                     self._parsed_version.append(int(num))
+                 except ValueError, e:
+-                    self._parsed_version.append(num)
++                    # bzr version number might contain non-numerical tags
++                    import re
++                    splitter = re.compile(r'[\D]') # Match non-digits
++                    splits = splitter.split(num)
++                    # if len(tag) > 1 some splits will be empty; remove
++                    splits = filter(lambda s: s != '', splits)
++                    tag_starti = len(splits[0])
++                    num_starti = num.find(splits[1], tag_starti)
++                    tag = num[tag_starti:num_starti]
++                    self._parsed_version.append(int(splits[0]))
++                    self._parsed_version.append(tag)
++                    self._parsed_version.append(int(splits[1]))
+         for current,other in zip(self._parsed_version, args):
+-            if type(current) != types.IntType:
+-                raise NotImplementedError(
+-                    'Cannot parse non-integer portion "%s" of Bzr version "%s"'
+-                    % (current, self.version()))
++            if type(current) != type (other):
++                # one of them is a pre-release string
++                if type(current) != types.IntType:
++                    return -1
++                else:
++                    return 1
+             c = cmp(current,other)
+             if c != 0:
+                 return c
+-        return 0
++        # see if one is longer than the other
++        verlen = len(self._parsed_version)
++        arglen = len(args)
++        if verlen == arglen:
++            return 0
++        elif verlen > arglen:
++            if type(self._parsed_version[arglen]) != types.IntType:
++                return -1 # self is a prerelease
++            else:
++                return 1
++        else:
++            if type(args[verlen]) != types.IntType:
++                return 1 # args is a prerelease
++            else:
++                return -1
+ 
+     def _vcs_get_user_id(self):
+         # excerpted from bzrlib.builtins.cmd_whoami.run()
+-- 
+1.7.6
+
diff --git a/be-1.0.1-remove_broken_vcs.patch b/be-1.0.1-remove_broken_vcs.patch
new file mode 100644
index 0000000..3503aae
--- /dev/null
+++ b/be-1.0.1-remove_broken_vcs.patch
@@ -0,0 +1,11 @@
+--- be-1.0.1/libbe/storage/vcs/base.py.remove_broken_vcs	2011-03-05 18:32:46.000000000 +0100
++++ be-1.0.1/libbe/storage/vcs/base.py	2011-08-04 17:57:21.467623287 +0200
+@@ -50,7 +50,7 @@
+ 
+     import libbe.ui.util.user
+ 
+-VCS_ORDER = ['arch', 'bzr', 'darcs', 'git', 'hg', 'monotone']
++VCS_ORDER = ['bzr', 'darcs', 'git']
+ """List VCS modules in order of preference.
+ 
+ Don't list this module, it is implicitly last.
diff --git a/be-1.0.1-version.patch b/be-1.0.1-version.patch
new file mode 100644
index 0000000..9ce7c6f
--- /dev/null
+++ b/be-1.0.1-version.patch
@@ -0,0 +1,29 @@
+From afcb4c7406af4f95a1a18c37e055d224abf9e5fe Mon Sep 17 00:00:00 2001
+From: Michel Alexandre Salim <salimma at fedoraproject.org>
+Date: Thu, 4 Aug 2011 18:00:47 +0200
+Subject: [PATCH] Update version string to 1.0.1
+
+The 1.0.1 tag was made without the version number being properly bumped
+to 1.0.1
+
+Signed-off-by: Michel Alexandre Salim <salimma at fedoraproject.org>
+---
+ libbe/version.py |    2 +-
+ 1 files changed, 1 insertions(+), 1 deletions(-)
+
+diff --git a/libbe/version.py b/libbe/version.py
+index 29f4eed..e80f5e3 100644
+--- a/libbe/version.py
++++ b/libbe/version.py
+@@ -41,7 +41,7 @@ except ImportError, e:
+         }
+ 
+ # Manually set a version string (optional, defaults to bzr revision id)
+-_VERSION = '1.0.0'
++_VERSION = '1.0.1'
+ 
+ def version(verbose=False):
+     """
+-- 
+1.7.6
+
diff --git a/be.spec b/be.spec
index 47e2114..4553b7b 100644
--- a/be.spec
+++ b/be.spec
@@ -2,7 +2,7 @@
 
 Name:           be
 Version:        1.0.1
-Release:        1%{?dist}
+Release:        2%{?dist}
 Summary:        Bugs Everywhere, a distributed bug tracker
 
 # for older rpmlint versions
@@ -12,9 +12,24 @@ URL:            http://bugseverywhere.org/
 Source0:        http://download.bugseverywhere.org/releases/be-%{version}.tar.gz
 # from commit 2aeaa4e265deb093a5e37c5973deb8d932974491
 Patch0:         be-1.0.0-manpage.patch
+# arch (tla) is orphaned in Fedora
+# hg module does not support the version in Fedora, and
+# monotone support is broken
+Patch1:         be-1.0.1-remove_broken_vcs.patch
+# extends bzr module's version parser to handle non-fully-numeric versions
+Patch2:         be-1.0.1-bzr_verparse.patch
+# fix incorrect version number
+Patch3:         be-1.0.1-version.patch
 
 BuildArch:      noarch
 BuildRequires:  python-docutils
+
+# for testing
+BuildRequires:  bzr
+BuildRequires:  darcs
+BuildRequires:  git
+BuildRequires:  PyYAML
+
 Requires:       PyYAML
 
 %if 0%{?el5}
@@ -35,8 +50,14 @@ instead of numbers, bugs have globally unique ids.
 %prep
 %setup -q
 %patch0 -p1 -b .manpage
+%patch1 -p1 -b .remove_broken_vcs
+rm -rf libbe/storage/vcs/{arch,hg,monotone}.*
+%patch2 -p1 -b .bzr_verparse
+%patch3 -p1 -b .version
 sed -i '1d' libbe/version.py
 sed -i '1d' misc/completion/be.bash
+# remove compiled files
+find . -name '*.py?' -exec rm '{}' \;
 
 
 %build
@@ -55,6 +76,13 @@ mkdir -p $COMPDIR
 cp -p misc/completion/be.bash $COMPDIR/
 
 
+%check
+export LANG=en_US.utf8
+bzr whoami "Koji <koji at fedoraproject.org>"
+git config --global user.email "koji at fedoraproject.org"
+git config --global user.name  "Koji"
+%{__python} test.py libbe.storage.{base,util.{config,mapfile,properties,settings_object,upgrade},vcs.{base,bzr,darcs,git}}
+
 %if 0%{?rhel}
 %clean
 rm -rf $RPM_BUILD_ROOT
@@ -76,6 +104,12 @@ rm -rf $RPM_BUILD_ROOT
 
 
 %changelog
+* Thu Aug  4 2011 Michel Salim <salimma at fedoraproject.org> - 1.0.1-2
+- Remove currently broken support for arch, hg and monotone
+- Improve bzr module's version comparison
+- Fix version string
+- Partially enable tests
+
 * Wed Jul 13 2011 Michel Salim <salimma at fedoraproject.org> - 1.0.1-1
 - Update to 1.0.1
 


More information about the scm-commits mailing list