Merge lp:~jameinel/loggerhead/sort-742390 into lp:loggerhead

Proposed by John A Meinel
Status: Merged
Merged at revision: 443
Proposed branch: lp:~jameinel/loggerhead/sort-742390
Merge into: lp:loggerhead
Diff against target: 45 lines (+12/-5)
2 files modified
loggerhead/history.py (+5/-1)
loggerhead/tests/test_history.py (+7/-4)
To merge this branch: bzr merge lp:~jameinel/loggerhead/sort-742390
Reviewer Review Type Date Requested Status
William Grant Approve
Review via email: mp+54855@code.launchpad.net

Commit message

Bug #742390, don't sort_natural if it isn't available.

Description of the change

Don't use sort_natural if it isn't available. It was introduced in bzr 2.3, and Launchpad is still using bzr 2.2.

To post a comment you must log in.
Revision history for this message
William Grant (wgrant) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'loggerhead/history.py'
2--- loggerhead/history.py 2011-03-16 14:43:36 +0000
3+++ loggerhead/history.py 2011-03-25 12:50:52 +0000
4@@ -720,7 +720,11 @@
5 # tag.sort_* functions expect (tag, data) pairs, so we generate them,
6 # and then strip them
7 tags = [(t, None) for t in self._branch_tags[revision.revision_id]]
8- tag.sort_natural(self._branch, tags)
9+ sort_func = getattr(tag, 'sort_natural', None)
10+ if sort_func is None:
11+ tags.sort()
12+ else:
13+ sort_func(self._branch, tags)
14 revtags = u', '.join([t[0] for t in tags])
15
16 entry = {
17
18=== modified file 'loggerhead/tests/test_history.py'
19--- loggerhead/tests/test_history.py 2011-03-16 14:43:36 +0000
20+++ loggerhead/tests/test_history.py 2011-03-25 12:50:52 +0000
21@@ -18,7 +18,7 @@
22 """Direct tests of the loggerhead/history.py module"""
23
24 from datetime import datetime
25-from bzrlib import tests
26+from bzrlib import tag, tests
27
28 from loggerhead import history as _mod_history
29
30@@ -224,9 +224,12 @@
31 b.tags.set_tag('tag-2', rev.revision_id)
32 b.tags.set_tag('Tag-10', rev.revision_id)
33 change = history._change_from_revision(rev)
34- # tags are 'naturally' sorted, sorting numbers in order, and ignoring
35- # case, etc.
36- self.assertEqual('tag-1, tag-2, Tag-10', change.tags)
37+ # If available, tags are 'naturally' sorted. (sorting numbers in order,
38+ # and ignoring case, etc.)
39+ if getattr(tag, 'sort_natural', None) is not None:
40+ self.assertEqual('tag-1, tag-2, Tag-10', change.tags)
41+ else:
42+ self.assertEqual('Tag-10, tag-1, tag-2', change.tags)
43
44 def test_committer_vs_authors(self):
45 tree = self.make_branch_and_tree('test')

Subscribers

People subscribed via source and target branches