Merge lp:~jelmer/bzr-builddeb/sort-tags-debversion into lp:bzr-builddeb

Proposed by Jelmer Vernooij
Status: Merged
Merged at revision: 487
Proposed branch: lp:~jelmer/bzr-builddeb/sort-tags-debversion
Merge into: lp:bzr-builddeb
Diff against target: 85 lines (+39/-1)
4 files modified
__init__.py (+9/-0)
debian/changelog (+2/-1)
tagging.py (+19/-0)
tests/test_tagging.py (+9/-0)
To merge this branch: bzr merge lp:~jelmer/bzr-builddeb/sort-tags-debversion
Reviewer Review Type Date Requested Status
Andrew Bennetts (community) Approve
Bzr-builddeb-hackers Pending
Review via email: mp+45779@code.launchpad.net

Description of the change

This adds support for "bzr tags --sort=debversion", if the version of bzr that is loaded supports it.

To post a comment you must log in.
Revision history for this message
Andrew Bennetts (spiv) wrote :

Looks good!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file '__init__.py'
2--- __init__.py 2010-09-10 02:46:41 +0000
3+++ __init__.py 2011-01-10 22:48:21 +0000
4@@ -173,6 +173,15 @@
5 from bzrlib.plugins.builddeb.revspec import RevisionSpec_package
6 SPEC_TYPES.append(RevisionSpec_package)
7
8+try:
9+ from bzrlib.tag import tag_sort_methods
10+except ImportError:
11+ pass # bzr tags --sort= can not be extended
12+else:
13+ tag_sort_methods.register_lazy("debversion",
14+ "bzrlib.plugins.builddeb.tagging", "sort_debversion",
15+ "Sort like Debian versions.")
16+
17
18 def load_tests(standard_tests, module, loader):
19 return loader.loadTestsFromModuleNames(['bzrlib.plugins.builddeb.tests'])
20
21=== modified file 'debian/changelog'
22--- debian/changelog 2010-09-10 02:53:47 +0000
23+++ debian/changelog 2011-01-10 22:48:21 +0000
24@@ -22,8 +22,9 @@
25 if we can't find the tarball.
26 * Determine Bazaar home directory using bzrlib to prevent test
27 isolation issues. LP: #614125
28+ * Support 'bzr tags --sort=debversion'. Closes #701244.
29
30- -- James Westby <james.westby@ubuntu.com> Wed, 18 Aug 2010 20:12:20 -0400
31+ -- Jelmer Vernooij <jelmer@debian.org> Mon, 10 Jan 2011 23:43:30 +0100
32
33 bzr-builddeb (2.5) unstable; urgency=low
34
35
36=== modified file 'tagging.py'
37--- tagging.py 2010-05-04 11:27:46 +0000
38+++ tagging.py 2011-01-10 22:48:21 +0000
39@@ -21,6 +21,14 @@
40
41 __all__ = ['is_upstream_tag', 'upstream_tag_version']
42
43+
44+try:
45+ from debian.changelog import Version
46+except ImportError:
47+ # Prior to 0.1.15 the debian module was called debian_bundle
48+ from debian_bundle.changelog import Version
49+
50+
51 def is_upstream_tag(tag):
52 """Return true if tag is an upstream tag.
53
54@@ -54,3 +62,14 @@
55 elif tag.startswith('ubuntu-'):
56 tag = tag[len('ubuntu-'):]
57 return tag
58+
59+
60+def sort_debversion(branch, tags):
61+ """Sort tags using Debian version in-place.
62+
63+ :param branch: Branch to use
64+ :param tags: List of tuples with name and version.
65+ """
66+ def debversion_key((version, revid)):
67+ return Version(version)
68+ tags.sort(key=debversion_key)
69
70=== modified file 'tests/test_tagging.py'
71--- tests/test_tagging.py 2010-05-04 11:27:46 +0000
72+++ tests/test_tagging.py 2011-01-10 22:48:21 +0000
73@@ -51,3 +51,12 @@
74
75 def test_git_upstream(self):
76 self.assertEqual('2.1', tagging.upstream_tag_version('upstream/2.1'))
77+
78+
79+class TestDebVersionSort(TestCase):
80+
81+ def test_sort(self):
82+ tags = [("1.0", "revid"), ("1.0.1", "revid"), ("1.0~1", "revid")]
83+ tagging.sort_debversion(None, tags)
84+ self.assertEquals(tags,
85+ [("1.0~1", "revid"), ("1.0", "revid"), ("1.0.1", "revid")])

Subscribers

People subscribed via source and target branches