# HG changeset patch
# User osimons
# Date 1284547916 0
# Node ID 88454000acf8ce9d0e7f8645fb2d191b705a1d00
# Parent f66764964ed2563eb363037b468cbf64388ced22
0.6dev: Merged [890] from trunk.
diff --git a/bitten/templates/bitten_config.html b/bitten/templates/bitten_config.html
--- a/bitten/templates/bitten_config.html
+++ b/bitten/templates/bitten_config.html
@@ -176,7 +176,7 @@
$platform.name |
-
[$rev_num]
diff --git a/bitten/tests/web_ui.py b/bitten/tests/web_ui.py
--- a/bitten/tests/web_ui.py
+++ b/bitten/tests/web_ui.py
@@ -104,6 +104,37 @@
self.assertEquals('/trac/attachment/build/test/',
data['config']['attachments']['attach_href'])
+ def test_bitten_keeps_order_of_revisions_from_versioncontrol(self):
+ # Trac's API specifies that they are sorted chronological (backwards)
+ # We must not assume that these revision numbers can be sorted later on,
+ # for example the mercurial plugin will return the revisions as strings
+ # (e.g. '880:4c19fa95fb9e')
+ config = BuildConfig(self.env, name='test', path='trunk')
+ config.insert()
+ platform = TargetPlatform(self.env, config='test', name='any')
+ platform.insert()
+
+ PermissionSystem(self.env).grant_permission('joe', 'BUILD_VIEW')
+ req = Mock(method='GET', base_path='', cgi_location='',
+ path_info='/build/'+config.name, href=Href('/trac'), args={},
+ chrome={}, authname='joe',
+ perm=PermissionCache(self.env, 'joe'))
+
+ # revisions are intentionally not sorted in any way - bitten should just keep them!
+ revision_ids = [5, 8, 2]
+ revision_list = [('trunk', revision, 'edit') for revision in revision_ids]
+ root = Mock(get_entries=lambda: ['foo'], get_history=lambda: revision_list)
+ self.repos = Mock(get_node=lambda path, rev=None: root,
+ sync=lambda: None, normalize_path=lambda path: path)
+ self.repos.authz = Mock(has_permission=lambda path: True, assert_permission=lambda path: None)
+
+ module = BuildConfigController(self.env)
+ assert module.match_request(req)
+ _, data, _ = module.process_request(req)
+
+ actual_revision_ids = data['config']['revisions']
+ self.assertEquals(revision_ids, actual_revision_ids)
+
def test_view_config_paging(self):
config = BuildConfig(self.env, name='test', path='trunk')
config.insert()
diff --git a/bitten/web_ui.py b/bitten/web_ui.py
--- a/bitten/web_ui.py
+++ b/bitten/web_ui.py
@@ -441,11 +441,14 @@
builds_per_page = 12 * len(platforms)
idx = 0
builds = {}
+ revisions = []
for platform, rev, build in collect_changes(repos, config):
if idx >= page * builds_per_page:
more = True
break
elif idx >= (page - 1) * builds_per_page:
+ if rev not in builds:
+ revisions.append(rev)
builds.setdefault(rev, {})
builds[rev].setdefault('href', req.href.changeset(rev))
if build and build.status != Build.PENDING:
@@ -467,6 +470,7 @@
builds[rev][platform.id] = build_data
idx += 1
data['config']['builds'] = builds
+ data['config']['revisions'] = revisions
if page > 1:
if page == 2:
|