allura-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hei...@apache.org
Subject allura git commit: [#7873] Performance improvements when displaying branches in the sidebar_menu.
Date Tue, 05 May 2015 13:48:10 GMT
Repository: allura
Updated Branches:
  refs/heads/hs/7873 [created] 86966b47c


[#7873] Performance improvements when displaying branches in the sidebar_menu.


Project: http://git-wip-us.apache.org/repos/asf/allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/allura/commit/86966b47
Tree: http://git-wip-us.apache.org/repos/asf/allura/tree/86966b47
Diff: http://git-wip-us.apache.org/repos/asf/allura/diff/86966b47

Branch: refs/heads/hs/7873
Commit: 86966b47ccd537cf20a1695ec709eb312f34a5a1
Parents: 31189d4
Author: Heith Seewald <hseewald@slashdotmedia.com>
Authored: Tue May 5 13:47:19 2015 +0000
Committer: Heith Seewald <hseewald@slashdotmedia.com>
Committed: Tue May 5 13:47:19 2015 +0000

----------------------------------------------------------------------
 Allura/allura/lib/repository.py | 24 ++++++++++++++----------
 ForgeGit/forgegit/git_main.py   |  2 +-
 2 files changed, 15 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/86966b47/Allura/allura/lib/repository.py
----------------------------------------------------------------------
diff --git a/Allura/allura/lib/repository.py b/Allura/allura/lib/repository.py
index 31e1395..feb31b9 100644
--- a/Allura/allura/lib/repository.py
+++ b/Allura/allura/lib/repository.py
@@ -168,17 +168,21 @@ class RepositoryApp(Application):
         branches = self.repo.get_branches()
         if branches:
             links.append(SitemapEntry('Branches'))
-            for branch in branches:
-                if branch.name == self.default_branch_name:
-                    branches.remove(branch)
-                    branches.insert(0, branch)
-                    break
-            max_branches = 10
-            for branch in branches[:max_branches]:
-                links.append(SitemapEntry(
-                    branch.name,
-                    quote(self.repo.url_for_commit(branch.name) + 'tree/')))
+            max_branches = 9
+
+            # Add the default branch first
+            links.append(SitemapEntry(
+                self.default_branch_name,
+                quote(self.repo.url_for_commit(self.default_branch_name) + 'tree/')))
+
+            if len(branches) > 1:
+                # Add more until the limit is hit
+                for branch in branches[:max_branches]:
+                    links.append(SitemapEntry(
+                        branch.name,
+                        quote(self.repo.url_for_commit(branch.name) + 'tree/')))
             if len(branches) > max_branches:
+                # Hide the rest behind a single entry.
                 links.append(
                     SitemapEntry(
                         'More Branches',

http://git-wip-us.apache.org/repos/asf/allura/blob/86966b47/ForgeGit/forgegit/git_main.py
----------------------------------------------------------------------
diff --git a/ForgeGit/forgegit/git_main.py b/ForgeGit/forgegit/git_main.py
index 62fc0f7..bb19ec3 100644
--- a/ForgeGit/forgegit/git_main.py
+++ b/ForgeGit/forgegit/git_main.py
@@ -66,7 +66,7 @@ class ForgeGitApp(RepositoryApp):
     def repo(self):
         return GM.Repository.query.get(app_config_id=self.config._id)
 
-    @property
+    @LazyProperty
     def default_branch_name(self):
         return self.repo.get_default_branch('master')
 


Mime
View raw message